Fix #661 - central boiler doesn't starts with Sonoff TRVZB

This commit is contained in:
Jean-Marc Collin
2024-11-25 19:21:07 +00:00
parent c090692adc
commit f29097fbc2
6 changed files with 63 additions and 26 deletions

View File

@@ -302,6 +302,7 @@ async def test_update_central_boiler_state_multiple(
assert entity.underlying_entities[1].entity_id == "switch.switch2"
assert entity.underlying_entities[2].entity_id == "switch.switch3"
assert entity.underlying_entities[3].entity_id == "switch.switch4"
assert entity.nb_device_actives == 0
assert api.nb_active_device_for_boiler_threshold == 1
assert api.nb_active_device_for_boiler == 0
@@ -337,6 +338,7 @@ async def test_update_central_boiler_state_multiple(
await asyncio.sleep(0.1)
assert entity.hvac_action == HVACAction.HEATING
assert entity.nb_device_actives == 1
assert mock_service_call.call_count == 1
# No switch of the boiler
@@ -366,6 +368,7 @@ async def test_update_central_boiler_state_multiple(
await asyncio.sleep(0.1)
assert entity.hvac_action == HVACAction.HEATING
assert entity.nb_device_actives == 2
# Only the first heater is started by the algo
assert mock_service_call.call_count == 1
@@ -591,6 +594,7 @@ async def test_update_central_boiler_state_simple_valve(
now: datetime = datetime.now(tz=tz)
assert entity.hvac_mode == HVACMode.HEAT
assert entity.nb_device_actives == 0
boiler_binary_sensor: CentralBoilerBinarySensor = search_entity(
hass, "binary_sensor.central_boiler", "binary_sensor"
@@ -612,6 +616,7 @@ async def test_update_central_boiler_state_simple_valve(
await asyncio.sleep(0.1)
assert entity.hvac_action == HVACAction.HEATING
assert entity.nb_device_actives == 1
assert mock_service_call.call_count >= 1
mock_service_call.assert_has_calls(
@@ -653,6 +658,7 @@ async def test_update_central_boiler_state_simple_valve(
await asyncio.sleep(0.1)
assert entity.hvac_action == HVACAction.IDLE
assert entity.nb_device_actives == 0
assert mock_service_call.call_count >= 1
mock_service_call.assert_has_calls(
@@ -750,6 +756,7 @@ async def test_update_central_boiler_state_simple_climate(
now: datetime = datetime.now(tz=tz)
assert entity.hvac_mode == HVACMode.HEAT
assert entity.nb_device_actives == 0
boiler_binary_sensor: CentralBoilerBinarySensor = search_entity(
hass, "binary_sensor.central_boiler", "binary_sensor"
@@ -772,6 +779,7 @@ async def test_update_central_boiler_state_simple_climate(
await asyncio.sleep(0.5)
assert entity.hvac_action == HVACAction.HEATING
assert entity.nb_device_actives == 1
assert mock_service_call.call_count >= 1
mock_service_call.assert_has_calls(
@@ -813,6 +821,7 @@ async def test_update_central_boiler_state_simple_climate(
await asyncio.sleep(0.5)
assert entity.hvac_action == HVACAction.IDLE
assert entity.nb_device_actives == 0
assert mock_service_call.call_count >= 1
mock_service_call.assert_has_calls(

View File

@@ -149,6 +149,7 @@ async def test_over_climate_valve_mono(hass: HomeAssistant, skip_hass_states_get
)
assert mock_get_state.call_count > 5 # each temp sensor + each valve
assert vtherm.nb_device_actives == 0
# initialize the temps
@@ -200,6 +201,7 @@ async def test_over_climate_valve_mono(hass: HomeAssistant, skip_hass_states_get
assert vtherm.hvac_action is HVACAction.HEATING
assert vtherm.is_device_active is True
assert vtherm.nb_device_actives == 1
# 2. Starts heating very slowly (18.9 vs 19)
now = now + timedelta(minutes=2)
@@ -245,6 +247,7 @@ async def test_over_climate_valve_mono(hass: HomeAssistant, skip_hass_states_get
assert vtherm.hvac_action is HVACAction.HEATING
assert vtherm.is_device_active is True
assert vtherm.nb_device_actives == 1
# 3. Stop heating 21 > 19
now = now + timedelta(minutes=2)
@@ -290,8 +293,7 @@ async def test_over_climate_valve_mono(hass: HomeAssistant, skip_hass_states_get
assert vtherm.hvac_action is HVACAction.OFF
assert vtherm.is_device_active is False
assert vtherm.nb_device_actives == 0
await hass.async_block_till_done()
@@ -415,6 +417,7 @@ async def test_over_climate_valve_multi_presence(
await vtherm.async_set_hvac_mode(HVACMode.HEAT)
assert vtherm.target_temperature == 17.2
assert vtherm.nb_device_actives == 0
# 2: set presence on -> should activate the valve and change target
# fmt: off
@@ -445,6 +448,8 @@ async def test_over_climate_valve_multi_presence(
]
)
assert vtherm.nb_device_actives >= 2 # should be 2 but when run in // with the first test it give 3
# 3: set presence off -> should deactivate the valve and change target
# fmt: off
with patch("custom_components.versatile_thermostat.base_thermostat.BaseThermostat.send_event") as mock_send_event, \
@@ -473,3 +478,5 @@ async def test_over_climate_valve_multi_presence(
call(domain='number', service='set_value', service_data={'value': 12}, target={'entity_id': 'number.mock_offset_calibration2'})
]
)
assert vtherm.nb_device_actives == 0