Handle mains power for Matter appliances (#121023)

This commit is contained in:
Marcel van der Veldt
2024-07-02 21:09:39 +02:00
committed by Franck Nijhof
parent b3e833f677
commit 1fa6972a66
4 changed files with 35 additions and 3 deletions
+7 -2
View File
@@ -315,14 +315,19 @@ async def test_room_airconditioner(
state = hass.states.get("climate.room_airconditioner_thermostat")
assert state
assert state.attributes["current_temperature"] == 20
assert state.attributes["min_temp"] == 16
assert state.attributes["max_temp"] == 32
# room airconditioner has mains power on OnOff cluster with value set to False
assert state.state == HVACMode.OFF
# test supported features correctly parsed
# WITHOUT temperature_range support
mask = ClimateEntityFeature.TARGET_TEMPERATURE | ClimateEntityFeature.TURN_OFF
assert state.attributes["supported_features"] & mask == mask
# set mains power to ON (OnOff cluster)
set_node_attribute(room_airconditioner, 1, 6, 0, True)
await trigger_subscription_callback(hass, matter_client)
state = hass.states.get("climate.room_airconditioner_thermostat")
# test supported HVAC modes include fan and dry modes
assert state.attributes["hvac_modes"] == [
HVACMode.OFF,
+6
View File
@@ -92,6 +92,12 @@ async def test_fan_base(
await trigger_subscription_callback(hass, matter_client)
state = hass.states.get(entity_id)
assert state.attributes["preset_mode"] == "sleep_wind"
# set mains power to OFF (OnOff cluster)
set_node_attribute(air_purifier, 1, 6, 0, False)
await trigger_subscription_callback(hass, matter_client)
state = hass.states.get(entity_id)
assert state.attributes["preset_mode"] is None
assert state.attributes["percentage"] == 0
async def test_fan_turn_on_with_percentage(