From 7bb1d1795d3d395c64b1f0bc6661687751dc1843 Mon Sep 17 00:00:00 2001 From: Igor via Mortimer Date: Tue, 2 Jun 2026 10:25:38 +0000 Subject: [PATCH] Avoid invalid climate on state from power sensor --- custom_components/smartir/climate.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/custom_components/smartir/climate.py b/custom_components/smartir/climate.py index f59fe46b0..7d2e6c8e4 100644 --- a/custom_components/smartir/climate.py +++ b/custom_components/smartir/climate.py @@ -425,7 +425,11 @@ async def _async_power_sensor_changed(self, event: Event[EventStateChangedData]) if self._power_sensor_restore_state == True and self._last_on_operation is not None: self._hvac_mode = self._last_on_operation else: - self._hvac_mode = STATE_ON + self._hvac_mode = ( + self._operation_modes[1] + if len(self._operation_modes) > 1 + else HVACMode.OFF + ) self.async_write_ha_state() @@ -451,4 +455,4 @@ def _async_update_humidity(self, state): if state.state != STATE_UNKNOWN and state.state != STATE_UNAVAILABLE: self._current_humidity = float(state.state) except ValueError as ex: - _LOGGER.error("Unable to update from humidity sensor: %s", ex) \ No newline at end of file + _LOGGER.error("Unable to update from humidity sensor: %s", ex)