Skip to content

Commit e3d3849

Browse files
authored
Fix missing endpoints for Aqara H1 wireless remotes (#3674)
* Fix missing endpoints for Aqara H1 wireless remotes The device sometimes doesn't report these endpoints as available, so quirks v2 code that `adds` or `replaces` clusters on those endpoints will cause ZHA to break. Zigpy now allows us to add these endpoints to the zigpy device, so we can also add clusters to the endpoints in the same quirk without issues. * Add test for verifying missing endpoints get added
1 parent 8335cd6 commit e3d3849

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

Diff for: tests/test_xiaomi.py

+17
Original file line numberDiff line numberDiff line change
@@ -1804,3 +1804,20 @@ async def test_aqara_fp1e_sensor(
18041804
assert len(ias_listener.attribute_updates) == 1
18051805
assert ias_listener.attribute_updates[0][0] == IasZone.AttributeDefs.zone_status.id
18061806
assert ias_listener.attribute_updates[0][1] == expected_motion_status
1807+
1808+
1809+
def test_h1_wireless_remotes(zigpy_device_from_v2_quirk):
1810+
"""Test Aqara H1 wireless remote quirk adds missing endpoints."""
1811+
# create device with endpoint 1 only and verify we don't get a KeyError
1812+
quirk = zigpy_device_from_v2_quirk(LUMI, "lumi.remote.b28ac1")
1813+
1814+
# verify the quirk adds endpoints 2 and 3
1815+
assert 2 in quirk.endpoints
1816+
assert 3 in quirk.endpoints
1817+
1818+
# verify the quirk adds the correct clusters to the new endpoints
1819+
assert OnOff.cluster_id in quirk.endpoints[2].out_clusters
1820+
assert OnOff.cluster_id in quirk.endpoints[3].out_clusters
1821+
1822+
assert MultistateInput.cluster_id in quirk.endpoints[2].in_clusters
1823+
assert MultistateInput.cluster_id in quirk.endpoints[3].in_clusters

Diff for: zhaquirks/xiaomi/aqara/remote_h1.py

+4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
"""Aqara H1-series wireless remote."""
22

33
from zigpy import types
4+
from zigpy.profiles import zha
45
from zigpy.quirks.v2 import ClusterType, QuirkBuilder
56
from zigpy.zcl.clusters.general import Identify, OnOff
67
from zigpy.zcl.foundation import BaseAttributeDefs, DataTypeId, ZCLAttributeDef
@@ -144,6 +145,9 @@ class PowerConfigurationClusterH1Remote(PowerConfigurationCluster):
144145
# .friendly_name(
145146
# manufacturer="Aqara", model="Wireless Remote Switch H1 (Double Rocker)"
146147
# )
148+
# add endpoints that are present but not exposed sometimes
149+
.adds_endpoint(2, device_type=zha.DeviceType.ON_OFF_LIGHT_SWITCH)
150+
.adds_endpoint(3, device_type=zha.DeviceType.ON_OFF_LIGHT_SWITCH)
147151
.replaces(AqaraRemoteManuSpecificCluster)
148152
.adds(Identify)
149153
.replaces(MultistateInputCluster)

0 commit comments

Comments
 (0)