Skip to content

Commit

Permalink
FIX restore preset after power preset
Browse files Browse the repository at this point in the history
  • Loading branch information
Jean-Marc Collin committed Jan 7, 2023
1 parent 62a5e05 commit 5fb148d
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion custom_components/versatile_thermostat/climate.py
Original file line number Diff line number Diff line change
Expand Up @@ -665,6 +665,7 @@ async def get_my_previous_state(self):

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._saved_preset_mode = self._attr_preset_mode

if not self._hvac_mode and old_state.state:
self._hvac_mode = old_state.state
Expand Down Expand Up @@ -996,6 +997,7 @@ async def _async_control_heating(self, time=None):
self,
self._attr_preset_mode,
)
await self._async_heater_turn_off()
return

on_time_sec: int = self._prop_algorithm.on_time_sec
Expand All @@ -1013,7 +1015,9 @@ async def _async_control_heating(self, time=None):
_LOGGER.debug("Cancelling the previous cycle that was running")
self._async_cancel_cycle()
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:
_LOGGER.info(
Expand Down

0 comments on commit 5fb148d

Please sign in to comment.