zigbee-herdsman 6.0.1 → 6.0.3

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.
Files changed (260) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/dist/adapter/ezsp/driver/uart.js +1 -1
  3. package/dist/adapter/ezsp/driver/uart.js.map +1 -1
  4. package/dist/adapter/z-stack/adapter/zStackAdapter.js +4 -4
  5. package/dist/adapter/z-stack/adapter/zStackAdapter.js.map +1 -1
  6. package/dist/adapter/zigate/adapter/zigateAdapter.js +4 -4
  7. package/dist/adapter/zigate/adapter/zigateAdapter.js.map +1 -1
  8. package/dist/controller/model/device.d.ts.map +1 -1
  9. package/dist/controller/model/device.js +1 -0
  10. package/dist/controller/model/device.js.map +1 -1
  11. package/package.json +14 -6
  12. package/.github/ISSUE_TEMPLATE/config.yml +0 -5
  13. package/.github/dependabot.yml +0 -22
  14. package/.github/workflows/ci.yml +0 -64
  15. package/.github/workflows/release-please.yml +0 -18
  16. package/.github/workflows/stale.yml +0 -20
  17. package/.github/workflows/typedoc.yaml +0 -47
  18. package/.release-please-manifest.json +0 -3
  19. package/.vscode/extensions.json +0 -3
  20. package/.vscode/settings.json +0 -11
  21. package/biome.json +0 -98
  22. package/examples/join-and-log.js +0 -24
  23. package/release-please-config.json +0 -9
  24. package/src/adapter/adapter.ts +0 -189
  25. package/src/adapter/adapterDiscovery.ts +0 -666
  26. package/src/adapter/const.ts +0 -12
  27. package/src/adapter/deconz/adapter/deconzAdapter.ts +0 -877
  28. package/src/adapter/deconz/driver/constants.ts +0 -246
  29. package/src/adapter/deconz/driver/driver.ts +0 -1540
  30. package/src/adapter/deconz/driver/frame.ts +0 -11
  31. package/src/adapter/deconz/driver/frameParser.ts +0 -753
  32. package/src/adapter/deconz/driver/parser.ts +0 -45
  33. package/src/adapter/deconz/driver/writer.ts +0 -22
  34. package/src/adapter/deconz/types.d.ts +0 -13
  35. package/src/adapter/ember/adapter/emberAdapter.ts +0 -2265
  36. package/src/adapter/ember/adapter/endpoints.ts +0 -86
  37. package/src/adapter/ember/adapter/oneWaitress.ts +0 -324
  38. package/src/adapter/ember/adapter/tokensManager.ts +0 -782
  39. package/src/adapter/ember/consts.ts +0 -178
  40. package/src/adapter/ember/enums.ts +0 -1746
  41. package/src/adapter/ember/ezsp/buffalo.ts +0 -1392
  42. package/src/adapter/ember/ezsp/consts.ts +0 -148
  43. package/src/adapter/ember/ezsp/enums.ts +0 -1114
  44. package/src/adapter/ember/ezsp/ezsp.ts +0 -9061
  45. package/src/adapter/ember/ezspError.ts +0 -10
  46. package/src/adapter/ember/types.ts +0 -866
  47. package/src/adapter/ember/uart/ash.ts +0 -1960
  48. package/src/adapter/ember/uart/consts.ts +0 -109
  49. package/src/adapter/ember/uart/enums.ts +0 -192
  50. package/src/adapter/ember/uart/parser.ts +0 -48
  51. package/src/adapter/ember/uart/queues.ts +0 -247
  52. package/src/adapter/ember/uart/writer.ts +0 -53
  53. package/src/adapter/ember/utils/initters.ts +0 -58
  54. package/src/adapter/ember/utils/math.ts +0 -73
  55. package/src/adapter/events.ts +0 -21
  56. package/src/adapter/ezsp/adapter/backup.ts +0 -109
  57. package/src/adapter/ezsp/adapter/ezspAdapter.ts +0 -614
  58. package/src/adapter/ezsp/driver/commands.ts +0 -2497
  59. package/src/adapter/ezsp/driver/consts.ts +0 -11
  60. package/src/adapter/ezsp/driver/driver.ts +0 -1002
  61. package/src/adapter/ezsp/driver/ezsp.ts +0 -802
  62. package/src/adapter/ezsp/driver/frame.ts +0 -101
  63. package/src/adapter/ezsp/driver/index.ts +0 -4
  64. package/src/adapter/ezsp/driver/multicast.ts +0 -78
  65. package/src/adapter/ezsp/driver/parser.ts +0 -81
  66. package/src/adapter/ezsp/driver/types/basic.ts +0 -201
  67. package/src/adapter/ezsp/driver/types/index.ts +0 -239
  68. package/src/adapter/ezsp/driver/types/named.ts +0 -2330
  69. package/src/adapter/ezsp/driver/types/struct.ts +0 -844
  70. package/src/adapter/ezsp/driver/uart.ts +0 -460
  71. package/src/adapter/ezsp/driver/utils/crc16ccitt.ts +0 -44
  72. package/src/adapter/ezsp/driver/utils/index.ts +0 -32
  73. package/src/adapter/ezsp/driver/writer.ts +0 -64
  74. package/src/adapter/index.ts +0 -3
  75. package/src/adapter/serialPort.ts +0 -58
  76. package/src/adapter/socketPortUtils.ts +0 -16
  77. package/src/adapter/tstype.ts +0 -78
  78. package/src/adapter/z-stack/adapter/adapter-backup.ts +0 -519
  79. package/src/adapter/z-stack/adapter/adapter-nv-memory.ts +0 -457
  80. package/src/adapter/z-stack/adapter/endpoints.ts +0 -57
  81. package/src/adapter/z-stack/adapter/manager.ts +0 -543
  82. package/src/adapter/z-stack/adapter/tstype.ts +0 -6
  83. package/src/adapter/z-stack/adapter/zStackAdapter.ts +0 -1190
  84. package/src/adapter/z-stack/constants/af.ts +0 -27
  85. package/src/adapter/z-stack/constants/common.ts +0 -285
  86. package/src/adapter/z-stack/constants/dbg.ts +0 -23
  87. package/src/adapter/z-stack/constants/index.ts +0 -11
  88. package/src/adapter/z-stack/constants/mac.ts +0 -128
  89. package/src/adapter/z-stack/constants/sapi.ts +0 -25
  90. package/src/adapter/z-stack/constants/sys.ts +0 -72
  91. package/src/adapter/z-stack/constants/util.ts +0 -82
  92. package/src/adapter/z-stack/constants/utils.ts +0 -14
  93. package/src/adapter/z-stack/constants/zdo.ts +0 -103
  94. package/src/adapter/z-stack/models/startup-options.ts +0 -13
  95. package/src/adapter/z-stack/structs/entries/address-manager-entry.ts +0 -44
  96. package/src/adapter/z-stack/structs/entries/address-manager-table.ts +0 -19
  97. package/src/adapter/z-stack/structs/entries/aps-link-key-data-entry.ts +0 -12
  98. package/src/adapter/z-stack/structs/entries/aps-link-key-data-table.ts +0 -21
  99. package/src/adapter/z-stack/structs/entries/aps-tc-link-key-entry.ts +0 -19
  100. package/src/adapter/z-stack/structs/entries/aps-tc-link-key-table.ts +0 -21
  101. package/src/adapter/z-stack/structs/entries/channel-list.ts +0 -8
  102. package/src/adapter/z-stack/structs/entries/has-configured.ts +0 -16
  103. package/src/adapter/z-stack/structs/entries/index.ts +0 -16
  104. package/src/adapter/z-stack/structs/entries/nib.ts +0 -66
  105. package/src/adapter/z-stack/structs/entries/nwk-key-descriptor.ts +0 -15
  106. package/src/adapter/z-stack/structs/entries/nwk-key.ts +0 -13
  107. package/src/adapter/z-stack/structs/entries/nwk-pan-id.ts +0 -8
  108. package/src/adapter/z-stack/structs/entries/nwk-sec-material-descriptor-entry.ts +0 -20
  109. package/src/adapter/z-stack/structs/entries/nwk-sec-material-descriptor-table.ts +0 -19
  110. package/src/adapter/z-stack/structs/entries/security-manager-entry.ts +0 -33
  111. package/src/adapter/z-stack/structs/entries/security-manager-table.ts +0 -22
  112. package/src/adapter/z-stack/structs/index.ts +0 -4
  113. package/src/adapter/z-stack/structs/serializable-memory-object.ts +0 -14
  114. package/src/adapter/z-stack/structs/struct.ts +0 -367
  115. package/src/adapter/z-stack/structs/table.ts +0 -198
  116. package/src/adapter/z-stack/unpi/constants.ts +0 -33
  117. package/src/adapter/z-stack/unpi/frame.ts +0 -62
  118. package/src/adapter/z-stack/unpi/index.ts +0 -4
  119. package/src/adapter/z-stack/unpi/parser.ts +0 -56
  120. package/src/adapter/z-stack/unpi/writer.ts +0 -21
  121. package/src/adapter/z-stack/utils/channel-list.ts +0 -40
  122. package/src/adapter/z-stack/utils/index.ts +0 -2
  123. package/src/adapter/z-stack/utils/network-options.ts +0 -26
  124. package/src/adapter/z-stack/znp/buffaloZnp.ts +0 -175
  125. package/src/adapter/z-stack/znp/definition.ts +0 -2713
  126. package/src/adapter/z-stack/znp/index.ts +0 -2
  127. package/src/adapter/z-stack/znp/parameterType.ts +0 -22
  128. package/src/adapter/z-stack/znp/tstype.ts +0 -44
  129. package/src/adapter/z-stack/znp/utils.ts +0 -10
  130. package/src/adapter/z-stack/znp/znp.ts +0 -342
  131. package/src/adapter/z-stack/znp/zpiObject.ts +0 -148
  132. package/src/adapter/zboss/adapter/zbossAdapter.ts +0 -526
  133. package/src/adapter/zboss/commands.ts +0 -1184
  134. package/src/adapter/zboss/consts.ts +0 -9
  135. package/src/adapter/zboss/driver.ts +0 -422
  136. package/src/adapter/zboss/enums.ts +0 -360
  137. package/src/adapter/zboss/frame.ts +0 -227
  138. package/src/adapter/zboss/reader.ts +0 -65
  139. package/src/adapter/zboss/types.ts +0 -0
  140. package/src/adapter/zboss/uart.ts +0 -428
  141. package/src/adapter/zboss/utils.ts +0 -58
  142. package/src/adapter/zboss/writer.ts +0 -49
  143. package/src/adapter/zigate/adapter/patchZdoBuffaloBE.ts +0 -27
  144. package/src/adapter/zigate/adapter/zigateAdapter.ts +0 -618
  145. package/src/adapter/zigate/driver/LICENSE +0 -17
  146. package/src/adapter/zigate/driver/buffaloZiGate.ts +0 -212
  147. package/src/adapter/zigate/driver/commandType.ts +0 -418
  148. package/src/adapter/zigate/driver/constants.ts +0 -150
  149. package/src/adapter/zigate/driver/frame.ts +0 -197
  150. package/src/adapter/zigate/driver/messageType.ts +0 -287
  151. package/src/adapter/zigate/driver/parameterType.ts +0 -32
  152. package/src/adapter/zigate/driver/ziGateObject.ts +0 -146
  153. package/src/adapter/zigate/driver/zigate.ts +0 -423
  154. package/src/adapter/zoh/adapter/utils.ts +0 -27
  155. package/src/adapter/zoh/adapter/zohAdapter.ts +0 -838
  156. package/src/buffalo/buffalo.ts +0 -342
  157. package/src/buffalo/index.ts +0 -1
  158. package/src/controller/controller.ts +0 -1022
  159. package/src/controller/database.ts +0 -124
  160. package/src/controller/events.ts +0 -52
  161. package/src/controller/greenPower.ts +0 -603
  162. package/src/controller/helpers/index.ts +0 -1
  163. package/src/controller/helpers/installCodes.ts +0 -107
  164. package/src/controller/helpers/request.ts +0 -96
  165. package/src/controller/helpers/requestQueue.ts +0 -125
  166. package/src/controller/helpers/zclFrameConverter.ts +0 -47
  167. package/src/controller/helpers/zclTransactionSequenceNumber.ts +0 -19
  168. package/src/controller/index.ts +0 -6
  169. package/src/controller/model/device.ts +0 -1248
  170. package/src/controller/model/endpoint.ts +0 -1105
  171. package/src/controller/model/entity.ts +0 -23
  172. package/src/controller/model/group.ts +0 -424
  173. package/src/controller/model/index.ts +0 -5
  174. package/src/controller/model/zigbeeEntity.ts +0 -30
  175. package/src/controller/touchlink.ts +0 -189
  176. package/src/controller/tstype.ts +0 -274
  177. package/src/index.ts +0 -12
  178. package/src/models/backup-storage-legacy.ts +0 -48
  179. package/src/models/backup-storage-unified.ts +0 -47
  180. package/src/models/backup.ts +0 -37
  181. package/src/models/index.ts +0 -5
  182. package/src/models/network-options.ts +0 -11
  183. package/src/utils/backup.ts +0 -152
  184. package/src/utils/index.ts +0 -5
  185. package/src/utils/logger.ts +0 -20
  186. package/src/utils/patchBigIntSerialization.ts +0 -8
  187. package/src/utils/queue.ts +0 -76
  188. package/src/utils/types.d.ts +0 -3
  189. package/src/utils/utils.ts +0 -19
  190. package/src/utils/wait.ts +0 -5
  191. package/src/utils/waitress.ts +0 -96
  192. package/src/zspec/consts.ts +0 -84
  193. package/src/zspec/enums.ts +0 -22
  194. package/src/zspec/index.ts +0 -3
  195. package/src/zspec/tstypes.ts +0 -18
  196. package/src/zspec/utils.ts +0 -247
  197. package/src/zspec/zcl/buffaloZcl.ts +0 -1220
  198. package/src/zspec/zcl/definition/cluster.ts +0 -5915
  199. package/src/zspec/zcl/definition/clusters-typegen.ts +0 -588
  200. package/src/zspec/zcl/definition/clusters-types.ts +0 -7331
  201. package/src/zspec/zcl/definition/consts.ts +0 -24
  202. package/src/zspec/zcl/definition/enums.ts +0 -203
  203. package/src/zspec/zcl/definition/foundation.ts +0 -329
  204. package/src/zspec/zcl/definition/manufacturerCode.ts +0 -729
  205. package/src/zspec/zcl/definition/status.ts +0 -69
  206. package/src/zspec/zcl/definition/tstype.ts +0 -377
  207. package/src/zspec/zcl/index.ts +0 -11
  208. package/src/zspec/zcl/utils.ts +0 -321
  209. package/src/zspec/zcl/zclFrame.ts +0 -356
  210. package/src/zspec/zcl/zclHeader.ts +0 -102
  211. package/src/zspec/zcl/zclStatusError.ts +0 -10
  212. package/src/zspec/zdo/buffaloZdo.ts +0 -2336
  213. package/src/zspec/zdo/definition/clusters.ts +0 -722
  214. package/src/zspec/zdo/definition/consts.ts +0 -16
  215. package/src/zspec/zdo/definition/enums.ts +0 -99
  216. package/src/zspec/zdo/definition/status.ts +0 -105
  217. package/src/zspec/zdo/definition/tstypes.ts +0 -1062
  218. package/src/zspec/zdo/index.ts +0 -7
  219. package/src/zspec/zdo/utils.ts +0 -76
  220. package/src/zspec/zdo/zdoStatusError.ts +0 -10
  221. package/test/adapter/adapter.test.ts +0 -1062
  222. package/test/adapter/ember/ash.test.ts +0 -337
  223. package/test/adapter/ember/consts.ts +0 -131
  224. package/test/adapter/ember/emberAdapter.test.ts +0 -3449
  225. package/test/adapter/ember/ezsp.test.ts +0 -385
  226. package/test/adapter/ember/ezspBuffalo.test.ts +0 -93
  227. package/test/adapter/ember/ezspError.test.ts +0 -12
  228. package/test/adapter/ember/math.test.ts +0 -206
  229. package/test/adapter/ezsp/frame.test.ts +0 -30
  230. package/test/adapter/ezsp/uart.test.ts +0 -181
  231. package/test/adapter/z-stack/adapter.test.ts +0 -3984
  232. package/test/adapter/z-stack/constants.test.ts +0 -33
  233. package/test/adapter/z-stack/structs.test.ts +0 -115
  234. package/test/adapter/z-stack/unpi.test.ts +0 -213
  235. package/test/adapter/z-stack/znp.test.ts +0 -1284
  236. package/test/adapter/zboss/fixZdoResponse.test.ts +0 -179
  237. package/test/adapter/zigate/patchZdoBuffaloBE.test.ts +0 -81
  238. package/test/adapter/zigate/zdo.test.ts +0 -187
  239. package/test/adapter/zoh/utils.test.ts +0 -36
  240. package/test/adapter/zoh/zohAdapter.test.ts +0 -1307
  241. package/test/buffalo.test.ts +0 -431
  242. package/test/controller.bench.ts +0 -193
  243. package/test/controller.test.ts +0 -8702
  244. package/test/greenpower.test.ts +0 -1408
  245. package/test/mockAdapters.ts +0 -65
  246. package/test/mockDevices.ts +0 -598
  247. package/test/requests.bench.ts +0 -206
  248. package/test/testUtils.ts +0 -20
  249. package/test/tsconfig.json +0 -9
  250. package/test/utils/math.ts +0 -19
  251. package/test/utils.test.ts +0 -279
  252. package/test/vitest.config.mts +0 -27
  253. package/test/zcl.test.ts +0 -2831
  254. package/test/zspec/utils.test.ts +0 -68
  255. package/test/zspec/zcl/buffalo.test.ts +0 -1374
  256. package/test/zspec/zcl/frame.test.ts +0 -960
  257. package/test/zspec/zcl/utils.test.ts +0 -273
  258. package/test/zspec/zdo/buffalo.test.ts +0 -1850
  259. package/test/zspec/zdo/utils.test.ts +0 -241
  260. package/tsconfig.json +0 -24
@@ -1,274 +0,0 @@
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
-
14
- export interface KeyValue {
15
- // biome-ignore lint/suspicious/noExplicitAny: API
16
- [s: string]: any;
17
- }
18
-
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
- */
36
- export type SendPolicy = "bulk" | "queue" | "immediate" | "keep-payload" | "keep-command" | "keep-cmd-undiv";
37
- export type DeviceType = "Coordinator" | "Router" | "EndDevice" | "Unknown" | "GreenPower";
38
-
39
- export type EntityType = DeviceType | "Group";
40
-
41
- export interface DatabaseEntry {
42
- id: number;
43
- type: EntityType;
44
- // biome-ignore lint/suspicious/noExplicitAny: API
45
- [s: string]: any;
46
- }
47
-
48
- export interface GreenPowerDeviceJoinedPayload {
49
- sourceID: number;
50
- deviceID: number;
51
- networkAddress: number;
52
- securityKey?: Buffer;
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;
package/src/index.ts DELETED
@@ -1,12 +0,0 @@
1
- /* v8 ignore start */
2
-
3
- export type * as AdapterEvents from "./adapter/events";
4
- export type * as AdapterTypes from "./adapter/tstype";
5
- export {Controller} from "./controller/controller";
6
- export type * as Events from "./controller/events";
7
- export type * as Models from "./controller/model";
8
- export type * as Types from "./controller/tstype";
9
- export {setLogger} from "./utils/logger";
10
- export * as ZSpec from "./zspec";
11
- export * as Zcl from "./zspec/zcl";
12
- export * as Zdo from "./zspec/zdo";
@@ -1,48 +0,0 @@
1
- import type {ZnpVersion} from "../adapter/z-stack/adapter/tstype";
2
- import type {NvSystemIds} from "../adapter/z-stack/constants/common";
3
-
4
- type LegacyNvItemKey =
5
- | "ZCD_NV_EXTADDR"
6
- | "ZCD_NV_NIB"
7
- | "ZCD_NV_PANID"
8
- | "ZCD_NV_EXTENDED_PAN_ID"
9
- | "ZCD_NV_NWK_ACTIVE_KEY_INFO"
10
- | "ZCD_NV_NWK_ALTERN_KEY_INFO"
11
- | "ZCD_NV_APS_USE_EXT_PANID"
12
- | "ZCD_NV_PRECFGKEY"
13
- | "ZCD_NV_PRECFGKEY_ENABLE"
14
- | "ZCD_NV_CHANLIST"
15
-
16
- /* Z-Stack 3.0.x tables */
17
- | "ZCD_NV_LEGACY_TCLK_TABLE_START"
18
- | "ZCD_NV_LEGACY_NWK_SEC_MATERIAL_TABLE_START"
19
-
20
- /* SimpleLink Z-Stack 3.x.0 tables */
21
- | "ZCD_NV_EX_TCLK_TABLE"
22
- | "ZCD_NV_EX_NWK_SEC_MATERIAL_TABLE";
23
-
24
- /**
25
- * Legacy backup format to allow for backup migration.
26
- */
27
- export interface LegacyBackupStorage {
28
- adapterType: "zStack";
29
- time: string;
30
- meta: {
31
- product: ZnpVersion;
32
- };
33
- data: Record<
34
- LegacyNvItemKey,
35
- {
36
- id: number;
37
- product: ZnpVersion;
38
- offset: number;
39
- osal: boolean;
40
- value: number[];
41
- len: number;
42
-
43
- /* System ID and Sub ID used in SimpleLink Z-Stack 3.x.0 */
44
- sysid?: NvSystemIds;
45
- subid?: number;
46
- }
47
- >;
48
- }
@@ -1,47 +0,0 @@
1
- /**
2
- * Unified configuration storage model based on
3
- * [zigpy/open-coordinator-backup](https://github.com/zigpy/open-coordinator-backup).
4
- *
5
- * This format should allow for seamless migration between adapter types or event vendors.
6
- */
7
- export interface UnifiedBackupStorage {
8
- metadata: {
9
- format: "zigpy/open-coordinator-backup";
10
- version: 1;
11
- source: string;
12
- internal: {
13
- /* zigbee-herdsman specific data */
14
- date: string;
15
- znpVersion?: number;
16
- ezspVersion?: number;
17
-
18
- [key: string]: unknown;
19
- };
20
- };
21
- stack_specific?: {
22
- zstack?: {
23
- tclk_seed?: string;
24
- };
25
- ezsp?: {
26
- hashed_tclk?: string;
27
- };
28
- };
29
- coordinator_ieee: string;
30
- pan_id: string;
31
- extended_pan_id: string;
32
- security_level: number;
33
- nwk_update_id: number;
34
- channel: number;
35
- channel_mask: number[];
36
- network_key: {
37
- key: string;
38
- sequence_number: number;
39
- frame_counter: number;
40
- };
41
- devices: {
42
- nwk_address: string | null;
43
- ieee_address: string;
44
- is_child: boolean;
45
- link_key: {key: string; rx_counter: number; tx_counter: number} | undefined;
46
- }[];
47
- }
@@ -1,37 +0,0 @@
1
- import type {ZnpVersion} from "../adapter/z-stack/adapter/tstype";
2
- import type {NetworkOptions} from "./network-options";
3
-
4
- /**
5
- * Internal representation of stored backup. Contains all essential network information.
6
- *
7
- * Additional `znp` object may contain extra information specific to Z-Stack based coordinators.
8
- */
9
- export interface Backup {
10
- networkOptions: NetworkOptions;
11
- logicalChannel: number;
12
- networkKeyInfo: {
13
- sequenceNumber: number;
14
- frameCounter: number;
15
- };
16
- securityLevel: number;
17
- networkUpdateId: number;
18
- coordinatorIeeeAddress: Buffer;
19
- devices: {
20
- networkAddress: number | null;
21
- ieeeAddress: Buffer;
22
- isDirectChild: boolean;
23
- linkKey?: {
24
- key: Buffer;
25
- rxCounter: number;
26
- txCounter: number;
27
- };
28
- }[];
29
- znp?: {
30
- version?: ZnpVersion;
31
- trustCenterLinkKeySeed?: Buffer;
32
- };
33
- ezsp?: {
34
- version?: number;
35
- hashed_tclk?: Buffer;
36
- };
37
- }
@@ -1,5 +0,0 @@
1
- /* v8 ignore start */
2
- export * from "./backup";
3
- export * from "./backup-storage-legacy";
4
- export * from "./backup-storage-unified";
5
- export * from "./network-options";
@@ -1,11 +0,0 @@
1
- /**
2
- * Buffer-oriented structure representing network configuration.
3
- */
4
- export interface NetworkOptions {
5
- panId: number;
6
- extendedPanId: Buffer;
7
- channelList: number[];
8
- networkKey: Buffer;
9
- networkKeyDistribute: boolean;
10
- hasDefaultExtendedPanId?: boolean;
11
- }
@@ -1,152 +0,0 @@
1
- import * as fs from "node:fs";
2
- import * as path from "node:path";
3
-
4
- import * as ZStackStructs from "../adapter/z-stack/structs";
5
- import * as ZStackUtils from "../adapter/z-stack/utils";
6
- import type * as Models from "../models";
7
-
8
- /**
9
- * Converts internal backup format to unified backup storage format as described by
10
- * [zigpy/open-coordinator-backup](https://github.com/zigpy/open-coordinator-backup).
11
- *
12
- * @param backup Backup to create unified backup format from.
13
- */
14
- export const toUnifiedBackup = (backup: Models.Backup): Models.UnifiedBackupStorage => {
15
- const packageInfo = JSON.parse(fs.readFileSync(path.join(__dirname, "../../", "package.json")).toString());
16
-
17
- return {
18
- metadata: {
19
- format: "zigpy/open-coordinator-backup",
20
- version: 1,
21
- source: `${packageInfo.name}@${packageInfo.version}`,
22
- internal: {
23
- date: new Date().toISOString(),
24
- ...(backup.znp ? {znpVersion: backup.znp?.version ?? undefined} : /* v8 ignore next */ undefined),
25
- ...(backup.ezsp ? {ezspVersion: backup.ezsp?.version ?? undefined} : /* v8 ignore next */ undefined),
26
- },
27
- },
28
- stack_specific: {
29
- /* v8 ignore next */
30
- ...(backup.znp ? {zstack: {tclk_seed: backup.znp?.trustCenterLinkKeySeed?.toString("hex") || undefined}} : undefined),
31
- ...(backup.ezsp ? {ezsp: {hashed_tclk: backup.ezsp?.hashed_tclk?.toString("hex") || undefined}} : /* v8 ignore next */ undefined),
32
- },
33
- coordinator_ieee: backup.coordinatorIeeeAddress.toString("hex"),
34
- pan_id: backup.networkOptions.panId.toString(16),
35
- extended_pan_id: backup.networkOptions.extendedPanId.toString("hex"),
36
- nwk_update_id: backup.networkUpdateId || 0,
37
- security_level: backup.securityLevel,
38
- channel: backup.logicalChannel,
39
- channel_mask: backup.networkOptions.channelList,
40
- network_key: {
41
- key: backup.networkOptions.networkKey.toString("hex"),
42
- sequence_number: backup.networkKeyInfo.sequenceNumber,
43
- frame_counter: backup.networkKeyInfo.frameCounter,
44
- },
45
- devices: backup.devices.map((device) => {
46
- return {
47
- nwk_address: device.networkAddress !== null ? device.networkAddress.toString(16) : /* v8 ignore next */ null,
48
- ieee_address: device.ieeeAddress.toString("hex"),
49
- is_child: device.isDirectChild,
50
- link_key: device.linkKey
51
- ? {key: device.linkKey.key.toString("hex"), rx_counter: device.linkKey.rxCounter, tx_counter: device.linkKey.txCounter}
52
- : undefined,
53
- };
54
- }),
55
- };
56
- };
57
-
58
- /**
59
- * Converts unified backup storage format to internal backup format.
60
- *
61
- * @param backup Unified format to convert to internal backup format.
62
- */
63
- export const fromUnifiedBackup = (backup: Models.UnifiedBackupStorage): Models.Backup => {
64
- const tclkSeedString = backup.stack_specific?.zstack?.tclk_seed || undefined;
65
-
66
- return {
67
- networkOptions: {
68
- panId: Number.parseInt(backup.pan_id, 16),
69
- extendedPanId: Buffer.from(backup.extended_pan_id, "hex"),
70
- channelList: backup.channel_mask,
71
- networkKey: Buffer.from(backup.network_key.key, "hex"),
72
- networkKeyDistribute: false,
73
- },
74
- logicalChannel: backup.channel,
75
- networkKeyInfo: {
76
- sequenceNumber: backup.network_key.sequence_number,
77
- frameCounter: backup.network_key.frame_counter,
78
- },
79
- coordinatorIeeeAddress: Buffer.from(backup.coordinator_ieee, "hex"),
80
- securityLevel: backup.security_level,
81
- networkUpdateId: backup.nwk_update_id,
82
- devices: backup.devices.map((device) => ({
83
- networkAddress: device.nwk_address ? Number.parseInt(device.nwk_address, 16) : null,
84
- ieeeAddress: Buffer.from(device.ieee_address, "hex"),
85
- isDirectChild: typeof device.is_child === "boolean" ? device.is_child : true,
86
- linkKey: device.link_key
87
- ? {key: Buffer.from(device.link_key.key, "hex"), rxCounter: device.link_key.rx_counter, txCounter: device.link_key.tx_counter}
88
- : undefined,
89
- })),
90
- znp: {
91
- version: backup.metadata.internal?.znpVersion || undefined,
92
- trustCenterLinkKeySeed: tclkSeedString ? Buffer.from(tclkSeedString, "hex") : undefined,
93
- },
94
- ezsp: {
95
- version: backup.metadata.internal?.ezspVersion || undefined,
96
- hashed_tclk: backup.stack_specific?.ezsp?.hashed_tclk ? Buffer.from(backup.stack_specific.ezsp.hashed_tclk, "hex") : undefined,
97
- },
98
- };
99
- };
100
-
101
- /**
102
- * Converts legacy Zigbee2MQTT format to internal backup format.
103
- *
104
- * @param backup Legacy format to convert.
105
- */
106
- export const fromLegacyBackup = (backup: Models.LegacyBackupStorage): Models.Backup => {
107
- if (!backup.data.ZCD_NV_NIB) {
108
- throw new Error("Backup corrupted - missing NIB");
109
- }
110
-
111
- if (!backup.data.ZCD_NV_NWK_ACTIVE_KEY_INFO) {
112
- throw new Error("Backup corrupted - missing active key info");
113
- }
114
-
115
- if (!backup.data.ZCD_NV_PRECFGKEY_ENABLE) {
116
- throw new Error("Backup corrupted - missing pre-configured key enable attribute");
117
- }
118
-
119
- if (!backup.data.ZCD_NV_EX_NWK_SEC_MATERIAL_TABLE && !backup.data.ZCD_NV_LEGACY_NWK_SEC_MATERIAL_TABLE_START) {
120
- throw new Error("Backup corrupted - missing network security material table");
121
- }
122
-
123
- if (!backup.data.ZCD_NV_EXTADDR) {
124
- throw new Error("Backup corrupted - missing adapter IEEE address NV entry");
125
- }
126
-
127
- const ieeeAddress = Buffer.from(backup.data.ZCD_NV_EXTADDR.value).reverse();
128
- const nib = ZStackStructs.nib(Buffer.from(backup.data.ZCD_NV_NIB.value));
129
- const activeKeyInfo = ZStackStructs.nwkKeyDescriptor(Buffer.from(backup.data.ZCD_NV_NWK_ACTIVE_KEY_INFO.value));
130
- const preconfiguredKeyEnabled = backup.data.ZCD_NV_PRECFGKEY_ENABLE.value[0] !== 0x00;
131
- const nwkSecMaterialSource = backup.data.ZCD_NV_EX_NWK_SEC_MATERIAL_TABLE || backup.data.ZCD_NV_LEGACY_NWK_SEC_MATERIAL_TABLE_START;
132
- const nwkSecMaterialEntry = ZStackStructs.nwkSecMaterialDescriptorEntry(Buffer.from(nwkSecMaterialSource.value));
133
-
134
- return {
135
- networkOptions: {
136
- panId: nib.nwkPanId,
137
- extendedPanId: nib.extendedPANID,
138
- channelList: ZStackUtils.unpackChannelList(nib.channelList),
139
- networkKey: activeKeyInfo.key,
140
- networkKeyDistribute: preconfiguredKeyEnabled,
141
- },
142
- logicalChannel: nib.nwkLogicalChannel,
143
- networkKeyInfo: {
144
- sequenceNumber: activeKeyInfo.keySeqNum,
145
- frameCounter: nwkSecMaterialEntry.FrameCounter,
146
- },
147
- coordinatorIeeeAddress: ieeeAddress,
148
- securityLevel: nib.SecurityLevel,
149
- networkUpdateId: nib.nwkUpdateId,
150
- devices: [],
151
- };
152
- };
@@ -1,5 +0,0 @@
1
- export * as BackupUtils from "./backup";
2
- export {Queue} from "./queue";
3
- export * as Utils from "./utils";
4
- export {wait} from "./wait";
5
- export {Waitress} from "./waitress";
@@ -1,20 +0,0 @@
1
- export interface Logger {
2
- debug: (messageOrLambda: string | (() => string), namespace: string) => void;
3
- info: (messageOrLambda: string | (() => string), namespace: string) => void;
4
- warning: (messageOrLambda: string | (() => string), namespace: string) => void;
5
- error: (messageOrLambda: string, namespace: string) => void;
6
- }
7
-
8
- export let logger: Logger = {
9
- debug: (messageOrLambda, namespace) =>
10
- console.debug(`[${new Date().toISOString()}] ${namespace}: ${typeof messageOrLambda === "function" ? messageOrLambda() : messageOrLambda}`),
11
- info: (messageOrLambda, namespace) =>
12
- console.info(`[${new Date().toISOString()}] ${namespace}: ${typeof messageOrLambda === "function" ? messageOrLambda() : messageOrLambda}`),
13
- warning: (messageOrLambda, namespace) =>
14
- console.warn(`[${new Date().toISOString()}] ${namespace}: ${typeof messageOrLambda === "function" ? messageOrLambda() : messageOrLambda}`),
15
- error: (message, namespace) => console.error(`[${new Date().toISOString()}] ${namespace}: ${message}`),
16
- };
17
-
18
- export function setLogger(l: Logger): void {
19
- logger = l;
20
- }
@@ -1,8 +0,0 @@
1
- // Patch BigInt serialization which is used in e.g. Zcl payloads.
2
- // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/BigInt#use_within_json
3
- // biome-ignore lint/suspicious/noExplicitAny: API
4
- (BigInt.prototype as any).toJSON = function (): string {
5
- return this.toString();
6
- };
7
-
8
- export {};