Compare commits

...

2 Commits

Author SHA1 Message Date
Jean-Marc Collin 5fb148d445 FIX restore preset after power preset 2023-01-07 19:44:43 +01:00
Jean-Marc Collin 62a5e05a7a FIX power management not intialized 2023-01-07 18:30:46 +01:00
@@ -248,16 +248,17 @@ class VersatileThermostat(ClimateEntity, RestoreEntity):
# Power management # Power management
self._device_power = device_power self._device_power = device_power
self._pmax_on = False
self._current_power = None
self._current_power_max = None
if ( if (
self._max_power_sensor_entity_id self._max_power_sensor_entity_id
and self._power_sensor_entity_id and self._power_sensor_entity_id
and self._device_power and self._device_power
): ):
self._pmax_on = True self._pmax_on = True
self._current_power = -1 self._current_power = 0
self._current_power_max = -1 self._current_power_max = 0
else:
self._pmax_on = False
# will be restored if possible # will be restored if possible
self._target_temp = None self._target_temp = None
@@ -664,6 +665,7 @@ class VersatileThermostat(ClimateEntity, RestoreEntity):
if old_state.attributes.get(ATTR_PRESET_MODE) in self._attr_preset_modes: if old_state.attributes.get(ATTR_PRESET_MODE) in self._attr_preset_modes:
self._attr_preset_mode = old_state.attributes.get(ATTR_PRESET_MODE) self._attr_preset_mode = old_state.attributes.get(ATTR_PRESET_MODE)
self._saved_preset_mode = self._attr_preset_mode
if not self._hvac_mode and old_state.state: if not self._hvac_mode and old_state.state:
self._hvac_mode = old_state.state self._hvac_mode = old_state.state
@@ -995,6 +997,7 @@ class VersatileThermostat(ClimateEntity, RestoreEntity):
self, self,
self._attr_preset_mode, self._attr_preset_mode,
) )
await self._async_heater_turn_off()
return return
on_time_sec: int = self._prop_algorithm.on_time_sec on_time_sec: int = self._prop_algorithm.on_time_sec
@@ -1012,7 +1015,9 @@ class VersatileThermostat(ClimateEntity, RestoreEntity):
_LOGGER.debug("Cancelling the previous cycle that was running") _LOGGER.debug("Cancelling the previous cycle that was running")
self._async_cancel_cycle() self._async_cancel_cycle()
self._async_cancel_cycle = None self._async_cancel_cycle = None
# await self._async_heater_turn_off() # Don't turn off if we will turn on just after
if on_time_sec <= 0:
await self._async_heater_turn_off()
if self._hvac_mode == HVAC_MODE_HEAT and on_time_sec > 0: if self._hvac_mode == HVAC_MODE_HEAT and on_time_sec > 0:
_LOGGER.info( _LOGGER.info(