zigbee-herdsman 4.5.0 → 5.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.release-please-manifest.json +1 -1
- package/CHANGELOG.md +18 -0
- package/dist/controller/helpers/zclFrameConverter.d.ts.map +1 -1
- package/dist/controller/helpers/zclFrameConverter.js +2 -14
- package/dist/controller/helpers/zclFrameConverter.js.map +1 -1
- package/dist/controller/model/device.js +3 -5
- package/dist/controller/model/device.js.map +1 -1
- package/dist/controller/model/endpoint.d.ts +1 -1
- package/dist/controller/model/endpoint.d.ts.map +1 -1
- package/dist/controller/model/endpoint.js +67 -43
- package/dist/controller/model/endpoint.js.map +1 -1
- package/dist/controller/model/group.d.ts.map +1 -1
- package/dist/controller/model/group.js +28 -17
- package/dist/controller/model/group.js.map +1 -1
- package/dist/zspec/zcl/buffaloZcl.d.ts.map +1 -1
- package/dist/zspec/zcl/buffaloZcl.js +5 -5
- package/dist/zspec/zcl/buffaloZcl.js.map +1 -1
- package/dist/zspec/zcl/definition/tstype.d.ts +1 -2
- package/dist/zspec/zcl/definition/tstype.d.ts.map +1 -1
- package/dist/zspec/zcl/utils.d.ts.map +1 -1
- package/dist/zspec/zcl/utils.js +8 -30
- package/dist/zspec/zcl/utils.js.map +1 -1
- package/dist/zspec/zcl/zclFrame.d.ts +1 -1
- package/dist/zspec/zcl/zclFrame.d.ts.map +1 -1
- package/dist/zspec/zcl/zclFrame.js +8 -6
- package/dist/zspec/zcl/zclFrame.js.map +1 -1
- package/package.json +2 -2
- package/src/controller/helpers/zclFrameConverter.ts +4 -12
- package/src/controller/model/device.ts +5 -5
- package/src/controller/model/endpoint.ts +86 -49
- package/src/controller/model/group.ts +33 -18
- package/src/zspec/zcl/buffaloZcl.ts +6 -4
- package/src/zspec/zcl/definition/tstype.ts +1 -2
- package/src/zspec/zcl/utils.ts +8 -35
- package/src/zspec/zcl/zclFrame.ts +10 -8
- package/test/controller.test.ts +352 -1360
- package/test/requests.bench.ts +5 -0
- package/test/zcl.test.ts +11 -15
- package/test/zspec/zcl/frame.test.ts +25 -25
- package/test/zspec/zcl/utils.test.ts +6 -14
|
@@ -548,13 +548,15 @@ export class BuffaloZcl extends Buffalo {
|
|
|
548
548
|
while (this.position - start < options.payload.payloadSize) {
|
|
549
549
|
const attributeID = this.readUInt16();
|
|
550
550
|
const type = this.readUInt8();
|
|
551
|
+
/* v8 ignore next */
|
|
552
|
+
let attribute: string | undefined | number = cluster.getAttribute(attributeID)?.name;
|
|
551
553
|
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
attribute = cluster.getAttribute(attributeID).name;
|
|
555
|
-
} catch {
|
|
554
|
+
// number type is only used when going into this if
|
|
555
|
+
if (!attribute) {
|
|
556
556
|
// this is spammy because of the many manufacturer-specific attributes not currently used
|
|
557
557
|
logger.debug(`Unknown attribute ${attributeID} in cluster ${cluster.name}`, NS);
|
|
558
|
+
|
|
559
|
+
attribute = attributeID;
|
|
558
560
|
}
|
|
559
561
|
|
|
560
562
|
frame.attributes[attribute] = this.read(type, options);
|
|
@@ -86,8 +86,7 @@ export interface Cluster {
|
|
|
86
86
|
commandsResponse: {
|
|
87
87
|
[s: string]: Command;
|
|
88
88
|
};
|
|
89
|
-
getAttribute: (key: number | string) => Attribute;
|
|
90
|
-
hasAttribute: (key: number | string) => boolean;
|
|
89
|
+
getAttribute: (key: number | string) => Attribute | undefined;
|
|
91
90
|
getCommand: (key: number | string) => Command;
|
|
92
91
|
getCommandResponse: (key: number | string) => Command;
|
|
93
92
|
}
|
package/src/zspec/zcl/utils.ts
CHANGED
|
@@ -187,7 +187,7 @@ function createCluster(name: string, cluster: ClusterDefinition, manufacturerCod
|
|
|
187
187
|
const commands: Record<string, Command> = cloneClusterEntriesWithName(cluster.commands);
|
|
188
188
|
const commandsResponse: Record<string, Command> = cloneClusterEntriesWithName(cluster.commandsResponse);
|
|
189
189
|
|
|
190
|
-
const
|
|
190
|
+
const getAttribute = (key: number | string): Attribute | undefined => {
|
|
191
191
|
if (typeof key === "number") {
|
|
192
192
|
let partialMatchAttr: Attribute | undefined;
|
|
193
193
|
|
|
@@ -208,29 +208,7 @@ function createCluster(name: string, cluster: ClusterDefinition, manufacturerCod
|
|
|
208
208
|
return partialMatchAttr;
|
|
209
209
|
}
|
|
210
210
|
|
|
211
|
-
|
|
212
|
-
const attr = attributes[attrKey];
|
|
213
|
-
|
|
214
|
-
if (attr.name === key) {
|
|
215
|
-
return attr;
|
|
216
|
-
}
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
return undefined;
|
|
220
|
-
};
|
|
221
|
-
|
|
222
|
-
const getAttribute = (key: number | string): Attribute => {
|
|
223
|
-
const result = getAttributeInternal(key);
|
|
224
|
-
if (!result) {
|
|
225
|
-
throw new Error(`Cluster '${name}' has no attribute '${key}'`);
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
-
return result;
|
|
229
|
-
};
|
|
230
|
-
|
|
231
|
-
const hasAttribute = (key: number | string): boolean => {
|
|
232
|
-
const result = getAttributeInternal(key);
|
|
233
|
-
return !!result;
|
|
211
|
+
return attributes[key];
|
|
234
212
|
};
|
|
235
213
|
|
|
236
214
|
const getCommand = (key: number | string): Command => {
|
|
@@ -243,12 +221,10 @@ function createCluster(name: string, cluster: ClusterDefinition, manufacturerCod
|
|
|
243
221
|
}
|
|
244
222
|
}
|
|
245
223
|
} else {
|
|
246
|
-
|
|
247
|
-
const cmd = commands[cmdKey];
|
|
224
|
+
const cmd = commands[key];
|
|
248
225
|
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
}
|
|
226
|
+
if (cmd) {
|
|
227
|
+
return cmd;
|
|
252
228
|
}
|
|
253
229
|
}
|
|
254
230
|
|
|
@@ -265,12 +241,10 @@ function createCluster(name: string, cluster: ClusterDefinition, manufacturerCod
|
|
|
265
241
|
}
|
|
266
242
|
}
|
|
267
243
|
} else {
|
|
268
|
-
|
|
269
|
-
const cmd = commandsResponse[cmdKey];
|
|
244
|
+
const cmd = commandsResponse[key];
|
|
270
245
|
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
}
|
|
246
|
+
if (cmd) {
|
|
247
|
+
return cmd;
|
|
274
248
|
}
|
|
275
249
|
}
|
|
276
250
|
|
|
@@ -285,7 +259,6 @@ function createCluster(name: string, cluster: ClusterDefinition, manufacturerCod
|
|
|
285
259
|
commands,
|
|
286
260
|
commandsResponse,
|
|
287
261
|
getAttribute,
|
|
288
|
-
hasAttribute,
|
|
289
262
|
getCommand,
|
|
290
263
|
getCommandResponse,
|
|
291
264
|
};
|
|
@@ -45,19 +45,21 @@ export class ZclFrame {
|
|
|
45
45
|
disableDefaultResponse: boolean,
|
|
46
46
|
manufacturerCode: number | undefined,
|
|
47
47
|
transactionSequenceNumber: number,
|
|
48
|
-
commandKey: number | string,
|
|
49
|
-
clusterKey: number | string,
|
|
48
|
+
commandKey: number | string | Command,
|
|
49
|
+
clusterKey: number | string | Cluster,
|
|
50
50
|
payload: ZclPayload,
|
|
51
51
|
customClusters: CustomClusters,
|
|
52
52
|
reservedBits = 0,
|
|
53
53
|
): ZclFrame {
|
|
54
|
-
const cluster = Utils.getCluster(clusterKey, manufacturerCode, customClusters);
|
|
54
|
+
const cluster = typeof clusterKey === "object" ? clusterKey : Utils.getCluster(clusterKey, manufacturerCode, customClusters);
|
|
55
55
|
const command: Command =
|
|
56
|
-
|
|
57
|
-
?
|
|
58
|
-
:
|
|
59
|
-
?
|
|
60
|
-
:
|
|
56
|
+
typeof commandKey === "object"
|
|
57
|
+
? commandKey
|
|
58
|
+
: frameType === FrameType.GLOBAL
|
|
59
|
+
? Utils.getGlobalCommand(commandKey)
|
|
60
|
+
: direction === Direction.CLIENT_TO_SERVER
|
|
61
|
+
? cluster.getCommand(commandKey)
|
|
62
|
+
: cluster.getCommandResponse(commandKey);
|
|
61
63
|
|
|
62
64
|
const header = new ZclHeader(
|
|
63
65
|
{reservedBits, frameType, direction, disableDefaultResponse, manufacturerSpecific: manufacturerCode != null},
|