From e575b7baa74f01633dbd666fff670e6a65d9fa03 Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Sun, 12 Mar 2023 16:05:14 -1000 Subject: [PATCH] Only write state if status has changed for shelly RPC devices --- homeassistant/components/shelly/entity.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/homeassistant/components/shelly/entity.py b/homeassistant/components/shelly/entity.py index 1f18a5f8e1..e13e2547a3 100644 --- a/homeassistant/components/shelly/entity.py +++ b/homeassistant/components/shelly/entity.py @@ -368,6 +368,7 @@ class ShellyRpcEntity(CoordinatorEntity[ShellyRpcCoordinator]): } self._attr_unique_id = f"{coordinator.mac}-{key}" self._attr_name = get_rpc_entity_name(coordinator.device, key) + self._last_status: dict | None = None @property def available(self) -> bool: @@ -386,7 +387,9 @@ class ShellyRpcEntity(CoordinatorEntity[ShellyRpcCoordinator]): @callback def _update_callback(self) -> None: """Handle device update.""" - self.async_write_ha_state() + if self.status != self._last_status: + self._last_status = self.status + self.async_write_ha_state() async def call_rpc(self, method: str, params: Any) -> Any: """Call RPC method."""