Skip to content

Commit

Permalink
Issue #683 - Window action Anti frost doesnt restore the previous temp
Browse files Browse the repository at this point in the history
  • Loading branch information
Jean-Marc Collin committed Dec 8, 2024
1 parent e9dcb21 commit 9b26d40
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
4 changes: 2 additions & 2 deletions custom_components/versatile_thermostat/base_thermostat.py
Original file line number Diff line number Diff line change
Expand Up @@ -1329,8 +1329,8 @@ async def _async_set_preset_mode_internal(
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)
Expand Down
2 changes: 1 addition & 1 deletion tests/test_overclimate_valve.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@


# @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):
Expand Down
8 changes: 6 additions & 2 deletions tests/test_window.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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(
Expand Down Expand Up @@ -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(
[
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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()
Expand Down

0 comments on commit 9b26d40

Please sign in to comment.