4
4
from zigpy_cc import uart
5
5
from zigpy_cc .buffalo import Buffalo , BuffaloOptions
6
6
from zigpy_cc .definition import Definition
7
- from zigpy_cc .types import CommandType , ParameterType , Subsystem
7
+ from zigpy_cc .types import CommandType , ParameterType , Subsystem , AddressMode
8
8
9
9
BufferAndListTypes = [
10
10
ParameterType .BUFFER ,
@@ -30,15 +30,15 @@ def __init__(
30
30
command_type ,
31
31
subsystem ,
32
32
command : str ,
33
- commandId ,
33
+ command_id ,
34
34
payload ,
35
35
parameters ,
36
36
sequence = None ,
37
37
):
38
38
self .command_type = CommandType (command_type )
39
39
self .subsystem = Subsystem (subsystem )
40
40
self .command = command
41
- self .command_id = commandId
41
+ self .command_id = command_id
42
42
self .payload = payload
43
43
self .parameters = parameters
44
44
self .sequence = sequence
@@ -101,11 +101,11 @@ def from_cluster(
101
101
data ,
102
102
* ,
103
103
radius = 30 ,
104
- group = None
104
+ addr_mode = None
105
105
):
106
106
if profile == zha .PROFILE_ID :
107
107
subsystem = Subsystem .AF
108
- if group is None :
108
+ if addr_mode is None :
109
109
cmd = next (c for c in Definition [subsystem ] if c ["ID" ] == 1 )
110
110
else :
111
111
cmd = next (c for c in Definition [subsystem ] if c ["ID" ] == 2 )
@@ -131,12 +131,11 @@ def from_cluster(
131
131
}
132
132
elif name == "dataRequestExt" :
133
133
payload = {
134
- # 1: group
135
- "dstaddrmode" : 1 ,
136
- "dstaddr" : group ,
137
- "destendpoint" : 0xFF ,
134
+ "dstaddrmode" : addr_mode ,
135
+ "dstaddr" : nwk ,
136
+ "destendpoint" : dst_ep ,
138
137
"dstpanid" : 0 ,
139
- "srcendpoint" : src_ep or 1 ,
138
+ "srcendpoint" : src_ep ,
140
139
"clusterid" : cluster ,
141
140
"transid" : sequence ,
142
141
"options" : 0 ,
@@ -146,7 +145,9 @@ def from_cluster(
146
145
}
147
146
elif name == "mgmtPermitJoinReq" :
148
147
addrmode = (
149
- 0x0F if nwk == BroadcastAddress .ALL_ROUTERS_AND_COORDINATOR else 0x02
148
+ AddressMode .ADDR_BROADCAST
149
+ if nwk == BroadcastAddress .ALL_ROUTERS_AND_COORDINATOR
150
+ else AddressMode .ADDR_16BIT
150
151
)
151
152
payload = cls .read_parameters (
152
153
bytes ([addrmode ]) + nwk .to_bytes (2 , "little" ) + data [1 :], parameters
@@ -168,29 +169,24 @@ def read_parameters(cls, data: bytes, parameters):
168
169
buffalo = Buffalo (data )
169
170
res = {}
170
171
length = None
171
- startIndex = None
172
+ start_index = None
172
173
for p in parameters :
173
174
options = BuffaloOptions ()
174
175
name = p ["name" ]
175
- if (
176
- name .endswith ("addr" )
177
- or name .endswith ("address" )
178
- or name .endswith ("addrofinterest" )
179
- ):
180
- options .is_address = True
181
- type = p ["parameterType" ]
182
- if type in BufferAndListTypes :
176
+ param_type = p ["parameterType" ]
177
+ if param_type in BufferAndListTypes :
183
178
if isinstance (length , int ):
184
179
options .length = length
185
180
186
- if type == ParameterType .LIST_ASSOC_DEV :
187
- if isinstance (startIndex , int ):
188
- options .startIndex = startIndex
181
+ if param_type == ParameterType .LIST_ASSOC_DEV :
182
+ if isinstance (start_index , int ):
183
+ options .startIndex = start_index
184
+
185
+ res [name ] = buffalo .read_parameter (name , param_type , options )
189
186
190
- res [name ] = buffalo .read_parameter (type , options )
191
- # For LIST_ASSOC_DEV, we need to grab the startindex which is
187
+ # For LIST_ASSOC_DEV, we need to grab the start_index which is
192
188
# right before the length
193
- startIndex = length
189
+ start_index = length
194
190
# When reading a buffer, assume that the previous parsed parameter
195
191
# contains the length of the buffer
196
192
length = res [name ]
0 commit comments