From 10c8281b3284fc6c17981d0816565fc2f9d32440 Mon Sep 17 00:00:00 2001 From: Jean-Marc Collin Date: Sat, 4 Jan 2025 17:38:17 +0000 Subject: [PATCH] Integration tests ok --- custom_components/versatile_thermostat/base_thermostat.py | 6 +++--- .../versatile_thermostat/feature_power_manager.py | 7 +++++-- custom_components/versatile_thermostat/underlyings.py | 5 +++++ 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/custom_components/versatile_thermostat/base_thermostat.py b/custom_components/versatile_thermostat/base_thermostat.py index c88d3c0..6b31ec8 100644 --- a/custom_components/versatile_thermostat/base_thermostat.py +++ b/custom_components/versatile_thermostat/base_thermostat.py @@ -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 @@ -1464,7 +1464,7 @@ 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 """ @@ -1472,7 +1472,7 @@ async def restore_preset_mode(self): 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""" diff --git a/custom_components/versatile_thermostat/feature_power_manager.py b/custom_components/versatile_thermostat/feature_power_manager.py index e9a2030..1224dee 100644 --- a/custom_components/versatile_thermostat/feature_power_manager.py +++ b/custom_components/versatile_thermostat/feature_power_manager.py @@ -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, { @@ -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, { diff --git a/custom_components/versatile_thermostat/underlyings.py b/custom_components/versatile_thermostat/underlyings.py index 1b95f44..ae5034d 100644 --- a/custom_components/versatile_thermostat/underlyings.py +++ b/custom_components/versatile_thermostat/underlyings.py @@ -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"""