From 82c1751f8519b53fe64b2bf32553432f73658083 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ludovic=20BOU=C3=89?= Date: Mon, 23 Jun 2025 12:40:37 +0200 Subject: [PATCH] Matter dishwasher alarm (#146842) * Update binary_sensor.py * Update silabs_dishwasher.json DishwasherAlarm * DishwasherAlarm * Update snapshot * DishwasherAlarm * test_dishwasher_alarm * DishwasherAlarm * Update silabs_dishwasher.json * Update snapshot --- .../components/matter/binary_sensor.py | 30 ++++++ homeassistant/components/matter/strings.json | 6 ++ .../fixtures/nodes/silabs_dishwasher.json | 8 ++ .../matter/snapshots/test_binary_sensor.ambr | 98 +++++++++++++++++++ tests/components/matter/test_binary_sensor.py | 18 ++++ 5 files changed, 160 insertions(+) diff --git a/homeassistant/components/matter/binary_sensor.py b/homeassistant/components/matter/binary_sensor.py index 2d04a936ee5..95efe46309c 100644 --- a/homeassistant/components/matter/binary_sensor.py +++ b/homeassistant/components/matter/binary_sensor.py @@ -377,4 +377,34 @@ DISCOVERY_SCHEMAS = [ ), allow_multi=True, ), + MatterDiscoverySchema( + platform=Platform.BINARY_SENSOR, + entity_description=MatterBinarySensorEntityDescription( + key="DishwasherAlarmInflowError", + translation_key="dishwasher_alarm_inflow", + device_class=BinarySensorDeviceClass.PROBLEM, + entity_category=EntityCategory.DIAGNOSTIC, + measurement_to_ha=lambda x: ( + x == clusters.DishwasherAlarm.Bitmaps.AlarmBitmap.kInflowError + ), + ), + entity_class=MatterBinarySensor, + required_attributes=(clusters.DishwasherAlarm.Attributes.State,), + allow_multi=True, + ), + MatterDiscoverySchema( + platform=Platform.BINARY_SENSOR, + entity_description=MatterBinarySensorEntityDescription( + key="DishwasherAlarmDoorError", + translation_key="dishwasher_alarm_door", + device_class=BinarySensorDeviceClass.PROBLEM, + entity_category=EntityCategory.DIAGNOSTIC, + measurement_to_ha=lambda x: ( + x == clusters.DishwasherAlarm.Bitmaps.AlarmBitmap.kDoorError + ), + ), + entity_class=MatterBinarySensor, + required_attributes=(clusters.DishwasherAlarm.Attributes.State,), + allow_multi=True, + ), ] diff --git a/homeassistant/components/matter/strings.json b/homeassistant/components/matter/strings.json index 72e4d8c50b7..01c8d74426e 100644 --- a/homeassistant/components/matter/strings.json +++ b/homeassistant/components/matter/strings.json @@ -88,6 +88,12 @@ }, "boost_state": { "name": "Boost state" + }, + "dishwasher_alarm_inflow": { + "name": "Inflow alarm" + }, + "dishwasher_alarm_door": { + "name": "Door alarm" } }, "button": { diff --git a/tests/components/matter/fixtures/nodes/silabs_dishwasher.json b/tests/components/matter/fixtures/nodes/silabs_dishwasher.json index c5015bc1c34..d0efcc7e004 100644 --- a/tests/components/matter/fixtures/nodes/silabs_dishwasher.json +++ b/tests/components/matter/fixtures/nodes/silabs_dishwasher.json @@ -417,6 +417,14 @@ "1/89/65528": [1], "1/89/65529": [0], "1/89/65531": [0, 1, 65528, 65529, 65531, 65532, 65533], + "1/93/0": 63, + "1/93/2": 0, + "1/93/3": 63, + "1/93/65533": 1, + "1/93/65532": 0, + "1/93/65531": [0, 2, 3, 65533, 65532, 65531, 65529, 65528], + "1/93/65529": [], + "1/93/65528": [], "1/96/0": null, "1/96/1": null, "1/96/3": [ diff --git a/tests/components/matter/snapshots/test_binary_sensor.ambr b/tests/components/matter/snapshots/test_binary_sensor.ambr index f13d86c4557..f6c7780c517 100644 --- a/tests/components/matter/snapshots/test_binary_sensor.ambr +++ b/tests/components/matter/snapshots/test_binary_sensor.ambr @@ -489,6 +489,104 @@ 'state': 'on', }) # --- +# name: test_binary_sensors[silabs_dishwasher][binary_sensor.dishwasher_door_alarm-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.dishwasher_door_alarm', + 'has_entity_name': True, + 'hidden_by': None, + 'icon': None, + 'id': , + 'labels': set({ + }), + 'name': None, + 'options': dict({ + }), + 'original_device_class': , + 'original_icon': None, + 'original_name': 'Door alarm', + 'platform': 'matter', + 'previous_unique_id': None, + 'suggested_object_id': None, + 'supported_features': 0, + 'translation_key': 'dishwasher_alarm_door', + 'unique_id': '00000000000004D2-0000000000000036-MatterNodeDevice-1-DishwasherAlarmDoorError-93-2', + 'unit_of_measurement': None, + }) +# --- +# name: test_binary_sensors[silabs_dishwasher][binary_sensor.dishwasher_door_alarm-state] + StateSnapshot({ + 'attributes': ReadOnlyDict({ + 'device_class': 'problem', + 'friendly_name': 'Dishwasher Door alarm', + }), + 'context': , + 'entity_id': 'binary_sensor.dishwasher_door_alarm', + 'last_changed': , + 'last_reported': , + 'last_updated': , + 'state': 'off', + }) +# --- +# name: test_binary_sensors[silabs_dishwasher][binary_sensor.dishwasher_inflow_alarm-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.dishwasher_inflow_alarm', + 'has_entity_name': True, + 'hidden_by': None, + 'icon': None, + 'id': , + 'labels': set({ + }), + 'name': None, + 'options': dict({ + }), + 'original_device_class': , + 'original_icon': None, + 'original_name': 'Inflow alarm', + 'platform': 'matter', + 'previous_unique_id': None, + 'suggested_object_id': None, + 'supported_features': 0, + 'translation_key': 'dishwasher_alarm_inflow', + 'unique_id': '00000000000004D2-0000000000000036-MatterNodeDevice-1-DishwasherAlarmInflowError-93-2', + 'unit_of_measurement': None, + }) +# --- +# name: test_binary_sensors[silabs_dishwasher][binary_sensor.dishwasher_inflow_alarm-state] + StateSnapshot({ + 'attributes': ReadOnlyDict({ + 'device_class': 'problem', + 'friendly_name': 'Dishwasher Inflow alarm', + }), + 'context': , + 'entity_id': 'binary_sensor.dishwasher_inflow_alarm', + 'last_changed': , + 'last_reported': , + 'last_updated': , + 'state': 'off', + }) +# --- # name: test_binary_sensors[silabs_evse_charging][binary_sensor.evse_charging_status-entry] EntityRegistryEntrySnapshot({ 'aliases': set({ diff --git a/tests/components/matter/test_binary_sensor.py b/tests/components/matter/test_binary_sensor.py index e221140b85b..873d6f17528 100644 --- a/tests/components/matter/test_binary_sensor.py +++ b/tests/components/matter/test_binary_sensor.py @@ -257,3 +257,21 @@ async def test_pump( state = hass.states.get("binary_sensor.mock_pump_problem") assert state assert state.state == "on" + + +@pytest.mark.parametrize("node_fixture", ["silabs_dishwasher"]) +async def test_dishwasher_alarm( + hass: HomeAssistant, + matter_client: MagicMock, + matter_node: MatterNode, +) -> None: + """Test dishwasher alarm sensors.""" + state = hass.states.get("binary_sensor.dishwasher_door_alarm") + assert state + + set_node_attribute(matter_node, 1, 93, 2, 4) + await trigger_subscription_callback(hass, matter_client) + + state = hass.states.get("binary_sensor.dishwasher_door_alarm") + assert state + assert state.state == "on"