Add blind type select for Matter WAGO Home Blind Control (#187769)

Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
Stefan Agner
2026-10-26 14:40:03 +01:00
committed by GitHub
co-authored by Claude Fable 5.1
parent 65e0414ff2
commit ee98e93a4e
8 changed files with 225 additions and 8 deletions
+15
View File
@@ -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,
),
),
]
+20
View File
@@ -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,),
),
]
@@ -313,6 +313,13 @@
}
},
"select": {
"blind_type": {
"name": "Blind type",
"state": {
"roller_shutter": "Roller shutter",
"venetian_blind": "Venetian blind"
}
},
"clean_mode": {
"name": "Clean mode"
},
@@ -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": [],
@@ -563,13 +563,13 @@
'object_id_base': None,
'options': dict({
}),
'original_device_class': <CoverDeviceClass.BLIND: 'blind'>,
'original_device_class': <CoverDeviceClass.SHUTTER: 'shutter'>,
'original_icon': None,
'original_name': None,
'platform': 'matter',
'previous_unique_id': None,
'suggested_object_id': None,
'supported_features': <CoverEntityFeature: 143>,
'supported_features': <CoverEntityFeature: 15>,
'translation_key': None,
'unique_id': '00000000000004D2-0000000000000157-MatterNodeDevice-1-MatterCoverPositionAwareLiftAndTilt-258-10',
'unit_of_measurement': None,
@@ -579,11 +579,10 @@
StateSnapshot({
'attributes': ReadOnlyDict({
<CoverEntityStateAttribute.CURRENT_POSITION: 'current_position'>: 100,
<CoverEntityStateAttribute.CURRENT_TILT_POSITION: 'current_tilt_position'>: 100,
<EntityStateAttribute.DEVICE_CLASS: 'device_class'>: 'blind',
<EntityStateAttribute.DEVICE_CLASS: 'device_class'>: 'shutter',
<EntityStateAttribute.FRIENDLY_NAME: 'friendly_name'>: 'Home Blind Wi-Fi',
<CoverEntityStateAttribute.IS_CLOSED: 'is_closed'>: False,
<EntityStateAttribute.SUPPORTED_FEATURES: 'supported_features'>: <CoverEntityFeature: 143>,
<EntityStateAttribute.SUPPORTED_FEATURES: 'supported_features'>: <CoverEntityFeature: 15>,
}),
'context': <ANY>,
'entity_id': 'cover.home_blind_wi_fi',
@@ -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({
<SelectEntityCapabilityAttribute.OPTIONS: 'options'>: list([
'roller_shutter',
'venetian_blind',
]),
}),
'config_entry_id': <ANY>,
'config_subentry_id': <ANY>,
'device_class': None,
'device_id': <DeviceEntry identifiers=[('matter', 'deviceid_00000000000004D2-0000000000000157-MatterNodeDevice'), ('matter', 'serial_serial_343')]>,
'disabled_by': None,
'domain': 'select',
'entity_category': <EntityCategory.CONFIG: 'config'>,
'entity_id': 'select.home_blind_wi_fi_blind_type',
'has_entity_name': True,
'hidden_by': None,
'icon': None,
'id': <ANY>,
'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({
<EntityStateAttribute.FRIENDLY_NAME: 'friendly_name'>: 'Home Blind Wi-Fi Blind type',
<SelectEntityCapabilityAttribute.OPTIONS: 'options'>: list([
'roller_shutter',
'venetian_blind',
]),
}),
'context': <ANY>,
'entity_id': 'select.home_blind_wi_fi_blind_type',
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,
'state': 'roller_shutter',
})
# ---
# name: test_selects[wago_home_blind_control][select.home_blind_wi_fi_connection_mode-entry]
EntityRegistryEntrySnapshot({
'aliases': list([
+65
View File
@@ -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"),
[
+51
View File
@@ -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,
)