From 9b26d40cecc61724269ecc6a7e6563a55b520385 Mon Sep 17 00:00:00 2001 From: Jean-Marc Collin Date: Sun, 8 Dec 2024 18:43:05 +0000 Subject: [PATCH] Issue #683 - Window action Anti frost doesnt restore the previous temp --- custom_components/versatile_thermostat/base_thermostat.py | 4 ++-- tests/test_overclimate_valve.py | 2 +- tests/test_window.py | 8 ++++++-- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/custom_components/versatile_thermostat/base_thermostat.py b/custom_components/versatile_thermostat/base_thermostat.py index 2a9e65b..0f25d3f 100644 --- a/custom_components/versatile_thermostat/base_thermostat.py +++ b/custom_components/versatile_thermostat/base_thermostat.py @@ -1329,8 +1329,8 @@ class BaseThermostat(ClimateEntity, RestoreEntity, Generic[T]): self._attr_preset_mode = PRESET_ACTIVITY await self._async_update_motion_temp() else: - if self._attr_preset_mode == PRESET_NONE: - self._saved_target_temp = self._target_temp + # if self._attr_preset_mode == PRESET_NONE: + # self._saved_target_temp = self._target_temp self._attr_preset_mode = preset_mode await self._async_internal_set_temperature( self.find_preset_temp(preset_mode) diff --git a/tests/test_overclimate_valve.py b/tests/test_overclimate_valve.py index 6b8d259..5c9ef00 100644 --- a/tests/test_overclimate_valve.py +++ b/tests/test_overclimate_valve.py @@ -19,7 +19,7 @@ logging.getLogger().setLevel(logging.DEBUG) # @pytest.mark.parametrize("expected_lingering_tasks", [True]) -# @pytest.mark.parametrize("expected_lingering_timers", [True]) +@pytest.mark.parametrize("expected_lingering_timers", [True]) # this test fails if run in // with the next because the underlying_valve_regulation is mixed. Don't know why # @pytest.mark.skip async def test_over_climate_valve_mono(hass: HomeAssistant, skip_hass_states_get): diff --git a/tests/test_window.py b/tests/test_window.py index d3ac4ed..e36c431 100644 --- a/tests/test_window.py +++ b/tests/test_window.py @@ -1802,7 +1802,7 @@ async def test_window_action_frost_temp(hass: HomeAssistant, skip_hass_states_is event_timestamp = event_timestamp + timedelta(minutes=1) await send_temperature_change_event(entity, 19, event_timestamp) - # 2. Make the temperature down + # 2. Make the temperature down -> no change with patch( "custom_components.versatile_thermostat.base_thermostat.BaseThermostat.send_event" ) as mock_send_event, patch( @@ -1824,7 +1824,7 @@ async def test_window_action_frost_temp(hass: HomeAssistant, skip_hass_states_is assert entity.window_state is STATE_OFF assert entity.window_auto_state is STATE_OFF - # 3. send one degre down in one minute + # 3. send one degre down in one minute -> window is on with patch( "custom_components.versatile_thermostat.base_thermostat.BaseThermostat.send_event" ) as mock_send_event, patch( @@ -1852,6 +1852,8 @@ async def test_window_action_frost_temp(hass: HomeAssistant, skip_hass_states_is assert entity.preset_mode is PRESET_BOOST # The eco temp assert entity.target_temperature == 10 + # The last temp is saved + assert entity._saved_target_temp == 21 mock_send_event.assert_has_calls( [ @@ -1889,6 +1891,7 @@ async def test_window_action_frost_temp(hass: HomeAssistant, skip_hass_states_is assert entity.preset_mode is PRESET_BOOST # The eco temp assert entity.target_temperature == 10 + assert entity._saved_target_temp == 21 # 5. send another plus 1.1 degre in one minute -> restore state with patch( @@ -1929,6 +1932,7 @@ async def test_window_action_frost_temp(hass: HomeAssistant, skip_hass_states_is assert entity.preset_mode is PRESET_BOOST # The eco temp assert entity.target_temperature == 21 + assert entity._saved_target_temp == 21 # Clean the entity entity.remove_thermostat()