zigbee-herdsman 5.0.4 → 6.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/.github/dependabot.yml +3 -0
- package/.github/workflows/ci.yml +1 -1
- package/.github/workflows/typedoc.yaml +1 -1
- package/.release-please-manifest.json +1 -1
- package/CHANGELOG.md +29 -0
- package/biome.json +1 -1
- package/dist/adapter/ember/ezsp/buffalo.d.ts +0 -2
- package/dist/adapter/ember/ezsp/buffalo.d.ts.map +1 -1
- package/dist/adapter/ember/ezsp/buffalo.js +0 -4
- package/dist/adapter/ember/ezsp/buffalo.js.map +1 -1
- package/dist/adapter/ember/uart/ash.d.ts.map +1 -1
- package/dist/adapter/ember/uart/ash.js +0 -2
- package/dist/adapter/ember/uart/ash.js.map +1 -1
- package/dist/buffalo/buffalo.d.ts +5 -0
- package/dist/buffalo/buffalo.d.ts.map +1 -1
- package/dist/buffalo/buffalo.js +7 -0
- package/dist/buffalo/buffalo.js.map +1 -1
- package/dist/controller/controller.d.ts.map +1 -1
- package/dist/controller/controller.js +8 -11
- package/dist/controller/controller.js.map +1 -1
- package/dist/controller/events.d.ts +2 -1
- package/dist/controller/events.d.ts.map +1 -1
- package/dist/controller/helpers/request.d.ts.map +1 -1
- package/dist/controller/helpers/request.js +2 -1
- package/dist/controller/helpers/request.js.map +1 -1
- package/dist/controller/helpers/zclFrameConverter.d.ts +2 -4
- package/dist/controller/helpers/zclFrameConverter.d.ts.map +1 -1
- package/dist/controller/helpers/zclFrameConverter.js +2 -0
- package/dist/controller/helpers/zclFrameConverter.js.map +1 -1
- package/dist/controller/model/device.d.ts +13 -24
- package/dist/controller/model/device.d.ts.map +1 -1
- package/dist/controller/model/device.js +88 -129
- package/dist/controller/model/device.js.map +1 -1
- package/dist/controller/model/endpoint.d.ts +17 -16
- package/dist/controller/model/endpoint.d.ts.map +1 -1
- package/dist/controller/model/endpoint.js +31 -16
- package/dist/controller/model/endpoint.js.map +1 -1
- package/dist/controller/model/group.d.ts +6 -6
- package/dist/controller/model/group.d.ts.map +1 -1
- package/dist/controller/model/group.js +5 -3
- package/dist/controller/model/group.js.map +1 -1
- package/dist/controller/model/index.d.ts +1 -0
- package/dist/controller/model/index.d.ts.map +1 -1
- package/dist/controller/model/index.js +3 -1
- package/dist/controller/model/index.js.map +1 -1
- package/dist/controller/model/zigbeeEntity.d.ts +8 -0
- package/dist/controller/model/zigbeeEntity.d.ts.map +1 -0
- package/dist/controller/model/zigbeeEntity.js +11 -0
- package/dist/controller/model/zigbeeEntity.js.map +1 -0
- package/dist/controller/tstype.d.ts +39 -0
- package/dist/controller/tstype.d.ts.map +1 -1
- package/dist/zspec/zcl/buffaloZcl.d.ts +32 -17
- package/dist/zspec/zcl/buffaloZcl.d.ts.map +1 -1
- package/dist/zspec/zcl/buffaloZcl.js +257 -121
- package/dist/zspec/zcl/buffaloZcl.js.map +1 -1
- package/dist/zspec/zcl/definition/cluster.d.ts.map +1 -1
- package/dist/zspec/zcl/definition/cluster.js +156 -33
- package/dist/zspec/zcl/definition/cluster.js.map +1 -1
- package/dist/zspec/zcl/definition/clusters-typegen.d.ts +2 -0
- package/dist/zspec/zcl/definition/clusters-typegen.d.ts.map +1 -0
- package/dist/zspec/zcl/definition/clusters-typegen.js +348 -0
- package/dist/zspec/zcl/definition/clusters-typegen.js.map +1 -0
- package/dist/zspec/zcl/definition/clusters-types.d.ts +7238 -0
- package/dist/zspec/zcl/definition/clusters-types.d.ts.map +1 -0
- package/dist/zspec/zcl/definition/clusters-types.js +3 -0
- package/dist/zspec/zcl/definition/clusters-types.js.map +1 -0
- package/dist/zspec/zcl/definition/enums.d.ts +14 -6
- package/dist/zspec/zcl/definition/enums.d.ts.map +1 -1
- package/dist/zspec/zcl/definition/enums.js +15 -6
- package/dist/zspec/zcl/definition/enums.js.map +1 -1
- package/dist/zspec/zcl/definition/foundation.d.ts.map +1 -1
- package/dist/zspec/zcl/definition/foundation.js +43 -15
- package/dist/zspec/zcl/definition/foundation.js.map +1 -1
- package/dist/zspec/zcl/definition/tstype.d.ts +105 -11
- package/dist/zspec/zcl/definition/tstype.d.ts.map +1 -1
- package/dist/zspec/zcl/index.d.ts +1 -0
- package/dist/zspec/zcl/index.d.ts.map +1 -1
- package/dist/zspec/zcl/index.js.map +1 -1
- package/dist/zspec/zcl/utils.d.ts +1 -1
- package/dist/zspec/zcl/utils.d.ts.map +1 -1
- package/dist/zspec/zcl/utils.js +1 -1
- package/dist/zspec/zcl/utils.js.map +1 -1
- package/dist/zspec/zcl/zclFrame.d.ts.map +1 -1
- package/dist/zspec/zcl/zclFrame.js +32 -20
- package/dist/zspec/zcl/zclFrame.js.map +1 -1
- package/dist/zspec/zdo/buffaloZdo.d.ts +0 -6
- package/dist/zspec/zdo/buffaloZdo.d.ts.map +1 -1
- package/dist/zspec/zdo/buffaloZdo.js +0 -8
- package/dist/zspec/zdo/buffaloZdo.js.map +1 -1
- package/package.json +3 -3
- package/src/adapter/ember/ezsp/buffalo.ts +0 -5
- package/src/adapter/ember/uart/ash.ts +0 -2
- package/src/adapter/ezsp/driver/driver.ts +1 -1
- package/src/buffalo/buffalo.ts +8 -0
- package/src/controller/controller.ts +13 -16
- package/src/controller/events.ts +2 -1
- package/src/controller/greenPower.ts +4 -4
- package/src/controller/helpers/request.ts +3 -1
- package/src/controller/helpers/zclFrameConverter.ts +13 -17
- package/src/controller/model/device.ts +103 -148
- package/src/controller/model/endpoint.ts +112 -64
- package/src/controller/model/group.ts +33 -9
- package/src/controller/model/index.ts +1 -0
- package/src/controller/model/zigbeeEntity.ts +30 -0
- package/src/controller/tstype.ts +251 -16
- package/src/zspec/zcl/buffaloZcl.ts +323 -238
- package/src/zspec/zcl/definition/cluster.ts +156 -33
- package/src/zspec/zcl/definition/clusters-typegen.ts +588 -0
- package/src/zspec/zcl/definition/clusters-types.ts +7331 -0
- package/src/zspec/zcl/definition/enums.ts +14 -5
- package/src/zspec/zcl/definition/foundation.ts +43 -15
- package/src/zspec/zcl/definition/tstype.ts +118 -8
- package/src/zspec/zcl/index.ts +1 -0
- package/src/zspec/zcl/utils.ts +1 -1
- package/src/zspec/zcl/zclFrame.ts +37 -19
- package/src/zspec/zdo/buffaloZdo.ts +0 -9
- package/test/controller.test.ts +356 -896
- package/test/greenpower.test.ts +0 -12
- package/test/zcl.test.ts +13 -11
- package/test/zspec/zcl/buffalo.test.ts +216 -74
- package/test/zspec/zcl/frame.test.ts +62 -28
- package/test/zspec/zcl/utils.test.ts +4 -4
package/src/controller/tstype.ts
CHANGED
|
@@ -1,24 +1,38 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
TClusterAttributes,
|
|
3
|
+
TClusterCommandResponses,
|
|
4
|
+
TClusterCommands,
|
|
5
|
+
TClusterPayload,
|
|
6
|
+
TClusters,
|
|
7
|
+
TFoundation,
|
|
8
|
+
TFoundationGenericPayload,
|
|
9
|
+
TFoundationPayload,
|
|
10
|
+
TPartialClusterAttributes,
|
|
11
|
+
} from "../zspec/zcl/definition/clusters-types";
|
|
12
|
+
import type {DataType} from "../zspec/zcl/definition/enums";
|
|
13
|
+
|
|
1
14
|
export interface KeyValue {
|
|
2
15
|
// biome-ignore lint/suspicious/noExplicitAny: API
|
|
3
16
|
[s: string]: any;
|
|
4
17
|
}
|
|
5
18
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
19
|
+
/**
|
|
20
|
+
* Send request policies:
|
|
21
|
+
* - 'bulk': Message must be sent together with other messages in the correct sequence.
|
|
22
|
+
* No immediate delivery required.
|
|
23
|
+
* - 'queue': Request shall be sent 'as-is' as soon as possible.
|
|
24
|
+
* Multiple identical requests shall be delivered multiple times.
|
|
25
|
+
* Not strict ordering required.
|
|
26
|
+
* - 'immediate': Request shall be sent immediately and not be kept for later retries (e.g. response message).
|
|
27
|
+
* - 'keep-payload': Request shall be sent as soon as possible.
|
|
28
|
+
* If immediate delivery fails, the exact same payload is only sent once, even if there were
|
|
29
|
+
* multiple requests.
|
|
30
|
+
* - 'keep-command': Request shall be sent as soon as possible.
|
|
31
|
+
* If immediate delivery fails, only the latest command for each command ID is kept for delivery.
|
|
32
|
+
* - 'keep-cmd-undiv': Request shall be sent as soon as possible.
|
|
33
|
+
* If immediate delivery fails, only the latest undivided set of commands is sent for each unique
|
|
34
|
+
* set of command IDs.
|
|
35
|
+
*/
|
|
22
36
|
export type SendPolicy = "bulk" | "queue" | "immediate" | "keep-payload" | "keep-command" | "keep-cmd-undiv";
|
|
23
37
|
export type DeviceType = "Coordinator" | "Router" | "EndDevice" | "Unknown" | "GreenPower";
|
|
24
38
|
|
|
@@ -37,3 +51,224 @@ export interface GreenPowerDeviceJoinedPayload {
|
|
|
37
51
|
networkAddress: number;
|
|
38
52
|
securityKey?: Buffer;
|
|
39
53
|
}
|
|
54
|
+
|
|
55
|
+
export interface TCustomCluster {
|
|
56
|
+
attributes: Record<string, unknown> | never;
|
|
57
|
+
commands: Record<string, Record<string, unknown | never>> | never;
|
|
58
|
+
commandResponses: Record<string, Record<string, unknown | never>> | never;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export type RawClusterAttribute = {value: unknown; type: DataType};
|
|
62
|
+
|
|
63
|
+
export type RawClusterAttributes = Record<number, RawClusterAttribute>;
|
|
64
|
+
|
|
65
|
+
// below Cluster types follow roughly the same logic:
|
|
66
|
+
// - if cluster has attributes/commands/commandsResponse
|
|
67
|
+
// - if Custom is defined and has attributes/commands/commandsResponse, use Custom and/or raw
|
|
68
|
+
// - else use raw
|
|
69
|
+
// - else
|
|
70
|
+
// - if cluster is ZCL
|
|
71
|
+
// - if Custom is defined and has attributes/commands/commandsResponse, use Custom and/or ZCL and/or raw
|
|
72
|
+
// - else use ZCL and/or raw
|
|
73
|
+
// - else
|
|
74
|
+
// - if Custom is defined, use Custom and/or raw
|
|
75
|
+
// - else use raw
|
|
76
|
+
//
|
|
77
|
+
// where `raw` represents the type used for full manual input (usually using ID)
|
|
78
|
+
|
|
79
|
+
export type ClusterOrRawAttributeKeys<
|
|
80
|
+
Cl extends string | number,
|
|
81
|
+
Custom extends TCustomCluster | undefined = undefined,
|
|
82
|
+
> = TClusterAttributes<Cl> extends never
|
|
83
|
+
? Custom extends TCustomCluster
|
|
84
|
+
? Custom["attributes"] extends never
|
|
85
|
+
? number[]
|
|
86
|
+
: (keyof Custom["attributes"] | number)[]
|
|
87
|
+
: number[]
|
|
88
|
+
: Cl extends keyof TClusters
|
|
89
|
+
? Custom extends TCustomCluster
|
|
90
|
+
? Custom["attributes"] extends never
|
|
91
|
+
? // don't use `TClusterAttributeKeys<Cl>` as that allows "symbol"
|
|
92
|
+
(keyof TClusters[Cl]["attributes"] | number)[]
|
|
93
|
+
: (keyof Custom["attributes"] | keyof TClusters[Cl]["attributes"] | number)[]
|
|
94
|
+
: (keyof TClusters[Cl]["attributes"] | number)[]
|
|
95
|
+
: Custom extends TCustomCluster
|
|
96
|
+
? Custom["attributes"] extends never
|
|
97
|
+
? number[]
|
|
98
|
+
: (keyof Custom["attributes"] | number)[]
|
|
99
|
+
: number[];
|
|
100
|
+
|
|
101
|
+
export type ClusterOrRawWriteAttributes<
|
|
102
|
+
Cl extends string | number,
|
|
103
|
+
Custom extends TCustomCluster | undefined = undefined,
|
|
104
|
+
> = TClusterAttributes<Cl> extends never
|
|
105
|
+
? Custom extends TCustomCluster
|
|
106
|
+
? Custom["attributes"] extends never
|
|
107
|
+
? RawClusterAttributes
|
|
108
|
+
: Custom["attributes"] & RawClusterAttributes
|
|
109
|
+
: RawClusterAttributes
|
|
110
|
+
: Cl extends keyof TClusters
|
|
111
|
+
? (Custom extends TCustomCluster
|
|
112
|
+
? Custom["attributes"] extends never
|
|
113
|
+
? TClusterAttributes<Cl>
|
|
114
|
+
: Custom["attributes"] & TClusterAttributes<Cl>
|
|
115
|
+
: TClusterAttributes<Cl>) &
|
|
116
|
+
RawClusterAttributes
|
|
117
|
+
: Custom extends TCustomCluster
|
|
118
|
+
? Custom["attributes"] extends never
|
|
119
|
+
? RawClusterAttributes
|
|
120
|
+
: Custom["attributes"] & RawClusterAttributes
|
|
121
|
+
: RawClusterAttributes;
|
|
122
|
+
|
|
123
|
+
export type PartialClusterOrRawWriteAttributes<
|
|
124
|
+
Cl extends string | number,
|
|
125
|
+
Custom extends TCustomCluster | undefined = undefined,
|
|
126
|
+
> = TClusterAttributes<Cl> extends never
|
|
127
|
+
? Custom extends TCustomCluster
|
|
128
|
+
? Custom["attributes"] extends never
|
|
129
|
+
? RawClusterAttributes
|
|
130
|
+
: Partial<Custom["attributes"]> & RawClusterAttributes
|
|
131
|
+
: RawClusterAttributes
|
|
132
|
+
: Cl extends keyof TClusters
|
|
133
|
+
? (Custom extends TCustomCluster
|
|
134
|
+
? Custom["attributes"] extends never
|
|
135
|
+
? TPartialClusterAttributes<Cl>
|
|
136
|
+
: Partial<Custom["attributes"]> & TPartialClusterAttributes<Cl>
|
|
137
|
+
: TPartialClusterAttributes<Cl>) &
|
|
138
|
+
RawClusterAttributes
|
|
139
|
+
: Custom extends TCustomCluster
|
|
140
|
+
? Custom["attributes"] extends never
|
|
141
|
+
? RawClusterAttributes
|
|
142
|
+
: Partial<Custom["attributes"]> & RawClusterAttributes
|
|
143
|
+
: RawClusterAttributes;
|
|
144
|
+
|
|
145
|
+
export type ClusterOrRawAttributes<
|
|
146
|
+
Cl extends string | number,
|
|
147
|
+
Custom extends TCustomCluster | undefined = undefined,
|
|
148
|
+
> = TClusterAttributes<Cl> extends never
|
|
149
|
+
? Custom extends TCustomCluster
|
|
150
|
+
? Custom["attributes"] extends never
|
|
151
|
+
? Record<number, unknown>
|
|
152
|
+
: Custom["attributes"] & Record<number, unknown>
|
|
153
|
+
: Record<number, unknown>
|
|
154
|
+
: Cl extends keyof TClusters
|
|
155
|
+
? (Custom extends TCustomCluster
|
|
156
|
+
? Custom["attributes"] extends never
|
|
157
|
+
? TClusterAttributes<Cl>
|
|
158
|
+
: Custom["attributes"] & TClusterAttributes<Cl>
|
|
159
|
+
: TClusterAttributes<Cl>) &
|
|
160
|
+
Record<number, unknown>
|
|
161
|
+
: Custom extends TCustomCluster
|
|
162
|
+
? Custom["attributes"] extends never
|
|
163
|
+
? Record<number, unknown>
|
|
164
|
+
: Custom["attributes"] & Record<number, unknown>
|
|
165
|
+
: Record<number, unknown>;
|
|
166
|
+
|
|
167
|
+
export type PartialClusterOrRawAttributes<
|
|
168
|
+
Cl extends string | number,
|
|
169
|
+
Custom extends TCustomCluster | undefined = undefined,
|
|
170
|
+
> = TClusterAttributes<Cl> extends never
|
|
171
|
+
? Custom extends TCustomCluster
|
|
172
|
+
? Custom["attributes"] extends never
|
|
173
|
+
? Record<number, unknown>
|
|
174
|
+
: Partial<Custom["attributes"]> & Record<number, unknown>
|
|
175
|
+
: Record<number, unknown>
|
|
176
|
+
: Cl extends keyof TClusters
|
|
177
|
+
? (Custom extends TCustomCluster
|
|
178
|
+
? Custom["attributes"] extends never
|
|
179
|
+
? TPartialClusterAttributes<Cl>
|
|
180
|
+
: Partial<Custom["attributes"]> & TPartialClusterAttributes<Cl>
|
|
181
|
+
: TPartialClusterAttributes<Cl>) &
|
|
182
|
+
Record<number, unknown>
|
|
183
|
+
: Custom extends TCustomCluster
|
|
184
|
+
? Custom["attributes"] extends never
|
|
185
|
+
? Record<number, unknown>
|
|
186
|
+
: Partial<Custom["attributes"]> & Record<number, unknown>
|
|
187
|
+
: Record<number, unknown>;
|
|
188
|
+
|
|
189
|
+
export type ClusterCommandKeys<Cl extends string | number, Custom extends TCustomCluster | undefined = undefined> = TClusterCommands<Cl> extends never
|
|
190
|
+
? Custom extends TCustomCluster
|
|
191
|
+
? Custom["commands"] extends never
|
|
192
|
+
? number[]
|
|
193
|
+
: (keyof Custom["commands"] | number)[]
|
|
194
|
+
: number[]
|
|
195
|
+
: Cl extends keyof TClusters
|
|
196
|
+
? Custom extends TCustomCluster
|
|
197
|
+
? Custom["commands"] extends never
|
|
198
|
+
? // don't use `TClusterCommandKeys<Cl>` as that allows "symbol"
|
|
199
|
+
(keyof TClusters[Cl]["commands"] | number)[]
|
|
200
|
+
: (keyof Custom["commands"] | keyof TClusters[Cl]["commands"] | number)[]
|
|
201
|
+
: (keyof TClusters[Cl]["commands"] | number)[]
|
|
202
|
+
: Custom extends TCustomCluster
|
|
203
|
+
? Custom["commands"] extends never
|
|
204
|
+
? number[]
|
|
205
|
+
: (keyof Custom["commands"] | number)[]
|
|
206
|
+
: number[];
|
|
207
|
+
|
|
208
|
+
export type ClusterCommandResponseKeys<
|
|
209
|
+
Cl extends string | number,
|
|
210
|
+
Custom extends TCustomCluster | undefined = undefined,
|
|
211
|
+
> = TClusterCommandResponses<Cl> extends never
|
|
212
|
+
? Custom extends TCustomCluster
|
|
213
|
+
? Custom["commandResponses"] extends never
|
|
214
|
+
? number[]
|
|
215
|
+
: (keyof Custom["commandResponses"] | number)[]
|
|
216
|
+
: number[]
|
|
217
|
+
: Cl extends keyof TClusters
|
|
218
|
+
? Custom extends TCustomCluster
|
|
219
|
+
? Custom["commandResponses"] extends never
|
|
220
|
+
? // don't use `TClusterCommandResponseKeys<Cl>` as that allows "symbol"
|
|
221
|
+
(keyof TClusters[Cl]["commandResponses"] | number)[]
|
|
222
|
+
: (keyof Custom["commandResponses"] | keyof TClusters[Cl]["commandResponses"] | number)[]
|
|
223
|
+
: (keyof TClusters[Cl]["commandResponses"] | number)[]
|
|
224
|
+
: Custom extends TCustomCluster
|
|
225
|
+
? Custom["commandResponses"] extends never
|
|
226
|
+
? number[]
|
|
227
|
+
: (keyof Custom["commandResponses"] | number)[]
|
|
228
|
+
: number[];
|
|
229
|
+
|
|
230
|
+
export type TCustomClusterPayload<Custom extends TCustomCluster, Co extends string | number> = Custom["commands"] extends never
|
|
231
|
+
? Custom["commandResponses"] extends never
|
|
232
|
+
? never
|
|
233
|
+
: Co extends keyof Custom["commandResponses"]
|
|
234
|
+
? Custom["commandResponses"][Co]
|
|
235
|
+
: never
|
|
236
|
+
: Co extends keyof Custom["commands"]
|
|
237
|
+
? Custom["commands"][Co]
|
|
238
|
+
: Co extends keyof Custom["commandResponses"]
|
|
239
|
+
? Custom["commandResponses"][Co]
|
|
240
|
+
: never;
|
|
241
|
+
|
|
242
|
+
export type ClusterOrRawPayload<
|
|
243
|
+
Cl extends string | number,
|
|
244
|
+
Co extends string | number,
|
|
245
|
+
Custom extends TCustomCluster | undefined = undefined,
|
|
246
|
+
> = Cl extends number
|
|
247
|
+
? Record<string, unknown>
|
|
248
|
+
: Co extends number
|
|
249
|
+
? Record<string, unknown>
|
|
250
|
+
: TClusterPayload<Cl, Co> extends never
|
|
251
|
+
? Custom extends TCustomCluster
|
|
252
|
+
? TCustomClusterPayload<Custom, Co> extends never
|
|
253
|
+
? never
|
|
254
|
+
: TCustomClusterPayload<Custom, Co>
|
|
255
|
+
: never
|
|
256
|
+
: Cl extends keyof TClusters
|
|
257
|
+
? Custom extends TCustomCluster
|
|
258
|
+
? TCustomClusterPayload<Custom, Co> extends never
|
|
259
|
+
? TClusterPayload<Cl, Co>
|
|
260
|
+
: TCustomClusterPayload<Custom, Co> & TClusterPayload<Cl, Co>
|
|
261
|
+
: TClusterPayload<Cl, Co>
|
|
262
|
+
: Custom extends TCustomCluster
|
|
263
|
+
? TCustomClusterPayload<Custom, Co> extends never
|
|
264
|
+
? never
|
|
265
|
+
: TCustomClusterPayload<Custom, Co>
|
|
266
|
+
: never;
|
|
267
|
+
|
|
268
|
+
export type FoundationOrRawPayload<Co extends string | number> = Co extends number
|
|
269
|
+
? TFoundationGenericPayload
|
|
270
|
+
: TFoundationPayload<Co> extends never
|
|
271
|
+
? never
|
|
272
|
+
: Co extends keyof TFoundation
|
|
273
|
+
? TFoundationPayload<Co>
|
|
274
|
+
: never;
|