Go to file
Matthew Treinish 85dbf1ffad
Add OPNSense device tracker (#26834)
* Add OPNSense device_tracker

This commit adds a new component for using an OPNSense router as a
device tracker. It uses pyopnsense to query the api to look at the
arptable for a list of devices on the network.

* Run black formatting locally to appease azure

* Apply suggestions from code review

Co-Authored-By: Fabian Affolter <mail@fabian-affolter.ch>

* Fix issues identified during code review

This commit updates several issues found in the module during code
review.

* Update homeassistant/components/opnsense/__init__.py

Co-Authored-By: Fabian Affolter <mail@fabian-affolter.ch>

* Update CODEOWNERS for recent changes

* Fix lint

* Apply suggestions from code review

Co-Authored-By: Martin Hjelmare <marhje52@kth.se>

* More fixes from review comments

This commit fixes several issues from review comments, including
abandoning all the use of async code. This also completely reworks the
tests to be a bit clearer.

* Revert tests to previous format

* Add device detection to opnsense device_tracker test

This commit adds actual device detection to the unit test for the setup
test. A fake api response is added to mocks for both api clients so that
they will register devices as expected and asserts are added for that.

The pyopnsense import is moved from the module level to be runtime in
the class. This was done because it was the only way to make the
MockDependency() call work as expected.

* Rerun black

* Fix lint

* Move import back to module level

* Return false on configuration errors in setup

This commit updates the connection logic to return false if we're unable
to connect to the configured OPNsense API endpoint for any reason.
Previously we would not catch if an endpoint was incorrectly configured
until we first tried to use it. In this case it would raise an unhandled
exception. To handle this more gracefully this adds an api call early in
the setup and catches any exception raised by that so we can return
False to indicate the setup failed.

* Update tests

* Add pyopnsense to test requirements

* Rerun gen_requirements script

* Fix failing isort lint job step

Since opening the PR originally yet another lint/style checker was added
which failed the PR in CI. This commit makes the adjustments to have
this pass the additional tool's checks.

* Fix comment

* Update manifest.json

Co-authored-by: Fabian Affolter <mail@fabian-affolter.ch>
Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
Co-authored-by: Pascal Vizeli <pascal.vizeli@syshack.ch>
2020-01-29 16:20:43 +01:00
.devcontainer Fixes invalid JSON syntax in devcontainer (#29911) 2019-12-13 12:41:56 +01:00
.github Cleanup of PR and issue templates (#31070) 2020-01-23 11:55:29 +01:00
.vscode Always run flake8 through pre-commit, and with doctests (#28490) 2019-11-06 21:38:00 +02:00
docs Update featured integrations screenshot in README (#30134) 2020-01-07 14:30:52 +01:00
homeassistant Add OPNSense device tracker (#26834) 2020-01-29 16:20:43 +01:00
script Add Gammu based local SMS notifications (#31233) 2020-01-28 09:35:41 +01:00
tests Add OPNSense device tracker (#26834) 2020-01-29 16:20:43 +01:00
.codecov.yml Only comment with changed coverage on release PRs [skip-ci] (#23224) 2019-04-18 20:58:35 -07:00
.coveragerc Add OPNSense device tracker (#26834) 2020-01-29 16:20:43 +01:00
.dockerignore Docker cleanup. (#8226) 2017-06-30 08:07:33 -07:00
.gitattributes Fix line endings [skipci] (#12333) 2018-02-11 23:07:28 -08:00
.gitignore Move imports in wake_on_lan component (#28100) 2019-10-22 23:14:52 -07:00
.ignore Include .ignore file for search utilities (#5290) 2017-01-16 22:52:53 -08:00
.pre-commit-config-all.yaml Upgrade pydocstyle to 5.0.2 (#30648) 2020-01-10 19:56:07 +01:00
.pre-commit-config.yaml Upgrade pydocstyle to 5.0.2 (#30648) 2020-01-10 19:56:07 +01:00
.readthedocs.yml Drop Python 3.6 support (#29978) 2019-12-16 07:29:19 +01:00
.travis.yml Drop Python 3.6 support (#29978) 2019-12-16 07:29:19 +01:00
CLA.md Update LICENSE.md and CLA.md to reflect the new Apache 2.0 license 2017-01-28 12:12:34 -08:00
CODEOWNERS Add OPNSense device tracker (#26834) 2020-01-29 16:20:43 +01:00
CODE_OF_CONDUCT.md Add organization docs 2017-01-22 16:21:20 -08:00
CONTRIBUTING.md Contributing: Add note about feature suggestions and bug tracking (#30225) 2019-12-30 17:54:16 +01:00
Dockerfile.dev Fix dev dockerfile 2019-11-05 21:38:30 +01:00
LICENSE.md Update license to official GitHub template (#16470) 2018-09-07 10:11:51 +02:00
MANIFEST.in Consolidate frontend (#9915) 2017-10-24 19:36:27 -07:00
README.rst Adjusts repository README (#29805) 2019-12-10 09:22:37 +01:00
azure-pipelines-ci.yml add --show-diff-on-failure to pre-commit (#30097) 2019-12-20 22:00:31 +01:00
azure-pipelines-release.yml Whitelist Frenck for release 2020-01-14 15:06:30 -08:00
azure-pipelines-translation.yml Update azure-pipelines-translation.yml for Azure Pipelines 2019-09-05 12:09:21 +02:00
azure-pipelines-wheels.yml Add gammu to wheels (#31239) 2020-01-28 09:41:50 +01:00
pylintrc Make pylint fail on informational messages too (#31136) 2020-01-24 23:27:15 +02:00
pyproject.toml Drop Python 3.6 support (#29978) 2019-12-16 07:29:19 +01:00
requirements_all.txt Add OPNSense device tracker (#26834) 2020-01-29 16:20:43 +01:00
requirements_docs.txt Upgrade Sphinx to 2.3.1 (#30310) 2019-12-31 15:32:26 +01:00
requirements_test.txt Upgrade pre-commit to 2.0.0 (#31267) 2020-01-29 12:04:25 +01:00
requirements_test_all.txt Add OPNSense device tracker (#26834) 2020-01-29 16:20:43 +01:00
requirements_test_pre_commit.txt Upgrade pydocstyle to 5.0.2 (#30648) 2020-01-10 19:56:07 +01:00
setup.cfg Drop Python 3.6 support (#29978) 2019-12-16 07:29:19 +01:00
setup.py Upgrade pyyaml to 5.3 (#31026) 2020-01-20 21:12:16 -08:00
tox.ini Add bandit, use to catch known vulnerable XML parsing (#28341) 2019-11-18 09:10:15 +01:00

README.rst

Home Assistant |Chat Status|
=================================================================================

Open source home automation that puts local control and privacy first. Powered by a worldwide community of tinkerers and DIY enthusiasts. Perfect to run on a Raspberry Pi or a local server.

Check out `home-assistant.io <https://home-assistant.io>`__ for `a
demo <https://home-assistant.io/demo/>`__, `installation instructions <https://home-assistant.io/getting-started/>`__,
`tutorials <https://home-assistant.io/getting-started/automation-2/>`__ and `documentation <https://home-assistant.io/docs/>`__.

|screenshot-states|

Featured integrations
---------------------

|screenshot-components|

The system is built using a modular approach so support for other devices or actions can be implemented easily. See also the `section on architecture <https://developers.home-assistant.io/docs/en/architecture_index.html>`__ and the `section on creating your own
components <https://developers.home-assistant.io/docs/en/creating_component_index.html>`__.

If you run into issues while using Home Assistant or during development
of a component, check the `Home Assistant help section <https://home-assistant.io/help/>`__ of our website for further help and information.

.. |Chat Status| image:: https://img.shields.io/discord/330944238910963714.svg
   :target: https://discord.gg/c5DvZ4e
.. |screenshot-states| image:: https://raw.github.com/home-assistant/home-assistant/master/docs/screenshots.png
   :target: https://home-assistant.io/demo/
.. |screenshot-components| image:: https://raw.github.com/home-assistant/home-assistant/dev/docs/screenshot-components.png
   :target: https://home-assistant.io/integrations/