zigbee-herdsman 6.0.2 → 6.0.4
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/CHANGELOG.md +14 -0
- package/package.json +9 -3
- package/.github/ISSUE_TEMPLATE/config.yml +0 -5
- package/.github/dependabot.yml +0 -22
- package/.github/workflows/ci.yml +0 -69
- package/.github/workflows/release-please.yml +0 -18
- package/.github/workflows/stale.yml +0 -20
- package/.github/workflows/typedoc.yaml +0 -47
- package/.release-please-manifest.json +0 -3
- package/.vscode/extensions.json +0 -3
- package/.vscode/settings.json +0 -11
- package/biome.json +0 -98
- package/examples/join-and-log.js +0 -24
- package/release-please-config.json +0 -9
- package/src/adapter/adapter.ts +0 -189
- package/src/adapter/adapterDiscovery.ts +0 -666
- package/src/adapter/const.ts +0 -12
- package/src/adapter/deconz/adapter/deconzAdapter.ts +0 -877
- package/src/adapter/deconz/driver/constants.ts +0 -246
- package/src/adapter/deconz/driver/driver.ts +0 -1540
- package/src/adapter/deconz/driver/frame.ts +0 -11
- package/src/adapter/deconz/driver/frameParser.ts +0 -753
- package/src/adapter/deconz/driver/parser.ts +0 -45
- package/src/adapter/deconz/driver/writer.ts +0 -22
- package/src/adapter/deconz/types.d.ts +0 -13
- package/src/adapter/ember/adapter/emberAdapter.ts +0 -2265
- package/src/adapter/ember/adapter/endpoints.ts +0 -86
- package/src/adapter/ember/adapter/oneWaitress.ts +0 -324
- package/src/adapter/ember/adapter/tokensManager.ts +0 -782
- package/src/adapter/ember/consts.ts +0 -178
- package/src/adapter/ember/enums.ts +0 -1746
- package/src/adapter/ember/ezsp/buffalo.ts +0 -1392
- package/src/adapter/ember/ezsp/consts.ts +0 -148
- package/src/adapter/ember/ezsp/enums.ts +0 -1114
- package/src/adapter/ember/ezsp/ezsp.ts +0 -9061
- package/src/adapter/ember/ezspError.ts +0 -10
- package/src/adapter/ember/types.ts +0 -866
- package/src/adapter/ember/uart/ash.ts +0 -1960
- package/src/adapter/ember/uart/consts.ts +0 -109
- package/src/adapter/ember/uart/enums.ts +0 -192
- package/src/adapter/ember/uart/parser.ts +0 -48
- package/src/adapter/ember/uart/queues.ts +0 -247
- package/src/adapter/ember/uart/writer.ts +0 -53
- package/src/adapter/ember/utils/initters.ts +0 -58
- package/src/adapter/ember/utils/math.ts +0 -73
- package/src/adapter/events.ts +0 -21
- package/src/adapter/ezsp/adapter/backup.ts +0 -109
- package/src/adapter/ezsp/adapter/ezspAdapter.ts +0 -614
- package/src/adapter/ezsp/driver/commands.ts +0 -2497
- package/src/adapter/ezsp/driver/consts.ts +0 -11
- package/src/adapter/ezsp/driver/driver.ts +0 -1002
- package/src/adapter/ezsp/driver/ezsp.ts +0 -802
- package/src/adapter/ezsp/driver/frame.ts +0 -101
- package/src/adapter/ezsp/driver/index.ts +0 -4
- package/src/adapter/ezsp/driver/multicast.ts +0 -78
- package/src/adapter/ezsp/driver/parser.ts +0 -81
- package/src/adapter/ezsp/driver/types/basic.ts +0 -201
- package/src/adapter/ezsp/driver/types/index.ts +0 -239
- package/src/adapter/ezsp/driver/types/named.ts +0 -2330
- package/src/adapter/ezsp/driver/types/struct.ts +0 -844
- package/src/adapter/ezsp/driver/uart.ts +0 -460
- package/src/adapter/ezsp/driver/utils/crc16ccitt.ts +0 -44
- package/src/adapter/ezsp/driver/utils/index.ts +0 -32
- package/src/adapter/ezsp/driver/writer.ts +0 -64
- package/src/adapter/index.ts +0 -3
- package/src/adapter/serialPort.ts +0 -58
- package/src/adapter/socketPortUtils.ts +0 -16
- package/src/adapter/tstype.ts +0 -78
- package/src/adapter/z-stack/adapter/adapter-backup.ts +0 -519
- package/src/adapter/z-stack/adapter/adapter-nv-memory.ts +0 -457
- package/src/adapter/z-stack/adapter/endpoints.ts +0 -57
- package/src/adapter/z-stack/adapter/manager.ts +0 -543
- package/src/adapter/z-stack/adapter/tstype.ts +0 -6
- package/src/adapter/z-stack/adapter/zStackAdapter.ts +0 -1190
- package/src/adapter/z-stack/constants/af.ts +0 -27
- package/src/adapter/z-stack/constants/common.ts +0 -285
- package/src/adapter/z-stack/constants/dbg.ts +0 -23
- package/src/adapter/z-stack/constants/index.ts +0 -11
- package/src/adapter/z-stack/constants/mac.ts +0 -128
- package/src/adapter/z-stack/constants/sapi.ts +0 -25
- package/src/adapter/z-stack/constants/sys.ts +0 -72
- package/src/adapter/z-stack/constants/util.ts +0 -82
- package/src/adapter/z-stack/constants/utils.ts +0 -14
- package/src/adapter/z-stack/constants/zdo.ts +0 -103
- package/src/adapter/z-stack/models/startup-options.ts +0 -13
- package/src/adapter/z-stack/structs/entries/address-manager-entry.ts +0 -44
- package/src/adapter/z-stack/structs/entries/address-manager-table.ts +0 -19
- package/src/adapter/z-stack/structs/entries/aps-link-key-data-entry.ts +0 -12
- package/src/adapter/z-stack/structs/entries/aps-link-key-data-table.ts +0 -21
- package/src/adapter/z-stack/structs/entries/aps-tc-link-key-entry.ts +0 -19
- package/src/adapter/z-stack/structs/entries/aps-tc-link-key-table.ts +0 -21
- package/src/adapter/z-stack/structs/entries/channel-list.ts +0 -8
- package/src/adapter/z-stack/structs/entries/has-configured.ts +0 -16
- package/src/adapter/z-stack/structs/entries/index.ts +0 -16
- package/src/adapter/z-stack/structs/entries/nib.ts +0 -66
- package/src/adapter/z-stack/structs/entries/nwk-key-descriptor.ts +0 -15
- package/src/adapter/z-stack/structs/entries/nwk-key.ts +0 -13
- package/src/adapter/z-stack/structs/entries/nwk-pan-id.ts +0 -8
- package/src/adapter/z-stack/structs/entries/nwk-sec-material-descriptor-entry.ts +0 -20
- package/src/adapter/z-stack/structs/entries/nwk-sec-material-descriptor-table.ts +0 -19
- package/src/adapter/z-stack/structs/entries/security-manager-entry.ts +0 -33
- package/src/adapter/z-stack/structs/entries/security-manager-table.ts +0 -22
- package/src/adapter/z-stack/structs/index.ts +0 -4
- package/src/adapter/z-stack/structs/serializable-memory-object.ts +0 -14
- package/src/adapter/z-stack/structs/struct.ts +0 -367
- package/src/adapter/z-stack/structs/table.ts +0 -198
- package/src/adapter/z-stack/unpi/constants.ts +0 -33
- package/src/adapter/z-stack/unpi/frame.ts +0 -62
- package/src/adapter/z-stack/unpi/index.ts +0 -4
- package/src/adapter/z-stack/unpi/parser.ts +0 -56
- package/src/adapter/z-stack/unpi/writer.ts +0 -21
- package/src/adapter/z-stack/utils/channel-list.ts +0 -40
- package/src/adapter/z-stack/utils/index.ts +0 -2
- package/src/adapter/z-stack/utils/network-options.ts +0 -26
- package/src/adapter/z-stack/znp/buffaloZnp.ts +0 -175
- package/src/adapter/z-stack/znp/definition.ts +0 -2713
- package/src/adapter/z-stack/znp/index.ts +0 -2
- package/src/adapter/z-stack/znp/parameterType.ts +0 -22
- package/src/adapter/z-stack/znp/tstype.ts +0 -44
- package/src/adapter/z-stack/znp/utils.ts +0 -10
- package/src/adapter/z-stack/znp/znp.ts +0 -342
- package/src/adapter/z-stack/znp/zpiObject.ts +0 -148
- package/src/adapter/zboss/adapter/zbossAdapter.ts +0 -526
- package/src/adapter/zboss/commands.ts +0 -1184
- package/src/adapter/zboss/consts.ts +0 -9
- package/src/adapter/zboss/driver.ts +0 -422
- package/src/adapter/zboss/enums.ts +0 -360
- package/src/adapter/zboss/frame.ts +0 -227
- package/src/adapter/zboss/reader.ts +0 -65
- package/src/adapter/zboss/types.ts +0 -0
- package/src/adapter/zboss/uart.ts +0 -428
- package/src/adapter/zboss/utils.ts +0 -58
- package/src/adapter/zboss/writer.ts +0 -49
- package/src/adapter/zigate/adapter/patchZdoBuffaloBE.ts +0 -27
- package/src/adapter/zigate/adapter/zigateAdapter.ts +0 -618
- package/src/adapter/zigate/driver/LICENSE +0 -17
- package/src/adapter/zigate/driver/buffaloZiGate.ts +0 -212
- package/src/adapter/zigate/driver/commandType.ts +0 -418
- package/src/adapter/zigate/driver/constants.ts +0 -150
- package/src/adapter/zigate/driver/frame.ts +0 -197
- package/src/adapter/zigate/driver/messageType.ts +0 -287
- package/src/adapter/zigate/driver/parameterType.ts +0 -32
- package/src/adapter/zigate/driver/ziGateObject.ts +0 -146
- package/src/adapter/zigate/driver/zigate.ts +0 -423
- package/src/adapter/zoh/adapter/utils.ts +0 -27
- package/src/adapter/zoh/adapter/zohAdapter.ts +0 -838
- package/src/buffalo/buffalo.ts +0 -342
- package/src/buffalo/index.ts +0 -1
- package/src/controller/controller.ts +0 -1022
- package/src/controller/database.ts +0 -124
- package/src/controller/events.ts +0 -52
- package/src/controller/greenPower.ts +0 -603
- package/src/controller/helpers/index.ts +0 -1
- package/src/controller/helpers/installCodes.ts +0 -107
- package/src/controller/helpers/request.ts +0 -96
- package/src/controller/helpers/requestQueue.ts +0 -125
- package/src/controller/helpers/zclFrameConverter.ts +0 -47
- package/src/controller/helpers/zclTransactionSequenceNumber.ts +0 -19
- package/src/controller/index.ts +0 -6
- package/src/controller/model/device.ts +0 -1249
- package/src/controller/model/endpoint.ts +0 -1105
- package/src/controller/model/entity.ts +0 -23
- package/src/controller/model/group.ts +0 -424
- package/src/controller/model/index.ts +0 -5
- package/src/controller/model/zigbeeEntity.ts +0 -30
- package/src/controller/touchlink.ts +0 -189
- package/src/controller/tstype.ts +0 -274
- package/src/index.ts +0 -12
- package/src/models/backup-storage-legacy.ts +0 -48
- package/src/models/backup-storage-unified.ts +0 -47
- package/src/models/backup.ts +0 -37
- package/src/models/index.ts +0 -5
- package/src/models/network-options.ts +0 -11
- package/src/utils/backup.ts +0 -152
- package/src/utils/index.ts +0 -5
- package/src/utils/logger.ts +0 -20
- package/src/utils/patchBigIntSerialization.ts +0 -8
- package/src/utils/queue.ts +0 -76
- package/src/utils/types.d.ts +0 -3
- package/src/utils/utils.ts +0 -19
- package/src/utils/wait.ts +0 -5
- package/src/utils/waitress.ts +0 -96
- package/src/zspec/consts.ts +0 -84
- package/src/zspec/enums.ts +0 -22
- package/src/zspec/index.ts +0 -3
- package/src/zspec/tstypes.ts +0 -18
- package/src/zspec/utils.ts +0 -247
- package/src/zspec/zcl/buffaloZcl.ts +0 -1220
- package/src/zspec/zcl/definition/cluster.ts +0 -5915
- package/src/zspec/zcl/definition/clusters-typegen.ts +0 -588
- package/src/zspec/zcl/definition/clusters-types.ts +0 -7331
- package/src/zspec/zcl/definition/consts.ts +0 -24
- package/src/zspec/zcl/definition/enums.ts +0 -203
- package/src/zspec/zcl/definition/foundation.ts +0 -329
- package/src/zspec/zcl/definition/manufacturerCode.ts +0 -729
- package/src/zspec/zcl/definition/status.ts +0 -69
- package/src/zspec/zcl/definition/tstype.ts +0 -377
- package/src/zspec/zcl/index.ts +0 -11
- package/src/zspec/zcl/utils.ts +0 -321
- package/src/zspec/zcl/zclFrame.ts +0 -356
- package/src/zspec/zcl/zclHeader.ts +0 -102
- package/src/zspec/zcl/zclStatusError.ts +0 -10
- package/src/zspec/zdo/buffaloZdo.ts +0 -2336
- package/src/zspec/zdo/definition/clusters.ts +0 -722
- package/src/zspec/zdo/definition/consts.ts +0 -16
- package/src/zspec/zdo/definition/enums.ts +0 -99
- package/src/zspec/zdo/definition/status.ts +0 -105
- package/src/zspec/zdo/definition/tstypes.ts +0 -1062
- package/src/zspec/zdo/index.ts +0 -7
- package/src/zspec/zdo/utils.ts +0 -76
- package/src/zspec/zdo/zdoStatusError.ts +0 -10
- package/test/adapter/adapter.test.ts +0 -1062
- package/test/adapter/ember/ash.test.ts +0 -337
- package/test/adapter/ember/consts.ts +0 -131
- package/test/adapter/ember/emberAdapter.test.ts +0 -3449
- package/test/adapter/ember/ezsp.test.ts +0 -385
- package/test/adapter/ember/ezspBuffalo.test.ts +0 -93
- package/test/adapter/ember/ezspError.test.ts +0 -12
- package/test/adapter/ember/math.test.ts +0 -206
- package/test/adapter/ezsp/frame.test.ts +0 -30
- package/test/adapter/ezsp/uart.test.ts +0 -181
- package/test/adapter/z-stack/adapter.test.ts +0 -3984
- package/test/adapter/z-stack/constants.test.ts +0 -33
- package/test/adapter/z-stack/structs.test.ts +0 -115
- package/test/adapter/z-stack/unpi.test.ts +0 -213
- package/test/adapter/z-stack/znp.test.ts +0 -1284
- package/test/adapter/zboss/fixZdoResponse.test.ts +0 -179
- package/test/adapter/zigate/patchZdoBuffaloBE.test.ts +0 -81
- package/test/adapter/zigate/zdo.test.ts +0 -187
- package/test/adapter/zoh/utils.test.ts +0 -36
- package/test/adapter/zoh/zohAdapter.test.ts +0 -1307
- package/test/benchOptions.ts +0 -14
- package/test/buffalo.test.ts +0 -431
- package/test/controller.bench.ts +0 -214
- package/test/controller.test.ts +0 -8702
- package/test/greenpower.test.ts +0 -1408
- package/test/mockAdapters.ts +0 -65
- package/test/mockDevices.ts +0 -598
- package/test/requests.bench.ts +0 -229
- package/test/testUtils.ts +0 -20
- package/test/tsconfig.json +0 -9
- package/test/utils/math.ts +0 -19
- package/test/utils.test.ts +0 -279
- package/test/vitest.config.mts +0 -26
- package/test/zcl.test.ts +0 -2831
- package/test/zspec/utils.test.ts +0 -68
- package/test/zspec/zcl/buffalo.test.ts +0 -1374
- package/test/zspec/zcl/frame.test.ts +0 -960
- package/test/zspec/zcl/utils.test.ts +0 -273
- package/test/zspec/zdo/buffalo.test.ts +0 -1850
- package/test/zspec/zdo/utils.test.ts +0 -241
- package/tsconfig.json +0 -24
|
@@ -1,273 +0,0 @@
|
|
|
1
|
-
import {describe, expect, it} from "vitest";
|
|
2
|
-
import * as Zcl from "../../../src/zspec/zcl";
|
|
3
|
-
import type {Command, CustomClusters} from "../../../src/zspec/zcl/definition/tstype";
|
|
4
|
-
|
|
5
|
-
const CUSTOM_CLUSTERS: CustomClusters = {
|
|
6
|
-
genBasic: {ID: Zcl.Clusters.genBasic.ID, commands: {}, commandsResponse: {}, attributes: {myCustomAttr: {ID: 65533, type: Zcl.DataType.UINT8}}},
|
|
7
|
-
myCustomCluster: {ID: 65534, commands: {}, commandsResponse: {}, attributes: {myCustomAttr: {ID: 65533, type: Zcl.DataType.UINT8}}},
|
|
8
|
-
myCustomClusterManuf: {
|
|
9
|
-
ID: 65533,
|
|
10
|
-
manufacturerCode: 65534,
|
|
11
|
-
commands: {},
|
|
12
|
-
commandsResponse: {},
|
|
13
|
-
attributes: {myCustomAttr: {ID: 65533, type: Zcl.DataType.UINT8}},
|
|
14
|
-
},
|
|
15
|
-
manuSpecificProfalux1NoManuf: {
|
|
16
|
-
ID: Zcl.Clusters.manuSpecificProfalux1.ID,
|
|
17
|
-
commands: {},
|
|
18
|
-
commandsResponse: {},
|
|
19
|
-
attributes: {myCustomAttr: {ID: 65533, type: Zcl.DataType.UINT8}},
|
|
20
|
-
},
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
describe("ZCL Utils", () => {
|
|
24
|
-
it("Creates status error", () => {
|
|
25
|
-
const zclError = new Zcl.StatusError(Zcl.Status.ABORT);
|
|
26
|
-
|
|
27
|
-
expect(zclError).toBeInstanceOf(Zcl.StatusError);
|
|
28
|
-
expect(zclError.code).toStrictEqual(Zcl.Status.ABORT);
|
|
29
|
-
expect(zclError.message).toStrictEqual(`Status '${Zcl.Status[Zcl.Status.ABORT]}'`);
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
it("Gets data type class", () => {
|
|
33
|
-
expect(Zcl.Utils.getDataTypeClass(Zcl.DataType.UINT16)).toStrictEqual(Zcl.DataTypeClass.ANALOG);
|
|
34
|
-
expect(Zcl.Utils.getDataTypeClass(Zcl.DataType.DATA16)).toStrictEqual(Zcl.DataTypeClass.DISCRETE);
|
|
35
|
-
expect(() => {
|
|
36
|
-
Zcl.Utils.getDataTypeClass(Zcl.DataType.NO_DATA);
|
|
37
|
-
}).toThrow();
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
it.each([
|
|
41
|
-
[
|
|
42
|
-
"by ID",
|
|
43
|
-
{key: Zcl.Clusters.genBasic.ID, manufacturerCode: undefined, customClusters: {}},
|
|
44
|
-
{cluster: Zcl.Clusters.genBasic, name: "genBasic"},
|
|
45
|
-
],
|
|
46
|
-
["by name", {key: "genAlarms", manufacturerCode: undefined, customClusters: {}}, {cluster: Zcl.Clusters.genAlarms, name: "genAlarms"}],
|
|
47
|
-
[
|
|
48
|
-
"by ID with no manufacturer code",
|
|
49
|
-
{key: Zcl.Clusters.genAlarms.ID, manufacturerCode: 123, customClusters: {}},
|
|
50
|
-
{cluster: Zcl.Clusters.genAlarms, name: "genAlarms"},
|
|
51
|
-
],
|
|
52
|
-
[
|
|
53
|
-
"by ID with non-matching manufacturer code",
|
|
54
|
-
{key: Zcl.Clusters.manuSpecificSinope.ID, manufacturerCode: 123, customClusters: {}},
|
|
55
|
-
{cluster: Zcl.Clusters.manuSpecificSinope, name: "manuSpecificSinope"},
|
|
56
|
-
],
|
|
57
|
-
[
|
|
58
|
-
"by ID with matching manufacturer code",
|
|
59
|
-
{key: Zcl.Clusters.manuSpecificSinope.ID, manufacturerCode: Zcl.Clusters.manuSpecificSinope.manufacturerCode!, customClusters: {}},
|
|
60
|
-
{cluster: Zcl.Clusters.manuSpecificSinope, name: "manuSpecificSinope"},
|
|
61
|
-
],
|
|
62
|
-
[
|
|
63
|
-
"custom by ID",
|
|
64
|
-
{key: CUSTOM_CLUSTERS.myCustomCluster.ID, manufacturerCode: undefined, customClusters: CUSTOM_CLUSTERS},
|
|
65
|
-
{cluster: CUSTOM_CLUSTERS.myCustomCluster, name: "myCustomCluster"},
|
|
66
|
-
],
|
|
67
|
-
[
|
|
68
|
-
"custom by name",
|
|
69
|
-
{key: "myCustomCluster", manufacturerCode: undefined, customClusters: CUSTOM_CLUSTERS},
|
|
70
|
-
{cluster: CUSTOM_CLUSTERS.myCustomCluster, name: "myCustomCluster"},
|
|
71
|
-
],
|
|
72
|
-
[
|
|
73
|
-
"custom by ID with no manufacturer code",
|
|
74
|
-
{key: CUSTOM_CLUSTERS.myCustomCluster.ID, manufacturerCode: 123, customClusters: CUSTOM_CLUSTERS},
|
|
75
|
-
{cluster: CUSTOM_CLUSTERS.myCustomCluster, name: "myCustomCluster"},
|
|
76
|
-
],
|
|
77
|
-
[
|
|
78
|
-
"custom by ID with non-matching manufacturer code",
|
|
79
|
-
{key: CUSTOM_CLUSTERS.myCustomClusterManuf.ID, manufacturerCode: 123, customClusters: CUSTOM_CLUSTERS},
|
|
80
|
-
{cluster: CUSTOM_CLUSTERS.myCustomClusterManuf, name: "myCustomClusterManuf"},
|
|
81
|
-
],
|
|
82
|
-
[
|
|
83
|
-
"custom by ID with matching manufacturer code",
|
|
84
|
-
{
|
|
85
|
-
key: CUSTOM_CLUSTERS.myCustomClusterManuf.ID,
|
|
86
|
-
manufacturerCode: CUSTOM_CLUSTERS.myCustomClusterManuf.manufacturerCode!,
|
|
87
|
-
customClusters: CUSTOM_CLUSTERS,
|
|
88
|
-
},
|
|
89
|
-
{cluster: CUSTOM_CLUSTERS.myCustomClusterManuf, name: "myCustomClusterManuf"},
|
|
90
|
-
],
|
|
91
|
-
[
|
|
92
|
-
"custom by ID overriding same Zcl ID entirely",
|
|
93
|
-
{key: CUSTOM_CLUSTERS.genBasic.ID, manufacturerCode: undefined, customClusters: CUSTOM_CLUSTERS},
|
|
94
|
-
{cluster: CUSTOM_CLUSTERS.genBasic, name: "genBasic"},
|
|
95
|
-
],
|
|
96
|
-
[
|
|
97
|
-
"by ID ignoring same custom ID if Zcl is better match with manufacturer code",
|
|
98
|
-
{
|
|
99
|
-
key: CUSTOM_CLUSTERS.manuSpecificProfalux1NoManuf.ID,
|
|
100
|
-
manufacturerCode: Zcl.ManufacturerCode.PROFALUX,
|
|
101
|
-
customClusters: CUSTOM_CLUSTERS,
|
|
102
|
-
},
|
|
103
|
-
{cluster: Zcl.Clusters.manuSpecificProfalux1, name: "manuSpecificProfalux1"},
|
|
104
|
-
],
|
|
105
|
-
])("Gets cluster %s", (_name, payload, expected) => {
|
|
106
|
-
const cluster = Zcl.Utils.getCluster(payload.key, payload.manufacturerCode, payload.customClusters);
|
|
107
|
-
|
|
108
|
-
expect(cluster.ID).toStrictEqual(expected.cluster.ID);
|
|
109
|
-
expect(cluster.name).toStrictEqual(expected.name);
|
|
110
|
-
|
|
111
|
-
for (const k in expected.cluster.attributes) {
|
|
112
|
-
expect(cluster.attributes[k]).toBeDefined();
|
|
113
|
-
expect(cluster.attributes[k].name).toStrictEqual(k);
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
expect(cluster.manufacturerCode).toStrictEqual(expected.cluster.manufacturerCode);
|
|
117
|
-
expect(cluster.getAttribute).toBeInstanceOf(Function);
|
|
118
|
-
expect(cluster.getCommand).toBeInstanceOf(Function);
|
|
119
|
-
expect(cluster.getCommandResponse).toBeInstanceOf(Function);
|
|
120
|
-
});
|
|
121
|
-
|
|
122
|
-
it("Creates empty cluster when getting by invalid ID", () => {
|
|
123
|
-
const cluster = Zcl.Utils.getCluster(99999, undefined, {});
|
|
124
|
-
expect(cluster.ID).toStrictEqual(99999);
|
|
125
|
-
expect(cluster.name).toStrictEqual("99999");
|
|
126
|
-
expect(cluster.manufacturerCode).toStrictEqual(undefined);
|
|
127
|
-
expect(cluster.attributes).toStrictEqual({});
|
|
128
|
-
expect(cluster.commands).toStrictEqual({});
|
|
129
|
-
expect(cluster.commandsResponse).toStrictEqual({});
|
|
130
|
-
expect(cluster.getAttribute).toBeInstanceOf(Function);
|
|
131
|
-
expect(cluster.getCommand).toBeInstanceOf(Function);
|
|
132
|
-
expect(cluster.getCommandResponse).toBeInstanceOf(Function);
|
|
133
|
-
});
|
|
134
|
-
|
|
135
|
-
it("Throws when getting invalid cluster name", () => {
|
|
136
|
-
expect(() => {
|
|
137
|
-
Zcl.Utils.getCluster("invalid", undefined, {});
|
|
138
|
-
}).toThrow();
|
|
139
|
-
});
|
|
140
|
-
|
|
141
|
-
it.each([
|
|
142
|
-
[
|
|
143
|
-
"by ID",
|
|
144
|
-
{key: Zcl.Clusters.genBasic.attributes.zclVersion.ID, manufacturerCode: undefined, customClusters: {}},
|
|
145
|
-
{cluster: Zcl.Clusters.genBasic, name: "zclVersion"},
|
|
146
|
-
],
|
|
147
|
-
["by name", {key: "alarmCount", manufacturerCode: undefined, customClusters: {}}, {cluster: Zcl.Clusters.genAlarms, name: "alarmCount"}],
|
|
148
|
-
[
|
|
149
|
-
"by ID with no manufacturer code",
|
|
150
|
-
{key: Zcl.Clusters.genAlarms.attributes.alarmCount.ID, manufacturerCode: 123, customClusters: {}},
|
|
151
|
-
{cluster: Zcl.Clusters.genAlarms, name: "alarmCount"},
|
|
152
|
-
],
|
|
153
|
-
[
|
|
154
|
-
"by ID with matching manufacturer code",
|
|
155
|
-
{
|
|
156
|
-
key: Zcl.Clusters.haDiagnostic.attributes.danfossSystemStatusCode.ID,
|
|
157
|
-
manufacturerCode: Zcl.ManufacturerCode.DANFOSS_A_S,
|
|
158
|
-
customClusters: {},
|
|
159
|
-
},
|
|
160
|
-
{cluster: Zcl.Clusters.haDiagnostic, name: "danfossSystemStatusCode"},
|
|
161
|
-
],
|
|
162
|
-
[
|
|
163
|
-
"custom by ID",
|
|
164
|
-
{key: CUSTOM_CLUSTERS.genBasic.attributes.myCustomAttr.ID, manufacturerCode: undefined, customClusters: CUSTOM_CLUSTERS},
|
|
165
|
-
{cluster: Zcl.Clusters.genBasic, name: "myCustomAttr"},
|
|
166
|
-
],
|
|
167
|
-
[
|
|
168
|
-
"custom by name",
|
|
169
|
-
{key: "myCustomAttr", manufacturerCode: undefined, customClusters: CUSTOM_CLUSTERS},
|
|
170
|
-
{cluster: Zcl.Clusters.genBasic, name: "myCustomAttr"},
|
|
171
|
-
],
|
|
172
|
-
])("Gets and checks cluster attribute %s", (_name, payload, expected) => {
|
|
173
|
-
const cluster = Zcl.Utils.getCluster(expected.cluster.ID, payload.manufacturerCode, payload.customClusters);
|
|
174
|
-
const attribute = cluster.getAttribute(payload.key);
|
|
175
|
-
expect(attribute).not.toBeUndefined();
|
|
176
|
-
expect(attribute).toStrictEqual(cluster.attributes[expected.name]);
|
|
177
|
-
});
|
|
178
|
-
|
|
179
|
-
it("Returns undefined when getting invalid attribute", () => {
|
|
180
|
-
const cluster = Zcl.Utils.getCluster(Zcl.Clusters.genAlarms.ID, undefined, {});
|
|
181
|
-
expect(cluster.getAttribute("abcd")).toBeUndefined();
|
|
182
|
-
expect(cluster.getAttribute(99999)).toBeUndefined();
|
|
183
|
-
});
|
|
184
|
-
|
|
185
|
-
it("Returns undefined when getting attribute with invalid manufacturer code", () => {
|
|
186
|
-
const cluster = Zcl.Utils.getCluster(Zcl.Clusters.haDiagnostic.ID, 123, {});
|
|
187
|
-
expect(cluster.getAttribute(Zcl.Clusters.haDiagnostic.attributes.danfossSystemStatusCode.ID)).toBeUndefined();
|
|
188
|
-
});
|
|
189
|
-
|
|
190
|
-
it.each([
|
|
191
|
-
["by ID", {key: Zcl.Clusters.genBasic.commands.resetFactDefault.ID}, {cluster: Zcl.Clusters.genBasic, name: "resetFactDefault"}],
|
|
192
|
-
["by name", {key: "resetAll"}, {cluster: Zcl.Clusters.genAlarms, name: "resetAll"}],
|
|
193
|
-
])("Gets cluster command %s", (_name, payload, expected) => {
|
|
194
|
-
const cluster = Zcl.Utils.getCluster(expected.cluster.ID, undefined, {});
|
|
195
|
-
const command = cluster.getCommand(payload.key);
|
|
196
|
-
expect(command).toStrictEqual(cluster.commands[expected.name]);
|
|
197
|
-
});
|
|
198
|
-
|
|
199
|
-
it("Throws when getting invalid command", () => {
|
|
200
|
-
const cluster = Zcl.Utils.getCluster(Zcl.Clusters.genAlarms.ID, undefined, {});
|
|
201
|
-
expect(() => {
|
|
202
|
-
cluster.getCommand("abcd");
|
|
203
|
-
}).toThrow();
|
|
204
|
-
expect(() => {
|
|
205
|
-
cluster.getCommand(99999);
|
|
206
|
-
}).toThrow();
|
|
207
|
-
});
|
|
208
|
-
|
|
209
|
-
it.each([
|
|
210
|
-
[
|
|
211
|
-
"by ID",
|
|
212
|
-
{key: Zcl.Clusters.genIdentify.commandsResponse.identifyQueryRsp.ID},
|
|
213
|
-
{cluster: Zcl.Clusters.genIdentify, name: "identifyQueryRsp"},
|
|
214
|
-
],
|
|
215
|
-
["by name", {key: "getEventLog"}, {cluster: Zcl.Clusters.genAlarms, name: "getEventLog"}],
|
|
216
|
-
])("Gets cluster command response %s", (_name, payload, expected) => {
|
|
217
|
-
const cluster = Zcl.Utils.getCluster(expected.cluster.ID, undefined, {});
|
|
218
|
-
const commandResponse = cluster.getCommandResponse(payload.key);
|
|
219
|
-
expect(commandResponse).toStrictEqual(cluster.commandsResponse[expected.name]);
|
|
220
|
-
});
|
|
221
|
-
|
|
222
|
-
it("Throws when getting invalid command response", () => {
|
|
223
|
-
const cluster = Zcl.Utils.getCluster(Zcl.Clusters.genAlarms.ID, undefined, {});
|
|
224
|
-
expect(() => {
|
|
225
|
-
cluster.getCommandResponse("abcd");
|
|
226
|
-
}).toThrow();
|
|
227
|
-
expect(() => {
|
|
228
|
-
cluster.getCommandResponse(99999);
|
|
229
|
-
}).toThrow();
|
|
230
|
-
});
|
|
231
|
-
|
|
232
|
-
it.each([
|
|
233
|
-
["by ID", {key: Zcl.Foundation.writeUndiv.ID}, {cluster: Zcl.Foundation.writeUndiv, name: "writeUndiv"}],
|
|
234
|
-
["by name", {key: "read"}, {cluster: Zcl.Foundation.read, name: "read"}],
|
|
235
|
-
])("Gets global command %s", (_name, payload, expected) => {
|
|
236
|
-
const command: Command = {
|
|
237
|
-
ID: expected.cluster.ID,
|
|
238
|
-
name: expected.name,
|
|
239
|
-
parameters: expected.cluster.parameters,
|
|
240
|
-
};
|
|
241
|
-
|
|
242
|
-
if (expected.cluster.response) {
|
|
243
|
-
command.response = expected.cluster.response;
|
|
244
|
-
}
|
|
245
|
-
|
|
246
|
-
expect(Zcl.Utils.getGlobalCommand(payload.key)).toStrictEqual(command);
|
|
247
|
-
});
|
|
248
|
-
|
|
249
|
-
it("Throws when getting invalid global command", () => {
|
|
250
|
-
expect(() => {
|
|
251
|
-
Zcl.Utils.getGlobalCommand(99999);
|
|
252
|
-
}).toThrow();
|
|
253
|
-
expect(() => {
|
|
254
|
-
Zcl.Utils.getGlobalCommand("abcd");
|
|
255
|
-
}).toThrow();
|
|
256
|
-
});
|
|
257
|
-
|
|
258
|
-
it("Checks cluster name", () => {
|
|
259
|
-
expect(Zcl.Utils.isClusterName("genBasic")).toBeTruthy();
|
|
260
|
-
expect(Zcl.Utils.isClusterName("genAlarms")).toBeTruthy();
|
|
261
|
-
expect(Zcl.Utils.isClusterName("invalid")).toBeFalsy();
|
|
262
|
-
});
|
|
263
|
-
|
|
264
|
-
it("Gets Foundation command", () => {
|
|
265
|
-
expect(Zcl.Utils.getFoundationCommand(0)).toStrictEqual(Zcl.Foundation.read);
|
|
266
|
-
});
|
|
267
|
-
|
|
268
|
-
it("Throws when getting invalid Foundation command ID", () => {
|
|
269
|
-
expect(() => {
|
|
270
|
-
Zcl.Utils.getFoundationCommand(9999);
|
|
271
|
-
}).toThrow(`Foundation command '9999' does not exist.`);
|
|
272
|
-
});
|
|
273
|
-
});
|