Fix all testus with feature_window_manager ok

This commit is contained in:
Jean-Marc Collin
2024-12-27 15:41:28 +00:00
parent 329598b95a
commit 9fc8f9c909
9 changed files with 35 additions and 28 deletions

View File

@@ -281,6 +281,7 @@ class FeatureWindowManager(BaseFeatureManager):
_LOGGER.debug(
"%s is already off. Forget turning off VTherm due to window detection"
)
self._window_state = new_state
return False
# self._window_state = new_state
@@ -537,7 +538,7 @@ class FeatureWindowManager(BaseFeatureManager):
@property
def last_slope(self) -> float:
"""Return the last slope (in °C/hour)"""
if not self.is_configured:
if not self._window_auto_algo:
return None
return self._window_auto_algo.last_slope

View File

@@ -1310,7 +1310,7 @@ async def test_auto_start_stop_fast_heat_window(
# VTherm should be heating
assert vtherm.hvac_mode == HVACMode.HEAT
# VTherm window_state should be off
assert vtherm.window_state == STATE_OFF
assert vtherm.window_state == STATE_UNKNOWN # cause condition is not evaluated
# 3. Set current temperature to 21 5 min later -> should turn off VTherm
now = now + timedelta(minutes=5)
@@ -1485,7 +1485,7 @@ async def test_auto_start_stop_fast_heat_window_mixed(
# VTherm should be heating
assert vtherm.hvac_mode == HVACMode.HEAT
# VTherm window_state should be off
assert vtherm.window_state == STATE_OFF
assert vtherm.window_state == STATE_UNKNOWN # cause try_condition is not evaluated
# 3. Open the window and wait for the delay
now = now + timedelta(minutes=2)

View File

@@ -282,11 +282,14 @@ async def test_full_over_switch_wo_central_config(
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
assert entity._window_auto_open_threshold == 3
assert entity._window_auto_max_duration == 5
assert (
entity.window_manager._window_sensor_entity_id
== "binary_sensor.mock_window_sensor"
)
assert entity.window_manager.window_delay_sec == 30
assert entity.window_manager.window_auto_close_threshold == 0.1
assert entity.window_manager.window_auto_open_threshold == 3
assert entity.window_manager.window_auto_max_duration == 5
assert (
entity.motion_manager.motion_sensor_entity_id
@@ -405,11 +408,14 @@ async def test_full_over_switch_with_central_config(
# We have an entity so window auto is not enabled
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
assert entity._window_auto_open_threshold == 4
assert entity._window_auto_max_duration == 31
assert (
entity.window_manager._window_sensor_entity_id
== "binary_sensor.mock_window_sensor"
)
assert entity.window_manager.window_delay_sec == 15
assert entity.window_manager.window_auto_close_threshold == 1
assert entity.window_manager.window_auto_open_threshold == 4
assert entity.window_manager.window_auto_max_duration == 31
assert (
entity.motion_manager.motion_sensor_entity_id

View File

@@ -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_UNKNOWN
assert entity.window_state is STATE_UNAVAILABLE
event_timestamp = now - timedelta(minutes=4)
await send_temperature_change_event(entity, 15, event_timestamp)
@@ -289,7 +289,7 @@ async def test_multiple_switchs(
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_UNAVAILABLE
event_timestamp = now - timedelta(minutes=4)
await send_temperature_change_event(entity, 15, event_timestamp)
@@ -426,7 +426,7 @@ async def test_multiple_climates(
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_UNAVAILABLE
event_timestamp = now - timedelta(minutes=4)
await send_temperature_change_event(entity, 15, event_timestamp)
@@ -451,7 +451,7 @@ async def test_multiple_climates(
assert entity.hvac_mode is HVACMode.OFF
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_UNAVAILABLE
event_timestamp = now - timedelta(minutes=4)
await send_temperature_change_event(entity, 15, event_timestamp)
@@ -527,7 +527,7 @@ async def test_multiple_climates_underlying_changes(
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_UNAVAILABLE
event_timestamp = now - timedelta(minutes=4)
await send_temperature_change_event(entity, 15, event_timestamp)
@@ -672,7 +672,7 @@ async def test_multiple_climates_underlying_changes_not_aligned(
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_UNAVAILABLE
event_timestamp = now - timedelta(minutes=4)
await send_temperature_change_event(entity, 15, event_timestamp)

View File

@@ -960,7 +960,7 @@ async def test_manual_hvac_off_should_take_the_lead_over_window(
# VTherm should be heating
assert vtherm.hvac_mode == HVACMode.HEAT
# VTherm window_state should be off
assert vtherm.window_state == STATE_OFF
assert vtherm.window_state == STATE_UNKNOWN # Cause try_condition is not called
# 2. Open the window and wait for the delay
now = now + timedelta(minutes=2)

View File

@@ -112,7 +112,7 @@ async def test_over_climate_valve_mono(hass: HomeAssistant, skip_hass_states_get
]
assert vtherm.preset_mode is PRESET_NONE
assert vtherm._security_state is False
assert vtherm._window_state is None
assert vtherm.window_state is STATE_UNAVAILABLE
assert vtherm.motion_state is STATE_UNAVAILABLE
assert vtherm.presence_state is STATE_UNAVAILABLE

View File

@@ -54,7 +54,7 @@ async def test_over_switch_full_start(hass: HomeAssistant, skip_hass_states_is_s
]
assert entity.preset_mode is PRESET_NONE
assert entity._security_state is False
assert entity._window_state is None
assert entity.window_state is STATE_UNKNOWN
assert entity.motion_state is STATE_UNKNOWN
assert entity.presence_state is STATE_UNKNOWN
assert entity._prop_algorithm is not None
@@ -113,7 +113,7 @@ async def test_over_climate_full_start(hass: HomeAssistant, skip_hass_states_is_
]
assert entity.preset_mode is PRESET_NONE
assert entity._security_state is False
assert entity._window_state is None
assert entity.window_state is STATE_UNAVAILABLE
assert entity.motion_state is STATE_UNAVAILABLE
assert entity.presence_state is STATE_UNAVAILABLE
assert entity.have_valve_regulation is False
@@ -169,7 +169,7 @@ async def test_over_4switch_full_start(hass: HomeAssistant, skip_hass_states_is_
]
assert entity.preset_mode is PRESET_NONE
assert entity._security_state is False
assert entity._window_state is None
assert entity.window_state is STATE_UNKNOWN
assert entity.motion_state is STATE_UNKNOWN
assert entity.presence_state is STATE_UNKNOWN
assert entity._prop_algorithm is not None

View File

@@ -90,8 +90,8 @@ async def test_over_switch_ac_full_start(
]
assert entity.preset_mode is PRESET_NONE
assert entity._security_state is False # pylint: disable=protected-access
assert entity._window_state is None # pylint: disable=protected-access
assert entity.motion_state is STATE_UNKNOWN # pylint: disable=protected-access
assert entity.window_state is STATE_UNKNOWN
assert entity.motion_state is STATE_UNKNOWN
assert entity.presence_state is STATE_UNKNOWN
assert entity._prop_algorithm is not None # pylint: disable=protected-access

View File

@@ -99,8 +99,8 @@ async def test_over_valve_full_start(
]
assert entity.preset_mode is PRESET_NONE
assert entity._security_state is False # pylint: disable=protected-access
assert entity._window_state is None # pylint: disable=protected-access
assert entity.motion_state is STATE_UNKNOWN # pylint: disable=protected-access
assert entity.window_state is STATE_UNKNOWN
assert entity.motion_state is STATE_UNKNOWN
assert entity.presence_state is STATE_UNKNOWN
assert entity._prop_algorithm is not None # pylint: disable=protected-access
assert entity.have_valve_regulation is False