Avoid writing unifiprotect state when nothing has changed (#100439)
This commit is contained in:
parent
7b71d27637
commit
8a98a0e830
7 changed files with 163 additions and 25 deletions
|
@ -193,3 +193,17 @@ class ProtectButton(ProtectDeviceEntity, ButtonEntity):
|
|||
|
||||
if self.entity_description.ufp_press is not None:
|
||||
await getattr(self.device, self.entity_description.ufp_press)()
|
||||
|
||||
@callback
|
||||
def _async_updated_event(self, device: ProtectModelWithId) -> None:
|
||||
"""Call back for incoming data that only writes when state has changed.
|
||||
|
||||
Only available is updated for these entities, and since the websocket
|
||||
update for the device will trigger an update for all entities connected
|
||||
to the device, we want to avoid writing state unless something has
|
||||
actually changed.
|
||||
"""
|
||||
previous_available = self._attr_available
|
||||
self._async_update_device_from_protect(device)
|
||||
if self._attr_available != previous_available:
|
||||
self.async_write_ha_state()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue