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
This commit is contained in:
Robert Svensson 2020-05-08 22:19:27 +02:00 committed by GitHub
parent efb52961f0
commit c8deae6445
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 367 additions and 168 deletions

View file

@ -40,6 +40,7 @@ class UniFiBase(Entity):
async def async_will_remove_from_hass(self) -> None:
"""Disconnect object when removed."""
LOGGER.debug("Removing %s entity %s (%s)", self.TYPE, self.entity_id, self.mac)
self.controller.entities[self.DOMAIN][self.TYPE].remove(self.mac)
async def async_remove(self):
@ -69,9 +70,10 @@ class UniFiBase(Entity):
entity_registry.async_remove(self.entity_id)
@callback
def async_update_callback(self):
def async_update_callback(self) -> None:
"""Update the entity's state."""
raise NotImplementedError
LOGGER.debug("Updating %s entity %s (%s)", self.TYPE, self.entity_id, self.mac)
self.async_write_ha_state()
async def options_updated(self) -> None:
"""Config entry options are updated, remove entity if option is disabled."""
@ -85,4 +87,4 @@ class UniFiBase(Entity):
@property
def should_poll(self) -> bool:
"""No polling needed."""
return True
return False