Commit Graph

93 Commits (3a054c3be7a61a253831bc5d53ca8014f5762edb)

Author SHA1 Message Date
Robert Svensson 48f1a55a28
Improve common structure in UniFi device tracker tests (#47526) 2021-03-07 13:20:04 +01:00
Robert Svensson 50d3aae418
Improve restoring UniFi POE entity state (#47148)
* Improve restoring data and better handling when the restore data is empty
Improve readability of some logic related to POE clients

* There is no need to check clients_all in Switch platform

* Add better tests when restoring state

* Port except handling shouldn't be needed anymore

* Walrusify get_last_state
2021-03-05 22:09:05 +01:00
Robert Svensson 793929f2ea
Increase test coverage of UniFi integration (#46347)
* Increase coverage of init

* Increase coverage of config_flow

* Improve coverage of controller

* Minor improvement to switch test

* Fix review comment

* Mock websocket class

* Replace the rest of the old websocket event tests

* Improve websocket fixture for cleaner tests

* Fix typing

* Improve connection state signalling based on Martins feedback

* Improve tests of reconnection_mechanisms based on Martins review comments

* Fix unload entry

* Fix isort issue after rebase

* Fix martins comment on not using caplog

* Fix wireless clients test

* Fix martins comments on wireless clients test
2021-03-05 21:28:41 +01:00
Quentame 198ecb0945
Uniformize platform setup (#47101)
* A platform is not a component

* Fix dynalite

* SUPPORTED_PLATFORMS --> PLATFORMS

* In tests

* In tests 2

* Fix SmartThings

* Fix ZHA test

* Fix Z-Wave

* Revert Z-Wave

* Use PLATFORMS const in ambient_station

* Fix ihc comment
2021-03-02 21:43:59 +01:00
J. Nick Koston c9df42b69a
Add support for pre-filtering events to the event bus (#46371) 2021-02-14 09:42:55 -10:00
Robert Svensson 618fcda821
Simplify UniFi entry configuration data (#45759)
* Simplify configuration structure by removing the controller key

* Fix flake8

* Fix review comments

* Don't use migrate_entry mechanism to flatten configuration
Keep legacy configuration when creating new entries as well
2021-02-06 21:32:18 +01:00
Robert Svensson 0d620eb7c3
Add unique id to UniFi config entries using the unique id of the site it is controlling (#45737)
* Add unique id to UniFi config entries using the unique id of the site it is controlling

* Fix failing test
2021-02-05 19:38:08 +01:00
Robert Svensson ae2c7e4c74
Improve UniFi tests (#45871) 2021-02-05 16:31:47 +01:00
Robert Svensson 83a75b02ea
Code quality improvements to UniFi integration (#45794)
* Do less inside try statements

* Replace controller id with config entry id since it doesn't serve a purpose anymore

* Improve how controller connection state is communicated in the client and device tracker
Remove the need to disable arguments-differ lint

* Remove broad exception handling from config flow
I'm not sure there ever was a reason for this more than to catch all exceptions

* Replace site string with constant for SSDP title_placeholders

* Unload platforms in the defacto way

* Noone reads the method descriptions

* Improve file descriptions
2021-02-01 17:55:16 +01:00
J. Nick Koston 88c4031e57
Fix exception when a unifi config entry is ignored (#45735)
* Fix exception when a unifi config entry is ignored

* Fix existing test
2021-01-30 16:45:46 +01:00
Robert Svensson 97fd05eb9f
Allow new UniFi flows to update existing entries if host and site match (#45668) 2021-01-29 18:14:39 +01:00
Robert Svensson 26764a805b
Don't parse previous messages when UniFi connection state change to available (#45544)
* Don't parse previous messages when connection state change to available

* Disable pylint for arguments-differ W0221 message
2021-01-26 16:41:28 +01:00
J. Nick Koston b68c287ff1
Add SSDP discovery to unifi (#45364) 2021-01-21 11:03:54 -06:00
J. Nick Koston 536e835b39
Switch frequently used unifi controller properties to attributes (#45365) 2021-01-20 16:58:02 -06:00
Robert Svensson da4404e8cf
Introduce reauthentication flow to UniFi integration (#45360)
* Improve site selection

* Reauth flow and tests
Add **kwargs to mock_aiohttp_client create_session to support inputting verify_ssl and cookie_jar

* Update homeassistant/components/unifi/config_flow.py

Co-authored-by: J. Nick Koston <nick@koston.org>

* Minor improvements

* Improve coverage

Co-authored-by: J. Nick Koston <nick@koston.org>
2021-01-20 22:10:40 +01:00
J. Nick Koston 41e7d960ee
Use dispatcher for unifi heartbeat tracking (#45211)
Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
2021-01-17 03:10:52 +01:00
J. Nick Koston 5e01b828af
Discover devices from device_trackers with router sources (#45160)
* Discover devices from device_trackers with router sources

* Update homeassistant/components/dhcp/__init__.py

Co-authored-by: Martin Hjelmare <marhje52@gmail.com>

* fix stop being called on the wrong context

* clean

* move it to base

* cleanup was too agressive

* Update homeassistant/components/dhcp/__init__.py

Co-authored-by: Martin Hjelmare <marhje52@gmail.com>

* coverage

* revert legacy changes

Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
2021-01-16 01:01:37 +01:00
J. Nick Koston b450d4c135
Improve unifi performance with many devices (#45006)
With 250 clients, there were about 18000 timers updated every
minute. To avoid this, we check which entities should be set
to not_home only once every second.
2021-01-10 20:12:21 +01:00
Franck Nijhof 65cf2fcb6f
Drop asynctest (#44746) 2021-01-01 22:31:56 +01:00
Robert Svensson 9651d1bcfa
Support more errors to better do retries in UniFi (#44108) 2020-12-10 21:25:50 +01:00
Jason Hunter 5a4c1dbcc4
Add DPI Restriction switch to UniFi integration (#42499)
* initial implementation for controlling DPI restrictions

* address PR review comments and add DataUpdateCoordinator

* fix existing tests against new lib version

* add tests for DPI switches

* bump aiounifi

* listen to events instead of polling

* fix tests

* remove useless test

* bump aiounifi

* rename device to UniFi Controller per PR feedback
2020-11-03 08:36:37 +01:00
springstan 6a7caad8dc
Use content type json constant (#40312) 2020-09-23 20:21:55 +02:00
timkoers 46b86f4a2f
Add UniFi Uptime sensor (#40058)
* Added UniFi Uptime sensor

Added the UniFi uptime data as a sensor. Untested.

* Update sensor.py

Updated code as a result of the tests.

* Changed timestamp format and device class

Converted state to iso timestamp and changed device class to DEVICE_CLASS_TIMESTAMP.

* Updated unit of measurement to None

* Added import

* Update homeassistant/components/unifi/sensor.py

Co-authored-by: Martin Hjelmare <marhje52@gmail.com>

* Removed whitespace

* Added the uptime sensors option to the config flow

* All the unit tests should be there now

* Whoops

* Fixed translation

* Properly formatted the code

* Flake8 really has angel eyes

* Black should also be satisfied now

* Should have satisfied all static code analysis tools

* Fixed add uptime sensor function

* Fixed overintendation

* Fixed unit tests

* Made a spelling mistake during editing of unit tests

* Test verifies if utc time is correct

* Converted to iso format

* Converted unit test to iso format

* Unit test sensor json had the wrong uptime name

* Added options_updated handler

* Fixed remove sensors unit test

* Update homeassistant/components/unifi/sensor.py

Co-authored-by: Robert Svensson <Kane610@users.noreply.github.com>

* Update homeassistant/components/unifi/sensor.py

Co-authored-by: Robert Svensson <Kane610@users.noreply.github.com>

* Update test_device_tracker.py

Removed uptime from the devices

* Fixed black formatting issue

* I think the code coverage should be good now

* Trying to add the sensors again

* Using signals to hopefully trigger the controller to add them again

* Forgot import

* Sorted components

* fixed isort comments

* Removed CLASS and DEVICE_CLASS

* Added TYPE again

* Removed double underscores

Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
Co-authored-by: Robert Svensson <Kane610@users.noreply.github.com>
2020-09-18 19:33:37 +02:00
Franck Nijhof 1c2ebdf307
Upgrade black to 20.8b1 (#39287) 2020-08-27 13:56:20 +02:00
Robert Svensson a3865fb383
UniFi - Increase time to mark UniFi devices as away (#36366) 2020-06-02 10:35:27 +02:00
Robert Svensson 785b8d2bd1
UniFi - Sites don't declare role on UniFiOS 1.7.0 beta (#35555)
* New way to identify role, compatible with standalone controller or as part of unifios

* Remove error

* Bump dependency to v22

* Remove unused import
2020-05-13 00:37:16 +02:00
Robert Svensson c71b6c8a71
UniFi - Update device registry after device has been upgraded (#35430)
* Update device registry if received event saying device has been updated

* Make sure event was the last updated
2020-05-10 17:14:45 +02:00
Robert Svensson c8deae6445
UniFi - Make clients proper push based (#35273)
* Improve client tracker to be more comprehensible and streamlined
Improve block switches
Improve tests

* Small clean up

* Add descriptions on ssid test

* Improve test

* Make polling default off, only POE clients left to verify

* Minor improvements

* On removal cancel scheduled updates

* POE works without polling now

* Combine else and if to an elif
2020-05-08 22:19:27 +02:00
Robert Svensson c19b222d5a
UniFi - Catch wlan_override without name key (#35366) 2020-05-08 09:51:10 -07:00
Robert Svensson 53f64bae09
UniFi - Make devices proper push based (#35152)
* Make devices proper push based

* Improve tests

* Bump dependency to v21
Update fix from #35295 to use library
2020-05-07 09:58:04 +02:00
Robert Svensson 5218b23fce
UniFi - Support SSID filter of SSIDs from access points with extra configuration (#35295) 2020-05-06 15:35:04 -07:00
Robert Svensson c5ce95ff06
UniFi - Improve signalling and handling of adding new entities (#34925)
* Change signalling and handling of adding devices

* Bump aiounifi to v19
Use the proper variable for roamradio
2020-05-04 19:29:49 +02:00
Robert Svensson a2048b4c7a
UniFi - Catch controllers running on UniFi OS that don't have a local user configured (#35060) 2020-05-02 14:16:45 -07:00
Robert Svensson 221b07595f
UniFi - Add support for 2.4/5 GHz separated SSIDs (#35062) 2020-05-02 14:16:18 -07:00
Robert Svensson 72e7beeb76
UniFi - Add simple options flow (#34990) 2020-04-30 22:33:22 -07:00
Paulus Schoutsen ec47216388
Use built-in test helpers on 3.8 (#34901) 2020-04-30 13:29:50 -07:00
Robert Svensson b578a76efa
UniFi - Move some preloading of unavailable clients earlier in setup phase (#34599)
Improve readability of setting up switch platform
2020-04-23 21:29:38 +02:00
Robert Svensson c3689d7416
UniFi - Store controller in config_entry.entry_id (#34553)
* Store controller in config_entry.entry_id

* Clean up imports
2020-04-23 16:48:24 +02:00
Robert Svensson 193e9bec97
UniFi - Simplify config option of block clients to just a multi select drop down (#34514) 2020-04-21 20:45:48 -07:00
Robert Svensson e5a861dc90
UniFi - refactor entity management (#34367)
* Move removal of sensor entities into a base class

* Fix martins comments on sensors

* Reflect sensor changes on device_tracker platform

* Reflect sensor changes on switch platform

* Improve layering

* Make sure to clean up entity and device registry when removing entities

* Fix martins comments
2020-04-19 21:30:06 +02:00
Robert Svensson 465eeab553
UniFi - Allow tracking of clients connected to third party APs (#34067)
* Allow disable wired bug work around

* Move small improvements from closed PR #34065

* Fix failing test

* Add new test

* Some extra logging

* Harmonize log outputs

* Add config flow string

* Fix Balloobs comments
2020-04-17 08:39:01 +02:00
Robert Svensson 374fe47809
UniFi - Support automatic removal of clients (#34307) 2020-04-16 15:08:53 -07:00
Robert Svensson 15ab63a4c2
UniFi: Add UDM/P (UniFi OS) support (#33766)
* Fix get_controller and all tests:wq

* Bump dependency to v16
2020-04-08 23:19:39 +02:00
Robert Svensson 314bc07cee
UniFi - Make POE control switches configurable (#32781)
* Allow control whether POE switches are to be created or not

* Fix options flow and test
2020-04-02 17:53:33 +02:00
Paulus Schoutsen 5123baba3f
Fix zone config (#32963)
* Fix zone config

* Add zone as dependency again to device tracker

* Fix tests
2020-03-18 18:14:25 -07:00
Paulus Schoutsen abd1909e2b
Make zone dependency of device tracker an after dep (#32880)
* Make zone dependency of device tracker an after dep

* Fix test
2020-03-17 06:59:39 -04:00
Robert Svensson fa63dc1e25
UniFi - Improve expected SSID filter behavior (#32785)
* Improve expected ssid filter behavior

* Fix tests
2020-03-16 12:10:45 +01:00
Robert Svensson 374a8157e7
Remove manual configuration support (#32699) 2020-03-12 11:56:50 +01:00
Paulus Schoutsen d216c1f2ac
UniFi - Add block network access control to config option (#32004)
* Add block network access control to config option

* Clean up
2020-03-04 21:55:56 -08:00
Jens Nistler ecd076c5e4
Mark clients away if they have never been seen. (#32222) 2020-02-27 11:50:34 -08:00