@@ -242,7 +242,7 @@ async def test_window_management_time_enough(
242
242
@pytest .mark .parametrize ("expected_lingering_tasks" , [True ])
243
243
@pytest .mark .parametrize ("expected_lingering_timers" , [True ])
244
244
async def test_window_auto_fast (hass : HomeAssistant , skip_hass_states_is_state ):
245
- """Test the Power management"""
245
+ """Test the Window management"""
246
246
247
247
entry = MockConfigEntry (
248
248
domain = DOMAIN ,
@@ -430,11 +430,11 @@ async def test_window_auto_auto_stop(hass: HomeAssistant, skip_hass_states_is_st
430
430
431
431
entry = MockConfigEntry (
432
432
domain = DOMAIN ,
433
- title = "TheOverSwitchMockName " ,
433
+ title = "TheOverClimateMockName " ,
434
434
unique_id = "uniqueId" ,
435
435
data = {
436
- CONF_NAME : "TheOverSwitchMockName " ,
437
- CONF_THERMOSTAT_TYPE : CONF_THERMOSTAT_SWITCH ,
436
+ CONF_NAME : "TheOverClimateMockName " ,
437
+ CONF_THERMOSTAT_TYPE : CONF_THERMOSTAT_CLIMATE ,
438
438
CONF_TEMP_SENSOR : "sensor.mock_temp_sensor" ,
439
439
CONF_EXTERNAL_TEMP_SENSOR : "sensor.mock_ext_temp_sensor" ,
440
440
CONF_CYCLE_MIN : 5 ,
@@ -447,10 +447,7 @@ async def test_window_auto_auto_stop(hass: HomeAssistant, skip_hass_states_is_st
447
447
CONF_USE_MOTION_FEATURE : False ,
448
448
CONF_USE_POWER_FEATURE : False ,
449
449
CONF_USE_PRESENCE_FEATURE : False ,
450
- CONF_HEATER : "switch.mock_switch" ,
451
- CONF_PROP_FUNCTION : PROPORTIONAL_FUNCTION_TPI ,
452
- CONF_TPI_COEF_INT : 0.3 ,
453
- CONF_TPI_COEF_EXT : 0.01 ,
450
+ CONF_CLIMATE : "switch.mock_climate" ,
454
451
CONF_MINIMAL_ACTIVATION_DELAY : 30 ,
455
452
CONF_SECURITY_DELAY_MIN : 5 ,
456
453
CONF_SECURITY_MIN_ON_PERCENT : 0.3 ,
@@ -461,15 +458,15 @@ async def test_window_auto_auto_stop(hass: HomeAssistant, skip_hass_states_is_st
461
458
)
462
459
463
460
entity : BaseThermostat = await create_thermostat (
464
- hass , entry , "climate.theoverswitchmockname "
461
+ hass , entry , "climate.theoverclimatemockname "
465
462
)
466
463
assert entity
467
464
468
465
tz = get_tz (hass ) # pylint: disable=invalid-name
469
466
now = datetime .now (tz )
470
467
471
468
tpi_algo = entity ._prop_algorithm
472
- assert tpi_algo
469
+ assert tpi_algo is None
473
470
474
471
await entity .async_set_hvac_mode (HVACMode .HEAT )
475
472
await entity .async_set_preset_mode (PRESET_BOOST )
@@ -484,18 +481,16 @@ async def test_window_auto_auto_stop(hass: HomeAssistant, skip_hass_states_is_st
484
481
with patch (
485
482
"custom_components.versatile_thermostat.base_thermostat.BaseThermostat.send_event"
486
483
) as mock_send_event , patch (
487
- "custom_components.versatile_thermostat.underlyings.UnderlyingSwitch.turn_on"
488
- ) as mock_heater_on , patch (
489
- "custom_components.versatile_thermostat.underlyings.UnderlyingSwitch.turn_off"
490
- ) as mock_heater_off , patch (
491
- "custom_components.versatile_thermostat.underlyings.UnderlyingSwitch.is_device_active" ,
484
+ "custom_components.versatile_thermostat.underlyings.UnderlyingClimate.set_hvac_mode"
485
+ ) as mock_set_hvac_mode , patch (
486
+ "custom_components.versatile_thermostat.underlyings.UnderlyingClimate.is_device_active" ,
492
487
return_value = True ,
493
488
):
494
489
event_timestamp = now - timedelta (minutes = 4 )
495
490
await send_temperature_change_event (entity , 19 , event_timestamp )
496
491
497
- # The heater turns on
498
- assert mock_heater_on .call_count == 1
492
+ # The climate turns on but was alredy on
493
+ assert mock_set_hvac_mode .call_count == 0
499
494
assert entity .last_temperature_slope is None
500
495
assert entity ._window_auto_algo .is_window_open_detected () is False
501
496
assert entity ._window_auto_algo .is_window_close_detected () is False
@@ -505,10 +500,8 @@ async def test_window_auto_auto_stop(hass: HomeAssistant, skip_hass_states_is_st
505
500
with patch (
506
501
"custom_components.versatile_thermostat.base_thermostat.BaseThermostat.send_event"
507
502
) as mock_send_event , patch (
508
- "custom_components.versatile_thermostat.underlyings.UnderlyingSwitch.turn_on"
509
- ) as mock_heater_on , patch (
510
- "custom_components.versatile_thermostat.underlyings.UnderlyingSwitch.turn_off"
511
- ) as mock_heater_off , patch (
503
+ "custom_components.versatile_thermostat.underlyings.UnderlyingClimate.set_hvac_mode"
504
+ ) as mock_set_hvac_mode , patch (
512
505
"custom_components.versatile_thermostat.underlyings.UnderlyingSwitch.is_device_active" ,
513
506
return_value = True ,
514
507
):
@@ -531,8 +524,7 @@ async def test_window_auto_auto_stop(hass: HomeAssistant, skip_hass_states_is_st
531
524
],
532
525
any_order = True ,
533
526
)
534
- assert mock_heater_on .call_count == 0
535
- assert mock_heater_off .call_count >= 1
527
+ assert mock_set_hvac_mode .call_count >= 1
536
528
assert entity .last_temperature_slope == - 1
537
529
assert entity ._window_auto_algo .is_window_open_detected () is True
538
530
assert entity ._window_auto_algo .is_window_close_detected () is False
@@ -543,17 +535,14 @@ async def test_window_auto_auto_stop(hass: HomeAssistant, skip_hass_states_is_st
543
535
with patch (
544
536
"custom_components.versatile_thermostat.base_thermostat.BaseThermostat.send_event"
545
537
) as mock_send_event , patch (
546
- "custom_components.versatile_thermostat.underlyings.UnderlyingSwitch.turn_on"
547
- ) as mock_heater_on , patch (
548
- "custom_components.versatile_thermostat.underlyings.UnderlyingSwitch.turn_off"
549
- ) as mock_heater_off , patch (
538
+ "custom_components.versatile_thermostat.underlyings.UnderlyingClimate.set_hvac_mode"
539
+ ) as mock_set_hvac_mode , patch (
550
540
"custom_components.versatile_thermostat.underlyings.UnderlyingSwitch.is_device_active" ,
551
541
return_value = False ,
552
542
):
553
543
await asyncio .sleep (0.3 )
554
544
555
- assert mock_heater_on .call_count == 1
556
- assert mock_heater_off .call_count == 0
545
+ assert mock_set_hvac_mode .call_count == 1
557
546
assert round (entity .last_temperature_slope , 3 ) == - 1
558
547
# Because the algorithm is not aware of the expiration, for the algo we are still in alert
559
548
assert entity ._window_auto_algo .is_window_open_detected () is True
@@ -674,12 +663,11 @@ async def test_window_auto_no_on_percent(
674
663
# Clean the entity
675
664
entity .remove_thermostat ()
676
665
677
- #PR - Adding Window Bypass
666
+
667
+ # PR - Adding Window Bypass
678
668
@pytest .mark .parametrize ("expected_lingering_tasks" , [True ])
679
669
@pytest .mark .parametrize ("expected_lingering_timers" , [True ])
680
- async def test_window_bypass (
681
- hass : HomeAssistant , skip_hass_states_is_state
682
- ):
670
+ async def test_window_bypass (hass : HomeAssistant , skip_hass_states_is_state ):
683
671
"""Test the Window management when bypass enabled"""
684
672
685
673
entry = MockConfigEntry (
@@ -810,7 +798,8 @@ async def test_window_bypass(
810
798
# Clean the entity
811
799
entity .remove_thermostat ()
812
800
813
- #PR - Adding Window bypass for window auto algorithm
801
+
802
+ # PR - Adding Window bypass for window auto algorithm
814
803
@pytest .mark .parametrize ("expected_lingering_tasks" , [True ])
815
804
@pytest .mark .parametrize ("expected_lingering_timers" , [True ])
816
805
async def test_window_auto_bypass (hass : HomeAssistant , skip_hass_states_is_state ):
@@ -921,7 +910,8 @@ async def test_window_auto_bypass(hass: HomeAssistant, skip_hass_states_is_state
921
910
# Clean the entity
922
911
entity .remove_thermostat ()
923
912
924
- #PR - Adding Window bypass AFTER detection have been done should reactivate the heater
913
+
914
+ # PR - Adding Window bypass AFTER detection have been done should reactivate the heater
925
915
@pytest .mark .parametrize ("expected_lingering_tasks" , [True ])
926
916
@pytest .mark .parametrize ("expected_lingering_timers" , [True ])
927
917
async def test_window_bypass_reactivate (hass : HomeAssistant , skip_hass_states_is_state ):
@@ -1049,4 +1039,4 @@ async def test_window_bypass_reactivate(hass: HomeAssistant, skip_hass_states_is
1049
1039
)
1050
1040
1051
1041
# Clean the entity
1052
- entity .remove_thermostat ()
1042
+ entity .remove_thermostat ()
0 commit comments