Skip to content

Commit 68e37ae

Browse files
Add quirk for Sonoff ZBMINIR2 (#3428)
Co-authored-by: TheJulianJES <[email protected]>
1 parent 4d53f30 commit 68e37ae

File tree

1 file changed

+88
-0
lines changed

1 file changed

+88
-0
lines changed

zhaquirks/sonoff/zbminir2.py

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
"""Sonoff ZBMINIR2 - Zigbee Switch."""
2+
3+
from zigpy import types
4+
from zigpy.quirks import CustomCluster
5+
from zigpy.quirks.v2 import QuirkBuilder
6+
import zigpy.types as t
7+
from zigpy.zcl import foundation
8+
from zigpy.zcl.foundation import BaseAttributeDefs, ZCLAttributeDef
9+
10+
11+
class SonoffCluster(CustomCluster):
12+
"""Custom Sonoff cluster."""
13+
14+
cluster_id = 0xFC11
15+
16+
class AttributeDefs(BaseAttributeDefs):
17+
"""Attribute definitions."""
18+
19+
external_trigger_mode = ZCLAttributeDef(
20+
id=0x0016,
21+
type=t.uint8_t,
22+
)
23+
detach_relay = ZCLAttributeDef(
24+
id=0x0017,
25+
type=t.Bool,
26+
)
27+
turbo_mode = ZCLAttributeDef(
28+
id=0x0012,
29+
type=t.int16s,
30+
)
31+
32+
async def _read_attributes(
33+
self,
34+
attribute_ids: list[t.uint16_t],
35+
*args,
36+
manufacturer: int | t.uint16_t | None = None,
37+
**kwargs,
38+
):
39+
"""Read attributes ZCL foundation command."""
40+
return await super()._read_attributes(
41+
attribute_ids,
42+
*args,
43+
manufacturer=foundation.ZCLHeader.NO_MANUFACTURER_ID,
44+
**kwargs,
45+
)
46+
47+
@property
48+
def _is_manuf_specific(self):
49+
return False
50+
51+
52+
class SonoffExternalSwitchTriggerType(types.enum8):
53+
"""extern switch trigger type."""
54+
55+
Edge_trigger = 0x00
56+
Pulse_trigger = 0x01
57+
Normally_off_follow_trigger = 0x02
58+
Normally_on_follow_trigger = 0x82
59+
60+
61+
(
62+
QuirkBuilder("SONOFF", "ZBMINIR2")
63+
.replaces(SonoffCluster)
64+
.enum(
65+
SonoffCluster.AttributeDefs.external_trigger_mode.name,
66+
SonoffExternalSwitchTriggerType,
67+
SonoffCluster.cluster_id,
68+
translation_key="external_trigger_mode",
69+
fallback_name="External trigger mode",
70+
)
71+
.switch(
72+
SonoffCluster.AttributeDefs.turbo_mode.name,
73+
SonoffCluster.cluster_id,
74+
off_value=9,
75+
on_value=20,
76+
translation_key="turbo_mode",
77+
fallback_name="Turbo mode",
78+
)
79+
.switch(
80+
SonoffCluster.AttributeDefs.detach_relay.name,
81+
SonoffCluster.cluster_id,
82+
off_value=0,
83+
on_value=1,
84+
translation_key="detach_relay",
85+
fallback_name="Detach relay",
86+
)
87+
.add_to_registry()
88+
)

0 commit comments

Comments
 (0)