Skip to content

Commit 990c8cd

Browse files
lboueCopilotTheJulianJES
authored
Add Matter Window covering operational status (home-assistant#156066)
Co-authored-by: Copilot <[email protected]> Co-authored-by: TheJulianJES <[email protected]>
1 parent f8c76f4 commit 990c8cd

File tree

3 files changed

+378
-0
lines changed

3 files changed

+378
-0
lines changed

homeassistant/components/matter/binary_sensor.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -485,4 +485,18 @@ def _update_from_device(self) -> None:
485485
required_attributes=(clusters.RefrigeratorAlarm.Attributes.State,),
486486
allow_multi=True,
487487
),
488+
MatterDiscoverySchema(
489+
platform=Platform.BINARY_SENSOR,
490+
entity_description=MatterBinarySensorEntityDescription(
491+
key="WindowCoveringConfigStatusOperational",
492+
device_class=BinarySensorDeviceClass.PROBLEM,
493+
entity_category=EntityCategory.DIAGNOSTIC,
494+
# unset Operational bit from ConfigStatus bitmap means problem
495+
device_to_ha=lambda x: not bool(
496+
x & clusters.WindowCovering.Bitmaps.ConfigStatus.kOperational
497+
),
498+
),
499+
entity_class=MatterBinarySensor,
500+
required_attributes=(clusters.WindowCovering.Attributes.ConfigStatus,),
501+
),
488502
]

tests/components/matter/snapshots/test_binary_sensor.ambr

Lines changed: 343 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -342,6 +342,55 @@
342342
'state': 'on',
343343
})
344344
# ---
345+
# name: test_binary_sensors[eve_shutter][binary_sensor.eve_shutter_switch_20eci1701_problem-entry]
346+
EntityRegistryEntrySnapshot({
347+
'aliases': set({
348+
}),
349+
'area_id': None,
350+
'capabilities': None,
351+
'config_entry_id': <ANY>,
352+
'config_subentry_id': <ANY>,
353+
'device_class': None,
354+
'device_id': <ANY>,
355+
'disabled_by': None,
356+
'domain': 'binary_sensor',
357+
'entity_category': <EntityCategory.DIAGNOSTIC: 'diagnostic'>,
358+
'entity_id': 'binary_sensor.eve_shutter_switch_20eci1701_problem',
359+
'has_entity_name': True,
360+
'hidden_by': None,
361+
'icon': None,
362+
'id': <ANY>,
363+
'labels': set({
364+
}),
365+
'name': None,
366+
'options': dict({
367+
}),
368+
'original_device_class': <BinarySensorDeviceClass.PROBLEM: 'problem'>,
369+
'original_icon': None,
370+
'original_name': 'Problem',
371+
'platform': 'matter',
372+
'previous_unique_id': None,
373+
'suggested_object_id': None,
374+
'supported_features': 0,
375+
'translation_key': None,
376+
'unique_id': '00000000000004D2-0000000000000094-MatterNodeDevice-1-WindowCoveringConfigStatusOperational-258-7',
377+
'unit_of_measurement': None,
378+
})
379+
# ---
380+
# name: test_binary_sensors[eve_shutter][binary_sensor.eve_shutter_switch_20eci1701_problem-state]
381+
StateSnapshot({
382+
'attributes': ReadOnlyDict({
383+
'device_class': 'problem',
384+
'friendly_name': 'Eve Shutter Switch 20ECI1701 Problem',
385+
}),
386+
'context': <ANY>,
387+
'entity_id': 'binary_sensor.eve_shutter_switch_20eci1701_problem',
388+
'last_changed': <ANY>,
389+
'last_reported': <ANY>,
390+
'last_updated': <ANY>,
391+
'state': 'off',
392+
})
393+
# ---
345394
# name: test_binary_sensors[heiman_motion_sensor_m1][binary_sensor.smart_motion_sensor_occupancy-entry]
346395
EntityRegistryEntrySnapshot({
347396
'aliases': set({
@@ -1614,3 +1663,297 @@
16141663
'state': 'off',
16151664
})
16161665
# ---
1666+
# name: test_binary_sensors[window_covering_full][binary_sensor.mock_full_window_covering_problem-entry]
1667+
EntityRegistryEntrySnapshot({
1668+
'aliases': set({
1669+
}),
1670+
'area_id': None,
1671+
'capabilities': None,
1672+
'config_entry_id': <ANY>,
1673+
'config_subentry_id': <ANY>,
1674+
'device_class': None,
1675+
'device_id': <ANY>,
1676+
'disabled_by': None,
1677+
'domain': 'binary_sensor',
1678+
'entity_category': <EntityCategory.DIAGNOSTIC: 'diagnostic'>,
1679+
'entity_id': 'binary_sensor.mock_full_window_covering_problem',
1680+
'has_entity_name': True,
1681+
'hidden_by': None,
1682+
'icon': None,
1683+
'id': <ANY>,
1684+
'labels': set({
1685+
}),
1686+
'name': None,
1687+
'options': dict({
1688+
}),
1689+
'original_device_class': <BinarySensorDeviceClass.PROBLEM: 'problem'>,
1690+
'original_icon': None,
1691+
'original_name': 'Problem',
1692+
'platform': 'matter',
1693+
'previous_unique_id': None,
1694+
'suggested_object_id': None,
1695+
'supported_features': 0,
1696+
'translation_key': None,
1697+
'unique_id': '00000000000004D2-0000000000000032-MatterNodeDevice-1-WindowCoveringConfigStatusOperational-258-7',
1698+
'unit_of_measurement': None,
1699+
})
1700+
# ---
1701+
# name: test_binary_sensors[window_covering_full][binary_sensor.mock_full_window_covering_problem-state]
1702+
StateSnapshot({
1703+
'attributes': ReadOnlyDict({
1704+
'device_class': 'problem',
1705+
'friendly_name': 'Mock Full Window Covering Problem',
1706+
}),
1707+
'context': <ANY>,
1708+
'entity_id': 'binary_sensor.mock_full_window_covering_problem',
1709+
'last_changed': <ANY>,
1710+
'last_reported': <ANY>,
1711+
'last_updated': <ANY>,
1712+
'state': 'off',
1713+
})
1714+
# ---
1715+
# name: test_binary_sensors[window_covering_lift][binary_sensor.mock_lift_window_covering_problem-entry]
1716+
EntityRegistryEntrySnapshot({
1717+
'aliases': set({
1718+
}),
1719+
'area_id': None,
1720+
'capabilities': None,
1721+
'config_entry_id': <ANY>,
1722+
'config_subentry_id': <ANY>,
1723+
'device_class': None,
1724+
'device_id': <ANY>,
1725+
'disabled_by': None,
1726+
'domain': 'binary_sensor',
1727+
'entity_category': <EntityCategory.DIAGNOSTIC: 'diagnostic'>,
1728+
'entity_id': 'binary_sensor.mock_lift_window_covering_problem',
1729+
'has_entity_name': True,
1730+
'hidden_by': None,
1731+
'icon': None,
1732+
'id': <ANY>,
1733+
'labels': set({
1734+
}),
1735+
'name': None,
1736+
'options': dict({
1737+
}),
1738+
'original_device_class': <BinarySensorDeviceClass.PROBLEM: 'problem'>,
1739+
'original_icon': None,
1740+
'original_name': 'Problem',
1741+
'platform': 'matter',
1742+
'previous_unique_id': None,
1743+
'suggested_object_id': None,
1744+
'supported_features': 0,
1745+
'translation_key': None,
1746+
'unique_id': '00000000000004D2-0000000000000032-MatterNodeDevice-1-WindowCoveringConfigStatusOperational-258-7',
1747+
'unit_of_measurement': None,
1748+
})
1749+
# ---
1750+
# name: test_binary_sensors[window_covering_lift][binary_sensor.mock_lift_window_covering_problem-state]
1751+
StateSnapshot({
1752+
'attributes': ReadOnlyDict({
1753+
'device_class': 'problem',
1754+
'friendly_name': 'Mock Lift Window Covering Problem',
1755+
}),
1756+
'context': <ANY>,
1757+
'entity_id': 'binary_sensor.mock_lift_window_covering_problem',
1758+
'last_changed': <ANY>,
1759+
'last_reported': <ANY>,
1760+
'last_updated': <ANY>,
1761+
'state': 'off',
1762+
})
1763+
# ---
1764+
# name: test_binary_sensors[window_covering_pa_lift][binary_sensor.longan_link_wncv_da01_problem-entry]
1765+
EntityRegistryEntrySnapshot({
1766+
'aliases': set({
1767+
}),
1768+
'area_id': None,
1769+
'capabilities': None,
1770+
'config_entry_id': <ANY>,
1771+
'config_subentry_id': <ANY>,
1772+
'device_class': None,
1773+
'device_id': <ANY>,
1774+
'disabled_by': None,
1775+
'domain': 'binary_sensor',
1776+
'entity_category': <EntityCategory.DIAGNOSTIC: 'diagnostic'>,
1777+
'entity_id': 'binary_sensor.longan_link_wncv_da01_problem',
1778+
'has_entity_name': True,
1779+
'hidden_by': None,
1780+
'icon': None,
1781+
'id': <ANY>,
1782+
'labels': set({
1783+
}),
1784+
'name': None,
1785+
'options': dict({
1786+
}),
1787+
'original_device_class': <BinarySensorDeviceClass.PROBLEM: 'problem'>,
1788+
'original_icon': None,
1789+
'original_name': 'Problem',
1790+
'platform': 'matter',
1791+
'previous_unique_id': None,
1792+
'suggested_object_id': None,
1793+
'supported_features': 0,
1794+
'translation_key': None,
1795+
'unique_id': '00000000000004D2-0000000000000001-MatterNodeDevice-1-WindowCoveringConfigStatusOperational-258-7',
1796+
'unit_of_measurement': None,
1797+
})
1798+
# ---
1799+
# name: test_binary_sensors[window_covering_pa_lift][binary_sensor.longan_link_wncv_da01_problem-state]
1800+
StateSnapshot({
1801+
'attributes': ReadOnlyDict({
1802+
'device_class': 'problem',
1803+
'friendly_name': 'Longan link WNCV DA01 Problem',
1804+
}),
1805+
'context': <ANY>,
1806+
'entity_id': 'binary_sensor.longan_link_wncv_da01_problem',
1807+
'last_changed': <ANY>,
1808+
'last_reported': <ANY>,
1809+
'last_updated': <ANY>,
1810+
'state': 'off',
1811+
})
1812+
# ---
1813+
# name: test_binary_sensors[window_covering_pa_tilt][binary_sensor.mock_pa_tilt_window_covering_problem-entry]
1814+
EntityRegistryEntrySnapshot({
1815+
'aliases': set({
1816+
}),
1817+
'area_id': None,
1818+
'capabilities': None,
1819+
'config_entry_id': <ANY>,
1820+
'config_subentry_id': <ANY>,
1821+
'device_class': None,
1822+
'device_id': <ANY>,
1823+
'disabled_by': None,
1824+
'domain': 'binary_sensor',
1825+
'entity_category': <EntityCategory.DIAGNOSTIC: 'diagnostic'>,
1826+
'entity_id': 'binary_sensor.mock_pa_tilt_window_covering_problem',
1827+
'has_entity_name': True,
1828+
'hidden_by': None,
1829+
'icon': None,
1830+
'id': <ANY>,
1831+
'labels': set({
1832+
}),
1833+
'name': None,
1834+
'options': dict({
1835+
}),
1836+
'original_device_class': <BinarySensorDeviceClass.PROBLEM: 'problem'>,
1837+
'original_icon': None,
1838+
'original_name': 'Problem',
1839+
'platform': 'matter',
1840+
'previous_unique_id': None,
1841+
'suggested_object_id': None,
1842+
'supported_features': 0,
1843+
'translation_key': None,
1844+
'unique_id': '00000000000004D2-0000000000000032-MatterNodeDevice-1-WindowCoveringConfigStatusOperational-258-7',
1845+
'unit_of_measurement': None,
1846+
})
1847+
# ---
1848+
# name: test_binary_sensors[window_covering_pa_tilt][binary_sensor.mock_pa_tilt_window_covering_problem-state]
1849+
StateSnapshot({
1850+
'attributes': ReadOnlyDict({
1851+
'device_class': 'problem',
1852+
'friendly_name': 'Mock PA Tilt Window Covering Problem',
1853+
}),
1854+
'context': <ANY>,
1855+
'entity_id': 'binary_sensor.mock_pa_tilt_window_covering_problem',
1856+
'last_changed': <ANY>,
1857+
'last_reported': <ANY>,
1858+
'last_updated': <ANY>,
1859+
'state': 'off',
1860+
})
1861+
# ---
1862+
# name: test_binary_sensors[window_covering_tilt][binary_sensor.mock_tilt_window_covering_problem-entry]
1863+
EntityRegistryEntrySnapshot({
1864+
'aliases': set({
1865+
}),
1866+
'area_id': None,
1867+
'capabilities': None,
1868+
'config_entry_id': <ANY>,
1869+
'config_subentry_id': <ANY>,
1870+
'device_class': None,
1871+
'device_id': <ANY>,
1872+
'disabled_by': None,
1873+
'domain': 'binary_sensor',
1874+
'entity_category': <EntityCategory.DIAGNOSTIC: 'diagnostic'>,
1875+
'entity_id': 'binary_sensor.mock_tilt_window_covering_problem',
1876+
'has_entity_name': True,
1877+
'hidden_by': None,
1878+
'icon': None,
1879+
'id': <ANY>,
1880+
'labels': set({
1881+
}),
1882+
'name': None,
1883+
'options': dict({
1884+
}),
1885+
'original_device_class': <BinarySensorDeviceClass.PROBLEM: 'problem'>,
1886+
'original_icon': None,
1887+
'original_name': 'Problem',
1888+
'platform': 'matter',
1889+
'previous_unique_id': None,
1890+
'suggested_object_id': None,
1891+
'supported_features': 0,
1892+
'translation_key': None,
1893+
'unique_id': '00000000000004D2-0000000000000032-MatterNodeDevice-1-WindowCoveringConfigStatusOperational-258-7',
1894+
'unit_of_measurement': None,
1895+
})
1896+
# ---
1897+
# name: test_binary_sensors[window_covering_tilt][binary_sensor.mock_tilt_window_covering_problem-state]
1898+
StateSnapshot({
1899+
'attributes': ReadOnlyDict({
1900+
'device_class': 'problem',
1901+
'friendly_name': 'Mock Tilt Window Covering Problem',
1902+
}),
1903+
'context': <ANY>,
1904+
'entity_id': 'binary_sensor.mock_tilt_window_covering_problem',
1905+
'last_changed': <ANY>,
1906+
'last_reported': <ANY>,
1907+
'last_updated': <ANY>,
1908+
'state': 'off',
1909+
})
1910+
# ---
1911+
# name: test_binary_sensors[zemismart_mt25b][binary_sensor.zemismart_mt25b_roller_motor_problem-entry]
1912+
EntityRegistryEntrySnapshot({
1913+
'aliases': set({
1914+
}),
1915+
'area_id': None,
1916+
'capabilities': None,
1917+
'config_entry_id': <ANY>,
1918+
'config_subentry_id': <ANY>,
1919+
'device_class': None,
1920+
'device_id': <ANY>,
1921+
'disabled_by': None,
1922+
'domain': 'binary_sensor',
1923+
'entity_category': <EntityCategory.DIAGNOSTIC: 'diagnostic'>,
1924+
'entity_id': 'binary_sensor.zemismart_mt25b_roller_motor_problem',
1925+
'has_entity_name': True,
1926+
'hidden_by': None,
1927+
'icon': None,
1928+
'id': <ANY>,
1929+
'labels': set({
1930+
}),
1931+
'name': None,
1932+
'options': dict({
1933+
}),
1934+
'original_device_class': <BinarySensorDeviceClass.PROBLEM: 'problem'>,
1935+
'original_icon': None,
1936+
'original_name': 'Problem',
1937+
'platform': 'matter',
1938+
'previous_unique_id': None,
1939+
'suggested_object_id': None,
1940+
'supported_features': 0,
1941+
'translation_key': None,
1942+
'unique_id': '00000000000004D2-000000000000007A-MatterNodeDevice-1-WindowCoveringConfigStatusOperational-258-7',
1943+
'unit_of_measurement': None,
1944+
})
1945+
# ---
1946+
# name: test_binary_sensors[zemismart_mt25b][binary_sensor.zemismart_mt25b_roller_motor_problem-state]
1947+
StateSnapshot({
1948+
'attributes': ReadOnlyDict({
1949+
'device_class': 'problem',
1950+
'friendly_name': 'Zemismart MT25B Roller Motor Problem',
1951+
}),
1952+
'context': <ANY>,
1953+
'entity_id': 'binary_sensor.zemismart_mt25b_roller_motor_problem',
1954+
'last_changed': <ANY>,
1955+
'last_reported': <ANY>,
1956+
'last_updated': <ANY>,
1957+
'state': 'off',
1958+
})
1959+
# ---

tests/components/matter/test_binary_sensor.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -414,3 +414,24 @@ async def test_thermostat_occupancy(
414414
state = hass.states.get("binary_sensor.longan_link_hvac_occupancy")
415415
assert state
416416
assert state.state == "off"
417+
418+
419+
@pytest.mark.parametrize("node_fixture", ["eve_shutter"])
420+
async def test_shutter_problem(
421+
hass: HomeAssistant,
422+
matter_client: MagicMock,
423+
matter_node: MatterNode,
424+
) -> None:
425+
"""Test shutter problem."""
426+
# Eve Shutter default state (ConfigStatus = 9)
427+
state = hass.states.get("binary_sensor.eve_shutter_switch_20eci1701_problem")
428+
assert state
429+
assert state.state == "off"
430+
431+
# Eve Shutter ConfigStatus Operational bit not set
432+
set_node_attribute(matter_node, 1, 258, 7, 8)
433+
await trigger_subscription_callback(hass, matter_client)
434+
435+
state = hass.states.get("binary_sensor.eve_shutter_switch_20eci1701_problem")
436+
assert state
437+
assert state.state == "on"

0 commit comments

Comments
 (0)