diff --git a/homeassistant/components/matter/binary_sensor.py b/homeassistant/components/matter/binary_sensor.py index b704a90e81f..84ed60d580b 100644 --- a/homeassistant/components/matter/binary_sensor.py +++ b/homeassistant/components/matter/binary_sensor.py @@ -176,6 +176,16 @@ DISCOVERY_SCHEMAS = [ required_attributes=(clusters.DoorLock.Attributes.DoorState,), featuremap_contains=clusters.DoorLock.Bitmaps.Feature.kDoorPositionSensor, ), + MatterDiscoverySchema( + platform=Platform.BINARY_SENSOR, + entity_description=MatterBinarySensorEntityDescription( + key="LockActuatorEnabledSensor", + translation_key="actuator", + entity_category=EntityCategory.DIAGNOSTIC, + ), + entity_class=MatterBinarySensor, + required_attributes=(clusters.DoorLock.Attributes.ActuatorEnabled,), + ), MatterDiscoverySchema( platform=Platform.BINARY_SENSOR, entity_description=MatterBinarySensorEntityDescription( diff --git a/homeassistant/components/matter/strings.json b/homeassistant/components/matter/strings.json index abaaf46ef42..94912340ba7 100644 --- a/homeassistant/components/matter/strings.json +++ b/homeassistant/components/matter/strings.json @@ -47,6 +47,9 @@ }, "entity": { "binary_sensor": { + "actuator": { + "name": "Actuator" + }, "alarm_door": { "name": "Door alarm" }, diff --git a/tests/components/matter/snapshots/test_binary_sensor.ambr b/tests/components/matter/snapshots/test_binary_sensor.ambr index af0422e21aa..6bc7517097f 100644 --- a/tests/components/matter/snapshots/test_binary_sensor.ambr +++ b/tests/components/matter/snapshots/test_binary_sensor.ambr @@ -149,6 +149,55 @@ 'state': 'on', }) # --- +# name: test_binary_sensors[aqara_u200][binary_sensor.aqara_smart_lock_u200_actuator-entry] + EntityRegistryEntrySnapshot({ + 'aliases': set({ + }), + 'area_id': None, + 'capabilities': None, + 'config_entry_id': , + 'config_subentry_id': , + 'device_class': None, + 'device_id': , + 'disabled_by': None, + 'domain': 'binary_sensor', + 'entity_category': , + 'entity_id': 'binary_sensor.aqara_smart_lock_u200_actuator', + 'has_entity_name': True, + 'hidden_by': None, + 'icon': None, + 'id': , + 'labels': set({ + }), + 'name': None, + 'object_id_base': 'Actuator', + 'options': dict({ + }), + 'original_device_class': None, + 'original_icon': None, + 'original_name': 'Actuator', + 'platform': 'matter', + 'previous_unique_id': None, + 'suggested_object_id': None, + 'supported_features': 0, + 'translation_key': 'actuator', + 'unique_id': '00000000000004D2-0000000000000014-MatterNodeDevice-1-LockActuatorEnabledSensor-257-2', + 'unit_of_measurement': None, + }) +# --- +# name: test_binary_sensors[aqara_u200][binary_sensor.aqara_smart_lock_u200_actuator-state] + StateSnapshot({ + 'attributes': ReadOnlyDict({ + 'friendly_name': 'Aqara Smart Lock U200 Actuator', + }), + 'context': , + 'entity_id': 'binary_sensor.aqara_smart_lock_u200_actuator', + 'last_changed': , + 'last_reported': , + 'last_updated': , + 'state': 'off', + }) +# --- # name: test_binary_sensors[eve_contact_sensor][binary_sensor.eve_door_door-entry] EntityRegistryEntrySnapshot({ 'aliases': set({ @@ -1045,6 +1094,55 @@ 'state': 'on', }) # --- +# name: test_binary_sensors[mock_door_lock][binary_sensor.mock_door_lock_actuator-entry] + EntityRegistryEntrySnapshot({ + 'aliases': set({ + }), + 'area_id': None, + 'capabilities': None, + 'config_entry_id': , + 'config_subentry_id': , + 'device_class': None, + 'device_id': , + 'disabled_by': None, + 'domain': 'binary_sensor', + 'entity_category': , + 'entity_id': 'binary_sensor.mock_door_lock_actuator', + 'has_entity_name': True, + 'hidden_by': None, + 'icon': None, + 'id': , + 'labels': set({ + }), + 'name': None, + 'object_id_base': 'Actuator', + 'options': dict({ + }), + 'original_device_class': None, + 'original_icon': None, + 'original_name': 'Actuator', + 'platform': 'matter', + 'previous_unique_id': None, + 'suggested_object_id': None, + 'supported_features': 0, + 'translation_key': 'actuator', + 'unique_id': '00000000000004D2-0000000000000001-MatterNodeDevice-1-LockActuatorEnabledSensor-257-2', + 'unit_of_measurement': None, + }) +# --- +# name: test_binary_sensors[mock_door_lock][binary_sensor.mock_door_lock_actuator-state] + StateSnapshot({ + 'attributes': ReadOnlyDict({ + 'friendly_name': 'Mock Door Lock Actuator', + }), + 'context': , + 'entity_id': 'binary_sensor.mock_door_lock_actuator', + 'last_changed': , + 'last_reported': , + 'last_updated': , + 'state': 'on', + }) +# --- # name: test_binary_sensors[mock_door_lock][binary_sensor.mock_door_lock_battery-entry] EntityRegistryEntrySnapshot({ 'aliases': set({ @@ -1095,6 +1193,55 @@ 'state': 'off', }) # --- +# name: test_binary_sensors[mock_door_lock_with_unbolt][binary_sensor.mock_door_lock_with_unbolt_actuator-entry] + EntityRegistryEntrySnapshot({ + 'aliases': set({ + }), + 'area_id': None, + 'capabilities': None, + 'config_entry_id': , + 'config_subentry_id': , + 'device_class': None, + 'device_id': , + 'disabled_by': None, + 'domain': 'binary_sensor', + 'entity_category': , + 'entity_id': 'binary_sensor.mock_door_lock_with_unbolt_actuator', + 'has_entity_name': True, + 'hidden_by': None, + 'icon': None, + 'id': , + 'labels': set({ + }), + 'name': None, + 'object_id_base': 'Actuator', + 'options': dict({ + }), + 'original_device_class': None, + 'original_icon': None, + 'original_name': 'Actuator', + 'platform': 'matter', + 'previous_unique_id': None, + 'suggested_object_id': None, + 'supported_features': 0, + 'translation_key': 'actuator', + 'unique_id': '00000000000004D2-0000000000000001-MatterNodeDevice-1-LockActuatorEnabledSensor-257-2', + 'unit_of_measurement': None, + }) +# --- +# name: test_binary_sensors[mock_door_lock_with_unbolt][binary_sensor.mock_door_lock_with_unbolt_actuator-state] + StateSnapshot({ + 'attributes': ReadOnlyDict({ + 'friendly_name': 'Mock Door Lock with unbolt Actuator', + }), + 'context': , + 'entity_id': 'binary_sensor.mock_door_lock_with_unbolt_actuator', + 'last_changed': , + 'last_reported': , + 'last_updated': , + 'state': 'on', + }) +# --- # name: test_binary_sensors[mock_door_lock_with_unbolt][binary_sensor.mock_door_lock_with_unbolt_battery-entry] EntityRegistryEntrySnapshot({ 'aliases': set({ @@ -1245,6 +1392,55 @@ 'state': 'on', }) # --- +# name: test_binary_sensors[mock_lock][binary_sensor.mock_lock_actuator-entry] + EntityRegistryEntrySnapshot({ + 'aliases': set({ + }), + 'area_id': None, + 'capabilities': None, + 'config_entry_id': , + 'config_subentry_id': , + 'device_class': None, + 'device_id': , + 'disabled_by': None, + 'domain': 'binary_sensor', + 'entity_category': , + 'entity_id': 'binary_sensor.mock_lock_actuator', + 'has_entity_name': True, + 'hidden_by': None, + 'icon': None, + 'id': , + 'labels': set({ + }), + 'name': None, + 'object_id_base': 'Actuator', + 'options': dict({ + }), + 'original_device_class': None, + 'original_icon': None, + 'original_name': 'Actuator', + 'platform': 'matter', + 'previous_unique_id': None, + 'suggested_object_id': None, + 'supported_features': 0, + 'translation_key': 'actuator', + 'unique_id': '00000000000004D2-0000000000000097-MatterNodeDevice-1-LockActuatorEnabledSensor-257-2', + 'unit_of_measurement': None, + }) +# --- +# name: test_binary_sensors[mock_lock][binary_sensor.mock_lock_actuator-state] + StateSnapshot({ + 'attributes': ReadOnlyDict({ + 'friendly_name': 'Mock Lock Actuator', + }), + 'context': , + 'entity_id': 'binary_sensor.mock_lock_actuator', + 'last_changed': , + 'last_reported': , + 'last_updated': , + 'state': 'on', + }) +# --- # name: test_binary_sensors[mock_lock][binary_sensor.mock_lock_battery-entry] EntityRegistryEntrySnapshot({ 'aliases': set({ @@ -2142,6 +2338,55 @@ 'state': 'off', }) # --- +# name: test_binary_sensors[secuyou_smart_lock][binary_sensor.secuyou_smart_lock_actuator-entry] + EntityRegistryEntrySnapshot({ + 'aliases': set({ + }), + 'area_id': None, + 'capabilities': None, + 'config_entry_id': , + 'config_subentry_id': , + 'device_class': None, + 'device_id': , + 'disabled_by': None, + 'domain': 'binary_sensor', + 'entity_category': , + 'entity_id': 'binary_sensor.secuyou_smart_lock_actuator', + 'has_entity_name': True, + 'hidden_by': None, + 'icon': None, + 'id': , + 'labels': set({ + }), + 'name': None, + 'object_id_base': 'Actuator', + 'options': dict({ + }), + 'original_device_class': None, + 'original_icon': None, + 'original_name': 'Actuator', + 'platform': 'matter', + 'previous_unique_id': None, + 'suggested_object_id': None, + 'supported_features': 0, + 'translation_key': 'actuator', + 'unique_id': '00000000000004D2-0000000000000002-MatterNodeDevice-1-LockActuatorEnabledSensor-257-2', + 'unit_of_measurement': None, + }) +# --- +# name: test_binary_sensors[secuyou_smart_lock][binary_sensor.secuyou_smart_lock_actuator-state] + StateSnapshot({ + 'attributes': ReadOnlyDict({ + 'friendly_name': 'Secuyou Smart Lock Actuator', + }), + 'context': , + 'entity_id': 'binary_sensor.secuyou_smart_lock_actuator', + 'last_changed': , + 'last_reported': , + 'last_updated': , + 'state': 'on', + }) +# --- # name: test_binary_sensors[silabs_dishwasher][binary_sensor.dishwasher_door_alarm-entry] EntityRegistryEntrySnapshot({ 'aliases': set({ diff --git a/tests/components/matter/test_binary_sensor.py b/tests/components/matter/test_binary_sensor.py index 8660206175e..f68c82bcb5a 100644 --- a/tests/components/matter/test_binary_sensor.py +++ b/tests/components/matter/test_binary_sensor.py @@ -119,6 +119,29 @@ async def test_battery_sensor( assert state.state == "on" +@pytest.mark.parametrize("node_fixture", ["mock_door_lock"]) +async def test_actuator_sensor( + hass: HomeAssistant, + entity_registry: er.EntityRegistry, + matter_client: MagicMock, + matter_node: MatterNode, +) -> None: + """Test actuator enabled sensor.""" + entity_id = "binary_sensor.mock_door_lock_actuator" + state = hass.states.get(entity_id) + assert state + assert state.state == "on" + + set_node_attribute(matter_node, 1, 257, 2, False) + await trigger_subscription_callback( + hass, matter_client, data=(matter_node.node_id, "1/257/2", False) + ) + + state = hass.states.get(entity_id) + assert state + assert state.state == "off" + + @pytest.mark.parametrize("node_fixture", ["mock_door_lock"]) async def test_optional_sensor_from_featuremap( hass: HomeAssistant,