From 95c5cf94c26edfa77697731d590d0f6737f6e921 Mon Sep 17 00:00:00 2001 From: Jean-Marc Collin Date: Mon, 2 Jan 2023 15:48:10 +0100 Subject: [PATCH] FIX exception when temperature state is not retrieved FIX start heating for 0 sec --- custom_components/versatile_thermostat/climate.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/custom_components/versatile_thermostat/climate.py b/custom_components/versatile_thermostat/climate.py index 7becd53..404b54f 100644 --- a/custom_components/versatile_thermostat/climate.py +++ b/custom_components/versatile_thermostat/climate.py @@ -789,7 +789,9 @@ class VersatileThermostat(ClimateEntity, RestoreEntity): _LOGGER.debug(event) new_state = event.data.get("new_state") old_state = event.data.get("old_state") - if new_state is None or new_state.state == old_state.state: + if new_state is None or ( + old_state is not None and new_state.state == old_state.state + ): return try: @@ -896,7 +898,7 @@ class VersatileThermostat(ClimateEntity, RestoreEntity): self._async_cancel_cycle = None await self._async_heater_turn_off() - if self._hvac_mode == HVAC_MODE_HEAT: + if self._hvac_mode == HVAC_MODE_HEAT and on_time_sec > 0: _LOGGER.info( "%s - start heating for %d min %d sec ", self,