Breakout heartbeat monitor and poe command queue in UniFi (#112529)

* Split out entity helper functionality to own class

* Split out heartbeat to own class

* Break out poe command

* Make more parts private

* Make more things private and simplify naming

* Sort initialize

* Fix ruff
This commit is contained in:
Robert Svensson 2024-04-23 21:45:20 +02:00 committed by GitHub
parent 3e0a45eee2
commit 8bf3c87336
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 193 additions and 91 deletions

View file

@ -460,7 +460,7 @@ class UnifiSensorEntity(UnifiEntity[HandlerT, ApiItemT], SensorEntity):
if description.is_connected_fn is not None:
# Send heartbeat if client is connected
if description.is_connected_fn(self.hub, self._obj_id):
self.hub.async_heartbeat(
self.hub.update_heartbeat(
self._attr_unique_id,
dt_util.utcnow() + self.hub.config.option_detection_time,
)
@ -485,4 +485,4 @@ class UnifiSensorEntity(UnifiEntity[HandlerT, ApiItemT], SensorEntity):
if self.entity_description.is_connected_fn is not None:
# Remove heartbeat registration
self.hub.async_heartbeat(self._attr_unique_id)
self.hub.remove_heartbeat(self._attr_unique_id)