Skip to content

Commit

Permalink
Integration tests ok
Browse files Browse the repository at this point in the history
  • Loading branch information
Jean-Marc Collin committed Jan 4, 2025
1 parent c01f96c commit 10c8281
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
6 changes: 3 additions & 3 deletions custom_components/versatile_thermostat/base_thermostat.py
Original file line number Diff line number Diff line change
Expand Up @@ -1452,7 +1452,7 @@ async def async_underlying_entity_turn_off(self):
control_heating to turn all off"""

for under in self._underlyings:
await under.turn_off()
await under.turn_off_and_cancel_cycle()

def save_preset_mode(self):
"""Save the current preset mode to be restored later
Expand All @@ -1464,15 +1464,15 @@ def save_preset_mode(self):
):
self._saved_preset_mode = self._attr_preset_mode

async def restore_preset_mode(self):
async def restore_preset_mode(self, force=False):
"""Restore a previous preset mode
We never restore a hidden preset mode. Normally that is not possible
"""
if (
self._saved_preset_mode not in HIDDEN_PRESETS
and self._saved_preset_mode is not None
):
await self.async_set_preset_mode_internal(self._saved_preset_mode)
await self.async_set_preset_mode_internal(self._saved_preset_mode, force=force)

def save_hvac_mode(self):
"""Save the current hvac-mode to be restored later"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ async def set_overpowering(self, overpowering: bool, power_consumption_max=0):

self._vtherm.save_preset_mode()
await self._vtherm.async_underlying_entity_turn_off()
await self._vtherm.async_set_preset_mode_internal(PRESET_POWER)
await self._vtherm.async_set_preset_mode_internal(PRESET_POWER, force=True)
self._vtherm.send_event(
EventType.POWER_EVENT,
{
Expand All @@ -198,9 +198,12 @@ async def set_overpowering(self, overpowering: bool, power_consumption_max=0):
)
self._overpowering_state = STATE_OFF

# restore state
if self._vtherm.is_over_climate:
await self._vtherm.restore_hvac_mode(False)
await self._vtherm.restore_hvac_mode()
await self._vtherm.restore_preset_mode()
# restart cycle
await self._vtherm.async_control_heating(force=True)
self._vtherm.send_event(
EventType.POWER_EVENT,
{
Expand Down
5 changes: 5 additions & 0 deletions custom_components/versatile_thermostat/underlyings.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,11 @@ def cap_sent_value(self, value) -> float:
"""capping of the value send to the underlying eqt"""
return value

async def turn_off_and_cancel_cycle(self):
"""Turn off and cancel eventual running cycle"""
self._cancel_cycle()
await self.turn_off()


class UnderlyingSwitch(UnderlyingEntity):
"""Represent a underlying switch"""
Expand Down

0 comments on commit 10c8281

Please sign in to comment.