From ee98e93a4e287ecb04c45f4b2477ec2ce45c2694 Mon Sep 17 00:00:00 2001 From: Stefan Agner Date: Mon, 26 Oct 2026 14:40:03 +0100 Subject: [PATCH] Add blind type select for Matter WAGO Home Blind Control (#187769) Co-authored-by: Claude Fable 5.1 --- homeassistant/components/matter/cover.py | 15 +++++ homeassistant/components/matter/select.py | 20 ++++++ homeassistant/components/matter/strings.json | 7 ++ .../nodes/wago_home_blind_control.json | 7 +- .../matter/snapshots/test_cover.ambr | 9 ++- .../matter/snapshots/test_select.ambr | 59 +++++++++++++++++ tests/components/matter/test_cover.py | 65 +++++++++++++++++++ tests/components/matter/test_select.py | 51 +++++++++++++++ 8 files changed, 225 insertions(+), 8 deletions(-) diff --git a/homeassistant/components/matter/cover.py b/homeassistant/components/matter/cover.py index 8e0772a9043c..03f4a6bcb276 100644 --- a/homeassistant/components/matter/cover.py +++ b/homeassistant/components/matter/cover.py @@ -33,6 +33,8 @@ OPERATIONAL_STATUS_MASK = 0b11 # writes to avoid writing intermittent states. STATE_WRITE_DEBOUNCE_COOLDOWN = 0.1 +WAGO_BLIND_TYPE_ROLLER_SHUTTER = 0 + # map Matter window cover types to HA device class TYPE_MAP = { clusters.WindowCovering.Enums.Type.kRollerShade: CoverDeviceClass.SHADE, @@ -291,6 +293,18 @@ class MatterCover(MatterEntity, CoverEntity): and feature_map & clusters.WindowCovering.Bitmaps.Feature.kTilt ): supported_features |= CoverEntityFeature.SET_TILT_POSITION + + # The WAGO Home Blind Control keeps reporting the tilt feature and a + # tilt blind Type when configured as a roller shutter + if ( + self.get_matter_attribute_value( + clusters.WindowCovering.Attributes.WagoBlindType + ) + == WAGO_BLIND_TYPE_ROLLER_SHUTTER + ): + self._attr_device_class = CoverDeviceClass.SHUTTER + self._attr_current_cover_tilt_position = None + supported_features &= ~CoverEntityFeature.SET_TILT_POSITION self._attr_supported_features = supported_features @@ -366,6 +380,7 @@ DISCOVERY_SCHEMAS = [ clusters.WindowCovering.Attributes.CurrentPositionTiltPercent100ths, clusters.WindowCovering.Attributes.TargetPositionLiftPercent100ths, clusters.WindowCovering.Attributes.TargetPositionTiltPercent100ths, + clusters.WindowCovering.Attributes.WagoBlindType, ), ), ] diff --git a/homeassistant/components/matter/select.py b/homeassistant/components/matter/select.py index 28b6ecf4e791..c359051140ef 100644 --- a/homeassistant/components/matter/select.py +++ b/homeassistant/components/matter/select.py @@ -780,4 +780,24 @@ DISCOVERY_SCHEMAS = [ required_attributes=(clusters.WindowCovering.Attributes.WagoManualMode,), vendor_id=(5428,), ), + MatterDiscoverySchema( + platform=Platform.SELECT, + entity_description=MatterSelectEntityDescription( + key="WagoBlindType", + entity_category=EntityCategory.CONFIG, + translation_key="blind_type", + options=["roller_shutter", "venetian_blind"], + device_to_ha={ + 0: "roller_shutter", + 1: "venetian_blind", + }.get, + ha_to_device={ + "roller_shutter": 0, + "venetian_blind": 1, + }.get, + ), + entity_class=MatterAttributeSelectEntity, + required_attributes=(clusters.WindowCovering.Attributes.WagoBlindType,), + vendor_id=(5428,), + ), ] diff --git a/homeassistant/components/matter/strings.json b/homeassistant/components/matter/strings.json index d98ab89fd8bf..ac9eb02bb01f 100644 --- a/homeassistant/components/matter/strings.json +++ b/homeassistant/components/matter/strings.json @@ -313,6 +313,13 @@ } }, "select": { + "blind_type": { + "name": "Blind type", + "state": { + "roller_shutter": "Roller shutter", + "venetian_blind": "Venetian blind" + } + }, "clean_mode": { "name": "Clean mode" }, diff --git a/tests/components/matter/fixtures/nodes/wago_home_blind_control.json b/tests/components/matter/fixtures/nodes/wago_home_blind_control.json index 56b924de05ae..1015ecd73de6 100644 --- a/tests/components/matter/fixtures/nodes/wago_home_blind_control.json +++ b/tests/components/matter/fixtures/nodes/wago_home_blind_control.json @@ -51,8 +51,8 @@ "0/40/6": "**REDACTED**", "0/40/7": 1, "0/40/8": "1.0", - "0/40/9": 200000, - "0/40/10": "2.0.0", + "0/40/9": 210000, + "0/40/10": "2.1.0", "0/40/19": { "0": 3, "1": 3 @@ -243,6 +243,7 @@ "1/258/355729410": 4600, "1/258/355729411": 1300, "1/258/355729412": true, + "1/258/355729413": 0, "1/258/65533": 5, "1/258/0": 8, "1/258/7": 29, @@ -251,7 +252,7 @@ "1/258/23": 1, "1/258/65531": [ 0, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 23, 65528, 65529, 65531, 65532, - 65533, 355729409, 355729410, 355729411, 355729412 + 65533, 355729409, 355729410, 355729411, 355729412, 355729413 ], "1/258/65529": [0, 1, 2, 5, 8], "1/258/65528": [], diff --git a/tests/components/matter/snapshots/test_cover.ambr b/tests/components/matter/snapshots/test_cover.ambr index 9204d8c646be..9757a73b6ca7 100644 --- a/tests/components/matter/snapshots/test_cover.ambr +++ b/tests/components/matter/snapshots/test_cover.ambr @@ -563,13 +563,13 @@ 'object_id_base': None, 'options': dict({ }), - 'original_device_class': , + 'original_device_class': , 'original_icon': None, 'original_name': None, 'platform': 'matter', 'previous_unique_id': None, 'suggested_object_id': None, - 'supported_features': , + 'supported_features': , 'translation_key': None, 'unique_id': '00000000000004D2-0000000000000157-MatterNodeDevice-1-MatterCoverPositionAwareLiftAndTilt-258-10', 'unit_of_measurement': None, @@ -579,11 +579,10 @@ StateSnapshot({ 'attributes': ReadOnlyDict({ : 100, - : 100, - : 'blind', + : 'shutter', : 'Home Blind Wi-Fi', : False, - : , + : , }), 'context': , 'entity_id': 'cover.home_blind_wi_fi', diff --git a/tests/components/matter/snapshots/test_select.ambr b/tests/components/matter/snapshots/test_select.ambr index 9f144ff94f8b..e6e288977b42 100644 --- a/tests/components/matter/snapshots/test_select.ambr +++ b/tests/components/matter/snapshots/test_select.ambr @@ -6397,6 +6397,65 @@ 'state': 'off', }) # --- +# name: test_selects[wago_home_blind_control][select.home_blind_wi_fi_blind_type-entry] + EntityRegistryEntrySnapshot({ + 'aliases': list([ + None, + ]), + 'area_id': None, + 'capabilities': dict({ + : list([ + 'roller_shutter', + 'venetian_blind', + ]), + }), + 'config_entry_id': , + 'config_subentry_id': , + 'device_class': None, + 'device_id': , + 'disabled_by': None, + 'domain': 'select', + 'entity_category': , + 'entity_id': 'select.home_blind_wi_fi_blind_type', + 'has_entity_name': True, + 'hidden_by': None, + 'icon': None, + 'id': , + 'labels': set({ + }), + 'name': None, + 'object_id_base': 'Blind type', + 'options': dict({ + }), + 'original_device_class': None, + 'original_icon': None, + 'original_name': 'Blind type', + 'platform': 'matter', + 'previous_unique_id': None, + 'suggested_object_id': None, + 'supported_features': 0, + 'translation_key': 'blind_type', + 'unique_id': '00000000000004D2-0000000000000157-MatterNodeDevice-1-WagoBlindType-258-355729413', + 'unit_of_measurement': None, + }) +# --- +# name: test_selects[wago_home_blind_control][select.home_blind_wi_fi_blind_type-state] + StateSnapshot({ + 'attributes': ReadOnlyDict({ + : 'Home Blind Wi-Fi Blind type', + : list([ + 'roller_shutter', + 'venetian_blind', + ]), + }), + 'context': , + 'entity_id': 'select.home_blind_wi_fi_blind_type', + 'last_changed': , + 'last_reported': , + 'last_updated': , + 'state': 'roller_shutter', + }) +# --- # name: test_selects[wago_home_blind_control][select.home_blind_wi_fi_connection_mode-entry] EntityRegistryEntrySnapshot({ 'aliases': list([ diff --git a/tests/components/matter/test_cover.py b/tests/components/matter/test_cover.py index 7239d7a43db1..4ac5e141a179 100644 --- a/tests/components/matter/test_cover.py +++ b/tests/components/matter/test_cover.py @@ -283,6 +283,71 @@ async def test_cover_position_aware_lift_null_tilt( assert "current_tilt_position" not in state.attributes +@pytest.mark.parametrize("node_fixture", ["wago_home_blind_control"]) +async def test_cover_wago_blind_type( + hass: HomeAssistant, + matter_client: MagicMock, + matter_node: MatterNode, + freezer: FrozenDateTimeFactory, +) -> None: + """Test the WAGO Home Blind Control hides tilt when set to roller shutter. + + The device keeps reporting the tilt feature and a tilt blind Type in + roller shutter mode; only the vendor BlindType attribute tells. + """ + entity_id = "cover.home_blind_wi_fi" + state = hass.states.get(entity_id) + assert state + assert state.attributes["device_class"] == "shutter" + assert ( + state.attributes["supported_features"] & CoverEntityFeature.SET_TILT_POSITION + == 0 + ) + assert "current_tilt_position" not in state.attributes + + await set_node_attribute_and_notify( + hass, + matter_client, + matter_node, + endpoint=1, + cluster_id=258, + attribute_id=clusters.WindowCovering.Attributes.WagoBlindType.attribute_id, + value=1, + ) + freezer.tick(STATE_WRITE_DEBOUNCE_COOLDOWN) + async_fire_time_changed(hass) + await hass.async_block_till_done() + state = hass.states.get(entity_id) + assert state + assert state.attributes["device_class"] == "blind" + assert ( + state.attributes["supported_features"] & CoverEntityFeature.SET_TILT_POSITION + != 0 + ) + assert state.attributes["current_tilt_position"] == 100 + + await set_node_attribute_and_notify( + hass, + matter_client, + matter_node, + endpoint=1, + cluster_id=258, + attribute_id=clusters.WindowCovering.Attributes.WagoBlindType.attribute_id, + value=0, + ) + freezer.tick(STATE_WRITE_DEBOUNCE_COOLDOWN) + async_fire_time_changed(hass) + await hass.async_block_till_done() + state = hass.states.get(entity_id) + assert state + assert state.attributes["device_class"] == "shutter" + assert ( + state.attributes["supported_features"] & CoverEntityFeature.SET_TILT_POSITION + == 0 + ) + assert "current_tilt_position" not in state.attributes + + @pytest.mark.parametrize( ("node_fixture", "entity_id"), [ diff --git a/tests/components/matter/test_select.py b/tests/components/matter/test_select.py index 68bae69eb1a5..71705bd9ab25 100644 --- a/tests/components/matter/test_select.py +++ b/tests/components/matter/test_select.py @@ -548,3 +548,54 @@ async def test_wago_travel_time_mode_select( ), value=True, ) + + +@pytest.mark.parametrize("node_fixture", ["wago_home_blind_control"]) +async def test_wago_blind_type_select( + hass: HomeAssistant, + matter_client: MagicMock, + matter_node: MatterNode, +) -> None: + """Test select entity for the WAGO WindowCovering BlindType attribute.""" + entity_id = "select.home_blind_wi_fi_blind_type" + state = hass.states.get(entity_id) + assert state + assert state.state == "roller_shutter" + assert state.attributes["options"] == ["roller_shutter", "venetian_blind"] + + set_node_attribute(matter_node, 1, 258, 355729413, 1) + await trigger_subscription_callback(hass, matter_client) + state = hass.states.get(entity_id) + assert state.state == "venetian_blind" + + await hass.services.async_call( + "select", + "select_option", + {"entity_id": entity_id, "option": "venetian_blind"}, + blocking=True, + ) + assert matter_client.write_attribute.call_count == 1 + assert matter_client.write_attribute.call_args == call( + node_id=matter_node.node_id, + attribute_path=create_attribute_path_from_attribute( + endpoint_id=1, + attribute=clusters.WindowCovering.Attributes.WagoBlindType, + ), + value=1, + ) + + await hass.services.async_call( + "select", + "select_option", + {"entity_id": entity_id, "option": "roller_shutter"}, + blocking=True, + ) + assert matter_client.write_attribute.call_count == 2 + assert matter_client.write_attribute.call_args == call( + node_id=matter_node.node_id, + attribute_path=create_attribute_path_from_attribute( + endpoint_id=1, + attribute=clusters.WindowCovering.Attributes.WagoBlindType, + ), + value=0, + )