Skip to content

Commit ca5559d

Browse files
committed
Edit lift_duration attribute
- Use ZCLAttributeDef for attribute
1 parent e9a9e88 commit ca5559d

File tree

3 files changed

+228
-68
lines changed

3 files changed

+228
-68
lines changed

zhaquirks/schneiderelectric/__init__.py

Lines changed: 219 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,12 @@
66
from zigpy.zcl.clusters.closures import WindowCovering
77
from zigpy.zcl.clusters.general import Basic
88
from zigpy.zcl.clusters.homeautomation import Diagnostic
9+
from zigpy.zcl.foundation import ZCLAttributeDef
910

1011
_LOGGER = logging.getLogger(__name__)
1112

12-
SE = "Schneider Electric"
13+
SE_MANUF_NAME = "Schneider Electric"
14+
SE_MANUF_ID = 4190
1315

1416

1517
class SEManufCluster(CustomCluster):
@@ -20,101 +22,259 @@ class SEManufCluster(CustomCluster):
2022

2123

2224
class SEBasicCluster(SEManufCluster, Basic):
23-
ATT_ID_E001 = 0xE001
24-
ATT_ID_E002 = 0xE002
25-
ATT_ID_E004 = 0xE004
26-
ATT_ID_E007 = 0xE007
27-
ATT_ID_E008 = 0xE008
28-
ATT_ID_E009 = 0xE009
29-
ATT_ID_E00A = 0xE00A
30-
ATT_ID_E00B = 0xE00B
3125

32-
attributes = Basic.attributes.copy()
26+
attributes: dict[int, ZCLAttributeDef] = Basic.attributes.copy()
3327

3428
attributes.update(
3529
{
36-
ATT_ID_E001: ("57345", t.CharacterString)
30+
0xE001: ZCLAttributeDef(
31+
id=0xE001,
32+
name="57345",
33+
type=t.CharacterString,
34+
access="r",
35+
is_manufacturer_specific=True,
36+
)
3737
}, # attribute_name:"57345" # ex: "002.004.016 R
3838
{
39-
ATT_ID_E002: ("57346", t.CharacterString)
39+
0xE002: ZCLAttributeDef(
40+
id=0xE002,
41+
name="57346",
42+
type=t.CharacterString,
43+
is_manufacturer_specific=True,
44+
)
4045
}, # attribute_name:"57346" # ex: "001.000.000"
4146
{
42-
ATT_ID_E004: ("57348", t.CharacterString)
47+
0xE004: ZCLAttributeDef(
48+
id=0xE004,
49+
name="57348",
50+
type=t.CharacterString,
51+
access="r",
52+
is_manufacturer_specific=True,
53+
)
4354
}, # attribute_name:"57348" # ex: "213249FEFF5ECFD"
44-
{ATT_ID_E007: ("57351", t.enum16)}, # attribute_name:"57351"
4555
{
46-
ATT_ID_E008: ("57352", t.CharacterString)
56+
0xE007: ZCLAttributeDef(
57+
id=0xE007,
58+
name="57351",
59+
type=t.enum16,
60+
access="r",
61+
is_manufacturer_specific=True,
62+
)
63+
}, # attribute_name:"57351"
64+
{
65+
0xE008: ZCLAttributeDef(
66+
id=0xE008,
67+
name="57352",
68+
type=t.CharacterString,
69+
access="r",
70+
is_manufacturer_specific=True,
71+
)
4772
}, # attribute_name:"57352" # ex: "Wiser Light"
4873
{
49-
ATT_ID_E009: ("57353", t.CharacterString)
74+
0xE009: ZCLAttributeDef(
75+
id=0xE009,
76+
name="57353",
77+
type=t.CharacterString,
78+
access="r",
79+
is_manufacturer_specific=True,
80+
)
5081
}, # attribute_name:"57353" # ex: "NHPB/SHUTTER/1"
5182
{
52-
ATT_ID_E00A: ("57354", t.CharacterString)
83+
0xE00A: ZCLAttributeDef(
84+
id=0xE00A,
85+
name="57354",
86+
type=t.CharacterString,
87+
access="r",
88+
is_manufacturer_specific=True,
89+
)
5390
}, # attribute_name:"57354" # ex: "Wiser Home"
54-
{ATT_ID_E00B: ("57355", t.CharacterString)}, # attribute_name:"57355"
91+
{
92+
0xE00B: ZCLAttributeDef(
93+
id=0xE00B,
94+
name="57355",
95+
type=t.CharacterString,
96+
access="r",
97+
is_manufacturer_specific=True,
98+
)
99+
}, # attribute_name:"57355"
55100
)
56101

57102

58-
class SEManufSwitchCluster(SEManufCluster):
59-
name = "Schneider Electric Manufacturer Specicific"
103+
class SESpecificCluster(SEManufCluster):
60104
cluster_id = 0xFF17
61105

62-
ATT_ID_0000 = 0x0000
63-
ATT_ID_0001 = 0x0001
64-
ATT_ID_0010 = 0x0010
65-
ATT_ID_0011 = 0x0011
66-
ATT_ID_0020 = 0x0020
67-
ATT_ID_0021 = 0x0021
68-
ATT_ID_FFFD = 0xFFFD
69-
70106
attributes = {
71-
{ATT_ID_0000: ("0", t.enum8)}, # attribute_name:"0"
72-
{ATT_ID_0001: ("1", t.enum8)}, # attribute_name:"1"
73-
{ATT_ID_0010: ("16", t.uint8_t)}, # attribute_name:"16"
74-
{ATT_ID_0011: ("17", t.uint16_t)}, # attribute_name:"17"
75-
{ATT_ID_0020: ("32", t.uint8_t)}, # attribute_name:"32"
76-
{ATT_ID_0021: ("33", t.uint16_t)}, # attribute_name:"33"
77-
{ATT_ID_FFFD: ("65533", t.uint16_t)}, # attribute_name:"65533"
107+
{
108+
0x0000: ZCLAttributeDef(
109+
id=0x0000,
110+
name="0",
111+
type=t.enum8,
112+
access="rw",
113+
is_manufacturer_specific=True,
114+
)
115+
}, # attribute_name:"0"
116+
{
117+
0x0001: ZCLAttributeDef(
118+
id=0x0001,
119+
name="1",
120+
type=t.enum8,
121+
access="rw",
122+
is_manufacturer_specific=True,
123+
)
124+
}, # attribute_name:"1"
125+
{
126+
0x0010: ZCLAttributeDef(
127+
id=0x0010,
128+
name="16",
129+
type=t.uint8_t,
130+
access="rw",
131+
is_manufacturer_specific=True,
132+
)
133+
}, # attribute_name:"16"
134+
{
135+
0x0011: ZCLAttributeDef(
136+
id=0x0011,
137+
name="17",
138+
type=t.uint16_t,
139+
access="rw",
140+
is_manufacturer_specific=True,
141+
)
142+
}, # attribute_name:"17"
143+
{
144+
0x0020: ZCLAttributeDef(
145+
id=0x0020,
146+
name="32",
147+
type=t.uint8_t,
148+
access="rw",
149+
is_manufacturer_specific=True,
150+
)
151+
}, # attribute_name:"32"
152+
{
153+
0x0021: ZCLAttributeDef(
154+
id=0x0021,
155+
name="33",
156+
type=t.uint16_t,
157+
access="rw",
158+
is_manufacturer_specific=True,
159+
)
160+
}, # attribute_name:"33"
161+
{
162+
0xFFFD: ZCLAttributeDef(
163+
id=0xFFFD,
164+
name="65533",
165+
type=t.uint16_t,
166+
access="r",
167+
is_manufacturer_specific=True,
168+
)
169+
}, # attribute_name:"65533"
78170
}
79171

80172

81173
class SEWindowCover(CustomCluster, WindowCovering):
82174
"""Manufacturer Specific Cluster of Device cover."""
83175

84-
ATT_ID_FFFD = 0xFFFD
85-
ATT_ID_E000 = 0xE000
86-
ATT_ID_E010 = 0xE010
87-
ATT_ID_E012 = 0xE012
88-
ATT_ID_E013 = 0xE013
89-
ATT_ID_E014 = 0xE014
90-
ATT_ID_E015 = 0xE015
91-
ATT_ID_E016 = 0xE016
92-
ATT_ID_E017 = 0xE017
176+
# TODO: Reverse lift percentage
93177

94-
attributes = WindowCovering.attributes.copy()
178+
attributes: dict[int, ZCLAttributeDef] = WindowCovering.attributes.copy()
95179

96180
attributes.update(
97181
{
98-
ATT_ID_FFFD: ("57344", t.uint16_t)
99-
}, # attribute_name:"57344" # seems to be lift_duration
100-
{ATT_ID_E000: ("65533", t.uint16_t)}, # attribute_name:"65533"
101-
{ATT_ID_E010: ("57360", t.bitmap8)}, # attribute_name:"57360"
102-
{ATT_ID_E012: ("57362", t.uint16_t)}, # attribute_name:"57362"
103-
{ATT_ID_E013: ("57363", t.bitmap8)}, # attribute_name:"57363"
104-
{ATT_ID_E014: ("57364", t.uint16_t)}, # attribute_name:"57364"
105-
{ATT_ID_E015: ("57365", t.uint16_t)}, # attribute_name:"57365"
106-
{ATT_ID_E016: ("57366", t.uint16_t)}, # attribute_name:"57366"
107-
{ATT_ID_E017: ("57367", t.uint8_t)}, # attribute_name:"57367"
182+
0xFFFD: ZCLAttributeDef(
183+
id=0xFFFD,
184+
name="lift_duration",
185+
type=t.uint16_t,
186+
access="rw",
187+
is_manufacturer_specific=True,
188+
)
189+
}, # attribute_name:"65533"
190+
{
191+
0xE000: ZCLAttributeDef(
192+
id=0xE000,
193+
name="57344",
194+
type=t.uint16_t,
195+
access="rw",
196+
is_manufacturer_specific=True,
197+
)
198+
}, # attribute_name:"57344"
199+
{
200+
0xE010: ZCLAttributeDef(
201+
id=0xE010,
202+
name="57360",
203+
type=t.bitmap8,
204+
access="r",
205+
is_manufacturer_specific=True,
206+
)
207+
}, # attribute_name:"57360"
208+
{
209+
0xE012: ZCLAttributeDef(
210+
id=0xE012,
211+
name="57362",
212+
type=t.uint16_t,
213+
access="rw",
214+
is_manufacturer_specific=True,
215+
)
216+
}, # attribute_name:"57362"
217+
{
218+
0xE013: ZCLAttributeDef(
219+
id=0xE013,
220+
name="57363",
221+
type=t.bitmap8,
222+
access="r",
223+
is_manufacturer_specific=True,
224+
)
225+
}, # attribute_name:"57363"
226+
{
227+
0xE014: ZCLAttributeDef(
228+
id=0xE014,
229+
name="57364",
230+
type=t.uint16_t,
231+
access="rw",
232+
is_manufacturer_specific=True,
233+
)
234+
}, # attribute_name:"57364"
235+
{
236+
0xE015: ZCLAttributeDef(
237+
id=0xE015,
238+
name="57365",
239+
type=t.uint16_t,
240+
access="rw",
241+
is_manufacturer_specific=True,
242+
)
243+
}, # attribute_name:"57365"
244+
{
245+
0xE016: ZCLAttributeDef(
246+
id=0xE016,
247+
name="57366",
248+
type=t.uint16_t,
249+
access="rw",
250+
is_manufacturer_specific=True,
251+
)
252+
}, # attribute_name:"57366"
253+
{
254+
0xE017: ZCLAttributeDef(
255+
id=0xE017,
256+
name="57367",
257+
type=t.uint8_t,
258+
access="rw",
259+
is_manufacturer_specific=True,
260+
)
261+
}, # attribute_name:"57367"
108262
)
109263

110264

111265
class SEDiagnostic(CustomCluster, Diagnostic):
112266

113-
ATT_ID_FFFD = 0xFFFD
114-
115-
attributes = Diagnostic.attributes.copy()
267+
attributes: dict[int, ZCLAttributeDef] = Diagnostic.attributes.copy()
116268

117269
# TODO: Check -> this attr don't seems to be manufacturer related (no "manf_id")
118270
attributes.update(
119-
{ATT_ID_FFFD: ("65533", t.uint16_t)}, # attribute_name:"65533"
271+
{
272+
0xFFFD: ZCLAttributeDef(
273+
id=0xFFFD,
274+
name="65533",
275+
type=t.uint16_t,
276+
access="r",
277+
is_manufacturer_specific=True,
278+
)
279+
}, # attribute_name:"65533"
120280
)

zhaquirks/schneiderelectric/shutters.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
OUTPUT_CLUSTERS,
2525
PROFILE_ID,
2626
)
27-
from zhaquirks.schneiderelectric import SE, SEManufSwitchCluster
27+
from zhaquirks.schneiderelectric import SE_MANUF_NAME, SESpecificCluster
2828

2929

3030
class NHPBShutter1(CustomDevice):
@@ -41,7 +41,7 @@ class NHPBShutter1(CustomDevice):
4141
# *is_full_function_device=True, *is_mains_powered=True, *is_receiver_on_when_idle=True,
4242
# *is_router=True, *is_security_capable=False)
4343
signature = {
44-
MODELS_INFO: [(SE, "NHPB/SHUTTER/1")],
44+
MODELS_INFO: [(SE_MANUF_NAME, "NHPB/SHUTTER/1")],
4545
ENDPOINTS: {
4646
5: {
4747
PROFILE_ID: zha.PROFILE_ID,
@@ -63,7 +63,7 @@ class NHPBShutter1(CustomDevice):
6363
Basic.cluster_id, # 0x0000
6464
Identify.cluster_id, # 0x0003
6565
Diagnostic.cluster_id, # 0x0B05
66-
SEManufSwitchCluster.cluster_id, # 0xff17
66+
SESpecificCluster.cluster_id, # 0xff17
6767
],
6868
OUTPUT_CLUSTERS: [
6969
Identify.cluster_id, # 0x0003

0 commit comments

Comments
 (0)