From 8776d30862f258ff1963ffa3fe8abe895a8da80b Mon Sep 17 00:00:00 2001 From: Simone Chemelli Date: Sat, 7 Sep 2024 17:00:46 +0000 Subject: [PATCH 1/2] fix: avoid updates during shutdown --- custom_components/midea_ac_lan/midea_entity.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/custom_components/midea_ac_lan/midea_entity.py b/custom_components/midea_ac_lan/midea_entity.py index 98ccaae..793c792 100644 --- a/custom_components/midea_ac_lan/midea_entity.py +++ b/custom_components/midea_ac_lan/midea_entity.py @@ -89,6 +89,9 @@ def icon(self) -> str: @callback def update_state(self, status: Any) -> None: # noqa: ANN401 """Update entity state.""" + if self.hass.is_stopping: + return + if not self.hass: _LOGGER.error( "Midea entity update_state for %s [%s] with status %s", From 93a225f620d9e10dc8a60d9d8bde866554f9cc79 Mon Sep 17 00:00:00 2001 From: Simone Chemelli Date: Thu, 19 Sep 2024 16:54:11 +0000 Subject: [PATCH 2/2] invert check --- custom_components/midea_ac_lan/midea_entity.py | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/custom_components/midea_ac_lan/midea_entity.py b/custom_components/midea_ac_lan/midea_entity.py index 793c792..28ec3d5 100644 --- a/custom_components/midea_ac_lan/midea_entity.py +++ b/custom_components/midea_ac_lan/midea_entity.py @@ -89,15 +89,23 @@ def icon(self) -> str: @callback def update_state(self, status: Any) -> None: # noqa: ANN401 """Update entity state.""" - if self.hass.is_stopping: - return - if not self.hass: _LOGGER.error( - "Midea entity update_state for %s [%s] with status %s", + "MideaEntity update_state for %s [%s] with status %s: HASS is None", + self.name, + type(self), + status, + ) + return + + if self.hass.is_stopping: + _LOGGER.debug( + "MideaEntity update_state for %s [%s] with status %s: HASS is stopping", self.name, type(self), status, ) + return + if self._entity_key in status or "available" in status: self.schedule_update_ha_state()