From 329598b95ad65e1900bb579f56d0d5a9beae16b6 Mon Sep 17 00:00:00 2001 From: Jean-Marc Collin Date: Fri, 27 Dec 2024 12:47:19 +0000 Subject: [PATCH] All windows tests ok --- .../versatile_thermostat/base_thermostat.py | 5 + .../feature_window_manager.py | 11 +- tests/commons.py | 2 +- tests/test_binary_sensors.py | 2 +- tests/test_central_config.py | 8 +- tests/test_central_mode.py | 4 +- tests/test_multiple_switch.py | 2 +- tests/test_window.py | 181 +++++++++++------- tests/test_window_feature_manager.py | 2 +- 9 files changed, 135 insertions(+), 82 deletions(-) diff --git a/custom_components/versatile_thermostat/base_thermostat.py b/custom_components/versatile_thermostat/base_thermostat.py index 35b3ae1..51f793e 100644 --- a/custom_components/versatile_thermostat/base_thermostat.py +++ b/custom_components/versatile_thermostat/base_thermostat.py @@ -854,6 +854,11 @@ class BaseThermostat(ClimateEntity, RestoreEntity, Generic[T]): """Get the motion manager""" return self._motion_manager + @property + def window_manager(self) -> FeatureWindowManager | None: + """Get the window manager""" + return self._window_manager + @property def window_state(self) -> str | None: """Get the window_state""" diff --git a/custom_components/versatile_thermostat/feature_window_manager.py b/custom_components/versatile_thermostat/feature_window_manager.py index 30a657d..8b036e9 100644 --- a/custom_components/versatile_thermostat/feature_window_manager.py +++ b/custom_components/versatile_thermostat/feature_window_manager.py @@ -154,7 +154,7 @@ class FeatureWindowManager(BaseFeatureManager): """Tries to get the last state from sensor Returns True if a change has been made""" ret = False - if self._is_configured: + if self._is_configured and self._window_sensor_entity_id is not None: window_state = self.hass.states.get(self._window_sensor_entity_id) if window_state and window_state.state not in ( @@ -200,8 +200,7 @@ class FeatureWindowManager(BaseFeatureManager): _LOGGER.debug( "Window delay condition is not satisfied. Ignore window event" ) - # TODO Why ? - # self._window_state = old_state.state or STATE_OFF + self._window_state = old_state.state or STATE_OFF return _LOGGER.debug("%s - Window delay condition is satisfied", self) @@ -215,6 +214,8 @@ class FeatureWindowManager(BaseFeatureManager): _LOGGER.info( "%s - Window ByPass is activated. Ignore window event", self ) + # We change tne state but we don't apply the change + self._window_state = new_state.state else: await self.update_window_state(new_state.state) @@ -353,12 +354,12 @@ class FeatureWindowManager(BaseFeatureManager): if in_cycle: slope = self._window_auto_algo.check_age_last_measurement( - temperature=self._vtherm.ema_temp, + temperature=self._vtherm.ema_temperature, datetime_now=self._vtherm.now, ) else: slope = self._window_auto_algo.add_temp_measurement( - temperature=self._vtherm.ema_temp, + temperature=self._vtherm.ema_temperature, datetime_measure=self._vtherm.last_temperature_measure, ) diff --git a/tests/commons.py b/tests/commons.py index 5b8a5b0..371cdec 100644 --- a/tests/commons.py +++ b/tests/commons.py @@ -800,7 +800,7 @@ async def send_window_change_event( ), }, ) - ret = await entity._async_windows_changed(window_event) + ret = await entity.window_manager._window_sensor_changed(window_event) if sleep: await asyncio.sleep(0.1) return ret diff --git a/tests/test_binary_sensors.py b/tests/test_binary_sensors.py index ad713ee..66cbe27 100644 --- a/tests/test_binary_sensors.py +++ b/tests/test_binary_sensors.py @@ -241,7 +241,7 @@ async def test_window_binary_sensors( await entity.async_set_preset_mode(PRESET_COMFORT) await entity.async_set_hvac_mode(HVACMode.HEAT) await send_temperature_change_event(entity, 15, now) - assert entity.window_state is STATE_OFF + assert entity.window_state is STATE_UNKNOWN await window_binary_sensor.async_my_climate_changed() assert window_binary_sensor.state is STATE_OFF diff --git a/tests/test_central_config.py b/tests/test_central_config.py index 7a42f75..02f0727 100644 --- a/tests/test_central_config.py +++ b/tests/test_central_config.py @@ -167,7 +167,7 @@ async def test_minimal_over_switch_wo_central_config( assert entity.max_temp == 18 assert entity.target_temperature_step == 0.3 assert entity.preset_modes == ["none", "frost", "eco", "comfort", "boost"] - assert entity.is_window_auto_configured is False + assert entity.window_manager.is_window_auto_configured is False assert entity.nb_underlying_entities == 1 assert entity.underlying_entity_id(0) == "switch.mock_switch" assert entity.proportional_algorithm is not None @@ -279,7 +279,9 @@ async def test_full_over_switch_wo_central_config( assert entity._security_default_on_percent == 0.1 assert entity.is_inversed is False - assert entity.is_window_auto_configured is False # we have an entity_id + assert ( + entity.window_manager.is_window_auto_configured is False + ) # we have an entity_id assert entity._window_sensor_entity_id == "binary_sensor.mock_window_sensor" assert entity._window_delay_sec == 30 assert entity._window_auto_close_threshold == 0.1 @@ -402,7 +404,7 @@ async def test_full_over_switch_with_central_config( assert entity.is_inversed is False # We have an entity so window auto is not enabled - assert entity.is_window_auto_configured is False + assert entity.window_manager.is_window_auto_configured is False assert entity._window_sensor_entity_id == "binary_sensor.mock_window_sensor" assert entity._window_delay_sec == 15 assert entity._window_auto_close_threshold == 1 diff --git a/tests/test_central_mode.py b/tests/test_central_mode.py index f598087..28e1903 100644 --- a/tests/test_central_mode.py +++ b/tests/test_central_mode.py @@ -816,7 +816,7 @@ async def test_switch_change_central_mode_true_with_window( assert entity.hvac_mode == HVACMode.HEAT assert entity.preset_mode == PRESET_ACTIVITY - assert entity.window_state is STATE_OFF + assert entity.window_state is STATE_UNKNOWN # 2 Open the window with patch( @@ -973,7 +973,7 @@ async def test_switch_change_central_mode_true_with_cool_only_and_window( assert entity.hvac_mode == HVACMode.HEAT assert entity.preset_mode == PRESET_ACTIVITY - assert entity.window_state is STATE_OFF + assert entity.window_state is STATE_UNKNOWN # 2 Change central_mode to COOL_ONLY with patch("homeassistant.core.ServiceRegistry.async_call"): diff --git a/tests/test_multiple_switch.py b/tests/test_multiple_switch.py index 8e11724..5ea309e 100644 --- a/tests/test_multiple_switch.py +++ b/tests/test_multiple_switch.py @@ -69,7 +69,7 @@ async def test_one_switch_cycle( assert entity.hvac_mode is HVACMode.HEAT assert entity.preset_mode is PRESET_BOOST assert entity.target_temperature == 19 - assert entity.window_state is STATE_OFF + assert entity.window_state is STATE_UNKNOWN event_timestamp = now - timedelta(minutes=4) await send_temperature_change_event(entity, 15, event_timestamp) diff --git a/tests/test_window.py b/tests/test_window.py index 6fa2254..1de2921 100644 --- a/tests/test_window.py +++ b/tests/test_window.py @@ -68,7 +68,7 @@ async def test_window_management_time_not_enough( assert entity.power_manager.overpowering_state is STATE_UNAVAILABLE assert entity.target_temperature == 19 - assert entity.window_state is STATE_OFF + assert entity.window_state is STATE_UNKNOWN # Open the window, but condition of time is not satisfied and check the thermostat don't turns off with patch( @@ -157,7 +157,7 @@ async def test_window_management_time_enough( assert entity.power_manager.overpowering_state is STATE_UNAVAILABLE assert entity.target_temperature == 19 - assert entity.window_state is STATE_OFF + assert entity.window_state is STATE_UNKNOWN # change temperature to force turning on the heater with patch( @@ -307,8 +307,8 @@ async def test_window_auto_fast(hass: HomeAssistant, skip_hass_states_is_state): assert entity.power_manager.overpowering_state is STATE_UNAVAILABLE assert entity.target_temperature == 21 - assert entity.window_state is STATE_OFF - assert entity.is_window_auto_configured is True + assert entity.window_state is STATE_UNKNOWN + assert entity.window_manager.is_window_auto_configured is True # Initialize the slope algo with 2 measurements event_timestamp = now + timedelta(minutes=1) @@ -337,8 +337,12 @@ async def test_window_auto_fast(hass: HomeAssistant, skip_hass_states_is_state): assert mock_send_event.call_count == 0 assert entity.is_device_active is True assert entity.last_temperature_slope == 0.0 - assert entity._window_auto_algo.is_window_open_detected() is False - assert entity._window_auto_algo.is_window_close_detected() is False + assert ( + entity.window_manager._window_auto_algo.is_window_open_detected() is False + ) + assert ( + entity.window_manager._window_auto_algo.is_window_close_detected() is False + ) assert entity.hvac_mode is HVACMode.HEAT # send one degre down in one minute @@ -361,8 +365,10 @@ async def test_window_auto_fast(hass: HomeAssistant, skip_hass_states_is_state): assert mock_heater_on.call_count == 0 assert mock_heater_off.call_count >= 1 assert entity.last_temperature_slope == -6.24 - assert entity._window_auto_algo.is_window_open_detected() is True - assert entity._window_auto_algo.is_window_close_detected() is False + assert entity.window_manager._window_auto_algo.is_window_open_detected() is True + assert ( + entity.window_manager._window_auto_algo.is_window_close_detected() is False + ) assert entity.window_auto_state == STATE_ON assert entity.hvac_mode is HVACMode.OFF @@ -397,8 +403,10 @@ async def test_window_auto_fast(hass: HomeAssistant, skip_hass_states_is_state): assert mock_heater_on.call_count == 0 assert mock_heater_off.call_count == 0 assert round(entity.last_temperature_slope, 3) == -7.49 - assert entity._window_auto_algo.is_window_open_detected() is True - assert entity._window_auto_algo.is_window_close_detected() is False + assert entity.window_manager._window_auto_algo.is_window_open_detected() is True + assert ( + entity.window_manager._window_auto_algo.is_window_close_detected() is False + ) assert entity.window_auto_state == STATE_ON assert entity.hvac_mode is HVACMode.OFF @@ -438,8 +446,12 @@ async def test_window_auto_fast(hass: HomeAssistant, skip_hass_states_is_state): assert mock_heater_on.call_count == 1 assert mock_heater_off.call_count == 0 assert entity.last_temperature_slope == 0.42 - assert entity._window_auto_algo.is_window_open_detected() is False - assert entity._window_auto_algo.is_window_close_detected() is True + assert ( + entity.window_manager._window_auto_algo.is_window_open_detected() is False + ) + assert ( + entity.window_manager._window_auto_algo.is_window_close_detected() is True + ) assert entity.window_auto_state == STATE_OFF assert entity.hvac_mode is HVACMode.HEAT @@ -481,6 +493,7 @@ async def test_window_auto_fast_and_sensor( CONF_SECURITY_DELAY_MIN: 5, CONF_SECURITY_MIN_ON_PERCENT: 0.3, CONF_WINDOW_SENSOR: "binary_sensor.fake_window_sensor", + CONF_WINDOW_DELAY: 10, CONF_WINDOW_AUTO_OPEN_THRESHOLD: 0.1, CONF_WINDOW_AUTO_CLOSE_THRESHOLD: 0.1, CONF_WINDOW_AUTO_MAX_DURATION: 10, # Should be 0 for test @@ -504,8 +517,10 @@ async def test_window_auto_fast_and_sensor( assert entity.preset_mode is PRESET_BOOST assert entity.target_temperature == 21 - assert entity.window_state is STATE_OFF - assert entity.is_window_auto_configured is False + assert entity.window_state is STATE_UNKNOWN + assert entity.window_auto_state is STATE_UNAVAILABLE + assert entity.window_manager.is_window_auto_configured is False + assert entity.window_manager.is_configured is True # Initialize the slope algo with 2 measurements event_timestamp = now + timedelta(minutes=1) @@ -534,8 +549,12 @@ async def test_window_auto_fast_and_sensor( assert mock_send_event.call_count == 0 assert entity.is_device_active is True assert entity.last_temperature_slope == 0.0 - assert entity._window_auto_algo.is_window_open_detected() is False - assert entity._window_auto_algo.is_window_close_detected() is False + assert ( + entity.window_manager._window_auto_algo.is_window_open_detected() is False + ) + assert ( + entity.window_manager._window_auto_algo.is_window_close_detected() is False + ) assert entity.hvac_mode is HVACMode.HEAT # send one degre down in one minute @@ -559,9 +578,11 @@ async def test_window_auto_fast_and_sensor( assert entity.last_temperature_slope == -6.24 # The window open should be detected (but not used) # because we need to calculate the slope anyway, we have the algorithm running - assert entity._window_auto_algo.is_window_open_detected() is True - assert entity._window_auto_algo.is_window_close_detected() is False - assert entity.window_auto_state == STATE_OFF + assert entity.window_manager._window_auto_algo.is_window_open_detected() is True + assert ( + entity.window_manager._window_auto_algo.is_window_close_detected() is False + ) + assert entity.window_auto_state == STATE_UNAVAILABLE assert entity.hvac_mode is HVACMode.HEAT # Clean the entity @@ -620,8 +641,8 @@ async def test_window_auto_auto_stop(hass: HomeAssistant, skip_hass_states_is_st assert entity.power_manager.overpowering_state is STATE_UNAVAILABLE assert entity.target_temperature == 21 - assert entity.window_state is STATE_OFF - assert entity.is_window_auto_configured is True + assert entity.window_state is STATE_UNKNOWN + assert entity.window_manager.is_window_auto_configured is True # 1. Initialize the slope algo with 2 measurements event_timestamp = now + timedelta(minutes=1) @@ -647,8 +668,12 @@ async def test_window_auto_auto_stop(hass: HomeAssistant, skip_hass_states_is_st # The climate turns on but was alredy on assert mock_set_hvac_mode.call_count == 0 assert entity.last_temperature_slope == 0.0 - assert entity._window_auto_algo.is_window_open_detected() is False - assert entity._window_auto_algo.is_window_close_detected() is False + assert ( + entity.window_manager._window_auto_algo.is_window_open_detected() is False + ) + assert ( + entity.window_manager._window_auto_algo.is_window_close_detected() is False + ) assert entity.hvac_mode is HVACMode.HEAT # 3. send one degre down in one minute @@ -665,8 +690,10 @@ async def test_window_auto_auto_stop(hass: HomeAssistant, skip_hass_states_is_st await send_temperature_change_event(entity, 18, event_timestamp, sleep=False) assert entity.last_temperature_slope == -6.24 - assert entity._window_auto_algo.is_window_open_detected() is True - assert entity._window_auto_algo.is_window_close_detected() is False + assert entity.window_manager._window_auto_algo.is_window_open_detected() is True + assert ( + entity.window_manager._window_auto_algo.is_window_close_detected() is False + ) assert mock_send_event.call_count == 2 # The heater turns off @@ -714,8 +741,12 @@ async def test_window_auto_auto_stop(hass: HomeAssistant, skip_hass_states_is_st assert mock_set_hvac_mode.call_count == 1 assert round(entity.last_temperature_slope, 3) == -0.29 - assert entity._window_auto_algo.is_window_open_detected() is False - assert entity._window_auto_algo.is_window_close_detected() is False + assert ( + entity.window_manager._window_auto_algo.is_window_open_detected() is False + ) + assert ( + entity.window_manager._window_auto_algo.is_window_close_detected() is False + ) # Clean the entity entity.remove_thermostat() @@ -756,7 +787,7 @@ async def test_window_auto_no_on_percent( CONF_SECURITY_MIN_ON_PERCENT: 0.3, CONF_WINDOW_AUTO_OPEN_THRESHOLD: 6, CONF_WINDOW_AUTO_CLOSE_THRESHOLD: 6, - CONF_WINDOW_AUTO_MAX_DURATION: 0, # Should be 0 for test + CONF_WINDOW_AUTO_MAX_DURATION: 1, # Should be 0 for test but 0 is not possible }, ) @@ -778,7 +809,8 @@ async def test_window_auto_no_on_percent( assert entity.power_manager.overpowering_state is STATE_UNAVAILABLE assert entity.target_temperature == 20 - assert entity.window_state is STATE_OFF + assert entity.window_state is STATE_UNKNOWN + assert entity.window_auto_state is STATE_UNKNOWN # Initialize the slope algo with 2 measurements event_timestamp = now + timedelta(minutes=1) @@ -806,8 +838,12 @@ async def test_window_auto_no_on_percent( # The heater don't turns on assert mock_heater_on.call_count == 0 assert entity.last_temperature_slope == 0.0 - assert entity._window_auto_algo.is_window_open_detected() is False - assert entity._window_auto_algo.is_window_close_detected() is False + assert ( + entity.window_manager._window_auto_algo.is_window_open_detected() is False + ) + assert ( + entity.window_manager._window_auto_algo.is_window_close_detected() is False + ) assert entity.hvac_mode is HVACMode.HEAT assert entity.proportional_algorithm.on_percent == 0.0 @@ -833,10 +869,12 @@ async def test_window_auto_no_on_percent( assert mock_heater_off.call_count == 1 assert entity.last_temperature_slope == -6.24 # The algo calculate open ... - assert entity._window_auto_algo.is_window_open_detected() is True - assert entity._window_auto_algo.is_window_close_detected() is False - # But the entity is still on - assert entity.window_auto_state == STATE_OFF + assert entity.window_manager._window_auto_algo.is_window_open_detected() is True + assert ( + entity.window_manager._window_auto_algo.is_window_close_detected() is False + ) + # But the entity is still on and window_auto is not detected + assert entity.window_auto_state == STATE_UNKNOWN assert entity.hvac_mode is HVACMode.HEAT # Clean the entity @@ -894,8 +932,8 @@ async def test_window_bypass(hass: HomeAssistant, skip_hass_states_is_state): assert entity.power_manager.overpowering_state is STATE_UNAVAILABLE assert entity.target_temperature == 19 - assert entity.window_state is STATE_OFF - assert entity.is_window_auto_configured is False + assert entity.window_state is STATE_UNKNOWN + assert entity.window_manager.is_window_auto_configured is False # change temperature to force turning on the heater with patch( @@ -920,8 +958,6 @@ async def test_window_bypass(hass: HomeAssistant, skip_hass_states_is_state): await entity.service_set_window_bypass_state(True) assert entity.is_window_bypass is True - # entity._is_window_bypass = True - # Open the window, condition of time is satisfied, check the thermostat and heater turns off with patch( "custom_components.versatile_thermostat.base_thermostat.BaseThermostat.send_event" @@ -936,7 +972,10 @@ async def test_window_bypass(hass: HomeAssistant, skip_hass_states_is_state): new_callable=PropertyMock, return_value=True, ): - await send_window_change_event(entity, True, False, datetime.now()) + try_function = await send_window_change_event( + entity, True, False, datetime.now() + ) + await try_function(None) assert mock_send_event.call_count == 0 @@ -944,7 +983,7 @@ async def test_window_bypass(hass: HomeAssistant, skip_hass_states_is_state): assert mock_heater_on.call_count == 0 # One call in set_hvac_mode turn_off and one call in the control_heating for security assert mock_heater_off.call_count == 0 - assert mock_condition.call_count == 1 + assert mock_condition.call_count > 0 assert entity.hvac_mode is HVACMode.HEAT assert entity.window_state == STATE_ON @@ -1037,8 +1076,8 @@ async def test_window_auto_bypass(hass: HomeAssistant, skip_hass_states_is_state assert entity.power_manager.overpowering_state is STATE_UNAVAILABLE assert entity.target_temperature == 21 - assert entity.window_state is STATE_OFF - assert entity.is_window_auto_configured + assert entity.window_state is STATE_UNKNOWN + assert entity.window_manager.is_window_auto_configured # Initialize the slope algo with 2 measurements event_timestamp = now + timedelta(minutes=1) @@ -1066,8 +1105,12 @@ async def test_window_auto_bypass(hass: HomeAssistant, skip_hass_states_is_state # The heater turns on assert entity.is_device_active is True assert entity.last_temperature_slope == 0.0 - assert entity._window_auto_algo.is_window_open_detected() is False - assert entity._window_auto_algo.is_window_close_detected() is False + assert ( + entity.window_manager._window_auto_algo.is_window_open_detected() is False + ) + assert ( + entity.window_manager._window_auto_algo.is_window_close_detected() is False + ) assert entity.hvac_mode is HVACMode.HEAT # send one degre down in one minute with window bypass on @@ -1094,9 +1137,11 @@ async def test_window_auto_bypass(hass: HomeAssistant, skip_hass_states_is_state assert mock_heater_on.call_count == 0 assert mock_heater_off.call_count == 0 assert entity.last_temperature_slope == -6.24 - assert entity._window_auto_algo.is_window_open_detected() is True - assert entity._window_auto_algo.is_window_close_detected() is False - assert entity.window_auto_state == STATE_OFF + assert entity.window_manager._window_auto_algo.is_window_open_detected() is True + assert ( + entity.window_manager._window_auto_algo.is_window_close_detected() is False + ) + assert entity.window_auto_state == STATE_UNKNOWN assert entity.hvac_mode is HVACMode.HEAT # Clean the entity @@ -1155,7 +1200,7 @@ async def test_window_bypass_reactivate(hass: HomeAssistant, skip_hass_states_is assert entity.power_manager.overpowering_state is STATE_UNAVAILABLE assert entity.target_temperature == 19 - assert entity.window_state is STATE_OFF + assert entity.window_state is STATE_UNKNOWN # change temperature to force turning on the heater with patch( @@ -1299,7 +1344,7 @@ async def test_window_action_fan_only(hass: HomeAssistant, skip_hass_states_is_s assert entity assert entity.is_over_climate is True - assert entity.window_action == CONF_WINDOW_FAN_ONLY + assert entity.window_manager.window_action == CONF_WINDOW_FAN_ONLY await entity.async_set_hvac_mode(HVACMode.HEAT) assert entity.hvac_mode == HVACMode.HEAT @@ -1307,7 +1352,7 @@ async def test_window_action_fan_only(hass: HomeAssistant, skip_hass_states_is_s assert entity.preset_mode == PRESET_COMFORT assert entity.target_temperature == 18 - assert entity.window_state is STATE_OFF + assert entity.window_state is STATE_UNKNOWN # 2. Open the window, condition of time is satisfied, check the thermostat and heater turns off with patch( @@ -1456,7 +1501,7 @@ async def test_window_action_fan_only_ko( assert entity assert entity.is_over_climate is True - assert entity.window_action == CONF_WINDOW_FAN_ONLY + assert entity.window_manager.window_action == CONF_WINDOW_FAN_ONLY await entity.async_set_hvac_mode(HVACMode.HEAT) assert entity.hvac_mode == HVACMode.HEAT @@ -1464,7 +1509,7 @@ async def test_window_action_fan_only_ko( assert entity.preset_mode == PRESET_COMFORT assert entity.target_temperature == 18 - assert entity.window_state is STATE_OFF + assert entity.window_state is STATE_UNKNOWN # 2. Open the window, condition of time is satisfied, check the thermostat and heater turns off with patch( @@ -1594,8 +1639,8 @@ async def test_window_action_eco_temp(hass: HomeAssistant, skip_hass_states_is_s assert entity.power_manager.overpowering_state is STATE_UNAVAILABLE assert entity.target_temperature == 21 - assert entity.window_state is STATE_OFF - assert entity.is_window_auto_configured is True + assert entity.window_state is STATE_UNKNOWN + assert entity.window_manager.is_window_auto_configured is True # 1. Initialize the slope algo with 2 measurements event_timestamp = now + timedelta(minutes=1) @@ -1624,8 +1669,8 @@ async def test_window_action_eco_temp(hass: HomeAssistant, skip_hass_states_is_s assert mock_send_event.call_count == 0 assert entity.is_device_active is True assert entity.hvac_mode is HVACMode.HEAT - assert entity.window_state is STATE_OFF - assert entity.window_auto_state is STATE_OFF + assert entity.window_state is STATE_UNKNOWN + assert entity.window_auto_state is STATE_UNKNOWN # 3. send one degre down in one minute with patch( @@ -1648,7 +1693,7 @@ async def test_window_action_eco_temp(hass: HomeAssistant, skip_hass_states_is_s assert mock_heater_off.call_count == 0 assert entity.last_temperature_slope == -6.24 assert entity.window_auto_state == STATE_ON - assert entity.window_state == STATE_OFF + assert entity.window_state == STATE_ON # No change on HVACMode assert entity.hvac_mode is HVACMode.HEAT # No change on preset @@ -1791,8 +1836,8 @@ async def test_window_action_frost_temp(hass: HomeAssistant, skip_hass_states_is assert entity.power_manager.overpowering_state is STATE_UNAVAILABLE assert entity.target_temperature == 21 - assert entity.window_state is STATE_OFF - assert entity.is_window_auto_configured is True + assert entity.window_state is STATE_UNKNOWN + assert entity.window_manager.is_window_auto_configured is True # 1. Initialize the slope algo with 2 measurements event_timestamp = now + timedelta(minutes=1) @@ -1821,8 +1866,8 @@ async def test_window_action_frost_temp(hass: HomeAssistant, skip_hass_states_is assert mock_send_event.call_count == 0 assert entity.is_device_active is True assert entity.hvac_mode is HVACMode.HEAT - assert entity.window_state is STATE_OFF - assert entity.window_auto_state is STATE_OFF + assert entity.window_state is STATE_UNKNOWN + assert entity.window_auto_state is STATE_UNKNOWN # 3. send one degre down in one minute with patch( @@ -1845,7 +1890,7 @@ async def test_window_action_frost_temp(hass: HomeAssistant, skip_hass_states_is assert mock_heater_off.call_count == 0 assert entity.last_temperature_slope == -6.24 assert entity.window_auto_state == STATE_ON - assert entity.window_state == STATE_OFF + assert entity.window_state == STATE_ON # No change on HVACMode assert entity.hvac_mode is HVACMode.HEAT # No change on preset @@ -1991,7 +2036,7 @@ async def test_bug_66( assert entity.hvac_mode is HVACMode.HEAT assert entity.preset_mode is PRESET_BOOST assert entity.target_temperature == 19 - assert entity.window_state is STATE_OFF + assert entity.window_state is STATE_UNKNOWN # Open the window and let the thermostat shut down with patch( @@ -2150,8 +2195,8 @@ async def test_window_action_frost_temp_preset_change( assert vtherm.preset_mode is PRESET_BOOST assert vtherm.target_temperature == 21 - assert vtherm.window_state is STATE_OFF - assert vtherm.is_window_auto_configured is False + assert vtherm.window_state is STATE_UNKNOWN + assert vtherm.window_manager.is_window_auto_configured is False # 1. Turn on the window sensor now = now + timedelta(minutes=1) @@ -2260,8 +2305,8 @@ async def test_window_action_frost_temp_temp_change( assert vtherm.preset_mode is PRESET_BOOST assert vtherm.target_temperature == 21 - assert vtherm.window_state is STATE_OFF - assert vtherm.is_window_auto_configured is False + assert vtherm.window_state is STATE_UNKNOWN + assert vtherm.window_manager.is_window_auto_configured is False # 1. Turn on the window sensor now = now + timedelta(minutes=1) diff --git a/tests/test_window_feature_manager.py b/tests/test_window_feature_manager.py index 21d9092..e6f26ff 100644 --- a/tests/test_window_feature_manager.py +++ b/tests/test_window_feature_manager.py @@ -678,7 +678,7 @@ async def test_window_feature_manager_window_auto( #fmt: on now = now + timedelta(minutes=10) # From 17 to new_temp in 10 minutes - type(fake_vtherm).ema_temp = PropertyMock(return_value=new_temp) + type(fake_vtherm).ema_temperature = PropertyMock(return_value=new_temp) type(fake_vtherm).last_temperature_measure = PropertyMock(return_value=now) type(fake_vtherm).now = PropertyMock(return_value=now) fake_vtherm.send_event = MagicMock()