@willieee802/zigbee-herdsman 0.14.112 → 0.15.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.
Files changed (348) hide show
  1. package/.release-please-manifest.json +4 -0
  2. package/CHANGELOG.md +27 -0
  3. package/dist/adapter/adapter.d.ts +61 -61
  4. package/dist/adapter/adapter.d.ts.map +1 -1
  5. package/dist/adapter/adapter.js +146 -100
  6. package/dist/adapter/adapter.js.map +1 -1
  7. package/dist/adapter/deconz/adapter/deconzAdapter.d.ts +68 -68
  8. package/dist/adapter/deconz/adapter/deconzAdapter.d.ts.map +1 -1
  9. package/dist/adapter/deconz/adapter/deconzAdapter.js +1060 -1063
  10. package/dist/adapter/deconz/adapter/deconzAdapter.js.map +1 -1
  11. package/dist/adapter/deconz/adapter/index.d.ts +2 -2
  12. package/dist/adapter/deconz/adapter/index.js +10 -10
  13. package/dist/adapter/deconz/driver/constants.d.ts +104 -104
  14. package/dist/adapter/deconz/driver/constants.js +55 -55
  15. package/dist/adapter/deconz/driver/driver.d.ts +81 -81
  16. package/dist/adapter/deconz/driver/driver.js +732 -732
  17. package/dist/adapter/deconz/driver/frame.d.ts +6 -6
  18. package/dist/adapter/deconz/driver/frame.js +13 -13
  19. package/dist/adapter/deconz/driver/frameParser.d.ts +2 -2
  20. package/dist/adapter/deconz/driver/frameParser.js +443 -443
  21. package/dist/adapter/deconz/driver/parser.d.ts +12 -12
  22. package/dist/adapter/deconz/driver/parser.js +61 -61
  23. package/dist/adapter/deconz/driver/writer.d.ts +8 -8
  24. package/dist/adapter/deconz/driver/writer.js +44 -44
  25. package/dist/adapter/events.d.ts +47 -47
  26. package/dist/adapter/events.js +14 -14
  27. package/dist/adapter/ezsp/adapter/backup.d.ts +9 -9
  28. package/dist/adapter/ezsp/adapter/backup.js +53 -53
  29. package/dist/adapter/ezsp/adapter/ezspAdapter.d.ts +59 -59
  30. package/dist/adapter/ezsp/adapter/ezspAdapter.js +585 -585
  31. package/dist/adapter/ezsp/adapter/index.d.ts +2 -2
  32. package/dist/adapter/ezsp/adapter/index.js +10 -10
  33. package/dist/adapter/ezsp/driver/commands.d.ts +36 -34
  34. package/dist/adapter/ezsp/driver/commands.d.ts.map +1 -1
  35. package/dist/adapter/ezsp/driver/commands.js +2359 -2357
  36. package/dist/adapter/ezsp/driver/commands.js.map +1 -1
  37. package/dist/adapter/ezsp/driver/consts.d.ts +10 -10
  38. package/dist/adapter/ezsp/driver/consts.js +13 -13
  39. package/dist/adapter/ezsp/driver/driver.d.ts +103 -103
  40. package/dist/adapter/ezsp/driver/driver.js +639 -639
  41. package/dist/adapter/ezsp/driver/driver.js.map +1 -1
  42. package/dist/adapter/ezsp/driver/ezsp.d.ts +96 -96
  43. package/dist/adapter/ezsp/driver/ezsp.d.ts.map +1 -1
  44. package/dist/adapter/ezsp/driver/ezsp.js +586 -577
  45. package/dist/adapter/ezsp/driver/ezsp.js.map +1 -1
  46. package/dist/adapter/ezsp/driver/index.d.ts +3 -3
  47. package/dist/adapter/ezsp/driver/index.js +8 -8
  48. package/dist/adapter/ezsp/driver/multicast.d.ts +12 -12
  49. package/dist/adapter/ezsp/driver/multicast.js +74 -74
  50. package/dist/adapter/ezsp/driver/parser.d.ts +12 -12
  51. package/dist/adapter/ezsp/driver/parser.js +111 -111
  52. package/dist/adapter/ezsp/driver/types/basic.d.ts +62 -62
  53. package/dist/adapter/ezsp/driver/types/basic.js +208 -208
  54. package/dist/adapter/ezsp/driver/types/basic.js.map +1 -1
  55. package/dist/adapter/ezsp/driver/types/index.d.ts +9 -9
  56. package/dist/adapter/ezsp/driver/types/index.js +133 -133
  57. package/dist/adapter/ezsp/driver/types/named.d.ts +697 -697
  58. package/dist/adapter/ezsp/driver/types/named.js +1726 -1726
  59. package/dist/adapter/ezsp/driver/types/named.js.map +1 -1
  60. package/dist/adapter/ezsp/driver/types/struct.d.ts +251 -251
  61. package/dist/adapter/ezsp/driver/types/struct.js +708 -708
  62. package/dist/adapter/ezsp/driver/types/struct.js.map +1 -1
  63. package/dist/adapter/ezsp/driver/uart.d.ts +44 -44
  64. package/dist/adapter/ezsp/driver/uart.d.ts.map +1 -1
  65. package/dist/adapter/ezsp/driver/uart.js +368 -366
  66. package/dist/adapter/ezsp/driver/uart.js.map +1 -1
  67. package/dist/adapter/ezsp/driver/utils/crc16ccitt.d.ts +2 -2
  68. package/dist/adapter/ezsp/driver/utils/crc16ccitt.js +55 -55
  69. package/dist/adapter/ezsp/driver/utils/index.d.ts +18 -18
  70. package/dist/adapter/ezsp/driver/utils/index.js +67 -67
  71. package/dist/adapter/ezsp/driver/writer.d.ts +13 -13
  72. package/dist/adapter/ezsp/driver/writer.js +88 -88
  73. package/dist/adapter/index.d.ts +4 -4
  74. package/dist/adapter/index.js +35 -35
  75. package/dist/adapter/serialPort.d.ts +8 -8
  76. package/dist/adapter/serialPort.js +22 -22
  77. package/dist/adapter/serialPort.js.map +1 -1
  78. package/dist/adapter/serialPortUtils.d.ts +12 -12
  79. package/dist/adapter/serialPortUtils.js +18 -18
  80. package/dist/adapter/socketPortUtils.d.ts +10 -10
  81. package/dist/adapter/socketPortUtils.js +16 -16
  82. package/dist/adapter/tstype.d.ts +85 -85
  83. package/dist/adapter/tstype.js +2 -2
  84. package/dist/adapter/z-stack/adapter/adapter-backup.d.ts +62 -62
  85. package/dist/adapter/z-stack/adapter/adapter-backup.js +441 -441
  86. package/dist/adapter/z-stack/adapter/adapter-nv-memory.d.ts +150 -150
  87. package/dist/adapter/z-stack/adapter/adapter-nv-memory.js +258 -258
  88. package/dist/adapter/z-stack/adapter/endpoints.d.ts +11 -11
  89. package/dist/adapter/z-stack/adapter/endpoints.js +73 -73
  90. package/dist/adapter/z-stack/adapter/index.d.ts +2 -2
  91. package/dist/adapter/z-stack/adapter/index.js +8 -8
  92. package/dist/adapter/z-stack/adapter/manager.d.ts +86 -86
  93. package/dist/adapter/z-stack/adapter/manager.js +476 -476
  94. package/dist/adapter/z-stack/adapter/tstype.d.ts +6 -6
  95. package/dist/adapter/z-stack/adapter/tstype.js +10 -10
  96. package/dist/adapter/z-stack/adapter/zStackAdapter.d.ts +81 -81
  97. package/dist/adapter/z-stack/adapter/zStackAdapter.js +868 -868
  98. package/dist/adapter/z-stack/constants/af.d.ts +23 -23
  99. package/dist/adapter/z-stack/constants/af.js +27 -27
  100. package/dist/adapter/z-stack/constants/common.d.ts +278 -278
  101. package/dist/adapter/z-stack/constants/common.js +289 -289
  102. package/dist/adapter/z-stack/constants/dbg.d.ts +22 -22
  103. package/dist/adapter/z-stack/constants/dbg.js +24 -24
  104. package/dist/adapter/z-stack/constants/index.d.ts +10 -10
  105. package/dist/adapter/z-stack/constants/index.js +47 -47
  106. package/dist/adapter/z-stack/constants/mac.d.ts +127 -127
  107. package/dist/adapter/z-stack/constants/mac.js +129 -129
  108. package/dist/adapter/z-stack/constants/sapi.d.ts +24 -24
  109. package/dist/adapter/z-stack/constants/sapi.js +26 -26
  110. package/dist/adapter/z-stack/constants/sys.d.ts +71 -71
  111. package/dist/adapter/z-stack/constants/sys.js +73 -73
  112. package/dist/adapter/z-stack/constants/util.d.ts +81 -81
  113. package/dist/adapter/z-stack/constants/util.js +83 -83
  114. package/dist/adapter/z-stack/constants/utils.d.ts +4 -4
  115. package/dist/adapter/z-stack/constants/utils.js +14 -14
  116. package/dist/adapter/z-stack/constants/zdo.d.ts +102 -102
  117. package/dist/adapter/z-stack/constants/zdo.js +104 -104
  118. package/dist/adapter/z-stack/models/index.d.ts +1 -1
  119. package/dist/adapter/z-stack/models/index.js +17 -17
  120. package/dist/adapter/z-stack/models/startup-options.d.ts +12 -12
  121. package/dist/adapter/z-stack/models/startup-options.js +2 -2
  122. package/dist/adapter/z-stack/structs/entries/address-manager-entry.d.ts +23 -23
  123. package/dist/adapter/z-stack/structs/entries/address-manager-entry.js +45 -45
  124. package/dist/adapter/z-stack/structs/entries/address-manager-table.d.ts +10 -10
  125. package/dist/adapter/z-stack/structs/entries/address-manager-table.js +22 -22
  126. package/dist/adapter/z-stack/structs/entries/aps-link-key-data-entry.d.ts +10 -10
  127. package/dist/adapter/z-stack/structs/entries/aps-link-key-data-entry.js +21 -21
  128. package/dist/adapter/z-stack/structs/entries/aps-link-key-data-table.d.ts +10 -10
  129. package/dist/adapter/z-stack/structs/entries/aps-link-key-data-table.js +23 -23
  130. package/dist/adapter/z-stack/structs/entries/aps-tc-link-key-entry.d.ts +10 -10
  131. package/dist/adapter/z-stack/structs/entries/aps-tc-link-key-entry.js +24 -24
  132. package/dist/adapter/z-stack/structs/entries/aps-tc-link-key-table.d.ts +10 -10
  133. package/dist/adapter/z-stack/structs/entries/aps-tc-link-key-table.js +23 -23
  134. package/dist/adapter/z-stack/structs/entries/channel-list.d.ts +8 -8
  135. package/dist/adapter/z-stack/structs/entries/channel-list.js +15 -15
  136. package/dist/adapter/z-stack/structs/entries/has-configured.d.ts +8 -8
  137. package/dist/adapter/z-stack/structs/entries/has-configured.js +16 -16
  138. package/dist/adapter/z-stack/structs/entries/index.d.ts +16 -16
  139. package/dist/adapter/z-stack/structs/entries/index.js +32 -32
  140. package/dist/adapter/z-stack/structs/entries/nib.d.ts +10 -10
  141. package/dist/adapter/z-stack/structs/entries/nib.js +68 -68
  142. package/dist/adapter/z-stack/structs/entries/nwk-key-descriptor.d.ts +10 -10
  143. package/dist/adapter/z-stack/structs/entries/nwk-key-descriptor.js +18 -18
  144. package/dist/adapter/z-stack/structs/entries/nwk-key.d.ts +8 -8
  145. package/dist/adapter/z-stack/structs/entries/nwk-key.js +15 -15
  146. package/dist/adapter/z-stack/structs/entries/nwk-pan-id.d.ts +8 -8
  147. package/dist/adapter/z-stack/structs/entries/nwk-pan-id.js +15 -15
  148. package/dist/adapter/z-stack/structs/entries/nwk-sec-material-descriptor-entry.d.ts +13 -13
  149. package/dist/adapter/z-stack/structs/entries/nwk-sec-material-descriptor-entry.js +23 -23
  150. package/dist/adapter/z-stack/structs/entries/nwk-sec-material-descriptor-table.d.ts +10 -10
  151. package/dist/adapter/z-stack/structs/entries/nwk-sec-material-descriptor-table.js +22 -22
  152. package/dist/adapter/z-stack/structs/entries/security-manager-entry.d.ts +20 -20
  153. package/dist/adapter/z-stack/structs/entries/security-manager-entry.js +36 -36
  154. package/dist/adapter/z-stack/structs/entries/security-manager-table.d.ts +10 -10
  155. package/dist/adapter/z-stack/structs/entries/security-manager-table.js +24 -24
  156. package/dist/adapter/z-stack/structs/index.d.ts +4 -4
  157. package/dist/adapter/z-stack/structs/index.js +20 -20
  158. package/dist/adapter/z-stack/structs/serializable-memory-object.d.ts +13 -13
  159. package/dist/adapter/z-stack/structs/serializable-memory-object.js +2 -2
  160. package/dist/adapter/z-stack/structs/struct.d.ts +99 -99
  161. package/dist/adapter/z-stack/structs/struct.js +295 -295
  162. package/dist/adapter/z-stack/structs/table.d.ts +94 -94
  163. package/dist/adapter/z-stack/structs/table.js +161 -161
  164. package/dist/adapter/z-stack/unpi/constants.d.ts +28 -28
  165. package/dist/adapter/z-stack/unpi/constants.js +41 -41
  166. package/dist/adapter/z-stack/unpi/frame.d.ts +16 -16
  167. package/dist/adapter/z-stack/unpi/frame.js +48 -48
  168. package/dist/adapter/z-stack/unpi/index.d.ts +5 -5
  169. package/dist/adapter/z-stack/unpi/index.js +37 -37
  170. package/dist/adapter/z-stack/unpi/parser.d.ts +10 -10
  171. package/dist/adapter/z-stack/unpi/parser.js +74 -74
  172. package/dist/adapter/z-stack/unpi/writer.d.ts +10 -10
  173. package/dist/adapter/z-stack/unpi/writer.js +44 -44
  174. package/dist/adapter/z-stack/utils/channel-list.d.ts +20 -20
  175. package/dist/adapter/z-stack/utils/channel-list.js +40 -40
  176. package/dist/adapter/z-stack/utils/index.d.ts +2 -2
  177. package/dist/adapter/z-stack/utils/index.js +18 -18
  178. package/dist/adapter/z-stack/utils/network-options.d.ts +8 -8
  179. package/dist/adapter/z-stack/utils/network-options.js +22 -22
  180. package/dist/adapter/z-stack/znp/buffaloZnp.d.ts +11 -11
  181. package/dist/adapter/z-stack/znp/buffaloZnp.js +113 -113
  182. package/dist/adapter/z-stack/znp/definition.d.ts +5 -5
  183. package/dist/adapter/z-stack/znp/definition.js +3050 -3050
  184. package/dist/adapter/z-stack/znp/index.d.ts +3 -3
  185. package/dist/adapter/z-stack/znp/index.js +10 -10
  186. package/dist/adapter/z-stack/znp/parameterType.d.ts +22 -22
  187. package/dist/adapter/z-stack/znp/parameterType.js +25 -25
  188. package/dist/adapter/z-stack/znp/tstype.d.ts +21 -21
  189. package/dist/adapter/z-stack/znp/tstype.js +2 -2
  190. package/dist/adapter/z-stack/znp/znp.d.ts +43 -43
  191. package/dist/adapter/z-stack/znp/znp.js +325 -325
  192. package/dist/adapter/z-stack/znp/zpiObject.d.ts +19 -19
  193. package/dist/adapter/z-stack/znp/zpiObject.js +96 -96
  194. package/dist/adapter/zigate/adapter/index.d.ts +2 -2
  195. package/dist/adapter/zigate/adapter/index.js +10 -10
  196. package/dist/adapter/zigate/adapter/zigateAdapter.d.ts +69 -69
  197. package/dist/adapter/zigate/adapter/zigateAdapter.js +678 -678
  198. package/dist/adapter/zigate/debug.d.ts +7 -7
  199. package/dist/adapter/zigate/debug.js +22 -22
  200. package/dist/adapter/zigate/driver/buffaloZiGate.d.ts +18 -18
  201. package/dist/adapter/zigate/driver/buffaloZiGate.js +139 -139
  202. package/dist/adapter/zigate/driver/commandType.d.ts +41 -41
  203. package/dist/adapter/zigate/driver/commandType.js +385 -385
  204. package/dist/adapter/zigate/driver/constants.d.ts +276 -276
  205. package/dist/adapter/zigate/driver/constants.js +371 -371
  206. package/dist/adapter/zigate/driver/frame.d.ts +26 -26
  207. package/dist/adapter/zigate/driver/frame.js +172 -172
  208. package/dist/adapter/zigate/driver/frame.js.map +1 -1
  209. package/dist/adapter/zigate/driver/messageType.d.ts +11 -11
  210. package/dist/adapter/zigate/driver/messageType.js +278 -278
  211. package/dist/adapter/zigate/driver/parameterType.d.ts +20 -20
  212. package/dist/adapter/zigate/driver/parameterType.js +23 -23
  213. package/dist/adapter/zigate/driver/ziGateObject.d.ts +23 -23
  214. package/dist/adapter/zigate/driver/ziGateObject.js +106 -106
  215. package/dist/adapter/zigate/driver/zigate.d.ts +49 -49
  216. package/dist/adapter/zigate/driver/zigate.js +303 -303
  217. package/dist/buffalo/buffalo.d.ts +50 -48
  218. package/dist/buffalo/buffalo.d.ts.map +1 -1
  219. package/dist/buffalo/buffalo.js +322 -307
  220. package/dist/buffalo/buffalo.js.map +1 -1
  221. package/dist/buffalo/index.d.ts +3 -3
  222. package/dist/buffalo/index.js +33 -33
  223. package/dist/buffalo/tstype.d.ts +8 -8
  224. package/dist/buffalo/tstype.js +2 -2
  225. package/dist/controller/controller.d.ts +110 -110
  226. package/dist/controller/controller.js +607 -607
  227. package/dist/controller/database.d.ts +18 -18
  228. package/dist/controller/database.js +93 -93
  229. package/dist/controller/events.d.ts +55 -55
  230. package/dist/controller/events.d.ts.map +1 -1
  231. package/dist/controller/events.js +101 -99
  232. package/dist/controller/events.js.map +1 -1
  233. package/dist/controller/greenPower.d.ts +12 -12
  234. package/dist/controller/greenPower.js +220 -220
  235. package/dist/controller/helpers/index.d.ts +2 -2
  236. package/dist/controller/helpers/index.js +28 -28
  237. package/dist/controller/helpers/request.d.ts +23 -0
  238. package/dist/controller/helpers/request.d.ts.map +1 -0
  239. package/dist/controller/helpers/request.js +72 -0
  240. package/dist/controller/helpers/request.js.map +1 -0
  241. package/dist/controller/helpers/zclFrameConverter.d.ts +7 -7
  242. package/dist/controller/helpers/zclFrameConverter.js +31 -31
  243. package/dist/controller/helpers/zclTransactionSequenceNumber.d.ts +5 -5
  244. package/dist/controller/helpers/zclTransactionSequenceNumber.js +13 -13
  245. package/dist/controller/index.d.ts +5 -5
  246. package/dist/controller/index.js +8 -8
  247. package/dist/controller/logger-stub.d.ts +6 -6
  248. package/dist/controller/logger-stub.js +2 -2
  249. package/dist/controller/model/device.d.ts +132 -127
  250. package/dist/controller/model/device.d.ts.map +1 -1
  251. package/dist/controller/model/device.js +708 -681
  252. package/dist/controller/model/device.js.map +1 -1
  253. package/dist/controller/model/endpoint.d.ts +131 -128
  254. package/dist/controller/model/endpoint.d.ts.map +1 -1
  255. package/dist/controller/model/endpoint.js +817 -665
  256. package/dist/controller/model/endpoint.js.map +1 -1
  257. package/dist/controller/model/entity.d.ts +14 -14
  258. package/dist/controller/model/entity.js +26 -26
  259. package/dist/controller/model/group.d.ts +39 -39
  260. package/dist/controller/model/group.js +221 -221
  261. package/dist/controller/model/index.d.ts +5 -5
  262. package/dist/controller/model/index.js +14 -14
  263. package/dist/controller/touchlink.d.ts +19 -19
  264. package/dist/controller/touchlink.js +157 -157
  265. package/dist/controller/tstype.d.ts +21 -20
  266. package/dist/controller/tstype.d.ts.map +1 -1
  267. package/dist/controller/tstype.js +9 -9
  268. package/dist/controller/tstype.js.map +1 -1
  269. package/dist/index.d.ts +3 -3
  270. package/dist/index.js +33 -33
  271. package/dist/models/backup-storage-legacy.d.ts +26 -26
  272. package/dist/models/backup-storage-legacy.js +2 -2
  273. package/dist/models/backup-storage-unified.d.ts +49 -49
  274. package/dist/models/backup-storage-unified.js +2 -2
  275. package/dist/models/backup.d.ts +37 -37
  276. package/dist/models/backup.js +2 -2
  277. package/dist/models/index.d.ts +4 -4
  278. package/dist/models/index.js +20 -20
  279. package/dist/models/network-options.d.ts +12 -12
  280. package/dist/models/network-options.js +2 -2
  281. package/dist/utils/assertString.d.ts +2 -2
  282. package/dist/utils/assertString.js +8 -8
  283. package/dist/utils/backup.d.ts +20 -20
  284. package/dist/utils/backup.js +187 -187
  285. package/dist/utils/equalsPartial.d.ts +2 -2
  286. package/dist/utils/equalsPartial.js +11 -11
  287. package/dist/utils/index.d.ts +9 -9
  288. package/dist/utils/index.js +45 -45
  289. package/dist/utils/isNumberArray.d.ts +2 -2
  290. package/dist/utils/isNumberArray.js +6 -6
  291. package/dist/utils/queue.d.ts +11 -11
  292. package/dist/utils/queue.js +50 -50
  293. package/dist/utils/realpathSync.d.ts +2 -2
  294. package/dist/utils/realpathSync.js +12 -12
  295. package/dist/utils/wait.d.ts +2 -2
  296. package/dist/utils/wait.js +8 -8
  297. package/dist/utils/waitress.d.ts +21 -21
  298. package/dist/utils/waitress.js +61 -61
  299. package/dist/zcl/buffaloZcl.d.ts +41 -41
  300. package/dist/zcl/buffaloZcl.js +591 -591
  301. package/dist/zcl/definition/buffaloZclDataType.d.ts +17 -17
  302. package/dist/zcl/definition/buffaloZclDataType.js +20 -20
  303. package/dist/zcl/definition/cluster.d.ts +29 -29
  304. package/dist/zcl/definition/cluster.d.ts.map +1 -1
  305. package/dist/zcl/definition/cluster.js +5335 -5215
  306. package/dist/zcl/definition/cluster.js.map +1 -1
  307. package/dist/zcl/definition/dataType.d.ts +59 -59
  308. package/dist/zcl/definition/dataType.d.ts.map +1 -1
  309. package/dist/zcl/definition/dataType.js +64 -64
  310. package/dist/zcl/definition/dataType.js.map +1 -1
  311. package/dist/zcl/definition/direction.d.ts +5 -5
  312. package/dist/zcl/definition/direction.js +8 -8
  313. package/dist/zcl/definition/endpointDeviceType.d.ts +4 -4
  314. package/dist/zcl/definition/endpointDeviceType.js +15 -15
  315. package/dist/zcl/definition/foundation.d.ts +11 -11
  316. package/dist/zcl/definition/foundation.js +167 -167
  317. package/dist/zcl/definition/frameControl.d.ts +10 -10
  318. package/dist/zcl/definition/frameControl.js +2 -2
  319. package/dist/zcl/definition/frameType.d.ts +5 -5
  320. package/dist/zcl/definition/frameType.js +8 -8
  321. package/dist/zcl/definition/index.d.ts +13 -13
  322. package/dist/zcl/definition/index.js +51 -51
  323. package/dist/zcl/definition/manufacturerCode.d.ts +1074 -1074
  324. package/dist/zcl/definition/manufacturerCode.js +1079 -1079
  325. package/dist/zcl/definition/powerSource.d.ts +4 -4
  326. package/dist/zcl/definition/powerSource.js +12 -12
  327. package/dist/zcl/definition/status.d.ts +38 -38
  328. package/dist/zcl/definition/status.js +41 -41
  329. package/dist/zcl/definition/tstype.d.ts +16 -16
  330. package/dist/zcl/definition/tstype.js +2 -2
  331. package/dist/zcl/index.d.ts +15 -15
  332. package/dist/zcl/index.js +55 -55
  333. package/dist/zcl/tstype.d.ts +56 -56
  334. package/dist/zcl/tstype.js +10 -10
  335. package/dist/zcl/utils.d.ts +6 -6
  336. package/dist/zcl/utils.js +165 -165
  337. package/dist/zcl/zclFrame.d.ts +45 -45
  338. package/dist/zcl/zclFrame.js +347 -347
  339. package/dist/zcl/zclStatusError.d.ts +5 -5
  340. package/dist/zcl/zclStatusError.js +13 -13
  341. package/package.json +6 -5
  342. package/release-please-config.json +13 -0
  343. package/.github/ISSUE_TEMPLATE/config.yml +0 -5
  344. package/.github/dependabot.yml +0 -6
  345. package/.github/workflows/ci.yml +0 -31
  346. package/.github/workflows/release.yml +0 -56
  347. package/.github/workflows/stale.yml +0 -19
  348. package/.github/workflows/update_deps.yml +0 -24
@@ -1,592 +1,592 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
- var __importDefault = (this && this.__importDefault) || function (mod) {
26
- return (mod && mod.__esModule) ? mod : { "default": mod };
27
- };
28
- Object.defineProperty(exports, "__esModule", { value: true });
29
- const buffalo_1 = require("../buffalo");
30
- const definition_1 = require("./definition");
31
- const tstype_1 = require("./tstype");
32
- const Utils = __importStar(require("./utils"));
33
- const debug_1 = __importDefault(require("debug"));
34
- const debug = {
35
- info: (0, debug_1.default)('zigbee-herdsman:controller:buffaloZcl'),
36
- error: (0, debug_1.default)('zigbee-herdsman:controller:buffaloZcl'),
37
- };
38
- const aliases = {
39
- 'boolean': 'uint8',
40
- 'bitmap8': 'uint8',
41
- 'enum8': 'uint8',
42
- 'data8': 'uint8',
43
- 'data16': 'uint16',
44
- 'bitmap16': 'uint16',
45
- 'uint16': 'uint16',
46
- 'enum16': 'uint16',
47
- 'clusterId': 'uint16',
48
- 'attrId': 'uint16',
49
- 'data24': 'uint24',
50
- 'bitmap24': 'uint24',
51
- 'data32': 'uint32',
52
- 'bitmap32': 'uint32',
53
- 'uint32': 'uint32',
54
- 'tod': 'uint32',
55
- 'date': 'uint32',
56
- 'utc': 'uint32',
57
- 'bacOid': 'uint32',
58
- 'singlePrec': 'floatle',
59
- 'doublePrec': 'doublele',
60
- 'bitmap40': 'uint40',
61
- 'data40': 'uint40',
62
- 'bitmap48': 'uint48',
63
- 'data48': 'uint48',
64
- 'bitmap56': 'uint56',
65
- 'data56': 'uint56',
66
- 'bitmap64': 'uint64',
67
- 'data64': 'uint64',
68
- 'ieeeAddr': 'uint64',
69
- 'longOctetStr': 'longCharStr',
70
- 'secKey': 'buffer16',
71
- 'noData': 'EMPTY',
72
- 'unknown': 'EMPTY',
73
- 'bag': 'array',
74
- 'set': 'array',
75
- };
76
- const extensionFieldSetsDateTypeLookup = {
77
- 6: ['uint8'],
78
- 8: ['uint8'],
79
- 258: ['uint8', 'unit8'],
80
- 768: ['uint16', 'uint16', 'uint16', 'uint8', 'uint8', 'uint8', 'uint16', 'uint16'],
81
- };
82
- class BuffaloZcl extends buffalo_1.Buffalo {
83
- readUseDataType(options) {
84
- return this.read(options.dataType, options);
85
- }
86
- writeUseDataType(value, options) {
87
- this.write(options.dataType, value, options);
88
- }
89
- readArray() {
90
- const values = [];
91
- const elementType = definition_1.DataType[this.readUInt8()];
92
- const numberOfElements = this.readUInt16();
93
- for (let i = 0; i < numberOfElements; i++) {
94
- const value = this.read(elementType, {});
95
- values.push(value);
96
- }
97
- return values;
98
- }
99
- writeArray(value) {
100
- const elTypeNumeric = typeof value.elementType === 'number' ? value.elementType : definition_1.DataType[value.elementType];
101
- this.writeUInt8(elTypeNumeric);
102
- this.writeUInt16(value.elements.length);
103
- value.elements.forEach(element => {
104
- this.write(definition_1.DataType[elTypeNumeric], element, {});
105
- });
106
- }
107
- readStruct() {
108
- const values = [];
109
- const numberOfElements = this.readUInt16();
110
- for (let i = 0; i < numberOfElements; i++) {
111
- const elementType = this.readUInt8();
112
- const value = this.read(definition_1.DataType[elementType], {});
113
- values.push({ elmType: elementType, elmVal: value });
114
- }
115
- return values;
116
- }
117
- readOctetStr() {
118
- const length = this.readUInt8();
119
- return this.readBuffer(length);
120
- }
121
- readCharStr(options) {
122
- const length = this.readUInt8();
123
- if (options.attrId === 65281) {
124
- const value = {};
125
- // Xiaomi struct parsing
126
- for (let i = 0; i < length; i++) {
127
- const index = this.readUInt8();
128
- const dataType = definition_1.DataType[this.readUInt8()];
129
- value[index] = this.read(dataType, {});
130
- if (this.position === this.buffer.length) {
131
- break;
132
- }
133
- }
134
- return value;
135
- }
136
- else {
137
- return this.readUtf8String(length);
138
- }
139
- }
140
- writeCharStr(value) {
141
- if (typeof value === 'string') {
142
- this.writeUInt8(value.length);
143
- this.writeUtf8String(value);
144
- }
145
- else {
146
- this.writeBuffer(value, value.length);
147
- }
148
- }
149
- readLongCharStr() {
150
- const length = this.readUInt16();
151
- return this.readUtf8String(length);
152
- }
153
- writeLongCharStr(value) {
154
- this.writeUInt16(value.length);
155
- this.writeUtf8String(value);
156
- }
157
- writeOctetStr(value) {
158
- this.writeUInt8(value.length);
159
- this.writeBuffer(value, value.length);
160
- }
161
- readExtensionFieldSets() {
162
- const value = [];
163
- while (this.isMore()) {
164
- const clstId = this.readUInt16();
165
- const len = this.readUInt8();
166
- const end = this.getPosition() + len;
167
- let index = 0;
168
- const extField = [];
169
- while (this.getPosition() < end) {
170
- extField.push(this.read(extensionFieldSetsDateTypeLookup[clstId][index], null));
171
- index++;
172
- }
173
- value.push({ extField, clstId, len });
174
- }
175
- return value;
176
- }
177
- writeExtensionFieldSets(values) {
178
- for (const value of values) {
179
- this.writeUInt16(value.clstId);
180
- this.writeUInt8(value.len);
181
- value.extField.forEach((entry, index) => {
182
- this.write(extensionFieldSetsDateTypeLookup[value.clstId][index], entry, null);
183
- });
184
- }
185
- }
186
- writeListZoneInfo(values) {
187
- for (const value of values) {
188
- this.writeUInt8(value.zoneID);
189
- this.writeUInt16(value.zoneStatus);
190
- }
191
- }
192
- readListZoneInfo(options) {
193
- const value = [];
194
- for (let i = 0; i < options.length; i++) {
195
- value.push({
196
- zoneID: this.readUInt8(),
197
- zoneStatus: this.readUInt16(),
198
- });
199
- }
200
- return value;
201
- }
202
- readListThermoTransitions(options) {
203
- const heat = options.payload['mode'] & 1;
204
- const cool = options.payload['mode'] & 2;
205
- const result = [];
206
- for (let i = 0; i < options.payload.numoftrans; i++) {
207
- const entry = {
208
- transitionTime: this.readUInt16()
209
- };
210
- if (heat) {
211
- entry.heatSetpoint = this.readUInt16();
212
- }
213
- if (cool) {
214
- entry.coolSetpoint = this.readUInt16();
215
- }
216
- result.push(entry);
217
- }
218
- return result;
219
- }
220
- writeListThermoTransitions(value) {
221
- for (const entry of value) {
222
- this.writeUInt16(entry.transitionTime);
223
- if (entry.hasOwnProperty('heatSetpoint')) {
224
- this.writeUInt16(entry.heatSetpoint);
225
- }
226
- if (entry.hasOwnProperty('coolSetpoint')) {
227
- this.writeUInt16(entry.coolSetpoint);
228
- }
229
- }
230
- }
231
- readGdpFrame(options) {
232
- // Commisioning
233
- if (options.payload.commandID === 0xE0) {
234
- const frame = {
235
- deviceID: this.readUInt8(),
236
- options: this.readUInt8(),
237
- extendedOptions: 0,
238
- securityKey: Buffer.alloc(16),
239
- keyMic: 0,
240
- outgoingCounter: 0,
241
- applicationInfo: 0,
242
- manufacturerID: 0,
243
- modelID: 0,
244
- numGdpCommands: 0,
245
- gpdCommandIdList: Buffer.alloc(0),
246
- numServerClusters: 0,
247
- numClientClusters: 0,
248
- gpdServerClusters: Buffer.alloc(0),
249
- gpdClientClusters: Buffer.alloc(0),
250
- };
251
- if (frame.options & 0x80) {
252
- frame.extendedOptions = this.readUInt8();
253
- }
254
- if (frame.extendedOptions & 0x20) {
255
- frame.securityKey = this.readBuffer(16);
256
- }
257
- if (frame.extendedOptions & 0x40) {
258
- frame.keyMic = this.readUInt32();
259
- }
260
- if (frame.extendedOptions & 0x80) {
261
- frame.outgoingCounter = this.readUInt32();
262
- }
263
- if (frame.options & 0x04) {
264
- frame.applicationInfo = this.readUInt8();
265
- }
266
- if (frame.applicationInfo & 0x01) {
267
- frame.manufacturerID = this.readUInt16();
268
- }
269
- if (frame.applicationInfo & 0x02) {
270
- frame.modelID = this.readUInt16();
271
- }
272
- if (frame.applicationInfo & 0x04) {
273
- frame.numGdpCommands = this.readUInt8();
274
- frame.gpdCommandIdList = this.readBuffer(frame.numGdpCommands);
275
- }
276
- if (frame.applicationInfo & 0x08) {
277
- const len = this.readUInt8();
278
- frame.numServerClusters = len & 0xF;
279
- frame.numClientClusters = (len >> 4) & 0xF;
280
- frame.gpdServerClusters = this.readBuffer(2 * frame.numServerClusters);
281
- frame.gpdClientClusters = this.readBuffer(2 * frame.numClientClusters);
282
- }
283
- return frame;
284
- // Channel Request
285
- }
286
- else if (options.payload.commandID === 0xE3) {
287
- const options = this.readUInt8();
288
- return {
289
- nextChannel: options & 0xF,
290
- nextNextChannel: options >> 4
291
- };
292
- // Manufacturer-specific Attribute Reporting
293
- }
294
- else if (options.payload.commandID == 0xA1) {
295
- const start = this.position;
296
- const frame = {
297
- manufacturerCode: this.readUInt16(),
298
- clusterID: this.readUInt16(),
299
- attributes: {},
300
- };
301
- const cluster = Utils.getCluster(frame.clusterID, frame.manufacturerCode);
302
- while (this.position - start < options.payload.payloadSize) {
303
- const attributeID = this.readUInt16();
304
- const type = this.readUInt8();
305
- let attribute = attributeID;
306
- try {
307
- attribute = cluster.getAttribute(attributeID).name;
308
- }
309
- catch (_a) {
310
- debug.info("Unknown attribute " + attributeID + " in cluster " + cluster.name);
311
- }
312
- frame.attributes[attribute] = this.read(definition_1.DataType[type], options);
313
- }
314
- return frame;
315
- }
316
- else if (this.position != this.buffer.length) {
317
- return { raw: this.buffer.slice(this.position) };
318
- }
319
- else {
320
- return {};
321
- }
322
- }
323
- writeGdpFrame(value) {
324
- if (value.commandID == 0xF0) { // Commissioning Reply
325
- const v = value;
326
- const panIDPresent = v.options & (1 << 0);
327
- const gpdSecurityKeyPresent = v.options & (1 << 1);
328
- const gpdKeyEncryption = v.options & (1 << 2);
329
- const securityLevel = v.options & (3 << 3) >> 3;
330
- const hasGPDKeyMIC = gpdKeyEncryption && gpdSecurityKeyPresent;
331
- const hasFrameCounter = gpdSecurityKeyPresent &&
332
- gpdKeyEncryption &&
333
- (securityLevel === 0b10 || securityLevel === 0b11);
334
- this.writeUInt8(1 +
335
- (panIDPresent ? 2 : 0) +
336
- (gpdSecurityKeyPresent ? 16 : 0) +
337
- (hasGPDKeyMIC ? 4 : 0) +
338
- (hasFrameCounter ? 4 : 0)); // Length
339
- this.writeUInt8(v.options);
340
- if (panIDPresent) {
341
- this.writeUInt16(v.panID);
342
- }
343
- if (gpdSecurityKeyPresent) {
344
- this.writeBuffer(v.securityKey, 16);
345
- }
346
- if (hasGPDKeyMIC) {
347
- this.writeUInt32(v.keyMic);
348
- }
349
- if (hasFrameCounter) {
350
- this.writeUInt32(v.frameCounter);
351
- }
352
- }
353
- else if (value.commandID == 0xF3) { // Channel configuration
354
- const v = value;
355
- this.writeUInt8(1);
356
- this.writeUInt8(v.operationalChannel & 0xF | ((v.basic ? 1 : 0) << 4));
357
- }
358
- else if (value.commandID == 0xF4 ||
359
- value.commandID == 0xF5 ||
360
- (value.commandID >= 0xF7 && value.commandID <= 0xFF)) {
361
- // Other commands sent to GPD
362
- const v = value;
363
- this.writeUInt8(v.buffer.length);
364
- this.writeBuffer(v.buffer, v.buffer.length);
365
- }
366
- }
367
- readListTuyaDataPointValues() {
368
- const value = [];
369
- while (this.isMore()) {
370
- try {
371
- const dp = this.readUInt8();
372
- const datatype = this.readUInt8();
373
- const len_hi = this.readUInt8();
374
- const len_lo = this.readUInt8();
375
- const data = this.readBuffer(len_lo + (len_hi << 8));
376
- value.push({ dp, datatype, data });
377
- }
378
- catch (error) {
379
- break;
380
- }
381
- }
382
- return value;
383
- }
384
- writeListTuyaDataPointValues(dpValues) {
385
- for (const dpValue of dpValues) {
386
- this.writeUInt8(dpValue.dp);
387
- this.writeUInt8(dpValue.datatype);
388
- const dataLen = dpValue.data.length;
389
- this.writeUInt8((dataLen >> 8) & 0xFF);
390
- this.writeUInt8(dataLen & 0xFF);
391
- this.writeBuffer(dpValue.data, dataLen);
392
- }
393
- }
394
- readListMiboxerZones() {
395
- const value = [];
396
- const len = this.readUInt8();
397
- for (let i = 0; i < len; i++) {
398
- value.push({
399
- groupId: this.readUInt16(),
400
- zoneNum: this.readUInt8(),
401
- });
402
- }
403
- return value;
404
- }
405
- readBigEndianUInt24() {
406
- return this.readBuffer(3).readUIntBE(0, 3);
407
- }
408
- writeListMiboxerZones(values) {
409
- this.writeUInt8(values.length);
410
- for (const value of values) {
411
- this.writeUInt16(value.groupId);
412
- this.writeUInt8(value.zoneNum);
413
- }
414
- }
415
- writeBigEndianUInt24(value) {
416
- const buffer = Buffer.alloc(3);
417
- buffer.writeUIntLE(value, 0, 3);
418
- this.writeBuffer(buffer.reverse(), 3);
419
- }
420
- readUInt40() {
421
- const lsb = this.readUInt32();
422
- const msb = this.readUInt8();
423
- return [msb, lsb];
424
- }
425
- writeUInt40(value) {
426
- this.writeUInt32(value[1]);
427
- this.writeUInt8(value[0]);
428
- }
429
- readUInt48() {
430
- const lsb = this.readUInt32();
431
- const msb = this.readUInt16();
432
- return [msb, lsb];
433
- }
434
- writeUInt48(value) {
435
- this.writeUInt32(value[1]);
436
- this.writeUInt16(value[0]);
437
- }
438
- readUInt56() {
439
- const lsb = this.readUInt32();
440
- const xsb = this.readUInt16();
441
- const msb = this.readUInt8();
442
- return [msb, xsb, lsb];
443
- }
444
- writeUInt56(value) {
445
- const temp = Buffer.alloc(8);
446
- temp.writeUInt32LE(value[1], 0);
447
- temp.writeUInt32LE(value[0], 4);
448
- this.writeBuffer(temp.slice(0, 7), 7);
449
- }
450
- readUInt64() {
451
- return this.readIeeeAddr();
452
- }
453
- writeUInt64(value) {
454
- const msb = parseInt(value.slice(2, 10), 16);
455
- const lsb = parseInt(value.slice(10), 16);
456
- this.writeUInt32(lsb);
457
- this.writeUInt32(msb);
458
- }
459
- writeStructuredSelector(value) {
460
- if (value != null) {
461
- const indexes = value.indexes || [];
462
- const indicatorType = value.indicatorType || tstype_1.StructuredIndicatorType.WriteWhole;
463
- const indicator = indexes.length + indicatorType;
464
- this.writeUInt8(indicator);
465
- for (const index of indexes) {
466
- this.writeUInt16(index);
467
- }
468
- }
469
- }
470
- write(type, value, options) {
471
- // TODO: write for the following is missing: struct
472
- type = aliases[type] || type;
473
- if (type === 'uint40') {
474
- return this.writeUInt40(value);
475
- }
476
- else if (type === 'EXTENSION_FIELD_SETS') {
477
- return this.writeExtensionFieldSets(value);
478
- }
479
- else if (type === 'LIST_ZONEINFO') {
480
- return this.writeListZoneInfo(value);
481
- }
482
- else if (type === 'LIST_THERMO_TRANSITIONS') {
483
- return this.writeListThermoTransitions(value);
484
- }
485
- else if (type === 'LIST_TUYA_DATAPOINT_VALUES') {
486
- return this.writeListTuyaDataPointValues(value);
487
- }
488
- else if (type === 'LIST_MIBOXER_ZONES') {
489
- return this.writeListMiboxerZones(value);
490
- }
491
- else if (type === 'BIG_ENDIAN_UINT24') {
492
- return this.writeBigEndianUInt24(value);
493
- }
494
- else if (type === 'GDP_FRAME') {
495
- return this.writeGdpFrame(value);
496
- }
497
- else if (type === 'uint48') {
498
- return this.writeUInt48(value);
499
- }
500
- else if (type === 'uint56') {
501
- return this.writeUInt56(value);
502
- }
503
- else if (type === 'uint64') {
504
- return this.writeUInt64(value);
505
- }
506
- else if (type === 'charStr') {
507
- return this.writeCharStr(value);
508
- }
509
- else if (type === 'longCharStr') {
510
- return this.writeLongCharStr(value);
511
- }
512
- else if (type === 'octetStr') {
513
- return this.writeOctetStr(value);
514
- }
515
- else if (type === 'array') {
516
- return this.writeArray(value);
517
- }
518
- else if (type === 'USE_DATA_TYPE') {
519
- return this.writeUseDataType(value, options);
520
- }
521
- else if (type == 'STRUCTURED_SELECTOR') {
522
- return this.writeStructuredSelector(value);
523
- }
524
- else {
525
- // In case the type is undefined, write it as a buffer to easily allow for custom types
526
- // e.g. for https://github.com/Koenkk/zigbee-herdsman/issues/127
527
- type = type === undefined ? 'BUFFER' : type;
528
- // TODO: remove uppercase once dataTypes are snake case
529
- return super.write(type.toUpperCase(), value, options);
530
- }
531
- }
532
- read(type, options) {
533
- type = aliases[type] || type;
534
- if (type === 'USE_DATA_TYPE') {
535
- return this.readUseDataType(options);
536
- }
537
- else if (type === 'EXTENSION_FIELD_SETS') {
538
- return this.readExtensionFieldSets();
539
- }
540
- else if (type === 'LIST_ZONEINFO') {
541
- return this.readListZoneInfo(options);
542
- }
543
- else if (type === 'LIST_THERMO_TRANSITIONS') {
544
- return this.readListThermoTransitions(options);
545
- }
546
- else if (type === 'GDP_FRAME') {
547
- return this.readGdpFrame(options);
548
- }
549
- else if (type === 'LIST_TUYA_DATAPOINT_VALUES') {
550
- return this.readListTuyaDataPointValues();
551
- }
552
- else if (type === 'LIST_MIBOXER_ZONES') {
553
- return this.readListMiboxerZones();
554
- }
555
- else if (type === 'BIG_ENDIAN_UINT24') {
556
- return this.readBigEndianUInt24();
557
- }
558
- else if (type === 'uint40') {
559
- return this.readUInt40();
560
- }
561
- else if (type === 'uint48') {
562
- return this.readUInt48();
563
- }
564
- else if (type === 'uint56') {
565
- return this.readUInt56();
566
- }
567
- else if (type === 'uint64') {
568
- return this.readUInt64();
569
- }
570
- else if (type === 'octetStr') {
571
- return this.readOctetStr();
572
- }
573
- else if (type === 'charStr') {
574
- return this.readCharStr(options);
575
- }
576
- else if (type === 'longCharStr') {
577
- return this.readLongCharStr();
578
- }
579
- else if (type === 'array') {
580
- return this.readArray();
581
- }
582
- else if (type === 'struct') {
583
- return this.readStruct();
584
- }
585
- else {
586
- // TODO: remove uppercase once dataTypes are snake case
587
- return super.read(type.toUpperCase(), options);
588
- }
589
- }
590
- }
591
- exports.default = BuffaloZcl;
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ var __importDefault = (this && this.__importDefault) || function (mod) {
26
+ return (mod && mod.__esModule) ? mod : { "default": mod };
27
+ };
28
+ Object.defineProperty(exports, "__esModule", { value: true });
29
+ const buffalo_1 = require("../buffalo");
30
+ const definition_1 = require("./definition");
31
+ const tstype_1 = require("./tstype");
32
+ const Utils = __importStar(require("./utils"));
33
+ const debug_1 = __importDefault(require("debug"));
34
+ const debug = {
35
+ info: (0, debug_1.default)('zigbee-herdsman:controller:buffaloZcl'),
36
+ error: (0, debug_1.default)('zigbee-herdsman:controller:buffaloZcl'),
37
+ };
38
+ const aliases = {
39
+ 'boolean': 'uint8',
40
+ 'bitmap8': 'uint8',
41
+ 'enum8': 'uint8',
42
+ 'data8': 'uint8',
43
+ 'data16': 'uint16',
44
+ 'bitmap16': 'uint16',
45
+ 'uint16': 'uint16',
46
+ 'enum16': 'uint16',
47
+ 'clusterId': 'uint16',
48
+ 'attrId': 'uint16',
49
+ 'data24': 'uint24',
50
+ 'bitmap24': 'uint24',
51
+ 'data32': 'uint32',
52
+ 'bitmap32': 'uint32',
53
+ 'uint32': 'uint32',
54
+ 'tod': 'uint32',
55
+ 'date': 'uint32',
56
+ 'utc': 'uint32',
57
+ 'bacOid': 'uint32',
58
+ 'singlePrec': 'floatle',
59
+ 'doublePrec': 'doublele',
60
+ 'bitmap40': 'uint40',
61
+ 'data40': 'uint40',
62
+ 'bitmap48': 'uint48',
63
+ 'data48': 'uint48',
64
+ 'bitmap56': 'uint56',
65
+ 'data56': 'uint56',
66
+ 'bitmap64': 'uint64',
67
+ 'data64': 'uint64',
68
+ 'ieeeAddr': 'uint64',
69
+ 'longOctetStr': 'longCharStr',
70
+ 'secKey': 'buffer16',
71
+ 'noData': 'EMPTY',
72
+ 'unknown': 'EMPTY',
73
+ 'bag': 'array',
74
+ 'set': 'array',
75
+ };
76
+ const extensionFieldSetsDateTypeLookup = {
77
+ 6: ['uint8'],
78
+ 8: ['uint8'],
79
+ 258: ['uint8', 'unit8'],
80
+ 768: ['uint16', 'uint16', 'uint16', 'uint8', 'uint8', 'uint8', 'uint16', 'uint16'],
81
+ };
82
+ class BuffaloZcl extends buffalo_1.Buffalo {
83
+ readUseDataType(options) {
84
+ return this.read(options.dataType, options);
85
+ }
86
+ writeUseDataType(value, options) {
87
+ this.write(options.dataType, value, options);
88
+ }
89
+ readArray() {
90
+ const values = [];
91
+ const elementType = definition_1.DataType[this.readUInt8()];
92
+ const numberOfElements = this.readUInt16();
93
+ for (let i = 0; i < numberOfElements; i++) {
94
+ const value = this.read(elementType, {});
95
+ values.push(value);
96
+ }
97
+ return values;
98
+ }
99
+ writeArray(value) {
100
+ const elTypeNumeric = typeof value.elementType === 'number' ? value.elementType : definition_1.DataType[value.elementType];
101
+ this.writeUInt8(elTypeNumeric);
102
+ this.writeUInt16(value.elements.length);
103
+ value.elements.forEach(element => {
104
+ this.write(definition_1.DataType[elTypeNumeric], element, {});
105
+ });
106
+ }
107
+ readStruct() {
108
+ const values = [];
109
+ const numberOfElements = this.readUInt16();
110
+ for (let i = 0; i < numberOfElements; i++) {
111
+ const elementType = this.readUInt8();
112
+ const value = this.read(definition_1.DataType[elementType], {});
113
+ values.push({ elmType: elementType, elmVal: value });
114
+ }
115
+ return values;
116
+ }
117
+ readOctetStr() {
118
+ const length = this.readUInt8();
119
+ return this.readBuffer(length);
120
+ }
121
+ readCharStr(options) {
122
+ const length = this.readUInt8();
123
+ if (options.attrId === 65281) {
124
+ const value = {};
125
+ // Xiaomi struct parsing
126
+ for (let i = 0; i < length; i++) {
127
+ const index = this.readUInt8();
128
+ const dataType = definition_1.DataType[this.readUInt8()];
129
+ value[index] = this.read(dataType, {});
130
+ if (this.position === this.buffer.length) {
131
+ break;
132
+ }
133
+ }
134
+ return value;
135
+ }
136
+ else {
137
+ return this.readUtf8String(length);
138
+ }
139
+ }
140
+ writeCharStr(value) {
141
+ if (typeof value === 'string') {
142
+ this.writeUInt8(value.length);
143
+ this.writeUtf8String(value);
144
+ }
145
+ else {
146
+ this.writeBuffer(value, value.length);
147
+ }
148
+ }
149
+ readLongCharStr() {
150
+ const length = this.readUInt16();
151
+ return this.readUtf8String(length);
152
+ }
153
+ writeLongCharStr(value) {
154
+ this.writeUInt16(value.length);
155
+ this.writeUtf8String(value);
156
+ }
157
+ writeOctetStr(value) {
158
+ this.writeUInt8(value.length);
159
+ this.writeBuffer(value, value.length);
160
+ }
161
+ readExtensionFieldSets() {
162
+ const value = [];
163
+ while (this.isMore()) {
164
+ const clstId = this.readUInt16();
165
+ const len = this.readUInt8();
166
+ const end = this.getPosition() + len;
167
+ let index = 0;
168
+ const extField = [];
169
+ while (this.getPosition() < end) {
170
+ extField.push(this.read(extensionFieldSetsDateTypeLookup[clstId][index], null));
171
+ index++;
172
+ }
173
+ value.push({ extField, clstId, len });
174
+ }
175
+ return value;
176
+ }
177
+ writeExtensionFieldSets(values) {
178
+ for (const value of values) {
179
+ this.writeUInt16(value.clstId);
180
+ this.writeUInt8(value.len);
181
+ value.extField.forEach((entry, index) => {
182
+ this.write(extensionFieldSetsDateTypeLookup[value.clstId][index], entry, null);
183
+ });
184
+ }
185
+ }
186
+ writeListZoneInfo(values) {
187
+ for (const value of values) {
188
+ this.writeUInt8(value.zoneID);
189
+ this.writeUInt16(value.zoneStatus);
190
+ }
191
+ }
192
+ readListZoneInfo(options) {
193
+ const value = [];
194
+ for (let i = 0; i < options.length; i++) {
195
+ value.push({
196
+ zoneID: this.readUInt8(),
197
+ zoneStatus: this.readUInt16(),
198
+ });
199
+ }
200
+ return value;
201
+ }
202
+ readListThermoTransitions(options) {
203
+ const heat = options.payload['mode'] & 1;
204
+ const cool = options.payload['mode'] & 2;
205
+ const result = [];
206
+ for (let i = 0; i < options.payload.numoftrans; i++) {
207
+ const entry = {
208
+ transitionTime: this.readUInt16()
209
+ };
210
+ if (heat) {
211
+ entry.heatSetpoint = this.readUInt16();
212
+ }
213
+ if (cool) {
214
+ entry.coolSetpoint = this.readUInt16();
215
+ }
216
+ result.push(entry);
217
+ }
218
+ return result;
219
+ }
220
+ writeListThermoTransitions(value) {
221
+ for (const entry of value) {
222
+ this.writeUInt16(entry.transitionTime);
223
+ if (entry.hasOwnProperty('heatSetpoint')) {
224
+ this.writeUInt16(entry.heatSetpoint);
225
+ }
226
+ if (entry.hasOwnProperty('coolSetpoint')) {
227
+ this.writeUInt16(entry.coolSetpoint);
228
+ }
229
+ }
230
+ }
231
+ readGdpFrame(options) {
232
+ // Commisioning
233
+ if (options.payload.commandID === 0xE0) {
234
+ const frame = {
235
+ deviceID: this.readUInt8(),
236
+ options: this.readUInt8(),
237
+ extendedOptions: 0,
238
+ securityKey: Buffer.alloc(16),
239
+ keyMic: 0,
240
+ outgoingCounter: 0,
241
+ applicationInfo: 0,
242
+ manufacturerID: 0,
243
+ modelID: 0,
244
+ numGdpCommands: 0,
245
+ gpdCommandIdList: Buffer.alloc(0),
246
+ numServerClusters: 0,
247
+ numClientClusters: 0,
248
+ gpdServerClusters: Buffer.alloc(0),
249
+ gpdClientClusters: Buffer.alloc(0),
250
+ };
251
+ if (frame.options & 0x80) {
252
+ frame.extendedOptions = this.readUInt8();
253
+ }
254
+ if (frame.extendedOptions & 0x20) {
255
+ frame.securityKey = this.readBuffer(16);
256
+ }
257
+ if (frame.extendedOptions & 0x40) {
258
+ frame.keyMic = this.readUInt32();
259
+ }
260
+ if (frame.extendedOptions & 0x80) {
261
+ frame.outgoingCounter = this.readUInt32();
262
+ }
263
+ if (frame.options & 0x04) {
264
+ frame.applicationInfo = this.readUInt8();
265
+ }
266
+ if (frame.applicationInfo & 0x01) {
267
+ frame.manufacturerID = this.readUInt16();
268
+ }
269
+ if (frame.applicationInfo & 0x02) {
270
+ frame.modelID = this.readUInt16();
271
+ }
272
+ if (frame.applicationInfo & 0x04) {
273
+ frame.numGdpCommands = this.readUInt8();
274
+ frame.gpdCommandIdList = this.readBuffer(frame.numGdpCommands);
275
+ }
276
+ if (frame.applicationInfo & 0x08) {
277
+ const len = this.readUInt8();
278
+ frame.numServerClusters = len & 0xF;
279
+ frame.numClientClusters = (len >> 4) & 0xF;
280
+ frame.gpdServerClusters = this.readBuffer(2 * frame.numServerClusters);
281
+ frame.gpdClientClusters = this.readBuffer(2 * frame.numClientClusters);
282
+ }
283
+ return frame;
284
+ // Channel Request
285
+ }
286
+ else if (options.payload.commandID === 0xE3) {
287
+ const options = this.readUInt8();
288
+ return {
289
+ nextChannel: options & 0xF,
290
+ nextNextChannel: options >> 4
291
+ };
292
+ // Manufacturer-specific Attribute Reporting
293
+ }
294
+ else if (options.payload.commandID == 0xA1) {
295
+ const start = this.position;
296
+ const frame = {
297
+ manufacturerCode: this.readUInt16(),
298
+ clusterID: this.readUInt16(),
299
+ attributes: {},
300
+ };
301
+ const cluster = Utils.getCluster(frame.clusterID, frame.manufacturerCode);
302
+ while (this.position - start < options.payload.payloadSize) {
303
+ const attributeID = this.readUInt16();
304
+ const type = this.readUInt8();
305
+ let attribute = attributeID;
306
+ try {
307
+ attribute = cluster.getAttribute(attributeID).name;
308
+ }
309
+ catch (_a) {
310
+ debug.info("Unknown attribute " + attributeID + " in cluster " + cluster.name);
311
+ }
312
+ frame.attributes[attribute] = this.read(definition_1.DataType[type], options);
313
+ }
314
+ return frame;
315
+ }
316
+ else if (this.position != this.buffer.length) {
317
+ return { raw: this.buffer.slice(this.position) };
318
+ }
319
+ else {
320
+ return {};
321
+ }
322
+ }
323
+ writeGdpFrame(value) {
324
+ if (value.commandID == 0xF0) { // Commissioning Reply
325
+ const v = value;
326
+ const panIDPresent = v.options & (1 << 0);
327
+ const gpdSecurityKeyPresent = v.options & (1 << 1);
328
+ const gpdKeyEncryption = v.options & (1 << 2);
329
+ const securityLevel = v.options & (3 << 3) >> 3;
330
+ const hasGPDKeyMIC = gpdKeyEncryption && gpdSecurityKeyPresent;
331
+ const hasFrameCounter = gpdSecurityKeyPresent &&
332
+ gpdKeyEncryption &&
333
+ (securityLevel === 0b10 || securityLevel === 0b11);
334
+ this.writeUInt8(1 +
335
+ (panIDPresent ? 2 : 0) +
336
+ (gpdSecurityKeyPresent ? 16 : 0) +
337
+ (hasGPDKeyMIC ? 4 : 0) +
338
+ (hasFrameCounter ? 4 : 0)); // Length
339
+ this.writeUInt8(v.options);
340
+ if (panIDPresent) {
341
+ this.writeUInt16(v.panID);
342
+ }
343
+ if (gpdSecurityKeyPresent) {
344
+ this.writeBuffer(v.securityKey, 16);
345
+ }
346
+ if (hasGPDKeyMIC) {
347
+ this.writeUInt32(v.keyMic);
348
+ }
349
+ if (hasFrameCounter) {
350
+ this.writeUInt32(v.frameCounter);
351
+ }
352
+ }
353
+ else if (value.commandID == 0xF3) { // Channel configuration
354
+ const v = value;
355
+ this.writeUInt8(1);
356
+ this.writeUInt8(v.operationalChannel & 0xF | ((v.basic ? 1 : 0) << 4));
357
+ }
358
+ else if (value.commandID == 0xF4 ||
359
+ value.commandID == 0xF5 ||
360
+ (value.commandID >= 0xF7 && value.commandID <= 0xFF)) {
361
+ // Other commands sent to GPD
362
+ const v = value;
363
+ this.writeUInt8(v.buffer.length);
364
+ this.writeBuffer(v.buffer, v.buffer.length);
365
+ }
366
+ }
367
+ readListTuyaDataPointValues() {
368
+ const value = [];
369
+ while (this.isMore()) {
370
+ try {
371
+ const dp = this.readUInt8();
372
+ const datatype = this.readUInt8();
373
+ const len_hi = this.readUInt8();
374
+ const len_lo = this.readUInt8();
375
+ const data = this.readBuffer(len_lo + (len_hi << 8));
376
+ value.push({ dp, datatype, data });
377
+ }
378
+ catch (error) {
379
+ break;
380
+ }
381
+ }
382
+ return value;
383
+ }
384
+ writeListTuyaDataPointValues(dpValues) {
385
+ for (const dpValue of dpValues) {
386
+ this.writeUInt8(dpValue.dp);
387
+ this.writeUInt8(dpValue.datatype);
388
+ const dataLen = dpValue.data.length;
389
+ this.writeUInt8((dataLen >> 8) & 0xFF);
390
+ this.writeUInt8(dataLen & 0xFF);
391
+ this.writeBuffer(dpValue.data, dataLen);
392
+ }
393
+ }
394
+ readListMiboxerZones() {
395
+ const value = [];
396
+ const len = this.readUInt8();
397
+ for (let i = 0; i < len; i++) {
398
+ value.push({
399
+ groupId: this.readUInt16(),
400
+ zoneNum: this.readUInt8(),
401
+ });
402
+ }
403
+ return value;
404
+ }
405
+ readBigEndianUInt24() {
406
+ return this.readBuffer(3).readUIntBE(0, 3);
407
+ }
408
+ writeListMiboxerZones(values) {
409
+ this.writeUInt8(values.length);
410
+ for (const value of values) {
411
+ this.writeUInt16(value.groupId);
412
+ this.writeUInt8(value.zoneNum);
413
+ }
414
+ }
415
+ writeBigEndianUInt24(value) {
416
+ const buffer = Buffer.alloc(3);
417
+ buffer.writeUIntLE(value, 0, 3);
418
+ this.writeBuffer(buffer.reverse(), 3);
419
+ }
420
+ readUInt40() {
421
+ const lsb = this.readUInt32();
422
+ const msb = this.readUInt8();
423
+ return [msb, lsb];
424
+ }
425
+ writeUInt40(value) {
426
+ this.writeUInt32(value[1]);
427
+ this.writeUInt8(value[0]);
428
+ }
429
+ readUInt48() {
430
+ const lsb = this.readUInt32();
431
+ const msb = this.readUInt16();
432
+ return [msb, lsb];
433
+ }
434
+ writeUInt48(value) {
435
+ this.writeUInt32(value[1]);
436
+ this.writeUInt16(value[0]);
437
+ }
438
+ readUInt56() {
439
+ const lsb = this.readUInt32();
440
+ const xsb = this.readUInt16();
441
+ const msb = this.readUInt8();
442
+ return [msb, xsb, lsb];
443
+ }
444
+ writeUInt56(value) {
445
+ const temp = Buffer.alloc(8);
446
+ temp.writeUInt32LE(value[1], 0);
447
+ temp.writeUInt32LE(value[0], 4);
448
+ this.writeBuffer(temp.slice(0, 7), 7);
449
+ }
450
+ readUInt64() {
451
+ return this.readIeeeAddr();
452
+ }
453
+ writeUInt64(value) {
454
+ const msb = parseInt(value.slice(2, 10), 16);
455
+ const lsb = parseInt(value.slice(10), 16);
456
+ this.writeUInt32(lsb);
457
+ this.writeUInt32(msb);
458
+ }
459
+ writeStructuredSelector(value) {
460
+ if (value != null) {
461
+ const indexes = value.indexes || [];
462
+ const indicatorType = value.indicatorType || tstype_1.StructuredIndicatorType.WriteWhole;
463
+ const indicator = indexes.length + indicatorType;
464
+ this.writeUInt8(indicator);
465
+ for (const index of indexes) {
466
+ this.writeUInt16(index);
467
+ }
468
+ }
469
+ }
470
+ write(type, value, options) {
471
+ // TODO: write for the following is missing: struct
472
+ type = aliases[type] || type;
473
+ if (type === 'uint40') {
474
+ return this.writeUInt40(value);
475
+ }
476
+ else if (type === 'EXTENSION_FIELD_SETS') {
477
+ return this.writeExtensionFieldSets(value);
478
+ }
479
+ else if (type === 'LIST_ZONEINFO') {
480
+ return this.writeListZoneInfo(value);
481
+ }
482
+ else if (type === 'LIST_THERMO_TRANSITIONS') {
483
+ return this.writeListThermoTransitions(value);
484
+ }
485
+ else if (type === 'LIST_TUYA_DATAPOINT_VALUES') {
486
+ return this.writeListTuyaDataPointValues(value);
487
+ }
488
+ else if (type === 'LIST_MIBOXER_ZONES') {
489
+ return this.writeListMiboxerZones(value);
490
+ }
491
+ else if (type === 'BIG_ENDIAN_UINT24') {
492
+ return this.writeBigEndianUInt24(value);
493
+ }
494
+ else if (type === 'GDP_FRAME') {
495
+ return this.writeGdpFrame(value);
496
+ }
497
+ else if (type === 'uint48') {
498
+ return this.writeUInt48(value);
499
+ }
500
+ else if (type === 'uint56') {
501
+ return this.writeUInt56(value);
502
+ }
503
+ else if (type === 'uint64') {
504
+ return this.writeUInt64(value);
505
+ }
506
+ else if (type === 'charStr') {
507
+ return this.writeCharStr(value);
508
+ }
509
+ else if (type === 'longCharStr') {
510
+ return this.writeLongCharStr(value);
511
+ }
512
+ else if (type === 'octetStr') {
513
+ return this.writeOctetStr(value);
514
+ }
515
+ else if (type === 'array') {
516
+ return this.writeArray(value);
517
+ }
518
+ else if (type === 'USE_DATA_TYPE') {
519
+ return this.writeUseDataType(value, options);
520
+ }
521
+ else if (type == 'STRUCTURED_SELECTOR') {
522
+ return this.writeStructuredSelector(value);
523
+ }
524
+ else {
525
+ // In case the type is undefined, write it as a buffer to easily allow for custom types
526
+ // e.g. for https://github.com/Koenkk/zigbee-herdsman/issues/127
527
+ type = type === undefined ? 'BUFFER' : type;
528
+ // TODO: remove uppercase once dataTypes are snake case
529
+ return super.write(type.toUpperCase(), value, options);
530
+ }
531
+ }
532
+ read(type, options) {
533
+ type = aliases[type] || type;
534
+ if (type === 'USE_DATA_TYPE') {
535
+ return this.readUseDataType(options);
536
+ }
537
+ else if (type === 'EXTENSION_FIELD_SETS') {
538
+ return this.readExtensionFieldSets();
539
+ }
540
+ else if (type === 'LIST_ZONEINFO') {
541
+ return this.readListZoneInfo(options);
542
+ }
543
+ else if (type === 'LIST_THERMO_TRANSITIONS') {
544
+ return this.readListThermoTransitions(options);
545
+ }
546
+ else if (type === 'GDP_FRAME') {
547
+ return this.readGdpFrame(options);
548
+ }
549
+ else if (type === 'LIST_TUYA_DATAPOINT_VALUES') {
550
+ return this.readListTuyaDataPointValues();
551
+ }
552
+ else if (type === 'LIST_MIBOXER_ZONES') {
553
+ return this.readListMiboxerZones();
554
+ }
555
+ else if (type === 'BIG_ENDIAN_UINT24') {
556
+ return this.readBigEndianUInt24();
557
+ }
558
+ else if (type === 'uint40') {
559
+ return this.readUInt40();
560
+ }
561
+ else if (type === 'uint48') {
562
+ return this.readUInt48();
563
+ }
564
+ else if (type === 'uint56') {
565
+ return this.readUInt56();
566
+ }
567
+ else if (type === 'uint64') {
568
+ return this.readUInt64();
569
+ }
570
+ else if (type === 'octetStr') {
571
+ return this.readOctetStr();
572
+ }
573
+ else if (type === 'charStr') {
574
+ return this.readCharStr(options);
575
+ }
576
+ else if (type === 'longCharStr') {
577
+ return this.readLongCharStr();
578
+ }
579
+ else if (type === 'array') {
580
+ return this.readArray();
581
+ }
582
+ else if (type === 'struct') {
583
+ return this.readStruct();
584
+ }
585
+ else {
586
+ // TODO: remove uppercase once dataTypes are snake case
587
+ return super.read(type.toUpperCase(), options);
588
+ }
589
+ }
590
+ }
591
+ exports.default = BuffaloZcl;
592
592
  //# sourceMappingURL=buffaloZcl.js.map