@@ -596,3 +596,60 @@ async def test_thermostat_remote_sensing(
596596 state = hass .states .get ("binary_sensor.mock_thermostat_occupancy_remote_sensing" )
597597 assert state
598598 assert state .state == "on"
599+
600+
601+ @pytest .mark .parametrize ("node_fixture" , ["heiman_smoke_detector" ])
602+ async def test_smoke_detector (
603+ hass : HomeAssistant ,
604+ matter_client : MagicMock ,
605+ matter_node : MatterNode ,
606+ ) -> None :
607+ """Test smoke detector sensor."""
608+ smoke_state_attribute = clusters .SmokeCoAlarm .Attributes .SmokeState
609+
610+ # Test initial state (SmokeState = 0, kNormal)
611+ state = hass .states .get ("binary_sensor.smoke_sensor_smoke" )
612+ assert state
613+ assert state .state == "off"
614+
615+ # Set SmokeState to kWarning (value 1)
616+ set_node_attribute (
617+ matter_node ,
618+ 1 ,
619+ smoke_state_attribute .cluster_id ,
620+ smoke_state_attribute .attribute_id ,
621+ 1 ,
622+ )
623+ await trigger_subscription_callback (hass , matter_client )
624+
625+ state = hass .states .get ("binary_sensor.smoke_sensor_smoke" )
626+ assert state
627+ assert state .state == "on"
628+
629+ # Set SmokeState to kCritical (value 2)
630+ set_node_attribute (
631+ matter_node ,
632+ 1 ,
633+ smoke_state_attribute .cluster_id ,
634+ smoke_state_attribute .attribute_id ,
635+ 2 ,
636+ )
637+ await trigger_subscription_callback (hass , matter_client )
638+
639+ state = hass .states .get ("binary_sensor.smoke_sensor_smoke" )
640+ assert state
641+ assert state .state == "on"
642+
643+ # Set SmokeState back to kNormal (value 0)
644+ set_node_attribute (
645+ matter_node ,
646+ 1 ,
647+ smoke_state_attribute .cluster_id ,
648+ smoke_state_attribute .attribute_id ,
649+ 0 ,
650+ )
651+ await trigger_subscription_callback (hass , matter_client )
652+
653+ state = hass .states .get ("binary_sensor.smoke_sensor_smoke" )
654+ assert state
655+ assert state .state == "off"
0 commit comments