Skip to content

Commit 4412bef

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

File tree

3 files changed

+229
-68
lines changed

3 files changed

+229
-68
lines changed
Lines changed: 220 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,18 @@
11
"""Module for Schneider Electric devices quirks."""
22
import logging
3+
from operator import is_
34

45
from zigpy.quirks import CustomCluster
56
import zigpy.types as t
67
from zigpy.zcl.clusters.closures import WindowCovering
78
from zigpy.zcl.clusters.general import Basic
89
from zigpy.zcl.clusters.homeautomation import Diagnostic
10+
from zigpy.zcl.foundation import ZCLAttributeDef
911

1012
_LOGGER = logging.getLogger(__name__)
1113

12-
SE = "Schneider Electric"
14+
SE_MANUF_NAME = "Schneider Electric"
15+
SE_MANUF_ID = 4190
1316

1417

1518
class SEManufCluster(CustomCluster):
@@ -20,101 +23,259 @@ class SEManufCluster(CustomCluster):
2023

2124

2225
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
3126

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

3429
attributes.update(
3530
{
36-
ATT_ID_E001: ("57345", t.CharacterString)
31+
0xE001: ZCLAttributeDef(
32+
id=0xE001,
33+
name="57345",
34+
type=t.CharacterString,
35+
access="r",
36+
is_manufacturer_specific=True,
37+
)
3738
}, # attribute_name:"57345" # ex: "002.004.016 R
3839
{
39-
ATT_ID_E002: ("57346", t.CharacterString)
40+
0xE002: ZCLAttributeDef(
41+
id=0xE002,
42+
name="57346",
43+
type=t.CharacterString,
44+
is_manufacturer_specific=True,
45+
)
4046
}, # attribute_name:"57346" # ex: "001.000.000"
4147
{
42-
ATT_ID_E004: ("57348", t.CharacterString)
48+
0xE004: ZCLAttributeDef(
49+
id=0xE004,
50+
name="57348",
51+
type=t.CharacterString,
52+
access="r",
53+
is_manufacturer_specific=True,
54+
)
4355
}, # attribute_name:"57348" # ex: "213249FEFF5ECFD"
44-
{ATT_ID_E007: ("57351", t.enum16)}, # attribute_name:"57351"
4556
{
46-
ATT_ID_E008: ("57352", t.CharacterString)
57+
0xE007: ZCLAttributeDef(
58+
id=0xE007,
59+
name="57351",
60+
type=t.enum16,
61+
access="r",
62+
is_manufacturer_specific=True,
63+
)
64+
}, # attribute_name:"57351"
65+
{
66+
0xE008: ZCLAttributeDef(
67+
id=0xE008,
68+
name="57352",
69+
type=t.CharacterString,
70+
access="r",
71+
is_manufacturer_specific=True,
72+
)
4773
}, # attribute_name:"57352" # ex: "Wiser Light"
4874
{
49-
ATT_ID_E009: ("57353", t.CharacterString)
75+
0xE009: ZCLAttributeDef(
76+
id=0xE009,
77+
name="57353",
78+
type=t.CharacterString,
79+
access="r",
80+
is_manufacturer_specific=True,
81+
)
5082
}, # attribute_name:"57353" # ex: "NHPB/SHUTTER/1"
5183
{
52-
ATT_ID_E00A: ("57354", t.CharacterString)
84+
0xE00A: ZCLAttributeDef(
85+
id=0xE00A,
86+
name="57354",
87+
type=t.CharacterString,
88+
access="r",
89+
is_manufacturer_specific=True,
90+
)
5391
}, # attribute_name:"57354" # ex: "Wiser Home"
54-
{ATT_ID_E00B: ("57355", t.CharacterString)}, # attribute_name:"57355"
92+
{
93+
0xE00B: ZCLAttributeDef(
94+
id=0xE00B,
95+
name="57355",
96+
type=t.CharacterString,
97+
access="r",
98+
is_manufacturer_specific=True,
99+
)
100+
}, # attribute_name:"57355"
55101
)
56102

57103

58-
class SEManufSwitchCluster(SEManufCluster):
59-
name = "Schneider Electric Manufacturer Specicific"
104+
class SESpecificCluster(SEManufCluster):
60105
cluster_id = 0xFF17
61106

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-
70107
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"
108+
{
109+
0x0000: ZCLAttributeDef(
110+
id=0x0000,
111+
name="0",
112+
type=t.enum8,
113+
access="rw",
114+
is_manufacturer_specific=True,
115+
)
116+
}, # attribute_name:"0"
117+
{
118+
0x0001: ZCLAttributeDef(
119+
id=0x0001,
120+
name="1",
121+
type=t.enum8,
122+
access="rw",
123+
is_manufacturer_specific=True,
124+
)
125+
}, # attribute_name:"1"
126+
{
127+
0x0010: ZCLAttributeDef(
128+
id=0x0010,
129+
name="16",
130+
type=t.uint8_t,
131+
access="rw",
132+
is_manufacturer_specific=True,
133+
)
134+
}, # attribute_name:"16"
135+
{
136+
0x0011: ZCLAttributeDef(
137+
id=0x0011,
138+
name="17",
139+
type=t.uint16_t,
140+
access="rw",
141+
is_manufacturer_specific=True,
142+
)
143+
}, # attribute_name:"17"
144+
{
145+
0x0020: ZCLAttributeDef(
146+
id=0x0020,
147+
name="32",
148+
type=t.uint8_t,
149+
access="rw",
150+
is_manufacturer_specific=True,
151+
)
152+
}, # attribute_name:"32"
153+
{
154+
0x0021: ZCLAttributeDef(
155+
id=0x0021,
156+
name="33",
157+
type=t.uint16_t,
158+
access="rw",
159+
is_manufacturer_specific=True,
160+
)
161+
}, # attribute_name:"33"
162+
{
163+
0xFFFD: ZCLAttributeDef(
164+
id=0xFFFD,
165+
name="65533",
166+
type=t.uint16_t,
167+
access="r",
168+
is_manufacturer_specific=True,
169+
)
170+
}, # attribute_name:"65533"
78171
}
79172

80173

81174
class SEWindowCover(CustomCluster, WindowCovering):
82175
"""Manufacturer Specific Cluster of Device cover."""
83176

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
177+
# TODO: Reverse lift percentage
93178

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

96181
attributes.update(
97182
{
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"
183+
0xFFFD: ZCLAttributeDef(
184+
id=0xFFFD,
185+
name="lift_duration",
186+
type=t.uint16_t,
187+
access="rw",
188+
is_manufacturer_specific=True,
189+
)
190+
}, # attribute_name:"65533"
191+
{
192+
0xE000: ZCLAttributeDef(
193+
id=0xE000,
194+
name="57344",
195+
type=t.uint16_t,
196+
access="rw",
197+
is_manufacturer_specific=True,
198+
)
199+
}, # attribute_name:"57344"
200+
{
201+
0xE010: ZCLAttributeDef(
202+
id=0xE010,
203+
name="57360",
204+
type=t.bitmap8,
205+
access="r",
206+
is_manufacturer_specific=True,
207+
)
208+
}, # attribute_name:"57360"
209+
{
210+
0xE012: ZCLAttributeDef(
211+
id=0xE012,
212+
name="57362",
213+
type=t.uint16_t,
214+
access="rw",
215+
is_manufacturer_specific=True,
216+
)
217+
}, # attribute_name:"57362"
218+
{
219+
0xE013: ZCLAttributeDef(
220+
id=0xE013,
221+
name="57363",
222+
type=t.bitmap8,
223+
access="r",
224+
is_manufacturer_specific=True,
225+
)
226+
}, # attribute_name:"57363"
227+
{
228+
0xE014: ZCLAttributeDef(
229+
id=0xE014,
230+
name="57364",
231+
type=t.uint16_t,
232+
access="rw",
233+
is_manufacturer_specific=True,
234+
)
235+
}, # attribute_name:"57364"
236+
{
237+
0xE015: ZCLAttributeDef(
238+
id=0xE015,
239+
name="57365",
240+
type=t.uint16_t,
241+
access="rw",
242+
is_manufacturer_specific=True,
243+
)
244+
}, # attribute_name:"57365"
245+
{
246+
0xE016: ZCLAttributeDef(
247+
id=0xE016,
248+
name="57366",
249+
type=t.uint16_t,
250+
access="rw",
251+
is_manufacturer_specific=True,
252+
)
253+
}, # attribute_name:"57366"
254+
{
255+
0xE017: ZCLAttributeDef(
256+
id=0xE017,
257+
name="57367",
258+
type=t.uint8_t,
259+
access="rw",
260+
is_manufacturer_specific=True,
261+
)
262+
}, # attribute_name:"57367"
108263
)
109264

110265

111266
class SEDiagnostic(CustomCluster, Diagnostic):
112267

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

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

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)