update state only on changes

This commit is contained in:
Martín Villagra
2021-08-31 13:49:39 +01:00
parent e13f02a881
commit 24152569e7

View File

@@ -234,12 +234,12 @@ class LocalTuyaEntity(RestoreEntity, pytuya.ContextualLogger):
def _update_handler(status): def _update_handler(status):
"""Update entity state when status was updated.""" """Update entity state when status was updated."""
if status is not None: if status is None:
self._status = status status = {}
if self._status != status:
self._status = status.copy()
if status:
self.status_updated() self.status_updated()
else:
self._status = {}
self.schedule_update_ha_state() self.schedule_update_ha_state()
signal = f"localtuya_{self._config_entry.data[CONF_DEVICE_ID]}" signal = f"localtuya_{self._config_entry.data[CONF_DEVICE_ID]}"