1
0
mirror of https://github.com/home-assistant/core.git synced 2026-02-15 07:36:16 +00:00

Add smoke detector test to Matter binary sensor tests (#162638)

This commit is contained in:
Ludovic BOUÉ
2026-02-09 19:36:34 +01:00
committed by GitHub
parent 88c4d88e06
commit 80bbe5df6a

View File

@@ -596,3 +596,60 @@ async def test_thermostat_remote_sensing(
state = hass.states.get("binary_sensor.mock_thermostat_occupancy_remote_sensing")
assert state
assert state.state == "on"
@pytest.mark.parametrize("node_fixture", ["heiman_smoke_detector"])
async def test_smoke_detector(
hass: HomeAssistant,
matter_client: MagicMock,
matter_node: MatterNode,
) -> None:
"""Test smoke detector sensor."""
smoke_state_attribute = clusters.SmokeCoAlarm.Attributes.SmokeState
# Test initial state (SmokeState = 0, kNormal)
state = hass.states.get("binary_sensor.smoke_sensor_smoke")
assert state
assert state.state == "off"
# Set SmokeState to kWarning (value 1)
set_node_attribute(
matter_node,
1,
smoke_state_attribute.cluster_id,
smoke_state_attribute.attribute_id,
1,
)
await trigger_subscription_callback(hass, matter_client)
state = hass.states.get("binary_sensor.smoke_sensor_smoke")
assert state
assert state.state == "on"
# Set SmokeState to kCritical (value 2)
set_node_attribute(
matter_node,
1,
smoke_state_attribute.cluster_id,
smoke_state_attribute.attribute_id,
2,
)
await trigger_subscription_callback(hass, matter_client)
state = hass.states.get("binary_sensor.smoke_sensor_smoke")
assert state
assert state.state == "on"
# Set SmokeState back to kNormal (value 0)
set_node_attribute(
matter_node,
1,
smoke_state_attribute.cluster_id,
smoke_state_attribute.attribute_id,
0,
)
await trigger_subscription_callback(hass, matter_client)
state = hass.states.get("binary_sensor.smoke_sensor_smoke")
assert state
assert state.state == "off"