Commit Graph

65 Commits (34a491f826e4891f62eb368370c2ad1a26e77da2)

Author SHA1 Message Date
Robert Svensson 83a75b02ea
Code quality improvements to UniFi integration ()
* 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
Robert Svensson 26764a805b
Don't parse previous messages when UniFi connection state change to available ()
* 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 536e835b39
Switch frequently used unifi controller properties to attributes () 2021-01-20 16:58:02 -06:00
J. Nick Koston 41e7d960ee
Use dispatcher for unifi heartbeat tracking ()
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 ()
* 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 ()
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
Philip Allgaier dde6305549
Cleanup unused loggers (components N-Z + tests) () 2020-10-16 21:24:08 -05:00
springstan 513f03eb1f
Return attribute dict directly without temporary variable v2 () 2020-10-06 16:55:16 +02:00
J. Nick Koston f352c51990
Improve unifi device tracker performance ()
* Improve unifi device tracker performance

The unifi websocket sends an update every second
which generates a significant amount of state
changed updates.

Avoid creating callback functions when they
are not going to be used.

* make _no_heartbeat/_make_disconnected instance methods

* remove extra empty line

* revert is_wired change

* remove extra line
2020-07-02 17:46:37 -05:00
Robert Svensson 3a83f4bdbe
Support guest events in UniFi device tracker () 2020-06-22 21:50:34 +02:00
Robert Svensson a3865fb383
UniFi - Increase time to mark UniFi devices as away () 2020-06-02 10:35:27 +02:00
Robert Svensson 648df6d984
UniFi - Fix disabled entities being enabled after a restart ()
* Async remove call removed too much, resulting in disabled entities coming back after a restart

* Calling super().async_remove is no longer needed, changed to self.async_remove

* Yes, they should be sets...
2020-05-19 23:57:41 +02:00
Robert Svensson c71b6c8a71
UniFi - Update device registry after device has been upgraded ()
* 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 b62c7abc5d
UniFi - Additional consolidation for cleanliness sake ()
* Some additional consolidation for cleanliness sake

* Remove unnecessary mac property
2020-05-09 00:34:18 +02:00
Robert Svensson c8deae6445
UniFi - Make clients proper push based ()
* 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 53f64bae09
UniFi - Make devices proper push based ()
* Make devices proper push based

* Improve tests

* Bump dependency to v21
Update fix from  to use library
2020-05-07 09:58:04 +02:00
Robert Svensson c5ce95ff06
UniFi - Improve signalling and handling of adding new entities ()
* 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 7b90cbd2b2
UniFi - Disconnected clients wrongfully marked as wired not created () 2020-04-30 21:06:16 -07:00
Robert Svensson b578a76efa
UniFi - Move some preloading of unavailable clients earlier in setup phase ()
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 ()
* Store controller in config_entry.entry_id

* Clean up imports
2020-04-23 16:48:24 +02:00
Robert Svensson 867138ebb8
UniFi - Only match ssid filter if ssid is present, this will only affect recently disconnected clients and clients which have a previously created entry in entity registry () 2020-04-21 21:13:19 +02:00
Robert Svensson e004cd029a
UniFi - Improve handling of client tracker is connected to better respect configured delay () 2020-04-21 21:12:44 +02:00
Robert Svensson f12bd7ad99
UniFi - Logs spam with not adding disabled entity ()
* Proposed solution, unfortunately this makes the implementation less pretty

* Clarify why mac is registered in init
2020-04-21 06:17:14 +02:00
Robert Svensson e5a861dc90
UniFi - refactor entity management ()
* 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 ()
* Allow disable wired bug work around

* Move small improvements from closed PR 

* 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 () 2020-04-16 15:08:53 -07:00
Robert Svensson 529656cf64
UniFi - Improve client tracker attributes based on connection ()
* Improve client tracker attributes by setting them to None when client is disconnected

* Fix martins comment
2020-04-06 01:26:11 +02:00
Paulus Schoutsen aaa1d06809
Directly call async_write_ha_state ()
* Directly call async_write_ha_state

* Address comments

* Fix tests
2020-04-01 14:19:51 -07:00
Robert Svensson fa63dc1e25
UniFi - Improve expected SSID filter behavior ()
* Improve expected ssid filter behavior

* Fix tests
2020-03-16 12:10:45 +01:00
Robert Svensson 015e779d56
UniFi - Client tracker schedules update on disconnect event () 2020-03-11 09:24:52 -07:00
Robert Svensson f17462b159
UniFi - Temporary workaround to get device tracker to mark cli… () 2020-02-28 10:28:03 -08:00
Jens Nistler ecd076c5e4
Mark clients away if they have never been seen. () 2020-02-27 11:50:34 -08:00
Robert Svensson 4cac0443e2
UniFi - Change handling of updated options ()
* Change handling of updated options

* Add tests
2020-02-12 16:15:08 -08:00
Robert Svensson 958a867c11
UniFi integration move to push messaging ()
* Rewrite UniFi integration to use push messaging

* Add signalling for new clients/devices

* Update list of known wireless clients when we get events of them connecting

* Reconnection logic for websocket

* Fix failing tests

* Bump requirement to v12

* Add new tests

* Update homeassistant/components/unifi/controller.py

Co-Authored-By: Martin Hjelmare <marhje52@gmail.com>
2020-01-31 20:23:25 +01:00
Robert Svensson 41d2d1f309 Handle wired bug on restart () 2019-12-30 12:40:52 -06:00
Robert Svensson 856dd63680 Add more logging to help future debug situations () 2019-12-11 15:45:21 +01:00
Robert Svensson 99328bd4c1
UniFi - honor detection time when UniFi wire bug happens () 2019-12-10 20:05:18 +01:00
Robert Svensson db0baab692 Only update disabled_by when enabled default and entity enabled states differ () 2019-12-10 11:02:26 +01:00
Bas Nijholt 2da3848f89 Sort imports according to PEP8 for unifi () 2019-12-09 12:19:33 +01:00
Robert Svensson 6565c17828
UniFi - Improve controller tests ()
* Improve controller tests and harmonize setup_unifi_integration to one
* Store listeners to dispatchers to be used during reset
2019-10-07 21:55:35 +02:00
Robert Svensson 09c5b9feb3
UniFi - Try to handle when UniFi erroneously marks offline client as wired ()
* Add controls to catch when client goes offline and UniFi bug marks client as wired
* Device trackers shouldn't jump between going away and home
* POE control shouldn't add normally wireless clients as POE control switches
2019-10-02 21:43:14 +02:00
Robert Svensson e2d7a01d65 Remove last of device tracker scanner () 2019-09-30 21:19:51 -07:00
Robert Svensson 0221d136de Remove support of UniFi device tracker configuration import () 2019-09-11 13:35:30 -06:00
Franck Nijhof ef0e9431b6 Use literal string interpolation in integrations T-W (f-strings) () 2019-09-03 21:12:51 +02:00
Robert Svensson b5426761f4
UniFi - Simplify getting controller from config entry ()
* Simplify getting controller from config entry

* Lint ignore no longer needed

* Fix tests
2019-09-01 17:57:25 +02:00
Robert Svensson d9ef92f6d2
UniFi - use entity registry disabled_by to control available entities ()
* Move ignoring logic to entity registry enabled default

* Handle config to option import better

* Properly enable and disable entity registry entries on changes from config entry options

* Fix balloobs comments

* Fix some tests

* Fix tests

* Simplify updating disable on entities

* Simplify device tracker update function

* Local entity disabled replaced on rebase

* Only alter entities with changed options

* Proper tracking of changed options

* Back to straightforward updating of disabled
2019-08-31 22:04:04 +02:00
Robert Svensson 0d7326168e UniFi - dont schedule updates on disabled entities ()
* Dont schedule updates on disabled entities

* Use entity enabled since it is available
2019-08-29 14:04:01 -07:00
Robert Svensson 588eac82c7
UniFi config entry options ()
Introduce config entry options for Unifi integration
Allow configuration.yaml options to be imported to new options
2019-08-21 22:22:42 +02:00
Robert Svensson 5ca6c990cf
UniFi - add ap_mac to attributes () 2019-08-16 20:29:38 +02:00
Robert Svensson ab7db5fbd0
UniFi - Use state to know if device is online () 2019-08-11 22:40:44 +02:00