Skip to content

Commit 746d5ba

Browse files
Add Aqara Dimmer Switch H2 EU support (#4202)
Co-authored-by: TheJulianJES <TheJulianJES@users.noreply.github.com>
1 parent b734d1b commit 746d5ba

File tree

2 files changed

+163
-0
lines changed

2 files changed

+163
-0
lines changed

zhaquirks/xiaomi/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -408,6 +408,8 @@ def _parse_aqara_attributes(self, value):
408408
"lumi.switch.n0acn2",
409409
]:
410410
attribute_names.update({149: CONSUMPTION, 150: VOLTAGE, 152: POWER})
411+
elif self.endpoint.device.model == "lumi.switch.agl011":
412+
attribute_names.update({150: VOLTAGE, 151: CONSUMPTION, 152: POWER})
411413
elif self.endpoint.device.model == "lumi.sensor_motion.aq2":
412414
attribute_names.update({11: ILLUMINANCE_MEASUREMENT})
413415
elif self.endpoint.device.model == "lumi.curtain.acn002":
Lines changed: 161 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,161 @@
1+
"""Quirk for Aqara Dimmer Switch H2 EU (lumi.switch.agl011)."""
2+
3+
from zigpy import types
4+
from zigpy.profiles import zha
5+
from zigpy.quirks.v2 import QuirkBuilder
6+
from zigpy.zcl.foundation import BaseAttributeDefs, ZCLAttributeDef
7+
8+
from zhaquirks.xiaomi import DeviceTemperatureCluster, XiaomiAqaraE1Cluster
9+
10+
11+
class ModeSwitch(types.enum16):
12+
"""Enum for dimmer mode switch."""
13+
14+
Quick = 0x01
15+
Anti_Flicker = 0x04
16+
17+
18+
class OperationMode(types.enum8):
19+
"""Enum for dimmer operation mode."""
20+
21+
Decoupled = 0x00
22+
Relay = 0x01
23+
24+
25+
class Phase(types.enum8):
26+
"""Enum for dimmer phase."""
27+
28+
Leading = 0x00
29+
Trailing = 0x01
30+
31+
32+
class PowerOnState(types.enum8):
33+
"""Enum for dimmer power-on state."""
34+
35+
On = 0x00
36+
Previous = 0x01
37+
Off = 0x02
38+
Inverted = 0x03
39+
40+
41+
class OppleCluster(XiaomiAqaraE1Cluster):
42+
"""Aqara manufacturer-specific cluster for the dimmer switch H2 EU."""
43+
44+
class AttributeDefs(BaseAttributeDefs):
45+
"""Attribute Definitions."""
46+
47+
flip_indicator_light = ZCLAttributeDef(
48+
id=0x00F0, type=types.uint8_t, access="rw", is_manufacturer_specific=True
49+
)
50+
led_indicator = ZCLAttributeDef(
51+
id=0x0203, type=types.Bool, access="rw", is_manufacturer_specific=True
52+
)
53+
max_brightness = ZCLAttributeDef(
54+
id=0x0516, type=types.uint8_t, access="rw", is_manufacturer_specific=True
55+
)
56+
min_brightness = ZCLAttributeDef(
57+
id=0x0515, type=types.uint8_t, access="rw", is_manufacturer_specific=True
58+
)
59+
mode_switch = ZCLAttributeDef(
60+
id=0x0004, type=types.uint16_t, access="rw", is_manufacturer_specific=True
61+
)
62+
operation_mode = ZCLAttributeDef(
63+
id=0x0200, type=types.uint8_t, access="rw", is_manufacturer_specific=True
64+
)
65+
phase = ZCLAttributeDef(
66+
id=0x030A, type=types.uint8_t, access="rw", is_manufacturer_specific=True
67+
)
68+
power_on_state = ZCLAttributeDef(
69+
id=0x0517, type=types.uint8_t, access="rw", is_manufacturer_specific=True
70+
)
71+
reporting_interval = ZCLAttributeDef(
72+
id=0x00F6, type=types.uint16_t, access="rw", is_manufacturer_specific=True
73+
)
74+
sensitivity = ZCLAttributeDef(
75+
id=0x0234, type=types.uint16_t, access="rw", is_manufacturer_specific=True
76+
)
77+
78+
79+
(
80+
QuirkBuilder("Aqara", "lumi.switch.agl011")
81+
.replaces_endpoint(1, device_type=zha.DeviceType.DIMMABLE_LIGHT)
82+
.adds(DeviceTemperatureCluster)
83+
.adds(OppleCluster)
84+
.switch(
85+
OppleCluster.AttributeDefs.flip_indicator_light.name,
86+
OppleCluster.cluster_id,
87+
translation_key="flip_indicator_light",
88+
fallback_name="Flip indicator light",
89+
)
90+
.switch(
91+
OppleCluster.AttributeDefs.led_indicator.name,
92+
OppleCluster.cluster_id,
93+
translation_key="led_indicator",
94+
fallback_name="LED indicator",
95+
)
96+
.number(
97+
OppleCluster.AttributeDefs.max_brightness.name,
98+
OppleCluster.cluster_id,
99+
min_value=1,
100+
max_value=100,
101+
step=1,
102+
translation_key="max_brightness",
103+
fallback_name="Maximum brightness",
104+
)
105+
.number(
106+
OppleCluster.AttributeDefs.min_brightness.name,
107+
OppleCluster.cluster_id,
108+
min_value=0,
109+
max_value=99,
110+
step=1,
111+
translation_key="min_brightness",
112+
fallback_name="Minimum brightness",
113+
)
114+
.enum(
115+
OppleCluster.AttributeDefs.mode_switch.name,
116+
ModeSwitch,
117+
OppleCluster.cluster_id,
118+
translation_key="mode_switch",
119+
fallback_name="Mode switch",
120+
)
121+
.enum(
122+
OppleCluster.AttributeDefs.operation_mode.name,
123+
OperationMode,
124+
OppleCluster.cluster_id,
125+
translation_key="operation_mode",
126+
fallback_name="Operation mode",
127+
)
128+
.enum(
129+
OppleCluster.AttributeDefs.phase.name,
130+
Phase,
131+
OppleCluster.cluster_id,
132+
translation_key="phase",
133+
fallback_name="Phase",
134+
)
135+
.enum(
136+
OppleCluster.AttributeDefs.power_on_state.name,
137+
PowerOnState,
138+
OppleCluster.cluster_id,
139+
translation_key="power_on_state",
140+
fallback_name="Power on state",
141+
)
142+
.number(
143+
OppleCluster.AttributeDefs.reporting_interval.name,
144+
OppleCluster.cluster_id,
145+
min_value=1,
146+
max_value=3600,
147+
step=1,
148+
translation_key="reporting_interval",
149+
fallback_name="Reporting interval",
150+
)
151+
.number(
152+
OppleCluster.AttributeDefs.sensitivity.name,
153+
OppleCluster.cluster_id,
154+
min_value=1,
155+
max_value=65535,
156+
step=1,
157+
translation_key="sensitivity",
158+
fallback_name="Sensitivity",
159+
)
160+
.add_to_registry()
161+
)

0 commit comments

Comments
 (0)