zigbee-herdsman 3.5.1 → 4.0.0

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 (726) hide show
  1. package/.github/dependabot.yml +9 -3
  2. package/.github/workflows/ci.yml +2 -4
  3. package/.github/workflows/stale.yml +1 -1
  4. package/.release-please-manifest.json +1 -1
  5. package/.vscode/extensions.json +3 -0
  6. package/.vscode/settings.json +11 -0
  7. package/CHANGELOG.md +25 -0
  8. package/biome.json +89 -0
  9. package/dist/adapter/adapter.d.ts +11 -11
  10. package/dist/adapter/adapter.d.ts.map +1 -1
  11. package/dist/adapter/adapter.js +14 -14
  12. package/dist/adapter/adapterDiscovery.d.ts +6 -6
  13. package/dist/adapter/adapterDiscovery.d.ts.map +1 -1
  14. package/dist/adapter/adapterDiscovery.js +139 -141
  15. package/dist/adapter/adapterDiscovery.js.map +1 -1
  16. package/dist/adapter/const.d.ts +1 -1
  17. package/dist/adapter/const.js +2 -2
  18. package/dist/adapter/deconz/adapter/deconzAdapter.d.ts +16 -16
  19. package/dist/adapter/deconz/adapter/deconzAdapter.d.ts.map +1 -1
  20. package/dist/adapter/deconz/adapter/deconzAdapter.js +95 -100
  21. package/dist/adapter/deconz/adapter/deconzAdapter.js.map +1 -1
  22. package/dist/adapter/deconz/driver/constants.d.ts +5 -5
  23. package/dist/adapter/deconz/driver/constants.d.ts.map +1 -1
  24. package/dist/adapter/deconz/driver/driver.d.ts +9 -9
  25. package/dist/adapter/deconz/driver/driver.d.ts.map +1 -1
  26. package/dist/adapter/deconz/driver/driver.js +112 -106
  27. package/dist/adapter/deconz/driver/driver.js.map +1 -1
  28. package/dist/adapter/deconz/driver/frame.d.ts +1 -1
  29. package/dist/adapter/deconz/driver/frame.d.ts.map +1 -1
  30. package/dist/adapter/deconz/driver/frame.js +1 -2
  31. package/dist/adapter/deconz/driver/frame.js.map +1 -1
  32. package/dist/adapter/deconz/driver/frameParser.d.ts +1 -1
  33. package/dist/adapter/deconz/driver/frameParser.d.ts.map +1 -1
  34. package/dist/adapter/deconz/driver/frameParser.js +66 -70
  35. package/dist/adapter/deconz/driver/frameParser.js.map +1 -1
  36. package/dist/adapter/deconz/driver/parser.d.ts +1 -1
  37. package/dist/adapter/deconz/driver/parser.d.ts.map +1 -1
  38. package/dist/adapter/deconz/driver/parser.js +2 -2
  39. package/dist/adapter/deconz/driver/parser.js.map +1 -1
  40. package/dist/adapter/deconz/driver/writer.d.ts +2 -2
  41. package/dist/adapter/deconz/driver/writer.d.ts.map +1 -1
  42. package/dist/adapter/deconz/driver/writer.js +1 -1
  43. package/dist/adapter/ember/adapter/emberAdapter.d.ts +19 -19
  44. package/dist/adapter/ember/adapter/emberAdapter.d.ts.map +1 -1
  45. package/dist/adapter/ember/adapter/emberAdapter.js +117 -97
  46. package/dist/adapter/ember/adapter/emberAdapter.js.map +1 -1
  47. package/dist/adapter/ember/adapter/endpoints.d.ts +1 -1
  48. package/dist/adapter/ember/adapter/endpoints.d.ts.map +1 -1
  49. package/dist/adapter/ember/adapter/oneWaitress.d.ts +5 -5
  50. package/dist/adapter/ember/adapter/oneWaitress.d.ts.map +1 -1
  51. package/dist/adapter/ember/adapter/oneWaitress.js +2 -2
  52. package/dist/adapter/ember/adapter/oneWaitress.js.map +1 -1
  53. package/dist/adapter/ember/adapter/tokensManager.d.ts +3 -3
  54. package/dist/adapter/ember/adapter/tokensManager.d.ts.map +1 -1
  55. package/dist/adapter/ember/adapter/tokensManager.js +20 -23
  56. package/dist/adapter/ember/adapter/tokensManager.js.map +1 -1
  57. package/dist/adapter/ember/enums.d.ts +4 -4
  58. package/dist/adapter/ember/enums.d.ts.map +1 -1
  59. package/dist/adapter/ember/enums.js +4 -6
  60. package/dist/adapter/ember/enums.js.map +1 -1
  61. package/dist/adapter/ember/ezsp/buffalo.d.ts +4 -4
  62. package/dist/adapter/ember/ezsp/buffalo.d.ts.map +1 -1
  63. package/dist/adapter/ember/ezsp/buffalo.js +30 -32
  64. package/dist/adapter/ember/ezsp/buffalo.js.map +1 -1
  65. package/dist/adapter/ember/ezsp/ezsp.d.ts +46 -46
  66. package/dist/adapter/ember/ezsp/ezsp.d.ts.map +1 -1
  67. package/dist/adapter/ember/ezsp/ezsp.js +85 -111
  68. package/dist/adapter/ember/ezsp/ezsp.js.map +1 -1
  69. package/dist/adapter/ember/ezspError.d.ts +1 -1
  70. package/dist/adapter/ember/types.d.ts +14 -14
  71. package/dist/adapter/ember/types.d.ts.map +1 -1
  72. package/dist/adapter/ember/uart/ash.d.ts +5 -5
  73. package/dist/adapter/ember/uart/ash.d.ts.map +1 -1
  74. package/dist/adapter/ember/uart/ash.js +80 -71
  75. package/dist/adapter/ember/uart/ash.js.map +1 -1
  76. package/dist/adapter/ember/uart/parser.d.ts +2 -2
  77. package/dist/adapter/ember/uart/parser.d.ts.map +1 -1
  78. package/dist/adapter/ember/uart/parser.js +2 -1
  79. package/dist/adapter/ember/uart/parser.js.map +1 -1
  80. package/dist/adapter/ember/uart/queues.js +27 -29
  81. package/dist/adapter/ember/uart/queues.js.map +1 -1
  82. package/dist/adapter/ember/uart/writer.d.ts +1 -1
  83. package/dist/adapter/ember/uart/writer.d.ts.map +1 -1
  84. package/dist/adapter/ember/uart/writer.js +3 -5
  85. package/dist/adapter/ember/uart/writer.js.map +1 -1
  86. package/dist/adapter/ember/utils/initters.d.ts +2 -2
  87. package/dist/adapter/ember/utils/initters.d.ts.map +1 -1
  88. package/dist/adapter/ember/utils/initters.js +1 -1
  89. package/dist/adapter/ember/utils/math.js +1 -1
  90. package/dist/adapter/events.d.ts +1 -1
  91. package/dist/adapter/events.d.ts.map +1 -1
  92. package/dist/adapter/ezsp/adapter/backup.d.ts +3 -3
  93. package/dist/adapter/ezsp/adapter/backup.d.ts.map +1 -1
  94. package/dist/adapter/ezsp/adapter/backup.js +8 -10
  95. package/dist/adapter/ezsp/adapter/backup.js.map +1 -1
  96. package/dist/adapter/ezsp/adapter/ezspAdapter.d.ts +12 -12
  97. package/dist/adapter/ezsp/adapter/ezspAdapter.d.ts.map +1 -1
  98. package/dist/adapter/ezsp/adapter/ezspAdapter.js +45 -44
  99. package/dist/adapter/ezsp/adapter/ezspAdapter.js.map +1 -1
  100. package/dist/adapter/ezsp/driver/driver.d.ts +12 -12
  101. package/dist/adapter/ezsp/driver/driver.d.ts.map +1 -1
  102. package/dist/adapter/ezsp/driver/driver.js +148 -141
  103. package/dist/adapter/ezsp/driver/driver.js.map +1 -1
  104. package/dist/adapter/ezsp/driver/ezsp.d.ts +7 -7
  105. package/dist/adapter/ezsp/driver/ezsp.d.ts.map +1 -1
  106. package/dist/adapter/ezsp/driver/ezsp.js +61 -59
  107. package/dist/adapter/ezsp/driver/ezsp.js.map +1 -1
  108. package/dist/adapter/ezsp/driver/frame.js +2 -2
  109. package/dist/adapter/ezsp/driver/index.d.ts +2 -2
  110. package/dist/adapter/ezsp/driver/multicast.d.ts +8 -5
  111. package/dist/adapter/ezsp/driver/multicast.d.ts.map +1 -1
  112. package/dist/adapter/ezsp/driver/multicast.js +9 -9
  113. package/dist/adapter/ezsp/driver/multicast.js.map +1 -1
  114. package/dist/adapter/ezsp/driver/parser.d.ts +1 -1
  115. package/dist/adapter/ezsp/driver/parser.js +3 -3
  116. package/dist/adapter/ezsp/driver/types/basic.d.ts +5 -5
  117. package/dist/adapter/ezsp/driver/types/basic.d.ts.map +1 -1
  118. package/dist/adapter/ezsp/driver/types/basic.js +12 -33
  119. package/dist/adapter/ezsp/driver/types/basic.js.map +1 -1
  120. package/dist/adapter/ezsp/driver/types/index.d.ts +3 -3
  121. package/dist/adapter/ezsp/driver/types/index.d.ts.map +1 -1
  122. package/dist/adapter/ezsp/driver/types/index.js +8 -9
  123. package/dist/adapter/ezsp/driver/types/index.js.map +1 -1
  124. package/dist/adapter/ezsp/driver/types/named.d.ts +2 -2
  125. package/dist/adapter/ezsp/driver/types/named.d.ts.map +1 -1
  126. package/dist/adapter/ezsp/driver/types/named.js +8 -11
  127. package/dist/adapter/ezsp/driver/types/named.js.map +1 -1
  128. package/dist/adapter/ezsp/driver/types/struct.d.ts +2 -2
  129. package/dist/adapter/ezsp/driver/types/struct.d.ts.map +1 -1
  130. package/dist/adapter/ezsp/driver/types/struct.js +207 -214
  131. package/dist/adapter/ezsp/driver/types/struct.js.map +1 -1
  132. package/dist/adapter/ezsp/driver/uart.d.ts +2 -2
  133. package/dist/adapter/ezsp/driver/uart.d.ts.map +1 -1
  134. package/dist/adapter/ezsp/driver/uart.js +48 -37
  135. package/dist/adapter/ezsp/driver/uart.js.map +1 -1
  136. package/dist/adapter/ezsp/driver/utils/crc16ccitt.d.ts +3 -3
  137. package/dist/adapter/ezsp/driver/utils/crc16ccitt.d.ts.map +1 -1
  138. package/dist/adapter/ezsp/driver/utils/crc16ccitt.js +16 -34
  139. package/dist/adapter/ezsp/driver/utils/crc16ccitt.js.map +1 -1
  140. package/dist/adapter/ezsp/driver/utils/index.d.ts +4 -4
  141. package/dist/adapter/ezsp/driver/utils/index.d.ts.map +1 -1
  142. package/dist/adapter/ezsp/driver/utils/index.js +4 -4
  143. package/dist/adapter/ezsp/driver/utils/index.js.map +1 -1
  144. package/dist/adapter/ezsp/driver/writer.d.ts +1 -1
  145. package/dist/adapter/ezsp/driver/writer.js +2 -2
  146. package/dist/adapter/index.d.ts +3 -3
  147. package/dist/adapter/serialPort.d.ts +3 -3
  148. package/dist/adapter/serialPort.d.ts.map +1 -1
  149. package/dist/adapter/serialPort.js +1 -0
  150. package/dist/adapter/serialPort.js.map +1 -1
  151. package/dist/adapter/socketPortUtils.js +3 -3
  152. package/dist/adapter/tstype.d.ts +6 -6
  153. package/dist/adapter/z-stack/adapter/adapter-backup.d.ts +4 -4
  154. package/dist/adapter/z-stack/adapter/adapter-backup.d.ts.map +1 -1
  155. package/dist/adapter/z-stack/adapter/adapter-backup.js +106 -119
  156. package/dist/adapter/z-stack/adapter/adapter-backup.js.map +1 -1
  157. package/dist/adapter/z-stack/adapter/adapter-nv-memory.d.ts +10 -10
  158. package/dist/adapter/z-stack/adapter/adapter-nv-memory.d.ts.map +1 -1
  159. package/dist/adapter/z-stack/adapter/adapter-nv-memory.js +23 -24
  160. package/dist/adapter/z-stack/adapter/adapter-nv-memory.js.map +1 -1
  161. package/dist/adapter/z-stack/adapter/manager.d.ts +6 -6
  162. package/dist/adapter/z-stack/adapter/manager.d.ts.map +1 -1
  163. package/dist/adapter/z-stack/adapter/manager.js +115 -127
  164. package/dist/adapter/z-stack/adapter/manager.js.map +1 -1
  165. package/dist/adapter/z-stack/adapter/tstype.d.ts +3 -3
  166. package/dist/adapter/z-stack/adapter/tstype.js +3 -3
  167. package/dist/adapter/z-stack/adapter/zStackAdapter.d.ts +10 -10
  168. package/dist/adapter/z-stack/adapter/zStackAdapter.d.ts.map +1 -1
  169. package/dist/adapter/z-stack/adapter/zStackAdapter.js +125 -137
  170. package/dist/adapter/z-stack/adapter/zStackAdapter.js.map +1 -1
  171. package/dist/adapter/z-stack/constants/common.d.ts.map +1 -1
  172. package/dist/adapter/z-stack/constants/common.js +0 -3
  173. package/dist/adapter/z-stack/constants/common.js.map +1 -1
  174. package/dist/adapter/z-stack/constants/index.d.ts +10 -10
  175. package/dist/adapter/z-stack/constants/index.d.ts.map +1 -1
  176. package/dist/adapter/z-stack/constants/index.js +2 -2
  177. package/dist/adapter/z-stack/constants/index.js.map +1 -1
  178. package/dist/adapter/z-stack/constants/utils.d.ts +1 -1
  179. package/dist/adapter/z-stack/constants/utils.js +2 -2
  180. package/dist/adapter/z-stack/constants/utils.js.map +1 -1
  181. package/dist/adapter/z-stack/models/startup-options.d.ts +2 -2
  182. package/dist/adapter/z-stack/models/startup-options.d.ts.map +1 -1
  183. package/dist/adapter/z-stack/structs/entries/address-manager-entry.d.ts +1 -1
  184. package/dist/adapter/z-stack/structs/entries/address-manager-entry.d.ts.map +1 -1
  185. package/dist/adapter/z-stack/structs/entries/address-manager-entry.js +4 -5
  186. package/dist/adapter/z-stack/structs/entries/address-manager-entry.js.map +1 -1
  187. package/dist/adapter/z-stack/structs/entries/address-manager-table.d.ts +2 -2
  188. package/dist/adapter/z-stack/structs/entries/address-manager-table.d.ts.map +1 -1
  189. package/dist/adapter/z-stack/structs/entries/address-manager-table.js +3 -4
  190. package/dist/adapter/z-stack/structs/entries/address-manager-table.js.map +1 -1
  191. package/dist/adapter/z-stack/structs/entries/aps-link-key-data-entry.d.ts +1 -1
  192. package/dist/adapter/z-stack/structs/entries/aps-link-key-data-entry.d.ts.map +1 -1
  193. package/dist/adapter/z-stack/structs/entries/aps-link-key-data-entry.js +1 -2
  194. package/dist/adapter/z-stack/structs/entries/aps-link-key-data-entry.js.map +1 -1
  195. package/dist/adapter/z-stack/structs/entries/aps-link-key-data-table.d.ts +2 -2
  196. package/dist/adapter/z-stack/structs/entries/aps-link-key-data-table.d.ts.map +1 -1
  197. package/dist/adapter/z-stack/structs/entries/aps-link-key-data-table.js +3 -4
  198. package/dist/adapter/z-stack/structs/entries/aps-link-key-data-table.js.map +1 -1
  199. package/dist/adapter/z-stack/structs/entries/aps-tc-link-key-entry.d.ts +1 -1
  200. package/dist/adapter/z-stack/structs/entries/aps-tc-link-key-entry.d.ts.map +1 -1
  201. package/dist/adapter/z-stack/structs/entries/aps-tc-link-key-entry.js +6 -7
  202. package/dist/adapter/z-stack/structs/entries/aps-tc-link-key-entry.js.map +1 -1
  203. package/dist/adapter/z-stack/structs/entries/aps-tc-link-key-table.d.ts +2 -2
  204. package/dist/adapter/z-stack/structs/entries/aps-tc-link-key-table.d.ts.map +1 -1
  205. package/dist/adapter/z-stack/structs/entries/aps-tc-link-key-table.js +3 -4
  206. package/dist/adapter/z-stack/structs/entries/aps-tc-link-key-table.js.map +1 -1
  207. package/dist/adapter/z-stack/structs/entries/channel-list.d.ts +1 -1
  208. package/dist/adapter/z-stack/structs/entries/channel-list.d.ts.map +1 -1
  209. package/dist/adapter/z-stack/structs/entries/channel-list.js +1 -2
  210. package/dist/adapter/z-stack/structs/entries/channel-list.js.map +1 -1
  211. package/dist/adapter/z-stack/structs/entries/has-configured.d.ts +1 -1
  212. package/dist/adapter/z-stack/structs/entries/has-configured.d.ts.map +1 -1
  213. package/dist/adapter/z-stack/structs/entries/has-configured.js +2 -3
  214. package/dist/adapter/z-stack/structs/entries/has-configured.js.map +1 -1
  215. package/dist/adapter/z-stack/structs/entries/index.d.ts +16 -16
  216. package/dist/adapter/z-stack/structs/entries/nib.d.ts +1 -1
  217. package/dist/adapter/z-stack/structs/entries/nib.d.ts.map +1 -1
  218. package/dist/adapter/z-stack/structs/entries/nib.js +49 -50
  219. package/dist/adapter/z-stack/structs/entries/nib.js.map +1 -1
  220. package/dist/adapter/z-stack/structs/entries/nwk-key-descriptor.d.ts +1 -1
  221. package/dist/adapter/z-stack/structs/entries/nwk-key-descriptor.d.ts.map +1 -1
  222. package/dist/adapter/z-stack/structs/entries/nwk-key-descriptor.js +1 -2
  223. package/dist/adapter/z-stack/structs/entries/nwk-key-descriptor.js.map +1 -1
  224. package/dist/adapter/z-stack/structs/entries/nwk-key.d.ts +1 -1
  225. package/dist/adapter/z-stack/structs/entries/nwk-key.d.ts.map +1 -1
  226. package/dist/adapter/z-stack/structs/entries/nwk-key.js +1 -2
  227. package/dist/adapter/z-stack/structs/entries/nwk-key.js.map +1 -1
  228. package/dist/adapter/z-stack/structs/entries/nwk-pan-id.d.ts +1 -1
  229. package/dist/adapter/z-stack/structs/entries/nwk-pan-id.d.ts.map +1 -1
  230. package/dist/adapter/z-stack/structs/entries/nwk-pan-id.js +1 -2
  231. package/dist/adapter/z-stack/structs/entries/nwk-pan-id.js.map +1 -1
  232. package/dist/adapter/z-stack/structs/entries/nwk-sec-material-descriptor-entry.d.ts +1 -1
  233. package/dist/adapter/z-stack/structs/entries/nwk-sec-material-descriptor-entry.d.ts.map +1 -1
  234. package/dist/adapter/z-stack/structs/entries/nwk-sec-material-descriptor-entry.js +3 -4
  235. package/dist/adapter/z-stack/structs/entries/nwk-sec-material-descriptor-entry.js.map +1 -1
  236. package/dist/adapter/z-stack/structs/entries/nwk-sec-material-descriptor-table.d.ts +2 -2
  237. package/dist/adapter/z-stack/structs/entries/nwk-sec-material-descriptor-table.d.ts.map +1 -1
  238. package/dist/adapter/z-stack/structs/entries/nwk-sec-material-descriptor-table.js +3 -4
  239. package/dist/adapter/z-stack/structs/entries/nwk-sec-material-descriptor-table.js.map +1 -1
  240. package/dist/adapter/z-stack/structs/entries/security-manager-entry.d.ts +1 -1
  241. package/dist/adapter/z-stack/structs/entries/security-manager-entry.d.ts.map +1 -1
  242. package/dist/adapter/z-stack/structs/entries/security-manager-entry.js +4 -5
  243. package/dist/adapter/z-stack/structs/entries/security-manager-entry.js.map +1 -1
  244. package/dist/adapter/z-stack/structs/entries/security-manager-table.d.ts +2 -2
  245. package/dist/adapter/z-stack/structs/entries/security-manager-table.d.ts.map +1 -1
  246. package/dist/adapter/z-stack/structs/entries/security-manager-table.js +3 -4
  247. package/dist/adapter/z-stack/structs/entries/security-manager-table.js.map +1 -1
  248. package/dist/adapter/z-stack/structs/index.d.ts +4 -4
  249. package/dist/adapter/z-stack/structs/serializable-memory-object.d.ts +2 -2
  250. package/dist/adapter/z-stack/structs/serializable-memory-object.d.ts.map +1 -1
  251. package/dist/adapter/z-stack/structs/struct.d.ts +8 -8
  252. package/dist/adapter/z-stack/structs/struct.d.ts.map +1 -1
  253. package/dist/adapter/z-stack/structs/struct.js +42 -43
  254. package/dist/adapter/z-stack/structs/struct.js.map +1 -1
  255. package/dist/adapter/z-stack/structs/table.d.ts +3 -3
  256. package/dist/adapter/z-stack/structs/table.d.ts.map +1 -1
  257. package/dist/adapter/z-stack/structs/table.js +10 -10
  258. package/dist/adapter/z-stack/structs/table.js.map +1 -1
  259. package/dist/adapter/z-stack/unpi/frame.d.ts +1 -1
  260. package/dist/adapter/z-stack/unpi/frame.d.ts.map +1 -1
  261. package/dist/adapter/z-stack/unpi/frame.js +2 -4
  262. package/dist/adapter/z-stack/unpi/frame.js.map +1 -1
  263. package/dist/adapter/z-stack/unpi/index.d.ts +4 -4
  264. package/dist/adapter/z-stack/unpi/parser.d.ts +1 -1
  265. package/dist/adapter/z-stack/unpi/parser.js +3 -3
  266. package/dist/adapter/z-stack/unpi/parser.js.map +1 -1
  267. package/dist/adapter/z-stack/unpi/writer.d.ts +2 -2
  268. package/dist/adapter/z-stack/unpi/writer.d.ts.map +1 -1
  269. package/dist/adapter/z-stack/unpi/writer.js +1 -1
  270. package/dist/adapter/z-stack/utils/index.d.ts +2 -2
  271. package/dist/adapter/z-stack/utils/network-options.d.ts +1 -1
  272. package/dist/adapter/z-stack/utils/network-options.d.ts.map +1 -1
  273. package/dist/adapter/z-stack/znp/buffaloZnp.d.ts +3 -3
  274. package/dist/adapter/z-stack/znp/buffaloZnp.d.ts.map +1 -1
  275. package/dist/adapter/z-stack/znp/buffaloZnp.js +34 -20
  276. package/dist/adapter/z-stack/znp/buffaloZnp.js.map +1 -1
  277. package/dist/adapter/z-stack/znp/definition.d.ts +2 -2
  278. package/dist/adapter/z-stack/znp/definition.d.ts.map +1 -1
  279. package/dist/adapter/z-stack/znp/definition.js +1111 -1111
  280. package/dist/adapter/z-stack/znp/index.d.ts +2 -2
  281. package/dist/adapter/z-stack/znp/tstype.d.ts +7 -7
  282. package/dist/adapter/z-stack/znp/tstype.d.ts.map +1 -1
  283. package/dist/adapter/z-stack/znp/utils.d.ts +1 -1
  284. package/dist/adapter/z-stack/znp/utils.d.ts.map +1 -1
  285. package/dist/adapter/z-stack/znp/utils.js +2 -2
  286. package/dist/adapter/z-stack/znp/znp.d.ts +7 -7
  287. package/dist/adapter/z-stack/znp/znp.d.ts.map +1 -1
  288. package/dist/adapter/z-stack/znp/znp.js +46 -45
  289. package/dist/adapter/z-stack/znp/znp.js.map +1 -1
  290. package/dist/adapter/z-stack/znp/zpiObject.d.ts +8 -8
  291. package/dist/adapter/z-stack/znp/zpiObject.d.ts.map +1 -1
  292. package/dist/adapter/z-stack/znp/zpiObject.js +6 -6
  293. package/dist/adapter/z-stack/znp/zpiObject.js.map +1 -1
  294. package/dist/adapter/zboss/adapter/zbossAdapter.d.ts +11 -11
  295. package/dist/adapter/zboss/adapter/zbossAdapter.d.ts.map +1 -1
  296. package/dist/adapter/zboss/adapter/zbossAdapter.js +37 -36
  297. package/dist/adapter/zboss/adapter/zbossAdapter.js.map +1 -1
  298. package/dist/adapter/zboss/commands.d.ts +4 -6
  299. package/dist/adapter/zboss/commands.d.ts.map +1 -1
  300. package/dist/adapter/zboss/commands.js +321 -287
  301. package/dist/adapter/zboss/commands.js.map +1 -1
  302. package/dist/adapter/zboss/driver.d.ts +9 -9
  303. package/dist/adapter/zboss/driver.d.ts.map +1 -1
  304. package/dist/adapter/zboss/driver.js +25 -25
  305. package/dist/adapter/zboss/driver.js.map +1 -1
  306. package/dist/adapter/zboss/frame.d.ts +9 -9
  307. package/dist/adapter/zboss/frame.d.ts.map +1 -1
  308. package/dist/adapter/zboss/frame.js +15 -15
  309. package/dist/adapter/zboss/frame.js.map +1 -1
  310. package/dist/adapter/zboss/reader.d.ts +2 -2
  311. package/dist/adapter/zboss/reader.d.ts.map +1 -1
  312. package/dist/adapter/zboss/reader.js +6 -5
  313. package/dist/adapter/zboss/reader.js.map +1 -1
  314. package/dist/adapter/zboss/uart.d.ts +3 -3
  315. package/dist/adapter/zboss/uart.d.ts.map +1 -1
  316. package/dist/adapter/zboss/uart.js +36 -36
  317. package/dist/adapter/zboss/uart.js.map +1 -1
  318. package/dist/adapter/zboss/writer.d.ts +1 -1
  319. package/dist/adapter/zboss/writer.d.ts.map +1 -1
  320. package/dist/adapter/zboss/writer.js +3 -5
  321. package/dist/adapter/zboss/writer.js.map +1 -1
  322. package/dist/adapter/zigate/adapter/patchZdoBuffaloBE.js +2 -2
  323. package/dist/adapter/zigate/adapter/patchZdoBuffaloBE.js.map +1 -1
  324. package/dist/adapter/zigate/adapter/zigateAdapter.d.ts +14 -14
  325. package/dist/adapter/zigate/adapter/zigateAdapter.d.ts.map +1 -1
  326. package/dist/adapter/zigate/adapter/zigateAdapter.js +52 -53
  327. package/dist/adapter/zigate/adapter/zigateAdapter.js.map +1 -1
  328. package/dist/adapter/zigate/driver/buffaloZiGate.d.ts +6 -6
  329. package/dist/adapter/zigate/driver/buffaloZiGate.d.ts.map +1 -1
  330. package/dist/adapter/zigate/driver/buffaloZiGate.js +41 -23
  331. package/dist/adapter/zigate/driver/buffaloZiGate.js.map +1 -1
  332. package/dist/adapter/zigate/driver/commandType.d.ts +2 -2
  333. package/dist/adapter/zigate/driver/commandType.d.ts.map +1 -1
  334. package/dist/adapter/zigate/driver/commandType.js +37 -37
  335. package/dist/adapter/zigate/driver/commandType.js.map +1 -1
  336. package/dist/adapter/zigate/driver/constants.d.ts +27 -200
  337. package/dist/adapter/zigate/driver/constants.d.ts.map +1 -1
  338. package/dist/adapter/zigate/driver/constants.js +40 -236
  339. package/dist/adapter/zigate/driver/constants.js.map +1 -1
  340. package/dist/adapter/zigate/driver/frame.d.ts.map +1 -1
  341. package/dist/adapter/zigate/driver/frame.js +4 -3
  342. package/dist/adapter/zigate/driver/frame.js.map +1 -1
  343. package/dist/adapter/zigate/driver/messageType.d.ts +1 -1
  344. package/dist/adapter/zigate/driver/messageType.js +76 -76
  345. package/dist/adapter/zigate/driver/ziGateObject.d.ts +3 -3
  346. package/dist/adapter/zigate/driver/ziGateObject.d.ts.map +1 -1
  347. package/dist/adapter/zigate/driver/ziGateObject.js +7 -6
  348. package/dist/adapter/zigate/driver/ziGateObject.js.map +1 -1
  349. package/dist/adapter/zigate/driver/zigate.d.ts +8 -8
  350. package/dist/adapter/zigate/driver/zigate.d.ts.map +1 -1
  351. package/dist/adapter/zigate/driver/zigate.js +59 -54
  352. package/dist/adapter/zigate/driver/zigate.js.map +1 -1
  353. package/dist/adapter/zoh/adapter/utils.js +1 -1
  354. package/dist/adapter/zoh/adapter/zohAdapter.d.ts +13 -13
  355. package/dist/adapter/zoh/adapter/zohAdapter.d.ts.map +1 -1
  356. package/dist/adapter/zoh/adapter/zohAdapter.js +101 -67
  357. package/dist/adapter/zoh/adapter/zohAdapter.js.map +1 -1
  358. package/dist/buffalo/buffalo.d.ts +2 -2
  359. package/dist/buffalo/buffalo.js +4 -4
  360. package/dist/buffalo/buffalo.js.map +1 -1
  361. package/dist/buffalo/index.d.ts +1 -1
  362. package/dist/controller/controller.d.ts +7 -7
  363. package/dist/controller/controller.d.ts.map +1 -1
  364. package/dist/controller/controller.js +94 -98
  365. package/dist/controller/controller.js.map +1 -1
  366. package/dist/controller/database.d.ts +1 -1
  367. package/dist/controller/database.d.ts.map +1 -1
  368. package/dist/controller/database.js +9 -9
  369. package/dist/controller/database.js.map +1 -1
  370. package/dist/controller/events.d.ts +6 -6
  371. package/dist/controller/events.d.ts.map +1 -1
  372. package/dist/controller/greenPower.d.ts +21 -21
  373. package/dist/controller/greenPower.d.ts.map +1 -1
  374. package/dist/controller/greenPower.js +41 -41
  375. package/dist/controller/greenPower.js.map +1 -1
  376. package/dist/controller/helpers/index.d.ts +1 -1
  377. package/dist/controller/helpers/request.d.ts +2 -2
  378. package/dist/controller/helpers/request.d.ts.map +1 -1
  379. package/dist/controller/helpers/request.js +31 -27
  380. package/dist/controller/helpers/request.js.map +1 -1
  381. package/dist/controller/helpers/requestQueue.d.ts +3 -3
  382. package/dist/controller/helpers/requestQueue.d.ts.map +1 -1
  383. package/dist/controller/helpers/requestQueue.js +20 -20
  384. package/dist/controller/helpers/requestQueue.js.map +1 -1
  385. package/dist/controller/helpers/zclFrameConverter.d.ts +2 -2
  386. package/dist/controller/helpers/zclFrameConverter.d.ts.map +1 -1
  387. package/dist/controller/helpers/zclFrameConverter.js +1 -1
  388. package/dist/controller/helpers/zclFrameConverter.js.map +1 -1
  389. package/dist/controller/helpers/zclTransactionSequenceNumber.d.ts +6 -4
  390. package/dist/controller/helpers/zclTransactionSequenceNumber.d.ts.map +1 -1
  391. package/dist/controller/helpers/zclTransactionSequenceNumber.js +6 -5
  392. package/dist/controller/helpers/zclTransactionSequenceNumber.js.map +1 -1
  393. package/dist/controller/index.d.ts +1 -1
  394. package/dist/controller/model/device.d.ts +23 -19
  395. package/dist/controller/model/device.d.ts.map +1 -1
  396. package/dist/controller/model/device.js +153 -128
  397. package/dist/controller/model/device.js.map +1 -1
  398. package/dist/controller/model/endpoint.d.ts +11 -11
  399. package/dist/controller/model/endpoint.d.ts.map +1 -1
  400. package/dist/controller/model/endpoint.js +84 -67
  401. package/dist/controller/model/endpoint.js.map +1 -1
  402. package/dist/controller/model/entity.d.ts +3 -3
  403. package/dist/controller/model/entity.d.ts.map +1 -1
  404. package/dist/controller/model/group.d.ts +4 -4
  405. package/dist/controller/model/group.d.ts.map +1 -1
  406. package/dist/controller/model/group.js +21 -9
  407. package/dist/controller/model/group.js.map +1 -1
  408. package/dist/controller/model/index.d.ts +4 -4
  409. package/dist/controller/touchlink.d.ts +1 -1
  410. package/dist/controller/touchlink.d.ts.map +1 -1
  411. package/dist/controller/touchlink.js +11 -11
  412. package/dist/controller/tstype.d.ts +3 -3
  413. package/dist/index.d.ts +10 -10
  414. package/dist/models/backup-storage-legacy.d.ts +14 -16
  415. package/dist/models/backup-storage-legacy.d.ts.map +1 -1
  416. package/dist/models/backup-storage-unified.d.ts +1 -1
  417. package/dist/models/backup.d.ts +2 -2
  418. package/dist/models/backup.d.ts.map +1 -1
  419. package/dist/models/index.d.ts +4 -4
  420. package/dist/utils/backup.d.ts +1 -1
  421. package/dist/utils/backup.d.ts.map +1 -1
  422. package/dist/utils/backup.js +26 -26
  423. package/dist/utils/backup.js.map +1 -1
  424. package/dist/utils/index.d.ts +5 -5
  425. package/dist/utils/logger.js +3 -3
  426. package/dist/utils/patchBigIntSerialization.js +1 -1
  427. package/dist/utils/patchBigIntSerialization.js.map +1 -1
  428. package/dist/utils/queue.d.ts.map +1 -1
  429. package/dist/utils/queue.js +1 -0
  430. package/dist/utils/queue.js.map +1 -1
  431. package/dist/utils/utils.d.ts.map +1 -1
  432. package/dist/utils/utils.js +5 -4
  433. package/dist/utils/utils.js.map +1 -1
  434. package/dist/utils/waitress.d.ts +1 -1
  435. package/dist/utils/waitress.js +3 -3
  436. package/dist/zspec/consts.d.ts +1 -1
  437. package/dist/zspec/consts.d.ts.map +1 -1
  438. package/dist/zspec/consts.js +1 -1
  439. package/dist/zspec/index.d.ts +3 -3
  440. package/dist/zspec/tstypes.d.ts +1 -1
  441. package/dist/zspec/utils.d.ts +4 -4
  442. package/dist/zspec/utils.d.ts.map +1 -1
  443. package/dist/zspec/utils.js +9 -13
  444. package/dist/zspec/utils.js.map +1 -1
  445. package/dist/zspec/zcl/buffaloZcl.d.ts +3 -3
  446. package/dist/zspec/zcl/buffaloZcl.d.ts.map +1 -1
  447. package/dist/zspec/zcl/buffaloZcl.js +127 -84
  448. package/dist/zspec/zcl/buffaloZcl.js.map +1 -1
  449. package/dist/zspec/zcl/definition/cluster.d.ts +1 -1
  450. package/dist/zspec/zcl/definition/cluster.d.ts.map +1 -1
  451. package/dist/zspec/zcl/definition/cluster.js +894 -893
  452. package/dist/zspec/zcl/definition/cluster.js.map +1 -1
  453. package/dist/zspec/zcl/definition/consts.js +7 -7
  454. package/dist/zspec/zcl/definition/foundation.d.ts +3 -3
  455. package/dist/zspec/zcl/definition/foundation.d.ts.map +1 -1
  456. package/dist/zspec/zcl/definition/foundation.js +88 -89
  457. package/dist/zspec/zcl/definition/foundation.js.map +1 -1
  458. package/dist/zspec/zcl/definition/manufacturerCode.d.ts +1 -1
  459. package/dist/zspec/zcl/definition/manufacturerCode.js +1 -1
  460. package/dist/zspec/zcl/definition/manufacturerCode.js.map +1 -1
  461. package/dist/zspec/zcl/definition/status.d.ts +3 -3
  462. package/dist/zspec/zcl/definition/status.js +3 -3
  463. package/dist/zspec/zcl/definition/tstype.d.ts +3 -3
  464. package/dist/zspec/zcl/definition/tstype.d.ts.map +1 -1
  465. package/dist/zspec/zcl/index.d.ts +10 -10
  466. package/dist/zspec/zcl/utils.d.ts +3 -3
  467. package/dist/zspec/zcl/utils.d.ts.map +1 -1
  468. package/dist/zspec/zcl/utils.js +18 -21
  469. package/dist/zspec/zcl/utils.js.map +1 -1
  470. package/dist/zspec/zcl/zclFrame.d.ts +7 -7
  471. package/dist/zspec/zcl/zclFrame.d.ts.map +1 -1
  472. package/dist/zspec/zcl/zclFrame.js +38 -41
  473. package/dist/zspec/zcl/zclFrame.js.map +1 -1
  474. package/dist/zspec/zcl/zclHeader.d.ts +2 -2
  475. package/dist/zspec/zcl/zclHeader.d.ts.map +1 -1
  476. package/dist/zspec/zcl/zclHeader.js +3 -3
  477. package/dist/zspec/zcl/zclStatusError.d.ts +1 -1
  478. package/dist/zspec/zdo/buffaloZdo.d.ts +7 -7
  479. package/dist/zspec/zdo/buffaloZdo.d.ts.map +1 -1
  480. package/dist/zspec/zdo/buffaloZdo.js +4 -4
  481. package/dist/zspec/zdo/buffaloZdo.js.map +1 -1
  482. package/dist/zspec/zdo/definition/status.d.ts +1 -1
  483. package/dist/zspec/zdo/definition/status.js +1 -1
  484. package/dist/zspec/zdo/definition/tstypes.d.ts +48 -48
  485. package/dist/zspec/zdo/definition/tstypes.d.ts.map +1 -1
  486. package/dist/zspec/zdo/index.d.ts +7 -7
  487. package/dist/zspec/zdo/utils.d.ts +2 -2
  488. package/dist/zspec/zdo/utils.d.ts.map +1 -1
  489. package/dist/zspec/zdo/utils.js +1 -1
  490. package/dist/zspec/zdo/utils.js.map +1 -1
  491. package/dist/zspec/zdo/zdoStatusError.d.ts +1 -1
  492. package/examples/join-and-log.js +5 -5
  493. package/package.json +6 -13
  494. package/src/adapter/adapter.ts +189 -0
  495. package/src/adapter/adapterDiscovery.ts +653 -0
  496. package/src/adapter/const.ts +12 -0
  497. package/src/adapter/deconz/adapter/deconzAdapter.ts +768 -0
  498. package/src/adapter/deconz/driver/constants.ts +180 -0
  499. package/src/adapter/deconz/driver/driver.ts +900 -0
  500. package/src/adapter/deconz/driver/frame.ts +11 -0
  501. package/src/adapter/deconz/driver/frameParser.ts +557 -0
  502. package/src/adapter/deconz/driver/parser.ts +45 -0
  503. package/src/adapter/deconz/driver/writer.ts +22 -0
  504. package/src/adapter/deconz/types.d.ts +13 -0
  505. package/src/adapter/ember/adapter/emberAdapter.ts +2266 -0
  506. package/src/adapter/ember/adapter/endpoints.ts +86 -0
  507. package/src/adapter/ember/adapter/oneWaitress.ts +322 -0
  508. package/src/adapter/ember/adapter/tokensManager.ts +782 -0
  509. package/src/adapter/ember/consts.ts +178 -0
  510. package/src/adapter/ember/enums.ts +2123 -0
  511. package/src/adapter/ember/ezsp/buffalo.ts +1397 -0
  512. package/src/adapter/ember/ezsp/consts.ts +148 -0
  513. package/src/adapter/ember/ezsp/enums.ts +1087 -0
  514. package/src/adapter/ember/ezsp/ezsp.ts +8985 -0
  515. package/src/adapter/ember/ezspError.ts +10 -0
  516. package/src/adapter/ember/types.ts +866 -0
  517. package/src/adapter/ember/uart/ash.ts +1969 -0
  518. package/src/adapter/ember/uart/consts.ts +109 -0
  519. package/src/adapter/ember/uart/enums.ts +192 -0
  520. package/src/adapter/ember/uart/parser.ts +48 -0
  521. package/src/adapter/ember/uart/queues.ts +247 -0
  522. package/src/adapter/ember/uart/writer.ts +53 -0
  523. package/src/adapter/ember/utils/initters.ts +58 -0
  524. package/src/adapter/ember/utils/math.ts +73 -0
  525. package/src/adapter/events.ts +21 -0
  526. package/src/adapter/ezsp/adapter/backup.ts +109 -0
  527. package/src/adapter/ezsp/adapter/ezspAdapter.ts +614 -0
  528. package/src/adapter/ezsp/driver/commands.ts +2497 -0
  529. package/src/adapter/ezsp/driver/consts.ts +11 -0
  530. package/src/adapter/ezsp/driver/driver.ts +1002 -0
  531. package/src/adapter/ezsp/driver/ezsp.ts +802 -0
  532. package/src/adapter/ezsp/driver/frame.ts +101 -0
  533. package/src/adapter/ezsp/driver/index.ts +4 -0
  534. package/src/adapter/ezsp/driver/multicast.ts +78 -0
  535. package/src/adapter/ezsp/driver/parser.ts +81 -0
  536. package/src/adapter/ezsp/driver/types/basic.ts +201 -0
  537. package/src/adapter/ezsp/driver/types/index.ts +239 -0
  538. package/src/adapter/ezsp/driver/types/named.ts +2330 -0
  539. package/src/adapter/ezsp/driver/types/struct.ts +844 -0
  540. package/src/adapter/ezsp/driver/uart.ts +460 -0
  541. package/src/adapter/ezsp/driver/utils/crc16ccitt.ts +44 -0
  542. package/src/adapter/ezsp/driver/utils/index.ts +32 -0
  543. package/src/adapter/ezsp/driver/writer.ts +64 -0
  544. package/src/adapter/index.ts +3 -0
  545. package/src/adapter/serialPort.ts +58 -0
  546. package/src/adapter/socketPortUtils.ts +16 -0
  547. package/src/adapter/tstype.ts +78 -0
  548. package/src/adapter/z-stack/adapter/adapter-backup.ts +519 -0
  549. package/src/adapter/z-stack/adapter/adapter-nv-memory.ts +457 -0
  550. package/src/adapter/z-stack/adapter/endpoints.ts +57 -0
  551. package/src/adapter/z-stack/adapter/manager.ts +543 -0
  552. package/src/adapter/z-stack/adapter/tstype.ts +6 -0
  553. package/src/adapter/z-stack/adapter/zStackAdapter.ts +1190 -0
  554. package/src/adapter/z-stack/constants/af.ts +27 -0
  555. package/src/adapter/z-stack/constants/common.ts +285 -0
  556. package/src/adapter/z-stack/constants/dbg.ts +23 -0
  557. package/src/adapter/z-stack/constants/index.ts +11 -0
  558. package/src/adapter/z-stack/constants/mac.ts +128 -0
  559. package/src/adapter/z-stack/constants/sapi.ts +25 -0
  560. package/src/adapter/z-stack/constants/sys.ts +72 -0
  561. package/src/adapter/z-stack/constants/util.ts +82 -0
  562. package/src/adapter/z-stack/constants/utils.ts +14 -0
  563. package/src/adapter/z-stack/constants/zdo.ts +103 -0
  564. package/src/adapter/z-stack/models/startup-options.ts +13 -0
  565. package/src/adapter/z-stack/structs/entries/address-manager-entry.ts +44 -0
  566. package/src/adapter/z-stack/structs/entries/address-manager-table.ts +19 -0
  567. package/src/adapter/z-stack/structs/entries/aps-link-key-data-entry.ts +12 -0
  568. package/src/adapter/z-stack/structs/entries/aps-link-key-data-table.ts +21 -0
  569. package/src/adapter/z-stack/structs/entries/aps-tc-link-key-entry.ts +19 -0
  570. package/src/adapter/z-stack/structs/entries/aps-tc-link-key-table.ts +21 -0
  571. package/src/adapter/z-stack/structs/entries/channel-list.ts +8 -0
  572. package/src/adapter/z-stack/structs/entries/has-configured.ts +16 -0
  573. package/src/adapter/z-stack/structs/entries/index.ts +16 -0
  574. package/src/adapter/z-stack/structs/entries/nib.ts +66 -0
  575. package/src/adapter/z-stack/structs/entries/nwk-key-descriptor.ts +15 -0
  576. package/src/adapter/z-stack/structs/entries/nwk-key.ts +13 -0
  577. package/src/adapter/z-stack/structs/entries/nwk-pan-id.ts +8 -0
  578. package/src/adapter/z-stack/structs/entries/nwk-sec-material-descriptor-entry.ts +20 -0
  579. package/src/adapter/z-stack/structs/entries/nwk-sec-material-descriptor-table.ts +19 -0
  580. package/src/adapter/z-stack/structs/entries/security-manager-entry.ts +33 -0
  581. package/src/adapter/z-stack/structs/entries/security-manager-table.ts +22 -0
  582. package/src/adapter/z-stack/structs/index.ts +4 -0
  583. package/src/adapter/z-stack/structs/serializable-memory-object.ts +14 -0
  584. package/src/adapter/z-stack/structs/struct.ts +367 -0
  585. package/src/adapter/z-stack/structs/table.ts +198 -0
  586. package/src/adapter/z-stack/unpi/constants.ts +33 -0
  587. package/src/adapter/z-stack/unpi/frame.ts +62 -0
  588. package/src/adapter/z-stack/unpi/index.ts +4 -0
  589. package/src/adapter/z-stack/unpi/parser.ts +56 -0
  590. package/src/adapter/z-stack/unpi/writer.ts +21 -0
  591. package/src/adapter/z-stack/utils/channel-list.ts +40 -0
  592. package/src/adapter/z-stack/utils/index.ts +2 -0
  593. package/src/adapter/z-stack/utils/network-options.ts +26 -0
  594. package/src/adapter/z-stack/znp/buffaloZnp.ts +175 -0
  595. package/src/adapter/z-stack/znp/definition.ts +2713 -0
  596. package/src/adapter/z-stack/znp/index.ts +2 -0
  597. package/src/adapter/z-stack/znp/parameterType.ts +22 -0
  598. package/src/adapter/z-stack/znp/tstype.ts +44 -0
  599. package/src/adapter/z-stack/znp/utils.ts +10 -0
  600. package/src/adapter/z-stack/znp/znp.ts +342 -0
  601. package/src/adapter/z-stack/znp/zpiObject.ts +148 -0
  602. package/src/adapter/zboss/adapter/zbossAdapter.ts +527 -0
  603. package/src/adapter/zboss/commands.ts +1184 -0
  604. package/src/adapter/zboss/consts.ts +9 -0
  605. package/src/adapter/zboss/driver.ts +423 -0
  606. package/src/adapter/zboss/enums.ts +360 -0
  607. package/src/adapter/zboss/frame.ts +227 -0
  608. package/src/adapter/zboss/reader.ts +65 -0
  609. package/src/adapter/zboss/types.ts +0 -0
  610. package/src/adapter/zboss/uart.ts +428 -0
  611. package/src/adapter/zboss/utils.ts +58 -0
  612. package/src/adapter/zboss/writer.ts +49 -0
  613. package/src/adapter/zigate/adapter/patchZdoBuffaloBE.ts +27 -0
  614. package/src/adapter/zigate/adapter/zigateAdapter.ts +618 -0
  615. package/src/adapter/zigate/driver/LICENSE +17 -0
  616. package/src/adapter/zigate/driver/buffaloZiGate.ts +212 -0
  617. package/src/adapter/zigate/driver/commandType.ts +418 -0
  618. package/src/adapter/zigate/driver/constants.ts +150 -0
  619. package/src/adapter/zigate/driver/frame.ts +197 -0
  620. package/src/adapter/zigate/driver/messageType.ts +287 -0
  621. package/src/adapter/zigate/driver/parameterType.ts +32 -0
  622. package/src/adapter/zigate/driver/ziGateObject.ts +146 -0
  623. package/src/adapter/zigate/driver/zigate.ts +426 -0
  624. package/src/adapter/zoh/adapter/utils.ts +27 -0
  625. package/src/adapter/zoh/adapter/zohAdapter.ts +837 -0
  626. package/src/buffalo/buffalo.ts +335 -0
  627. package/src/buffalo/index.ts +1 -0
  628. package/src/controller/controller.ts +1048 -0
  629. package/src/controller/database.ts +124 -0
  630. package/src/controller/events.ts +51 -0
  631. package/src/controller/greenPower.ts +603 -0
  632. package/src/controller/helpers/index.ts +1 -0
  633. package/src/controller/helpers/request.ts +94 -0
  634. package/src/controller/helpers/requestQueue.ts +125 -0
  635. package/src/controller/helpers/zclFrameConverter.ts +51 -0
  636. package/src/controller/helpers/zclTransactionSequenceNumber.ts +19 -0
  637. package/src/controller/index.ts +6 -0
  638. package/src/controller/model/device.ts +1320 -0
  639. package/src/controller/model/endpoint.ts +1040 -0
  640. package/src/controller/model/entity.ts +23 -0
  641. package/src/controller/model/group.ts +333 -0
  642. package/src/controller/model/index.ts +4 -0
  643. package/src/controller/touchlink.ts +189 -0
  644. package/src/controller/tstype.ts +39 -0
  645. package/src/index.ts +12 -0
  646. package/src/models/backup-storage-legacy.ts +48 -0
  647. package/src/models/backup-storage-unified.ts +47 -0
  648. package/src/models/backup.ts +37 -0
  649. package/src/models/index.ts +5 -0
  650. package/src/models/network-options.ts +11 -0
  651. package/src/utils/backup.ts +152 -0
  652. package/src/utils/index.ts +5 -0
  653. package/src/utils/logger.ts +20 -0
  654. package/src/utils/patchBigIntSerialization.ts +8 -0
  655. package/src/utils/queue.ts +76 -0
  656. package/src/utils/types.d.ts +3 -0
  657. package/src/utils/utils.ts +20 -0
  658. package/src/utils/wait.ts +5 -0
  659. package/src/utils/waitress.ts +95 -0
  660. package/src/zspec/consts.ts +84 -0
  661. package/src/zspec/enums.ts +22 -0
  662. package/src/zspec/index.ts +3 -0
  663. package/src/zspec/tstypes.ts +18 -0
  664. package/src/zspec/utils.ts +308 -0
  665. package/src/zspec/zcl/buffaloZcl.ts +1133 -0
  666. package/src/zspec/zcl/definition/cluster.ts +5398 -0
  667. package/src/zspec/zcl/definition/consts.ts +24 -0
  668. package/src/zspec/zcl/definition/enums.ts +194 -0
  669. package/src/zspec/zcl/definition/foundation.ts +301 -0
  670. package/src/zspec/zcl/definition/manufacturerCode.ts +729 -0
  671. package/src/zspec/zcl/definition/status.ts +69 -0
  672. package/src/zspec/zcl/definition/tstype.ts +236 -0
  673. package/src/zspec/zcl/index.ts +10 -0
  674. package/src/zspec/zcl/utils.ts +342 -0
  675. package/src/zspec/zcl/zclFrame.ts +336 -0
  676. package/src/zspec/zcl/zclHeader.ts +102 -0
  677. package/src/zspec/zcl/zclStatusError.ts +10 -0
  678. package/src/zspec/zdo/buffaloZdo.ts +2345 -0
  679. package/src/zspec/zdo/definition/clusters.ts +722 -0
  680. package/src/zspec/zdo/definition/consts.ts +16 -0
  681. package/src/zspec/zdo/definition/enums.ts +99 -0
  682. package/src/zspec/zdo/definition/status.ts +105 -0
  683. package/src/zspec/zdo/definition/tstypes.ts +1062 -0
  684. package/src/zspec/zdo/index.ts +7 -0
  685. package/src/zspec/zdo/utils.ts +76 -0
  686. package/src/zspec/zdo/zdoStatusError.ts +10 -0
  687. package/test/adapter/adapter.test.ts +1062 -0
  688. package/test/adapter/ember/ash.test.ts +337 -0
  689. package/test/adapter/ember/consts.ts +131 -0
  690. package/test/adapter/ember/emberAdapter.test.ts +3449 -0
  691. package/test/adapter/ember/ezsp.test.ts +386 -0
  692. package/test/adapter/ember/ezspBuffalo.test.ts +92 -0
  693. package/test/adapter/ember/ezspError.test.ts +11 -0
  694. package/test/adapter/ember/math.test.ts +205 -0
  695. package/test/adapter/ezsp/frame.test.ts +29 -0
  696. package/test/adapter/ezsp/uart.test.ts +180 -0
  697. package/test/adapter/z-stack/adapter.test.ts +3985 -0
  698. package/test/adapter/z-stack/constants.test.ts +32 -0
  699. package/test/adapter/z-stack/structs.test.ts +114 -0
  700. package/test/adapter/z-stack/unpi.test.ts +212 -0
  701. package/test/adapter/z-stack/znp.test.ts +1284 -0
  702. package/test/adapter/zboss/fixZdoResponse.test.ts +178 -0
  703. package/test/adapter/zigate/patchZdoBuffaloBE.test.ts +80 -0
  704. package/test/adapter/zigate/zdo.test.ts +187 -0
  705. package/test/adapter/zoh/utils.test.ts +35 -0
  706. package/test/adapter/zoh/zohAdapter.test.ts +1306 -0
  707. package/test/buffalo.test.ts +430 -0
  708. package/test/controller.test.ts +10005 -0
  709. package/test/greenpower.test.ts +1421 -0
  710. package/test/mockAdapters.ts +65 -0
  711. package/test/mockDevices.ts +472 -0
  712. package/test/testUtils.ts +20 -0
  713. package/test/tsconfig.json +10 -0
  714. package/test/utils/math.ts +19 -0
  715. package/test/utils.test.ts +227 -0
  716. package/test/vitest.config.mts +25 -0
  717. package/test/zcl.test.ts +2832 -0
  718. package/test/zspec/utils.test.ts +131 -0
  719. package/test/zspec/zcl/buffalo.test.ts +1231 -0
  720. package/test/zspec/zcl/frame.test.ts +925 -0
  721. package/test/zspec/zcl/utils.test.ts +280 -0
  722. package/test/zspec/zdo/buffalo.test.ts +1849 -0
  723. package/test/zspec/zdo/utils.test.ts +240 -0
  724. package/.prettierignore +0 -2
  725. package/.prettierrc +0 -26
  726. package/eslint.config.mjs +0 -32
@@ -0,0 +1,2832 @@
1
+ import * as Zcl from "../src/zspec/zcl";
2
+ import {BuffaloZcl} from "../src/zspec/zcl/buffaloZcl";
3
+ import {BuffaloZclDataType, DataType, Direction, FrameType, StructuredIndicatorType} from "../src/zspec/zcl/definition/enums";
4
+
5
+ describe("Zcl", () => {
6
+ it("Get cluster by name", () => {
7
+ const cluster = Zcl.Utils.getCluster("genIdentify", undefined, {});
8
+ expect(cluster.ID).toBe(3);
9
+ expect(cluster.name).toBe("genIdentify");
10
+ expect(cluster.commands.identifyQuery.ID).toBe(1);
11
+ expect(cluster.commands.identifyQuery.name).toBe("identifyQuery");
12
+ expect(cluster.commandsResponse.identifyQueryRsp.ID).toBe(0);
13
+ expect(cluster.commandsResponse.identifyQueryRsp.name).toBe("identifyQueryRsp");
14
+ });
15
+
16
+ it("Get cluster by ID", () => {
17
+ const cluster1 = Zcl.Utils.getCluster(0, undefined, {});
18
+ // @ts-expect-error testing
19
+ delete cluster1.getAttribute;
20
+ // @ts-expect-error testing
21
+ delete cluster1.getCommand;
22
+ // @ts-expect-error testing
23
+ delete cluster1.hasAttribute;
24
+ // @ts-expect-error testing
25
+ delete cluster1.getCommandResponse;
26
+ const cluster2 = Zcl.Utils.getCluster("genBasic", undefined, {});
27
+ // @ts-expect-error testing
28
+ delete cluster2.getAttribute;
29
+ // @ts-expect-error testing
30
+ delete cluster2.getCommand;
31
+ // @ts-expect-error testing
32
+ delete cluster2.hasAttribute;
33
+ // @ts-expect-error testing
34
+ delete cluster2.getCommandResponse;
35
+ expect(cluster1).toStrictEqual(cluster2);
36
+ });
37
+
38
+ it("Get cluster attribute by ID", () => {
39
+ const cluster = Zcl.Utils.getCluster(0, undefined, {});
40
+ const attribute = cluster.getAttribute(1);
41
+ expect(attribute).toStrictEqual({ID: 1, type: DataType.UINT8, name: "appVersion"});
42
+ });
43
+
44
+ it("Cluster has attribute", () => {
45
+ const cluster = Zcl.Utils.getCluster(0, undefined, {});
46
+ expect(cluster.hasAttribute("zclVersion")).toBeTruthy();
47
+ expect(cluster.hasAttribute("NOTEXISTING")).toBeFalsy();
48
+ expect(cluster.hasAttribute(0)).toBeTruthy();
49
+ expect(cluster.hasAttribute(910293)).toBeFalsy();
50
+ });
51
+
52
+ it("Get specific command by name", () => {
53
+ const cluster = Zcl.Utils.getCluster("genIdentify", undefined, {});
54
+ const command = cluster.getCommand("ezmodeInvoke");
55
+ expect(command.ID).toBe(2);
56
+ expect(command.name).toBe("ezmodeInvoke");
57
+ });
58
+
59
+ it("Get global command by name", () => {
60
+ const command = Zcl.Utils.getGlobalCommand("readRsp");
61
+ expect(command.ID).toBe(1);
62
+ expect(command.name).toBe("readRsp");
63
+ });
64
+
65
+ it("Get global command non existing", () => {
66
+ expect(() => {
67
+ Zcl.Utils.getGlobalCommand("nonexisting");
68
+ }).toThrow("Global command with key 'nonexisting' does not exist");
69
+ });
70
+
71
+ it("Get cluster by name non-existing", () => {
72
+ expect(() => {
73
+ Zcl.Utils.getCluster("notExisting", undefined, {});
74
+ }).toThrow("Cluster with name 'notExisting' does not exist");
75
+ });
76
+
77
+ it("Get cluster by id non-existing", () => {
78
+ expect(JSON.parse(JSON.stringify(Zcl.Utils.getCluster(0x190231, undefined, {})))).toStrictEqual({
79
+ ID: 1638961,
80
+ attributes: {},
81
+ name: "1638961",
82
+ commands: {},
83
+ commandsResponse: {},
84
+ });
85
+ });
86
+
87
+ it("Get specific command by ID", () => {
88
+ const cluster = Zcl.Utils.getCluster("genIdentify", undefined, {});
89
+ const command = cluster.getCommand(2);
90
+ expect(command).toStrictEqual(cluster.getCommand("ezmodeInvoke"));
91
+ });
92
+
93
+ it("Get specific command by name server to client", () => {
94
+ const cluster = Zcl.Utils.getCluster("genIdentify", undefined, {});
95
+ const command = cluster.getCommandResponse(0);
96
+ expect(command.ID).toBe(0);
97
+ expect(command.name).toBe("identifyQueryRsp");
98
+ });
99
+
100
+ it("Get specific command by name non existing", () => {
101
+ expect(() => {
102
+ const cluster = Zcl.Utils.getCluster("genIdentify", undefined, {});
103
+ cluster.getCommandResponse("nonexisting");
104
+ }).toThrow("Cluster 'genIdentify' has no command response 'nonexisting'");
105
+ });
106
+
107
+ it("Get discrete or analog of unkown type", () => {
108
+ expect(() => {
109
+ // @ts-expect-error invalid on purpose
110
+ Zcl.Utils.getDataTypeClass(99999);
111
+ }).toThrow("Don't know value type for 'undefined'");
112
+ });
113
+
114
+ it("ZclFrame from buffer parse payload with unknown frame type", () => {
115
+ expect(() => {
116
+ // @ts-ignore
117
+ Zcl.Frame.parsePayload({frameControl: {frameType: 9}}, undefined);
118
+ }).toThrow("Unsupported frameType '9'");
119
+ });
120
+
121
+ it("ZclFrame from buffer report", () => {
122
+ const buffer = Buffer.from([0x18, 0x4a, 0x0a, 0x55, 0x00, 0x39, 0x00, 0x00, 0x00, 0x00]);
123
+ const frame = Zcl.Frame.fromBuffer(Zcl.Clusters.genAnalogInput.ID, Zcl.Header.fromBuffer(buffer)!, buffer, {});
124
+ const header = new Zcl.Header(
125
+ {
126
+ reservedBits: 0,
127
+ direction: 1,
128
+ disableDefaultResponse: true,
129
+ frameType: 0,
130
+ manufacturerSpecific: false,
131
+ },
132
+ undefined,
133
+ 74,
134
+ 10,
135
+ );
136
+
137
+ const payload = [
138
+ {
139
+ attrData: 0,
140
+ attrId: 85,
141
+ dataType: 57,
142
+ },
143
+ ];
144
+
145
+ expect(frame.header).toStrictEqual(header);
146
+ expect(frame.payload).toStrictEqual(payload);
147
+ expect(frame.header.isGlobal).toBe(true);
148
+ expect(frame.header.isSpecific).toBe(false);
149
+ expect(frame.isCluster("genAnalogInput")).toBe(true);
150
+ expect(frame.isCommand("report")).toBe(true);
151
+ });
152
+
153
+ it("ZclFrame from buffer tradfriArrowSingle", () => {
154
+ const buffer = Buffer.from([0x05, 0x7c, 0x11, 0x1d, 0x07, 0x00, 0x01, 0x0d, 0x00]);
155
+ const frame = Zcl.Frame.fromBuffer(Zcl.Clusters.genScenes.ID, Zcl.Header.fromBuffer(buffer)!, buffer, {});
156
+ const header = new Zcl.Header(
157
+ {
158
+ reservedBits: 0,
159
+ direction: 0,
160
+ disableDefaultResponse: false,
161
+ frameType: 1,
162
+ manufacturerSpecific: true,
163
+ },
164
+ 4476,
165
+ 29,
166
+ 7,
167
+ );
168
+
169
+ const payload = {value: 256, value2: 13};
170
+
171
+ expect(frame.header).toStrictEqual(header);
172
+ expect(frame.payload).toStrictEqual(payload);
173
+ expect(frame.command.ID).toStrictEqual(7);
174
+ expect(frame.command.name).toStrictEqual("tradfriArrowSingle");
175
+ });
176
+
177
+ it("ZclFrame from buffer genGroups getMembership", () => {
178
+ const buffer = Buffer.from([0x11, 0x7c, 0x02, 2, 10, 0, 20, 0]);
179
+ const frame = Zcl.Frame.fromBuffer(Zcl.Clusters.genGroups.ID, Zcl.Header.fromBuffer(buffer)!, buffer, {});
180
+ const header = new Zcl.Header(
181
+ {
182
+ reservedBits: 0,
183
+ direction: 0,
184
+ disableDefaultResponse: true,
185
+ frameType: 1,
186
+ manufacturerSpecific: false,
187
+ },
188
+ undefined,
189
+ 124,
190
+ 2,
191
+ );
192
+
193
+ const payload = {groupcount: 2, grouplist: [10, 20]};
194
+
195
+ expect(frame.header).toStrictEqual(header);
196
+ expect(frame.payload).toStrictEqual(payload);
197
+ });
198
+
199
+ it("ZclFrame from buffer genGroups getMembership", () => {
200
+ const buffer = Buffer.from([0x19, 0x7c, 0x03, 0, 10, 0]);
201
+ const frame = Zcl.Frame.fromBuffer(Zcl.Clusters.genGroups.ID, Zcl.Header.fromBuffer(buffer)!, buffer, {});
202
+ const header = new Zcl.Header(
203
+ {
204
+ reservedBits: 0,
205
+ direction: 1,
206
+ disableDefaultResponse: true,
207
+ frameType: 1,
208
+ manufacturerSpecific: false,
209
+ },
210
+ undefined,
211
+ 124,
212
+ 3,
213
+ );
214
+
215
+ const payload = {groupid: 10, status: 0};
216
+
217
+ expect(frame.header).toStrictEqual(header);
218
+ expect(frame.payload).toStrictEqual(payload);
219
+ });
220
+
221
+ it("ZclFrame from buffer occupancy report", () => {
222
+ const buffer = Buffer.from([24, 169, 10, 0, 0, 24, 1]);
223
+ const frame = Zcl.Frame.fromBuffer(Zcl.Clusters.msOccupancySensing.ID, Zcl.Header.fromBuffer(buffer)!, buffer, {});
224
+ const header = new Zcl.Header(
225
+ {
226
+ reservedBits: 0,
227
+ direction: 1,
228
+ disableDefaultResponse: true,
229
+ frameType: 0,
230
+ manufacturerSpecific: false,
231
+ },
232
+ undefined,
233
+ 169,
234
+ 10,
235
+ );
236
+
237
+ const payload = [{attrId: 0, dataType: 24, attrData: 1}];
238
+
239
+ expect(frame.header).toStrictEqual(header);
240
+ expect(frame.payload).toStrictEqual(payload);
241
+ });
242
+
243
+ it("ZclFrame from buffer configReportRsp - short", () => {
244
+ const buffer = Buffer.from([0x08, 0x01, 0x07, 0x00]);
245
+ const frame = Zcl.Frame.fromBuffer(Zcl.Clusters.genPowerCfg.ID, Zcl.Header.fromBuffer(buffer)!, buffer, {});
246
+ const header = new Zcl.Header(
247
+ {
248
+ reservedBits: 0,
249
+ direction: 1,
250
+ disableDefaultResponse: false,
251
+ frameType: 0,
252
+ manufacturerSpecific: false,
253
+ },
254
+ undefined,
255
+ 1,
256
+ 7,
257
+ );
258
+
259
+ const payload = [{status: 0}];
260
+
261
+ expect(frame.header).toStrictEqual(header);
262
+ expect(frame.payload).toStrictEqual(payload);
263
+ });
264
+
265
+ it("ZclFrame from buffer configReportRsp - long", () => {
266
+ const buffer = Buffer.from([0x08, 0x01, 0x07, 0x00, 0x01, 0x34, 0x12, 0x01, 0x01, 0x35, 0x12]);
267
+ const frame = Zcl.Frame.fromBuffer(Zcl.Clusters.genPowerCfg.ID, Zcl.Header.fromBuffer(buffer)!, buffer, {});
268
+ const header = new Zcl.Header(
269
+ {
270
+ reservedBits: 0,
271
+ direction: 1,
272
+ disableDefaultResponse: false,
273
+ frameType: 0,
274
+ manufacturerSpecific: false,
275
+ },
276
+ undefined,
277
+ 1,
278
+ 7,
279
+ );
280
+
281
+ const payload = [
282
+ {status: 0, direction: 1, attrId: 0x1234},
283
+ {status: 1, direction: 1, attrId: 0x1235},
284
+ ];
285
+
286
+ expect(frame.header).toStrictEqual(header);
287
+ expect(frame.payload).toStrictEqual(payload);
288
+ });
289
+
290
+ it("ZclFrame from buffer configReportRsp (hvacThermostat)", () => {
291
+ const buffer = Buffer.from([0x18, 0x03, 0x07, 0x00, 0x00, 0x12, 0x00]);
292
+ const frame = Zcl.Frame.fromBuffer(Zcl.Clusters.hvacThermostat.ID, Zcl.Header.fromBuffer(buffer)!, buffer, {});
293
+ const header = new Zcl.Header(
294
+ {
295
+ reservedBits: 0,
296
+ direction: 1,
297
+ disableDefaultResponse: true,
298
+ frameType: 0,
299
+ manufacturerSpecific: false,
300
+ },
301
+ undefined,
302
+ 3,
303
+ 7,
304
+ );
305
+
306
+ const payload = [{status: 0, direction: 0, attrId: 18}];
307
+
308
+ expect(frame.payload).toStrictEqual(payload);
309
+ expect(frame.header).toStrictEqual(header);
310
+ });
311
+
312
+ it("ZclFrame from buffer getWeeklyScheduleRsp (hvacThermostat)", () => {
313
+ const bufferHeat = Buffer.from([
314
+ 9, 7, 0, 6, 64, 1, 104, 1, 252, 8, 58, 2, 152, 8, 208, 2, 102, 8, 72, 3, 102, 8, 222, 3, 252, 8, 100, 5, 52, 8,
315
+ ]);
316
+ const frameHeat = Zcl.Frame.fromBuffer(Zcl.Clusters.hvacThermostat.ID, Zcl.Header.fromBuffer(bufferHeat)!, bufferHeat, {});
317
+ expect(frameHeat.payload).toStrictEqual({
318
+ numoftrans: 6,
319
+ dayofweek: 64,
320
+ mode: 1,
321
+ transitions: [
322
+ {transitionTime: 360, heatSetpoint: 2300},
323
+ {transitionTime: 570, heatSetpoint: 2200},
324
+ {transitionTime: 720, heatSetpoint: 2150},
325
+ {transitionTime: 840, heatSetpoint: 2150},
326
+ {transitionTime: 990, heatSetpoint: 2300},
327
+ {transitionTime: 1380, heatSetpoint: 2100},
328
+ ],
329
+ });
330
+
331
+ const bufferCool = Buffer.from([
332
+ 9, 7, 0, 6, 64, 2, 104, 1, 252, 8, 58, 2, 152, 8, 208, 2, 102, 8, 72, 3, 102, 8, 222, 3, 252, 8, 100, 5, 52, 8,
333
+ ]);
334
+ const frameCool = Zcl.Frame.fromBuffer(Zcl.Clusters.hvacThermostat.ID, Zcl.Header.fromBuffer(bufferCool)!, bufferCool, {});
335
+ expect(frameCool.payload).toStrictEqual({
336
+ numoftrans: 6,
337
+ dayofweek: 64,
338
+ mode: 2,
339
+ transitions: [
340
+ {transitionTime: 360, coolSetpoint: 2300},
341
+ {transitionTime: 570, coolSetpoint: 2200},
342
+ {transitionTime: 720, coolSetpoint: 2150},
343
+ {transitionTime: 840, coolSetpoint: 2150},
344
+ {transitionTime: 990, coolSetpoint: 2300},
345
+ {transitionTime: 1380, coolSetpoint: 2100},
346
+ ],
347
+ });
348
+
349
+ const bufferHeatAndCool = Buffer.from([9, 7, 0, 1, 64, 3, 104, 1, 252, 8, 58, 2]);
350
+ const frameHeatAndCool = Zcl.Frame.fromBuffer(
351
+ Zcl.Clusters.hvacThermostat.ID,
352
+ Zcl.Header.fromBuffer(bufferHeatAndCool)!,
353
+ bufferHeatAndCool,
354
+ {},
355
+ );
356
+ expect(frameHeatAndCool.payload).toStrictEqual({
357
+ numoftrans: 1,
358
+ dayofweek: 64,
359
+ mode: 3,
360
+ transitions: [{transitionTime: 360, coolSetpoint: 570, heatSetpoint: 2300}],
361
+ });
362
+ });
363
+
364
+ it("ZclFrame to buffer setWeeklyScheduleRsp (hvacThermostat)", () => {
365
+ const payloadHeat = {
366
+ numoftrans: 6,
367
+ dayofweek: 64,
368
+ mode: 1,
369
+ transitions: [
370
+ {transitionTime: 360, heatSetpoint: 23},
371
+ {transitionTime: 570, heatSetpoint: 2200},
372
+ {transitionTime: 720, heatSetpoint: 2150},
373
+ {transitionTime: 840, heatSetpoint: 2150},
374
+ {transitionTime: 990, heatSetpoint: 2300},
375
+ {transitionTime: 1380, heatSetpoint: 2100},
376
+ ],
377
+ };
378
+ const frameHeat = Zcl.Frame.create(
379
+ FrameType.SPECIFIC,
380
+ Direction.CLIENT_TO_SERVER,
381
+ false,
382
+ undefined,
383
+ 8,
384
+ "setWeeklySchedule",
385
+ 513,
386
+ payloadHeat,
387
+ {},
388
+ );
389
+ expect(frameHeat.toBuffer()).toStrictEqual(
390
+ Buffer.from([1, 8, 1, 6, 64, 1, 104, 1, 23, 0, 58, 2, 152, 8, 208, 2, 102, 8, 72, 3, 102, 8, 222, 3, 252, 8, 100, 5, 52, 8]),
391
+ );
392
+
393
+ const payloadCool = {
394
+ numoftrans: 6,
395
+ dayofweek: 64,
396
+ mode: 2,
397
+ transitions: [
398
+ {transitionTime: 360, coolSetpoint: 2300},
399
+ {transitionTime: 570, coolSetpoint: 2200},
400
+ {transitionTime: 720, coolSetpoint: 2150},
401
+ {transitionTime: 840, coolSetpoint: 2150},
402
+ {transitionTime: 990, coolSetpoint: 2300},
403
+ {transitionTime: 1380, coolSetpoint: 2100},
404
+ ],
405
+ };
406
+ const frameCool = Zcl.Frame.create(
407
+ FrameType.SPECIFIC,
408
+ Direction.CLIENT_TO_SERVER,
409
+ false,
410
+ undefined,
411
+ 8,
412
+ "setWeeklySchedule",
413
+ 513,
414
+ payloadCool,
415
+ {},
416
+ );
417
+ expect(frameCool.toBuffer()).toStrictEqual(
418
+ Buffer.from([1, 8, 1, 6, 64, 2, 104, 1, 252, 8, 58, 2, 152, 8, 208, 2, 102, 8, 72, 3, 102, 8, 222, 3, 252, 8, 100, 5, 52, 8]),
419
+ );
420
+
421
+ const payloadHeatAndCool = {
422
+ numoftrans: 6,
423
+ dayofweek: 64,
424
+ mode: 2,
425
+ transitions: [{transitionTime: 360, coolSetpoint: 570, heatSetpoint: 2300}],
426
+ };
427
+ const frameHeatAndCool = Zcl.Frame.create(
428
+ FrameType.SPECIFIC,
429
+ Direction.CLIENT_TO_SERVER,
430
+ false,
431
+ undefined,
432
+ 8,
433
+ "setWeeklySchedule",
434
+ 513,
435
+ payloadHeatAndCool,
436
+ {},
437
+ );
438
+ expect(frameHeatAndCool.toBuffer()).toStrictEqual(Buffer.from([1, 8, 1, 6, 64, 2, 104, 1, 252, 8, 58, 2]));
439
+ });
440
+
441
+ it("ZclFrame from buffer configReportRsp failed", () => {
442
+ const buffer = Buffer.from([0x08, 0x01, 0x07, 0x02, 0x01, 0x01, 0x01]);
443
+ const frame = Zcl.Frame.fromBuffer(Zcl.Clusters.genPowerCfg.ID, Zcl.Header.fromBuffer(buffer)!, buffer, {});
444
+ const header = new Zcl.Header(
445
+ {
446
+ reservedBits: 0,
447
+ direction: 1,
448
+ disableDefaultResponse: false,
449
+ frameType: 0,
450
+ manufacturerSpecific: false,
451
+ },
452
+ undefined,
453
+ 1,
454
+ 7,
455
+ );
456
+
457
+ const payload = [{status: 2, direction: 1, attrId: 257}];
458
+
459
+ expect(frame.header).toStrictEqual(header);
460
+ expect(frame.payload).toStrictEqual(payload);
461
+ });
462
+
463
+ it("ZclFrame from buffer defaultRsp", () => {
464
+ const buffer = Buffer.from([0x18, 0x04, 0x0b, 0x0c, 0x82]);
465
+ const frame = Zcl.Frame.fromBuffer(Zcl.Clusters.genBasic.ID, Zcl.Header.fromBuffer(buffer)!, buffer, {});
466
+ const header = new Zcl.Header(
467
+ {
468
+ reservedBits: 0,
469
+ direction: 1,
470
+ disableDefaultResponse: true,
471
+ frameType: 0,
472
+ manufacturerSpecific: false,
473
+ },
474
+ undefined,
475
+ 4,
476
+ 11,
477
+ );
478
+
479
+ const payload = {cmdId: 12, statusCode: 130};
480
+
481
+ expect(frame.header).toStrictEqual(header);
482
+ expect(frame.payload).toStrictEqual(payload);
483
+ });
484
+
485
+ test.each([
486
+ [
487
+ [
488
+ 28, 95, 17, 3, 10, 1, 255, 66, 68, 3, 40, 29, 5, 33, 190, 45, 8, 33, 47, 18, 9, 33, 2, 21, 100, 16, 1, 101, 16, 0, 110, 32, 255, 111,
489
+ 32, 255, 148, 32, 4, 149, 57, 184, 30, 21, 62, 150, 57, 211, 249, 17, 69, 151, 57, 0, 48, 104, 59, 152, 57, 0, 0, 0, 0, 155, 33, 1, 0,
490
+ 156, 32, 1, 10, 33, 56, 38, 12, 40, 0, 0,
491
+ ],
492
+ [
493
+ {
494
+ attrId: 65281,
495
+ dataType: 66,
496
+ attrData: {
497
+ "3": 29,
498
+ "5": 11710,
499
+ "8": 4655,
500
+ "9": 5378,
501
+ "10": 9784,
502
+ "12": 0,
503
+ "100": 1,
504
+ "101": 0,
505
+ "110": 255,
506
+ "111": 255,
507
+ "148": 4,
508
+ "149": 0.14562499523162842,
509
+ "150": 2335.614013671875,
510
+ "151": 0.0035429000854492188,
511
+ "152": 0,
512
+ "155": 1,
513
+ "156": 1,
514
+ },
515
+ },
516
+ ],
517
+ ],
518
+ [
519
+ [
520
+ 28, 95, 17, 3, 10, 5, 0, 66, 21, 108, 117, 109, 105, 46, 115, 101, 110, 115, 111, 114, 95, 119, 108, 101, 97, 107, 46, 97, 113, 49, 1,
521
+ 255, 66, 34, 1, 33, 213, 12, 3, 40, 33, 4, 33, 168, 19, 5, 33, 43, 0, 6, 36, 0, 0, 5, 0, 0, 8, 33, 4, 2, 10, 33, 0, 0, 100, 16, 0,
522
+ ],
523
+ [
524
+ {attrId: 5, dataType: 66, attrData: "lumi.sensor_wleak.aq1"},
525
+ {attrId: 65281, dataType: 66, attrData: {"1": 3285, "3": 33, "4": 5032, "5": 43, "6": 327680, "8": 516, "10": 0, "100": 0}},
526
+ ],
527
+ ],
528
+ ])("ZclFrame from buffer xiaomiStruct", (data, payload) => {
529
+ const buffer = Buffer.from(data);
530
+ const frame = Zcl.Frame.fromBuffer(Zcl.Clusters.genBasic.ID, Zcl.Header.fromBuffer(buffer)!, buffer, {});
531
+ const header = new Zcl.Header(
532
+ {
533
+ reservedBits: 0,
534
+ direction: 1,
535
+ disableDefaultResponse: true,
536
+ frameType: 0,
537
+ manufacturerSpecific: true,
538
+ },
539
+ 4447,
540
+ 3,
541
+ 10,
542
+ );
543
+
544
+ expect(frame.header).toStrictEqual(header);
545
+ expect(frame.payload).toStrictEqual(payload);
546
+ });
547
+
548
+ it("ZclFrame from buffer struct", () => {
549
+ const buffer = Buffer.from([28, 52, 18, 194, 10, 2, 255, 76, 6, 0, 16, 1, 33, 206, 11, 33, 168, 67, 36, 1, 0, 0, 0, 0, 33, 48, 2, 32, 86]);
550
+ const frame = Zcl.Frame.fromBuffer(Zcl.Clusters.genBasic.ID, Zcl.Header.fromBuffer(buffer)!, buffer, {});
551
+ const header = new Zcl.Header(
552
+ {
553
+ reservedBits: 0,
554
+ direction: 1,
555
+ disableDefaultResponse: true,
556
+ frameType: 0,
557
+ manufacturerSpecific: true,
558
+ },
559
+ 4660,
560
+ 194,
561
+ 10,
562
+ );
563
+
564
+ const payload = [
565
+ {
566
+ attrId: 65282,
567
+ dataType: 76,
568
+ numElms: 6,
569
+ structElms: [
570
+ {elmType: 16, elmVal: 1},
571
+ {elmType: 33, elmVal: 3022},
572
+ {elmType: 33, elmVal: 17320},
573
+ {elmType: 36, elmVal: 1},
574
+ {elmType: 33, elmVal: 560},
575
+ {elmType: 32, elmVal: 86},
576
+ ],
577
+ attrData: [
578
+ {elmType: 16, elmVal: 1},
579
+ {elmType: 33, elmVal: 3022},
580
+ {elmType: 33, elmVal: 17320},
581
+ {elmType: 36, elmVal: 1},
582
+ {elmType: 33, elmVal: 560},
583
+ {elmType: 32, elmVal: 86},
584
+ ],
585
+ },
586
+ ];
587
+
588
+ expect(frame.header).toStrictEqual(header);
589
+ expect(frame.payload).toStrictEqual(payload);
590
+ });
591
+
592
+ it("ZclFrame from buffer discoverRsp", () => {
593
+ const buffer = Buffer.from([24, 23, 13, 0, 32, 0, 32, 33, 0, 32, 49, 0, 48, 51, 0, 32, 53, 0, 24]);
594
+ const frame = Zcl.Frame.fromBuffer(Zcl.Clusters.genPowerCfg.ID, Zcl.Header.fromBuffer(buffer)!, buffer, {});
595
+ const header = new Zcl.Header(
596
+ {
597
+ reservedBits: 0,
598
+ direction: 1,
599
+ disableDefaultResponse: true,
600
+ frameType: 0,
601
+ manufacturerSpecific: false,
602
+ },
603
+ undefined,
604
+ 23,
605
+ 13,
606
+ );
607
+
608
+ const payload = {
609
+ discComplete: 0,
610
+ attrInfos: [
611
+ {attrId: 32, dataType: 32},
612
+ {attrId: 33, dataType: 32},
613
+ {attrId: 49, dataType: 48},
614
+ {attrId: 51, dataType: 32},
615
+ {attrId: 53, dataType: 24},
616
+ ],
617
+ };
618
+
619
+ expect(frame.header).toStrictEqual(header);
620
+ expect(frame.payload).toStrictEqual(payload);
621
+ expect(frame.cluster.name).toEqual("genPowerCfg");
622
+ expect(frame.command.name).toEqual("discoverRsp");
623
+ });
624
+
625
+ it("ZclFrame from buffer error on malformed", () => {
626
+ const buffer = Buffer.from([0x08, 0x01]);
627
+ expect(() => {
628
+ Zcl.Frame.fromBuffer(Zcl.Clusters.genPowerCfg.ID, Zcl.Header.fromBuffer(buffer)!, buffer, {});
629
+ }).toThrow("Invalid ZclHeader");
630
+ });
631
+
632
+ it("ZclFrame from buffer readRsp failed", () => {
633
+ const buffer = Buffer.from([8, 1, 1, 1, 0, 2]);
634
+ const frame = Zcl.Frame.fromBuffer(Zcl.Clusters.genBasic.ID, Zcl.Header.fromBuffer(buffer)!, buffer, {});
635
+ const header = new Zcl.Header(
636
+ {
637
+ reservedBits: 0,
638
+ direction: 1,
639
+ disableDefaultResponse: false,
640
+ frameType: 0,
641
+ manufacturerSpecific: false,
642
+ },
643
+ undefined,
644
+ 1,
645
+ 1,
646
+ );
647
+
648
+ const payload = [{status: 2, attrId: 1}];
649
+
650
+ expect(frame.header).toStrictEqual(header);
651
+ expect(frame.payload).toStrictEqual(payload);
652
+ });
653
+
654
+ it("ZclFrame from buffer readRsp success", () => {
655
+ const buffer = Buffer.from([8, 1, 1, 1, 0, 0, 32, 3]);
656
+ const frame = Zcl.Frame.fromBuffer(Zcl.Clusters.genBasic.ID, Zcl.Header.fromBuffer(buffer)!, buffer, {});
657
+ const header = new Zcl.Header(
658
+ {
659
+ reservedBits: 0,
660
+ direction: 1,
661
+ disableDefaultResponse: false,
662
+ frameType: 0,
663
+ manufacturerSpecific: false,
664
+ },
665
+ undefined,
666
+ 1,
667
+ 1,
668
+ );
669
+
670
+ const payload = [{status: Zcl.Status.SUCCESS, attrId: 1, dataType: Zcl.DataType.UINT8, attrData: 3}];
671
+
672
+ expect(frame.header).toStrictEqual(header);
673
+ expect(frame.payload).toStrictEqual(payload);
674
+ });
675
+
676
+ it("ZclFrame from buffer GPD commission", () => {
677
+ const buffer = Buffer.from([
678
+ 0x11, 0x00, 0x04, 0x00, 0x00, 0xfe, 0xf4, 0x46, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xe0, 0x1b, 0x02, 0x81, 0xf2, 0xf1, 0xec, 0x92, 0xab, 0xff,
679
+ 0x8f, 0x13, 0x63, 0xe1, 0x46, 0xbe, 0xb5, 0x18, 0xc9, 0x0c, 0xab, 0xa4, 0x46, 0xd4, 0xd5, 0xf9, 0x01, 0x00, 0x00,
680
+ ]);
681
+ const frame = Zcl.Frame.fromBuffer(Zcl.Clusters.greenPower.ID, Zcl.Header.fromBuffer(buffer)!, buffer, {});
682
+ const header = new Zcl.Header(
683
+ {
684
+ reservedBits: 0,
685
+ direction: 0,
686
+ disableDefaultResponse: true,
687
+ frameType: 1,
688
+ manufacturerSpecific: false,
689
+ },
690
+ undefined,
691
+ 0,
692
+ 4,
693
+ );
694
+
695
+ const payload = {
696
+ options: 0,
697
+ srcID: 4650238,
698
+ frameCounter: 249,
699
+ commandID: 224,
700
+ payloadSize: 27,
701
+ commandFrame: {
702
+ deviceID: 2,
703
+ options: 129,
704
+ extendedOptions: 242,
705
+ gpdClientClusters: Buffer.alloc(0),
706
+ gpdServerClusters: Buffer.alloc(0),
707
+ manufacturerID: 0,
708
+ modelID: 0,
709
+ numClientClusters: 0,
710
+ numServerClusters: 0,
711
+ securityKey: Buffer.from([0xf1, 0xec, 0x92, 0xab, 0xff, 0x8f, 0x13, 0x63, 0xe1, 0x46, 0xbe, 0xb5, 0x18, 0xc9, 0x0c, 0xab]),
712
+ keyMic: 3587458724,
713
+ outgoingCounter: 505,
714
+ applicationInfo: 0,
715
+ numGpdCommands: 0,
716
+ gpdCommandIdList: Buffer.alloc(0),
717
+ genericSwitchConfig: 0,
718
+ currentContactStatus: 0,
719
+ },
720
+ };
721
+
722
+ expect(frame.header).toStrictEqual(header);
723
+ expect(frame.payload).toStrictEqual(payload);
724
+ });
725
+
726
+ it("ZclFrame from buffer GPD scene 0", () => {
727
+ const buffer = Buffer.from([0x11, 0x00, 0x00, 0xa0, 0x14, 0xfe, 0xf4, 0x46, 0x00, 0xe5, 0x04, 0x00, 0x00, 0x10, 0xff]);
728
+ const frame = Zcl.Frame.fromBuffer(Zcl.Clusters.greenPower.ID, Zcl.Header.fromBuffer(buffer)!, buffer, {});
729
+ const header = new Zcl.Header(
730
+ {
731
+ reservedBits: 0,
732
+ direction: 0,
733
+ disableDefaultResponse: true,
734
+ frameType: 1,
735
+ manufacturerSpecific: false,
736
+ },
737
+ undefined,
738
+ 0,
739
+ 0,
740
+ );
741
+
742
+ const payload = {
743
+ srcID: 4650238,
744
+ commandFrame: {},
745
+ commandID: 16,
746
+ frameCounter: 1253,
747
+ options: 5280,
748
+ payloadSize: 255,
749
+ };
750
+
751
+ expect(frame.header).toStrictEqual(header);
752
+ expect(frame.payload).toStrictEqual(payload);
753
+ });
754
+
755
+ it("ZclFrame from buffer GPD with extra data", () => {
756
+ const buffer = Buffer.from([0x11, 0x00, 0x00, 0xa0, 0x14, 0xfe, 0xf4, 0x46, 0x00, 0xe5, 0x04, 0x00, 0x00, 0x10, 0xff, 0x01]);
757
+ const frame = Zcl.Frame.fromBuffer(Zcl.Clusters.greenPower.ID, Zcl.Header.fromBuffer(buffer)!, buffer, {});
758
+ const header = new Zcl.Header(
759
+ {
760
+ reservedBits: 0,
761
+ direction: 0,
762
+ disableDefaultResponse: true,
763
+ frameType: 1,
764
+ manufacturerSpecific: false,
765
+ },
766
+ undefined,
767
+ 0,
768
+ 0,
769
+ );
770
+
771
+ const payload = {
772
+ srcID: 4650238,
773
+ commandFrame: {raw: Buffer.from([1])},
774
+ commandID: 16,
775
+ frameCounter: 1253,
776
+ options: 5280,
777
+ payloadSize: 255,
778
+ };
779
+
780
+ expect(frame.header).toStrictEqual(header);
781
+ expect(frame.payload).toStrictEqual(payload);
782
+ });
783
+
784
+ it("ZclFrame from buffer GPD pairing", () => {
785
+ const buffer = Buffer.from([
786
+ 0x19, 0x17, 0x01, 0x68, 0xe5, 0x00, 0xf8, 0x71, 0x71, 0x01, 0x47, 0x65, 0xa1, 0x1c, 0x00, 0x4b, 0x12, 0x00, 0x00, 0x00, 0x02, 0x1c, 0x12,
787
+ 0x00, 0x00, 0x09, 0x3c, 0xed, 0x1d, 0xbf, 0x25, 0x63, 0xf9, 0x29, 0x5c, 0x0d, 0x3d, 0x9f, 0xc5, 0x76, 0xe1, 0, 0, 0, 0, 0, 0,
788
+ ]);
789
+ const frame = Zcl.Frame.fromBuffer(Zcl.Clusters.greenPower.ID, Zcl.Header.fromBuffer(buffer)!, buffer, {});
790
+ const header = new Zcl.Header(
791
+ {
792
+ reservedBits: 0,
793
+ direction: 1,
794
+ disableDefaultResponse: true,
795
+ frameType: 1,
796
+ manufacturerSpecific: false,
797
+ },
798
+ undefined,
799
+ 23,
800
+ 1,
801
+ );
802
+
803
+ const payload = {
804
+ options: 0x00e568,
805
+ srcID: 0x017171f8,
806
+ sinkIEEEAddr: "0x00124b001ca16547",
807
+ sinkNwkAddr: 0,
808
+ deviceID: 2,
809
+ frameCounter: 4636,
810
+ gpdKey: Buffer.from([0x09, 0x3c, 0xed, 0x1d, 0xbf, 0x25, 0x63, 0xf9, 0x29, 0x5c, 0x0d, 0x3d, 0x9f, 0xc5, 0x76, 0xe1]),
811
+ };
812
+
813
+ expect(frame.header).toStrictEqual(header);
814
+ expect(frame.payload).toStrictEqual(payload);
815
+ });
816
+
817
+ it("ZclFrame from buffer readRsp alias type", () => {
818
+ const buffer = Buffer.from([8, 1, 1, 1, 0, 0, 8, 3]);
819
+ const frame = Zcl.Frame.fromBuffer(Zcl.Clusters.genBasic.ID, Zcl.Header.fromBuffer(buffer)!, buffer, {});
820
+ const header = new Zcl.Header(
821
+ {
822
+ reservedBits: 0,
823
+ direction: 1,
824
+ disableDefaultResponse: false,
825
+ frameType: 0,
826
+ manufacturerSpecific: false,
827
+ },
828
+ undefined,
829
+ 1,
830
+ 1,
831
+ );
832
+
833
+ const payload = [{status: Zcl.Status.SUCCESS, attrId: 1, dataType: Zcl.DataType.DATA8, attrData: 3}];
834
+
835
+ expect(frame.header).toStrictEqual(header);
836
+ expect(frame.payload).toStrictEqual(payload);
837
+ });
838
+
839
+ it("ZclFrame from buffer configReportRsp server to client", () => {
840
+ const buffer = Buffer.from([8, 1, 6, 1, 1, 0, 10, 10]);
841
+ const frame = Zcl.Frame.fromBuffer(Zcl.Clusters.genBasic.ID, Zcl.Header.fromBuffer(buffer)!, buffer, {});
842
+ const header = new Zcl.Header(
843
+ {
844
+ reservedBits: 0,
845
+ direction: 1,
846
+ disableDefaultResponse: false,
847
+ frameType: 0,
848
+ manufacturerSpecific: false,
849
+ },
850
+ undefined,
851
+ 1,
852
+ 6,
853
+ );
854
+
855
+ const payload = [{attrId: 1, direction: 1, timeout: 2570}];
856
+
857
+ expect(frame.header).toStrictEqual(header);
858
+ expect(frame.payload).toStrictEqual(payload);
859
+ });
860
+
861
+ it("ZclFrame from buffer configReportRsp client to server analog", () => {
862
+ const buffer = Buffer.from([8, 1, 6, 0, 0, 1, 32, 1, 0, 10, 0, 20]);
863
+ const frame = Zcl.Frame.fromBuffer(Zcl.Clusters.genBasic.ID, Zcl.Header.fromBuffer(buffer)!, buffer, {});
864
+ const header = new Zcl.Header(
865
+ {
866
+ reservedBits: 0,
867
+ direction: 1,
868
+ disableDefaultResponse: false,
869
+ frameType: 0,
870
+ manufacturerSpecific: false,
871
+ },
872
+ undefined,
873
+ 1,
874
+ 6,
875
+ );
876
+
877
+ const payload = [{attrId: 256, dataType: 32, direction: 0, maxRepIntval: 10, minRepIntval: 1, repChange: 20}];
878
+
879
+ expect(frame.header).toStrictEqual(header);
880
+ expect(frame.payload).toStrictEqual(payload);
881
+ });
882
+
883
+ it("ZclFrame from buffer configReportRsp client to server analog", () => {
884
+ const buffer = Buffer.from([8, 1, 6, 0, 0, 1, 8, 1, 0, 10, 0]);
885
+ const frame = Zcl.Frame.fromBuffer(Zcl.Clusters.genBasic.ID, Zcl.Header.fromBuffer(buffer)!, buffer, {});
886
+ const header = new Zcl.Header(
887
+ {
888
+ reservedBits: 0,
889
+ direction: 1,
890
+ disableDefaultResponse: false,
891
+ frameType: 0,
892
+ manufacturerSpecific: false,
893
+ },
894
+ undefined,
895
+ 1,
896
+ 6,
897
+ );
898
+
899
+ const payload = [{attrId: 256, dataType: 8, direction: 0, maxRepIntval: 10, minRepIntval: 1}];
900
+
901
+ expect(frame.header).toStrictEqual(header);
902
+ expect(frame.payload).toStrictEqual(payload);
903
+ });
904
+
905
+ it("ZclFrame from buffer readRsp", () => {
906
+ const buffer = Buffer.from([
907
+ 24, 7, 1, 5, 0, 0, 66, 30, 84, 82, 65, 68, 70, 82, 73, 32, 98, 117, 108, 98, 32, 69, 50, 55, 32, 87, 83, 32, 111, 112, 97, 108, 32, 57,
908
+ 56, 48, 108, 109, 6, 0, 0, 66, 8, 50, 48, 49, 55, 48, 51, 51, 49, 7, 0, 0, 48, 1, 10, 0, 0, 65, 15, 76, 69, 68, 49, 53, 52, 53, 71, 49,
909
+ 50, 69, 50, 55, 69, 85,
910
+ ]);
911
+ const frame = Zcl.Frame.fromBuffer(Zcl.Clusters.genBasic.ID, Zcl.Header.fromBuffer(buffer)!, buffer, {});
912
+ const header = new Zcl.Header(
913
+ {
914
+ reservedBits: 0,
915
+ direction: 1,
916
+ disableDefaultResponse: true,
917
+ frameType: 0,
918
+ manufacturerSpecific: false,
919
+ },
920
+ undefined,
921
+ 7,
922
+ 1,
923
+ );
924
+
925
+ const payload = [
926
+ {attrId: 5, status: 0, dataType: 66, attrData: "TRADFRI bulb E27 WS opal 980lm"},
927
+ {attrId: 6, status: 0, dataType: 66, attrData: "20170331"},
928
+ {attrId: 7, status: 0, dataType: 48, attrData: 1},
929
+ {attrId: 10, status: 0, dataType: 65, attrData: Buffer.from([76, 69, 68, 49, 53, 52, 53, 71, 49, 50, 69, 50, 55, 69, 85])},
930
+ ];
931
+
932
+ expect(frame.header).toStrictEqual(header);
933
+ expect(frame.payload).toStrictEqual(payload);
934
+ });
935
+
936
+ it("ZclFrame with Assa (manufacturer specific) cluster create", () => {
937
+ const payload = [{attrId: 0x0012, status: 0, attrData: 1, dataType: 32}];
938
+ const frame = Zcl.Frame.create(FrameType.GLOBAL, Direction.CLIENT_TO_SERVER, false, 0x101d, 8, "readRsp", 0xfc00, payload, {});
939
+
940
+ expect(frame.cluster.name).toBe("manuSpecificAssaDoorLock");
941
+ });
942
+
943
+ it("ZclFrame with Assa (manufacturer specific) cluster create with non Assamanufcode", () => {
944
+ const payload = [{attrId: 0x0012, status: 0, attrData: 1, dataType: 32}];
945
+ const frame = Zcl.Frame.create(FrameType.GLOBAL, Direction.CLIENT_TO_SERVER, false, 0x10f3, 8, "readRsp", 0xfc00, payload, {});
946
+
947
+ expect(frame.cluster.name).toBe("manuSpecificAssaDoorLock");
948
+ });
949
+
950
+ it("ZclFrame with Assa (manufacturer specific) cluster fromBuffer", () => {
951
+ const buffer = Buffer.from([0x04, 0xf2, 0x10, 0x08, 0x01, 0x00, 0x00, 0x00, 0x20, 0x01]);
952
+ const frame = Zcl.Frame.fromBuffer(0xfc00, Zcl.Header.fromBuffer(buffer)!, buffer, {});
953
+ expect(frame.cluster.name).toBe("manuSpecificAssaDoorLock");
954
+ });
955
+
956
+ it("ZclFrame to buffer with reservered bits", () => {
957
+ const expected = Buffer.from([224, 8, 12, 0, 0, 240]);
958
+ const payload = {startAttrId: 0, maxAttrIds: 240};
959
+ const frame = Zcl.Frame.create(FrameType.GLOBAL, Direction.CLIENT_TO_SERVER, false, undefined, 8, "discover", 0, payload, {}, 7);
960
+
961
+ expect(frame.toBuffer()).toStrictEqual(expected);
962
+ });
963
+
964
+ it("ZclFrame from buffer with reservered bits", () => {
965
+ const buffer = Buffer.from([224, 8, 12, 0, 0, 240]);
966
+ const frame = Zcl.Frame.fromBuffer(0, Zcl.Header.fromBuffer(buffer)!, buffer, {});
967
+ const header = new Zcl.Header(
968
+ {
969
+ reservedBits: 7,
970
+ direction: 0,
971
+ disableDefaultResponse: false,
972
+ frameType: 0,
973
+ manufacturerSpecific: false,
974
+ },
975
+ undefined,
976
+ 8,
977
+ 12,
978
+ );
979
+
980
+ const payload = {startAttrId: 0, maxAttrIds: 240};
981
+
982
+ expect(frame.header).toStrictEqual(header);
983
+ expect(frame.payload).toStrictEqual(payload);
984
+ });
985
+
986
+ it("ZclFrame to buffer discover", () => {
987
+ const expected = Buffer.from([0, 8, 12, 0, 0, 240]);
988
+ const payload = {startAttrId: 0, maxAttrIds: 240};
989
+ const frame = Zcl.Frame.create(FrameType.GLOBAL, Direction.CLIENT_TO_SERVER, false, undefined, 8, "discover", 0, payload, {});
990
+
991
+ expect(frame.toBuffer()).toStrictEqual(expected);
992
+ });
993
+
994
+ it("ZclFrame to buffer queryNextImageResponse with non zero status", () => {
995
+ const expected = Buffer.from([9, 8, 2, 1]);
996
+ const payload = {status: 1};
997
+ const frame = Zcl.Frame.create(
998
+ FrameType.SPECIFIC,
999
+ Direction.SERVER_TO_CLIENT,
1000
+ false,
1001
+ undefined,
1002
+ 8,
1003
+ "queryNextImageResponse",
1004
+ 25,
1005
+ payload,
1006
+ {},
1007
+ );
1008
+
1009
+ expect(frame.toBuffer()).toStrictEqual(expected);
1010
+ });
1011
+
1012
+ it("ZclFrame to buffer queryNextImageResponse with zero status", () => {
1013
+ const expected = Buffer.from([9, 8, 2, 0, 1, 0, 3, 0, 5, 0, 0, 0, 6, 0, 0, 0]);
1014
+ const payload = {status: 0, manufacturerCode: 1, imageType: 3, fileVersion: 5, imageSize: 6};
1015
+ const frame = Zcl.Frame.create(
1016
+ FrameType.SPECIFIC,
1017
+ Direction.SERVER_TO_CLIENT,
1018
+ false,
1019
+ undefined,
1020
+ 8,
1021
+ "queryNextImageResponse",
1022
+ 25,
1023
+ payload,
1024
+ {},
1025
+ );
1026
+
1027
+ expect(frame.toBuffer()).toStrictEqual(expected);
1028
+ });
1029
+
1030
+ it("ZclFrame to buffer queryNextImageResponse with zero status and missing parameters", () => {
1031
+ const payload = {status: 0};
1032
+ const frame = Zcl.Frame.create(
1033
+ FrameType.SPECIFIC,
1034
+ Direction.SERVER_TO_CLIENT,
1035
+ false,
1036
+ undefined,
1037
+ 8,
1038
+ "queryNextImageResponse",
1039
+ 25,
1040
+ payload,
1041
+ {},
1042
+ );
1043
+
1044
+ let error;
1045
+ try {
1046
+ frame.toBuffer();
1047
+ } catch (e) {
1048
+ error = e;
1049
+ }
1050
+ expect(error).toStrictEqual(new Error(`Parameter 'manufacturerCode' is missing`));
1051
+ });
1052
+
1053
+ it("ZclFrame to buffer readRsp UTC", () => {
1054
+ const expected = Buffer.from([24, 74, 1, 0, 0, 0, 226, 234, 83, 218, 36]);
1055
+ const payload = [{attrId: 0, status: 0, attrData: 618288106, dataType: 226}];
1056
+ const frame = Zcl.Frame.create(FrameType.GLOBAL, Direction.SERVER_TO_CLIENT, true, undefined, 74, "readRsp", 0, payload, {});
1057
+
1058
+ expect(frame.toBuffer()).toStrictEqual(expected);
1059
+ });
1060
+
1061
+ it("ZclFrame to buffer write Livolo malformed", () => {
1062
+ // Created as example for https://github.com/Koenkk/zigbee-herdsman/issues/127
1063
+ const expectedOn = Buffer.from([0x1c, 0xd2, 0x1a, 0xe9, 0x02, 0x01, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00]);
1064
+ const payloadOn = [{attrId: 1, attrData: Buffer.from([1, 0, 0, 0, 0, 0, 0, 0]), dataType: 1}];
1065
+ const frameOn = Zcl.Frame.create(FrameType.GLOBAL, Direction.SERVER_TO_CLIENT, true, 0x1ad2, 233, "write", 0, payloadOn, {});
1066
+ expect(frameOn.toBuffer()).toStrictEqual(expectedOn);
1067
+
1068
+ const expectedOff = Buffer.from([0x1c, 0xd2, 0x1a, 0xe9, 0x02, 0x01, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00]);
1069
+ const payloadOff = [{attrId: 1, attrData: Buffer.from([0, 0, 0, 0, 0, 0, 0, 0]), dataType: 1}];
1070
+ const frameOff = Zcl.Frame.create(FrameType.GLOBAL, Direction.SERVER_TO_CLIENT, true, 0x1ad2, 233, "write", 0, payloadOff, {});
1071
+ expect(frameOff.toBuffer()).toStrictEqual(expectedOff);
1072
+ });
1073
+
1074
+ it("ZclFrame write request with string as bytes array", () => {
1075
+ const payload = [{attrId: 0x0401, attrData: [0x07, 0x00, 0x02, 0x01, 0x00, 0x00, 0x00, 0x14], dataType: 0x42}];
1076
+ const frame = Zcl.Frame.create(FrameType.GLOBAL, Direction.CLIENT_TO_SERVER, true, 0x115f, 15, "write", 0, payload, {});
1077
+
1078
+ const expected = [0x14, 0x5f, 0x11, 0x0f, 0x02, 0x01, 0x04, 0x42, 0x07, 0x00, 0x02, 0x01, 0x00, 0x00, 0x00, 0x14];
1079
+ expect(Buffer.from(expected)).toStrictEqual(frame.toBuffer());
1080
+ });
1081
+
1082
+ it("ZclFrame write rsp", () => {
1083
+ const payload = [{status: 0x11, attrId: 0x22}];
1084
+ const frame = Zcl.Frame.create(FrameType.GLOBAL, Direction.CLIENT_TO_SERVER, true, 0x115f, 15, "writeRsp", 0, payload, {});
1085
+ const buffer = frame.toBuffer();
1086
+
1087
+ const expected = [0x14, 0x5f, 0x11, 0x0f, 0x04, 0x11, 0x22, 0x00];
1088
+ expect(Buffer.from(expected)).toStrictEqual(buffer);
1089
+ });
1090
+
1091
+ //{ frameType: 0, manufSpec: 0, direction: 0, disDefaultRsp: 0 } 0 8 'discover' { startAttrId: 0, maxAttrIds: 240 }
1092
+ it("ZclFrame to buffer readRsp success", () => {
1093
+ const expected = Buffer.from([8, 1, 1, 1, 0, 0, 32, 3]);
1094
+ const payload = [{status: Zcl.Status.SUCCESS, attrId: 1, dataType: Zcl.DataType.UINT8, attrData: 3}];
1095
+ const frame = Zcl.Frame.create(FrameType.GLOBAL, Direction.SERVER_TO_CLIENT, false, undefined, 1, 1, 0, payload, {});
1096
+
1097
+ expect(frame.toBuffer()).toStrictEqual(expected);
1098
+ });
1099
+
1100
+ it("ZclFrame to buffer defaultRsp success", () => {
1101
+ const expected = Buffer.from([0x18, 0x04, 0x0b, 0x0c, 0x82]);
1102
+ const payload = {cmdId: 12, statusCode: 130};
1103
+ const frame = Zcl.Frame.create(FrameType.GLOBAL, Direction.SERVER_TO_CLIENT, true, undefined, 4, 11, 0, payload, {});
1104
+
1105
+ expect(frame.toBuffer()).toStrictEqual(expected);
1106
+ });
1107
+
1108
+ it("ZclFrame to buffer readStructured single element", () => {
1109
+ const expected = Buffer.from([0x18, 0x02, 0x0e, 0x01, 0x00, 0x01, 0x02, 0x00]);
1110
+ const payload = [{attrId: 0x0001, selector: {indexes: [2]}}];
1111
+ const frame = Zcl.Frame.create(FrameType.GLOBAL, Direction.SERVER_TO_CLIENT, true, undefined, 2, 0x0e, Zcl.Clusters.genBasic.ID, payload, {});
1112
+
1113
+ expect(frame.toBuffer()).toStrictEqual(expected);
1114
+ });
1115
+
1116
+ it("ZclFrame to buffer readStructured multiple elements", () => {
1117
+ const expected = Buffer.from([
1118
+ 0x18, 0x02, 0x0e, 0x02, 0x00, 0x02, 0x03, 0x00, 0x04, 0x00, 0x05, 0x00, 0x03, 0x06, 0x00, 0x07, 0x00, 0x08, 0x00,
1119
+ ]);
1120
+ const payload = [
1121
+ {attrId: 0x0002, selector: {indexes: [3, 4]}},
1122
+ {attrId: 0x0005, selector: {indexes: [6, 7, 8]}},
1123
+ ];
1124
+ const frame = Zcl.Frame.create(FrameType.GLOBAL, Direction.SERVER_TO_CLIENT, true, undefined, 2, 0x0e, Zcl.Clusters.genBasic.ID, payload, {});
1125
+
1126
+ expect(frame.toBuffer()).toStrictEqual(expected);
1127
+ });
1128
+
1129
+ it("ZclFrame to buffer readStructured whole attribute", () => {
1130
+ const expected = Buffer.from([0x18, 0x02, 0x0e, 0x09, 0x00, 0x00]);
1131
+ const payload = [{attrId: 0x0009, selector: {}}];
1132
+ const frame = Zcl.Frame.create(FrameType.GLOBAL, Direction.SERVER_TO_CLIENT, true, undefined, 2, 0x0e, Zcl.Clusters.genBasic.ID, payload, {});
1133
+
1134
+ expect(frame.toBuffer()).toStrictEqual(expected);
1135
+ });
1136
+
1137
+ it("ZclFrame from buffer readStructured single elements", () => {
1138
+ const buffer = Buffer.from([0x18, 0x02, 0x0e, 0x01, 0x00, 0x01, 0x02, 0x00]);
1139
+ const frame = Zcl.Frame.fromBuffer(Zcl.Clusters.genBasic.ID, Zcl.Header.fromBuffer(buffer)!, buffer, {});
1140
+ const header = new Zcl.Header(
1141
+ {
1142
+ reservedBits: 0,
1143
+ direction: Direction.SERVER_TO_CLIENT,
1144
+ disableDefaultResponse: true,
1145
+ frameType: FrameType.GLOBAL,
1146
+ manufacturerSpecific: false,
1147
+ },
1148
+ undefined,
1149
+ 2,
1150
+ 0x0e,
1151
+ );
1152
+ const payload = [{attrId: 0x0001, selector: {indexes: [2]}}];
1153
+
1154
+ expect(frame.header).toStrictEqual(header);
1155
+ expect(frame.payload).toStrictEqual(payload);
1156
+ });
1157
+
1158
+ it("ZclFrame from buffer readStructured multiple elements", () => {
1159
+ const buffer = Buffer.from([
1160
+ 0x18, 0x02, 0x0e, 0x02, 0x00, 0x02, 0x03, 0x00, 0x04, 0x00, 0x05, 0x00, 0x03, 0x06, 0x00, 0x07, 0x00, 0x08, 0x00,
1161
+ ]);
1162
+ const frame = Zcl.Frame.fromBuffer(Zcl.Clusters.genBasic.ID, Zcl.Header.fromBuffer(buffer)!, buffer, {});
1163
+ const header = new Zcl.Header(
1164
+ {
1165
+ reservedBits: 0,
1166
+ direction: Direction.SERVER_TO_CLIENT,
1167
+ disableDefaultResponse: true,
1168
+ frameType: FrameType.GLOBAL,
1169
+ manufacturerSpecific: false,
1170
+ },
1171
+ undefined,
1172
+ 2,
1173
+ 0x0e,
1174
+ );
1175
+ const payload = [
1176
+ {attrId: 0x0002, selector: {indexes: [3, 4]}},
1177
+ {attrId: 0x0005, selector: {indexes: [6, 7, 8]}},
1178
+ ];
1179
+
1180
+ expect(frame.header).toStrictEqual(header);
1181
+ expect(frame.payload).toStrictEqual(payload);
1182
+ });
1183
+
1184
+ it("ZclFrame from buffer readStructured whole attribute", () => {
1185
+ const buffer = Buffer.from([0x18, 0x02, 0x0e, 0x09, 0x00, 0x00]);
1186
+ const frame = Zcl.Frame.fromBuffer(Zcl.Clusters.genBasic.ID, Zcl.Header.fromBuffer(buffer)!, buffer, {});
1187
+ const header = new Zcl.Header(
1188
+ {
1189
+ reservedBits: 0,
1190
+ direction: Direction.SERVER_TO_CLIENT,
1191
+ disableDefaultResponse: true,
1192
+ frameType: FrameType.GLOBAL,
1193
+ manufacturerSpecific: false,
1194
+ },
1195
+ undefined,
1196
+ 2,
1197
+ 0x0e,
1198
+ );
1199
+ const payload = [{attrId: 0x0009, selector: {indicatorType: StructuredIndicatorType.Whole}}];
1200
+
1201
+ expect(frame.header).toStrictEqual(header);
1202
+ expect(frame.payload).toStrictEqual(payload);
1203
+ });
1204
+
1205
+ it("ZclFrame to buffer writeStructured single element", () => {
1206
+ const expected = Buffer.from([0x10, 0x02, 0x0f, 0x01, 0x00, 0x01, 0x02, 0x00, 0x20, 0x03]);
1207
+ const payload = [{attrId: 0x0001, selector: {indexes: [2]}, dataType: Zcl.DataType.UINT8, elementData: 3}];
1208
+ const frame = Zcl.Frame.create(FrameType.GLOBAL, Direction.CLIENT_TO_SERVER, true, undefined, 2, 0x0f, Zcl.Clusters.genBasic.ID, payload, {});
1209
+
1210
+ expect(frame.toBuffer()).toStrictEqual(expected);
1211
+ });
1212
+
1213
+ it("ZclFrame to buffer writeStructured multiple elements", () => {
1214
+ const expected = Buffer.from([
1215
+ 0x10, 0x02, 0x0f, 0x02, 0x00, 0x02, 0x03, 0x00, 0x04, 0x00, 0x42, 0x03, 0x66, 0x6f, 0x6f, 0x05, 0x00, 0x03, 0x06, 0x00, 0x07, 0x00, 0x08,
1216
+ 0x00, 0x42, 0x03, 0x62, 0x61, 0x72,
1217
+ ]);
1218
+ const payload = [
1219
+ {attrId: 0x0002, selector: {indexes: [3, 4]}, dataType: Zcl.DataType.CHAR_STR, elementData: "foo"},
1220
+ {attrId: 0x0005, selector: {indexes: [6, 7, 8]}, dataType: Zcl.DataType.CHAR_STR, elementData: "bar"},
1221
+ ];
1222
+ const frame = Zcl.Frame.create(FrameType.GLOBAL, Direction.CLIENT_TO_SERVER, true, undefined, 2, 0x0f, Zcl.Clusters.genBasic.ID, payload, {});
1223
+
1224
+ expect(frame.toBuffer()).toStrictEqual(expected);
1225
+ });
1226
+
1227
+ it("ZclFrame to buffer writeStructured whole attribute", () => {
1228
+ const expected = Buffer.from([0x10, 0x02, 0x0f, 0x09, 0x00, 0x00, 0x48, 0x20, 0x03, 0x00, 0x0a, 0x0b, 0x0c]);
1229
+ const payload = [
1230
+ {attrId: 0x0009, selector: {}, dataType: Zcl.DataType.ARRAY, elementData: {elementType: Zcl.DataType.UINT8, elements: [10, 11, 12]}},
1231
+ ];
1232
+ const frame = Zcl.Frame.create(FrameType.GLOBAL, Direction.CLIENT_TO_SERVER, true, undefined, 2, 0x0f, Zcl.Clusters.genBasic.ID, payload, {});
1233
+
1234
+ expect(frame.toBuffer()).toStrictEqual(expected);
1235
+ });
1236
+
1237
+ it("ZclFrame to buffer writeStructured add element into set/bag", () => {
1238
+ const expected = Buffer.from([0x10, 0x02, 0x0f, 0x0d, 0x00, 0x10, 0x42, 0x03, 0x66, 0x6f, 0x6f]);
1239
+ const payload = [
1240
+ {attrId: 0x000d, selector: {indicatorType: StructuredIndicatorType.WriteAdd}, dataType: Zcl.DataType.CHAR_STR, elementData: "foo"},
1241
+ ];
1242
+ const frame = Zcl.Frame.create(FrameType.GLOBAL, Direction.CLIENT_TO_SERVER, true, undefined, 2, 0x0f, Zcl.Clusters.genBasic.ID, payload, {});
1243
+
1244
+ expect(frame.toBuffer()).toStrictEqual(expected);
1245
+ });
1246
+
1247
+ it("ZclFrame to buffer writeStructured remove element from set/bag", () => {
1248
+ const expected = Buffer.from([0x10, 0x02, 0x0f, 0x0e, 0x00, 0x20, 0x42, 0x03, 0x62, 0x61, 0x72]);
1249
+ const payload = [
1250
+ {attrId: 0x000e, selector: {indicatorType: StructuredIndicatorType.WriteRemove}, dataType: Zcl.DataType.CHAR_STR, elementData: "bar"},
1251
+ ];
1252
+ const frame = Zcl.Frame.create(FrameType.GLOBAL, Direction.CLIENT_TO_SERVER, true, undefined, 2, 0x0f, Zcl.Clusters.genBasic.ID, payload, {});
1253
+
1254
+ expect(frame.toBuffer()).toStrictEqual(expected);
1255
+ });
1256
+
1257
+ it("ZclFrame to buffer writeStructured Livolo malformed", () => {
1258
+ const expected = Buffer.from([0x7c, 0xd2, 0x1a, 0xe9, 0x0f, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00]);
1259
+ const payload = [{attrId: 0x0000, selector: null, elementData: [0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00]}];
1260
+ const frame = Zcl.Frame.create(
1261
+ FrameType.GLOBAL,
1262
+ Direction.SERVER_TO_CLIENT,
1263
+ true,
1264
+ 0x1ad2,
1265
+ 0xe9,
1266
+ 0x0f,
1267
+ Zcl.Clusters.genBasic.ID,
1268
+ payload,
1269
+ {},
1270
+ 3,
1271
+ );
1272
+
1273
+ expect(frame.toBuffer()).toStrictEqual(expected);
1274
+ });
1275
+
1276
+ it("ZclFrame to buffer writeStructuredRsp success", () => {
1277
+ const expected = Buffer.from([8, 1, 0x10, 0]);
1278
+ const payload = [{status: Zcl.Status.SUCCESS}];
1279
+ const frame = Zcl.Frame.create(
1280
+ FrameType.GLOBAL,
1281
+ Direction.SERVER_TO_CLIENT,
1282
+ false,
1283
+ undefined,
1284
+ 1,
1285
+ 0x10,
1286
+ Zcl.Clusters.genBasic.ID,
1287
+ payload,
1288
+ {},
1289
+ );
1290
+
1291
+ expect(frame.toBuffer()).toStrictEqual(expected);
1292
+ });
1293
+
1294
+ it("ZclFrame to buffer writeStructuredRsp failed selector unknown or none for type", () => {
1295
+ const expected = Buffer.from([8, 1, 0x10, 147, 1, 0, 0]);
1296
+ const payload = [{status: Zcl.Status.ACTION_DENIED, attrId: 1, selector: {indicatorType: StructuredIndicatorType.Whole}}];
1297
+ const frame = Zcl.Frame.create(
1298
+ FrameType.GLOBAL,
1299
+ Direction.SERVER_TO_CLIENT,
1300
+ false,
1301
+ undefined,
1302
+ 1,
1303
+ 0x10,
1304
+ Zcl.Clusters.genBasic.ID,
1305
+ payload,
1306
+ {},
1307
+ );
1308
+
1309
+ expect(frame.toBuffer()).toStrictEqual(expected);
1310
+ });
1311
+
1312
+ it("ZclFrame to buffer writeStructuredRsp failed with selector", () => {
1313
+ const expected = Buffer.from([8, 1, 0x10, 147, 1, 0, 1, 254, 0]);
1314
+ const payload = [{status: Zcl.Status.ACTION_DENIED, attrId: 1, selector: {indexes: [254]}}];
1315
+ const frame = Zcl.Frame.create(
1316
+ FrameType.GLOBAL,
1317
+ Direction.SERVER_TO_CLIENT,
1318
+ false,
1319
+ undefined,
1320
+ 1,
1321
+ 0x10,
1322
+ Zcl.Clusters.genBasic.ID,
1323
+ payload,
1324
+ {},
1325
+ );
1326
+
1327
+ expect(frame.toBuffer()).toStrictEqual(expected);
1328
+ });
1329
+
1330
+ it("ZclFrame to buffer writeStructuredRsp failed mixed selectors", () => {
1331
+ const expected = Buffer.from([8, 1, 0x10, 147, 16, 0, 0, 149, 14, 0, 2, 254, 0, 32, 0]);
1332
+ const payload = [
1333
+ {status: Zcl.Status.ACTION_DENIED, attrId: 16, selector: {indicatorType: StructuredIndicatorType.Whole}},
1334
+ {status: Zcl.Status.ABORT, attrId: 14, selector: {indexes: [254, 32]}},
1335
+ ];
1336
+ const frame = Zcl.Frame.create(
1337
+ FrameType.GLOBAL,
1338
+ Direction.SERVER_TO_CLIENT,
1339
+ false,
1340
+ undefined,
1341
+ 1,
1342
+ 0x10,
1343
+ Zcl.Clusters.genBasic.ID,
1344
+ payload,
1345
+ {},
1346
+ );
1347
+
1348
+ expect(frame.toBuffer()).toStrictEqual(expected);
1349
+ });
1350
+
1351
+ it("ZclFrame from buffer writeStructuredRsp success", () => {
1352
+ const buffer = Buffer.from([8, 1, 0x10, 0]);
1353
+ const frame = Zcl.Frame.fromBuffer(Zcl.Clusters.genBasic.ID, Zcl.Header.fromBuffer(buffer)!, buffer, {});
1354
+ const header = new Zcl.Header(
1355
+ {
1356
+ reservedBits: 0,
1357
+ direction: Direction.SERVER_TO_CLIENT,
1358
+ disableDefaultResponse: false,
1359
+ frameType: FrameType.GLOBAL,
1360
+ manufacturerSpecific: false,
1361
+ },
1362
+ undefined,
1363
+ 1,
1364
+ 0x10,
1365
+ );
1366
+ const payload = [{status: Zcl.Status.SUCCESS}];
1367
+
1368
+ expect(frame.header).toStrictEqual(header);
1369
+ expect(frame.payload).toStrictEqual(payload);
1370
+ });
1371
+
1372
+ it("ZclFrame from buffer writeStructuredRsp failed selector unknown or none for type", () => {
1373
+ const buffer = Buffer.from([8, 1, 0x10, 147, 1, 0, 0]);
1374
+ const frame = Zcl.Frame.fromBuffer(Zcl.Clusters.genBasic.ID, Zcl.Header.fromBuffer(buffer)!, buffer, {});
1375
+ const header = new Zcl.Header(
1376
+ {
1377
+ reservedBits: 0,
1378
+ direction: Direction.SERVER_TO_CLIENT,
1379
+ disableDefaultResponse: false,
1380
+ frameType: FrameType.GLOBAL,
1381
+ manufacturerSpecific: false,
1382
+ },
1383
+ undefined,
1384
+ 1,
1385
+ 0x10,
1386
+ );
1387
+ const payload = [{status: Zcl.Status.ACTION_DENIED, attrId: 1, selector: {indicatorType: StructuredIndicatorType.Whole}}];
1388
+
1389
+ expect(frame.header).toStrictEqual(header);
1390
+ expect(frame.payload).toStrictEqual(payload);
1391
+ });
1392
+
1393
+ it("ZclFrame from buffer writeStructuredRsp failed with selector", () => {
1394
+ const buffer = Buffer.from([8, 1, 0x10, 147, 1, 0, 1, 254, 0]);
1395
+ const frame = Zcl.Frame.fromBuffer(Zcl.Clusters.genBasic.ID, Zcl.Header.fromBuffer(buffer)!, buffer, {});
1396
+ const header = new Zcl.Header(
1397
+ {
1398
+ reservedBits: 0,
1399
+ direction: Direction.SERVER_TO_CLIENT,
1400
+ disableDefaultResponse: false,
1401
+ frameType: FrameType.GLOBAL,
1402
+ manufacturerSpecific: false,
1403
+ },
1404
+ undefined,
1405
+ 1,
1406
+ 0x10,
1407
+ );
1408
+ const payload = [{status: Zcl.Status.ACTION_DENIED, attrId: 1, selector: {indexes: [254]}}];
1409
+
1410
+ expect(frame.header).toStrictEqual(header);
1411
+ expect(frame.payload).toStrictEqual(payload);
1412
+ });
1413
+
1414
+ it("ZclFrame from buffer writeStructuredRsp failed mixed selectors", () => {
1415
+ const buffer = Buffer.from([8, 1, 0x10, 147, 16, 0, 0, 149, 14, 0, 2, 254, 0, 32, 0]);
1416
+ const frame = Zcl.Frame.fromBuffer(Zcl.Clusters.genBasic.ID, Zcl.Header.fromBuffer(buffer)!, buffer, {});
1417
+ const header = new Zcl.Header(
1418
+ {
1419
+ reservedBits: 0,
1420
+ direction: Direction.SERVER_TO_CLIENT,
1421
+ disableDefaultResponse: false,
1422
+ frameType: FrameType.GLOBAL,
1423
+ manufacturerSpecific: false,
1424
+ },
1425
+ undefined,
1426
+ 1,
1427
+ 0x10,
1428
+ );
1429
+ const payload = [
1430
+ {status: Zcl.Status.ACTION_DENIED, attrId: 16, selector: {indicatorType: StructuredIndicatorType.Whole}},
1431
+ {status: Zcl.Status.ABORT, attrId: 14, selector: {indexes: [254, 32]}},
1432
+ ];
1433
+
1434
+ expect(frame.header).toStrictEqual(header);
1435
+ expect(frame.payload).toStrictEqual(payload);
1436
+ });
1437
+
1438
+ it("ZclFrame from buffer ssIasAce arm command", () => {
1439
+ const buffer = Buffer.from([1, 87, 0, 0, 6, 49, 50, 51, 52, 53, 54, 0]);
1440
+ const frame = Zcl.Frame.fromBuffer(Zcl.Clusters.ssIasAce.ID, Zcl.Header.fromBuffer(buffer)!, buffer, {});
1441
+ const header = new Zcl.Header(
1442
+ {
1443
+ reservedBits: 0,
1444
+ direction: 0,
1445
+ disableDefaultResponse: false,
1446
+ frameType: 1,
1447
+ manufacturerSpecific: false,
1448
+ },
1449
+ undefined,
1450
+ 87,
1451
+ 0,
1452
+ );
1453
+
1454
+ const payload = {
1455
+ armmode: 0,
1456
+ code: "123456",
1457
+ zoneid: 0,
1458
+ };
1459
+
1460
+ expect(frame.header).toStrictEqual(header);
1461
+ expect(frame.payload).toStrictEqual(payload);
1462
+ expect(frame.header.isGlobal).toBe(false);
1463
+ expect(frame.header.isSpecific).toBe(true);
1464
+ expect(frame.isCluster("ssIasAce")).toBe(true);
1465
+ expect(frame.isCommand("arm")).toBe(true);
1466
+ });
1467
+
1468
+ it("ZclFrame to buffer discoverRsp", () => {
1469
+ const expected = Buffer.from([24, 23, 13, 0, 32, 0, 32, 33, 0, 32, 49, 0, 48, 51, 0, 32, 53, 0, 24]);
1470
+ const payload = {
1471
+ discComplete: 0,
1472
+ attrInfos: [
1473
+ {attrId: 32, dataType: 32},
1474
+ {attrId: 33, dataType: 32},
1475
+ {attrId: 49, dataType: 48},
1476
+ {attrId: 51, dataType: 32},
1477
+ {attrId: 53, dataType: 24},
1478
+ ],
1479
+ };
1480
+
1481
+ const frame = Zcl.Frame.create(FrameType.GLOBAL, Direction.SERVER_TO_CLIENT, true, undefined, 23, 13, 0, payload, {});
1482
+
1483
+ expect(frame.toBuffer()).toStrictEqual(expected);
1484
+ });
1485
+
1486
+ it("ZclFrame to buffer tradfriArrowSingle", () => {
1487
+ const expected = Buffer.from([0x05, 0x7c, 0x11, 0x1d, 0x07, 0x00, 0x01, 0x0d, 0x00]);
1488
+ const payload = {value: 256, value2: 13};
1489
+
1490
+ const frame = Zcl.Frame.create(FrameType.SPECIFIC, Direction.CLIENT_TO_SERVER, false, 4476, 29, 7, 5, payload, {});
1491
+
1492
+ expect(frame.toBuffer()).toStrictEqual(expected);
1493
+ });
1494
+
1495
+ it("ZclFrame to buffer readRsp failed", () => {
1496
+ const expected = Buffer.from([8, 1, 1, 1, 0, 2]);
1497
+ const payload = [{status: 2, attrId: 1}];
1498
+
1499
+ const frame = Zcl.Frame.create(FrameType.GLOBAL, Direction.SERVER_TO_CLIENT, false, undefined, 1, 1, 0, payload, {});
1500
+
1501
+ expect(frame.toBuffer()).toStrictEqual(expected);
1502
+ });
1503
+
1504
+ it("ZclFrame to buffer offWithEffect", () => {
1505
+ const expected = Buffer.from([0x1, 1, 64, 1, 0]);
1506
+ const payload = {effectid: 1, effectvariant: 0};
1507
+
1508
+ const frame = Zcl.Frame.create(FrameType.SPECIFIC, Direction.CLIENT_TO_SERVER, false, undefined, 1, 64, 6, payload, {});
1509
+
1510
+ expect(frame.toBuffer()).toStrictEqual(expected);
1511
+ });
1512
+
1513
+ it("ZclFrame to buffer offWithEffect", () => {
1514
+ const expected = Buffer.from([9, 9, 0, 1]);
1515
+
1516
+ const frame = Zcl.Frame.create(FrameType.SPECIFIC, Direction.SERVER_TO_CLIENT, false, undefined, 9, "restartDeviceRsp", 21, {status: 1}, {});
1517
+
1518
+ expect(frame.toBuffer()).toStrictEqual(expected);
1519
+ });
1520
+
1521
+ it("ZclFrame to buffer invalid frametype", () => {
1522
+ expect(() => {
1523
+ Zcl.Frame.create(
1524
+ // @ts-expect-error invalid on purpose
1525
+ 3,
1526
+ Direction.CLIENT_TO_SERVER,
1527
+ false,
1528
+ undefined,
1529
+ 1,
1530
+ 64,
1531
+ 6,
1532
+ {},
1533
+ {},
1534
+ ).toBuffer();
1535
+ }).toThrow("Frametype '3' not valid");
1536
+ });
1537
+
1538
+ it("BuffaloZcl read array", () => {
1539
+ const buffer = Buffer.from([32, 3, 0, 1, 2, 3]);
1540
+ const buffalo = new BuffaloZcl(buffer);
1541
+ const value = buffalo.read(DataType.ARRAY, {});
1542
+ expect(buffalo.getPosition()).toBe(6);
1543
+ expect(value).toStrictEqual([1, 2, 3]);
1544
+ });
1545
+
1546
+ it("BuffaloZcl read struct", () => {
1547
+ const buffer = Buffer.from([0, 2, 0, 32, 8, 33, 4, 0]);
1548
+ const buffalo = new BuffaloZcl(buffer, 1);
1549
+ const value = buffalo.read(DataType.STRUCT, {});
1550
+ expect(buffalo.getPosition()).toBe(8);
1551
+ expect(value).toStrictEqual([
1552
+ {elmType: 32, elmVal: 8},
1553
+ {elmType: 33, elmVal: 4},
1554
+ ]);
1555
+ });
1556
+
1557
+ it("BuffaloZcl read longCharStr", () => {
1558
+ const buffer = Buffer.from([5, 0, 0x68, 0x65, 0x6c, 0x6c, 0x6f]);
1559
+ const buffalo = new BuffaloZcl(buffer);
1560
+ const value = buffalo.read(DataType.LONG_CHAR_STR, {});
1561
+ expect(buffalo.getPosition()).toBe(7);
1562
+ expect(value).toStrictEqual("hello");
1563
+ });
1564
+
1565
+ it("BuffaloZcl read longOctetStr", () => {
1566
+ const buffer = Buffer.from([5, 0, 0x68, 0x65, 0x6c, 0x6c, 0x6f]);
1567
+ const buffalo = new BuffaloZcl(buffer);
1568
+ const value = buffalo.read(DataType.LONG_OCTET_STR, {});
1569
+ expect(buffalo.getPosition()).toBe(7);
1570
+ expect(value).toStrictEqual(buffer.subarray(2));
1571
+ });
1572
+
1573
+ it("BuffaloZcl read extensionFieldSets", () => {
1574
+ const buffer = Buffer.from([0, 3, 8, 1, 0, 2, 0, 3, 0, 4, 5]);
1575
+ const buffalo = new BuffaloZcl(buffer);
1576
+ const value = buffalo.read(BuffaloZclDataType.EXTENSION_FIELD_SETS, {});
1577
+ expect(buffalo.getPosition()).toBe(11);
1578
+ expect(value).toStrictEqual([{clstId: 768, len: 8, extField: [1, 2, 3, 4, 5]}]);
1579
+ });
1580
+
1581
+ it("BuffaloZcl read list zoneinfo", () => {
1582
+ const buffer = Buffer.from([1, 5, 0, 2, 6, 0]);
1583
+ const buffalo = new BuffaloZcl(buffer);
1584
+ const value = buffalo.read(BuffaloZclDataType.LIST_ZONEINFO, {length: 2});
1585
+ expect(buffalo.getPosition()).toBe(6);
1586
+ expect(value).toStrictEqual([
1587
+ {zoneID: 1, zoneStatus: 5},
1588
+ {zoneID: 2, zoneStatus: 6},
1589
+ ]);
1590
+ });
1591
+
1592
+ it.each([DataType.UINT40, DataType.DATA40, DataType.BITMAP40])("BuffaloZcl read uint40, data40, bitmap40", (type) => {
1593
+ const buffer = Buffer.from([1, 5, 4, 5, 6, 7]);
1594
+ const buffalo = new BuffaloZcl(buffer);
1595
+ const value = buffalo.read(type, {});
1596
+ expect(buffalo.getPosition()).toBe(5);
1597
+ expect(value).toStrictEqual(25853953281);
1598
+ });
1599
+
1600
+ it.each([DataType.UINT48, DataType.DATA48, DataType.BITMAP48])("BuffaloZcl read uint48, data48, bitmap48", (type) => {
1601
+ const buffer = Buffer.from([1, 5, 4, 5, 6, 7]);
1602
+ const buffalo = new BuffaloZcl(buffer);
1603
+ const value = buffalo.read(type, {});
1604
+ expect(buffalo.getPosition()).toBe(6);
1605
+ expect(value).toStrictEqual(7722435347713);
1606
+ });
1607
+
1608
+ it.each([DataType.UINT56, DataType.DATA56, DataType.BITMAP56])("BuffaloZcl read uint56, data56, bitmap56", (type) => {
1609
+ const buffer = Buffer.from([1, 5, 4, 5, 6, 7, 7]);
1610
+ const buffalo = new BuffaloZcl(buffer);
1611
+ const value = buffalo.read(type, {});
1612
+ expect(buffalo.getPosition()).toBe(7);
1613
+ expect(value).toStrictEqual(1978047272322305n);
1614
+ });
1615
+
1616
+ it.each([DataType.UINT64, DataType.DATA64, DataType.BITMAP64])("BuffaloZcl read uint64, data64, bitmap64", (type) => {
1617
+ const buffer = Buffer.from([1, 5, 4, 5, 6, 7, 7, 9]);
1618
+ const buffalo = new BuffaloZcl(buffer);
1619
+ const value = buffalo.read(type, {});
1620
+ expect(buffalo.getPosition()).toBe(8);
1621
+ expect(value).toStrictEqual(0x0907070605040501n);
1622
+ });
1623
+
1624
+ it("BuffaloZcl read int40", () => {
1625
+ const buffer = Buffer.from([254, 255, 255, 255, 127]);
1626
+ const buffalo = new BuffaloZcl(buffer);
1627
+ const value = buffalo.read(DataType.INT40, {});
1628
+ expect(buffalo.getPosition()).toBe(5);
1629
+ expect(value).toStrictEqual(549755813886);
1630
+ });
1631
+
1632
+ it("BuffaloZcl read int56", () => {
1633
+ const buffer = Buffer.from([1, 5, 4, 5, 6, 7, 7]);
1634
+ const buffalo = new BuffaloZcl(buffer);
1635
+ const value = buffalo.read(DataType.INT56, {});
1636
+ expect(buffalo.getPosition()).toBe(7);
1637
+ expect(value).toStrictEqual(1978047272322305n);
1638
+ });
1639
+
1640
+ it("BuffaloZcl read int64", () => {
1641
+ const buffer = Buffer.from([1, 5, 4, 5, 6, 7, 7, 9]);
1642
+ const buffalo = new BuffaloZcl(buffer);
1643
+ const value = buffalo.read(DataType.INT64, {});
1644
+ expect(buffalo.getPosition()).toBe(8);
1645
+ expect(value).toStrictEqual(650496393613673729n);
1646
+ });
1647
+
1648
+ it.each([
1649
+ ["no data point", Buffer.from([]), []],
1650
+ ["single data point", Buffer.from([1, 4, 0, 1, 1]), [{dp: 1, datatype: 4, data: Buffer.from([1])}]],
1651
+ [
1652
+ "two data points",
1653
+ Buffer.from([1, 4, 0, 1, 1, 4, 2, 0, 4, 0, 0, 0, 90]),
1654
+ [
1655
+ {dp: 1, datatype: 4, data: Buffer.from([1])},
1656
+ {dp: 4, datatype: 2, data: Buffer.from([0, 0, 0, 90])},
1657
+ ],
1658
+ ],
1659
+ ["incomplete data point is ignored", Buffer.from([1, 4, 0, 1, 1, 4]), [{dp: 1, datatype: 4, data: Buffer.from([1])}]],
1660
+ [
1661
+ "incomplete data buffer",
1662
+ Buffer.from([1, 4, 0, 1, 1, 4, 2, 0, 4, 0, 0, 0]),
1663
+ [
1664
+ {dp: 1, datatype: 4, data: Buffer.from([1])},
1665
+ {dp: 4, datatype: 2, data: Buffer.from([0, 0, 0])},
1666
+ ],
1667
+ ],
1668
+ ])("BuffaloZcl read readListTuyaDataPointValues %s", (_name, buffer, payload) => {
1669
+ const buffalo = new BuffaloZcl(buffer);
1670
+ const value = buffalo.read(BuffaloZclDataType.LIST_TUYA_DATAPOINT_VALUES, {});
1671
+ expect(buffalo.isMore()).not.toBeTruthy();
1672
+ expect(value).toStrictEqual(payload);
1673
+ });
1674
+
1675
+ it("BuffaloZcl write charStr", () => {
1676
+ const payload = "hello";
1677
+ const buffer = Buffer.alloc(7);
1678
+ const expected = Buffer.from([5, 0x68, 0x65, 0x6c, 0x6c, 0x6f, 0]);
1679
+ const buffalo = new BuffaloZcl(buffer);
1680
+ buffalo.write(DataType.CHAR_STR, payload, {});
1681
+ expect(buffalo.getPosition()).toBe(6);
1682
+ expect(buffer).toStrictEqual(expected);
1683
+ });
1684
+
1685
+ it("BuffaloZcl write longCharStr", () => {
1686
+ const payload = "hello";
1687
+ const buffer = Buffer.alloc(7);
1688
+ const expected = Buffer.from([5, 0, 0x68, 0x65, 0x6c, 0x6c, 0x6f]);
1689
+ const buffalo = new BuffaloZcl(buffer);
1690
+ buffalo.write(DataType.LONG_CHAR_STR, payload, {});
1691
+ expect(buffalo.getPosition()).toBe(7);
1692
+ expect(buffer).toStrictEqual(expected);
1693
+ });
1694
+
1695
+ it("BuffaloZcl write octetStr", () => {
1696
+ const payload = [1, 2, 4];
1697
+ const buffer = Buffer.alloc(5);
1698
+ const expected = Buffer.from([3, 1, 2, 4, 0]);
1699
+ const buffalo = new BuffaloZcl(buffer);
1700
+ buffalo.write(DataType.OCTET_STR, payload, {});
1701
+ expect(buffalo.getPosition()).toBe(4);
1702
+ expect(buffer).toStrictEqual(expected);
1703
+ });
1704
+
1705
+ it("BuffaloZcl write longOctetStr", () => {
1706
+ const payload = [1, 2, 3, 4, 5];
1707
+ const buffer = Buffer.alloc(7);
1708
+ const expected = Buffer.from([5, 0, 1, 2, 3, 4, 5]);
1709
+ const buffalo = new BuffaloZcl(buffer);
1710
+ buffalo.write(DataType.LONG_OCTET_STR, payload, {});
1711
+ expect(buffalo.getPosition()).toBe(7);
1712
+ expect(buffer).toStrictEqual(expected);
1713
+ });
1714
+
1715
+ it("BuffaloZcl write extensionFieldSets", () => {
1716
+ const payload = [{clstId: 768, len: 8, extField: [1, 2, 3, 4, 5]}];
1717
+ const buffer = Buffer.alloc(12);
1718
+ const expected = Buffer.from([0, 3, 8, 1, 0, 2, 0, 3, 0, 4, 5, 0]);
1719
+ const buffalo = new BuffaloZcl(buffer);
1720
+ buffalo.write(BuffaloZclDataType.EXTENSION_FIELD_SETS, payload, {});
1721
+ expect(buffalo.getPosition()).toBe(11);
1722
+ expect(buffer).toStrictEqual(expected);
1723
+ });
1724
+
1725
+ it("BuffaloZcl write zoneinfo", () => {
1726
+ const payload = [
1727
+ {zoneID: 1, zoneStatus: 5},
1728
+ {zoneID: 2, zoneStatus: 6},
1729
+ ];
1730
+ const buffer = Buffer.alloc(6);
1731
+ const expected = Buffer.from([1, 5, 0, 2, 6, 0]);
1732
+ const buffalo = new BuffaloZcl(buffer);
1733
+ buffalo.write(BuffaloZclDataType.LIST_ZONEINFO, payload, {});
1734
+ expect(buffalo.getPosition()).toBe(6);
1735
+ expect(buffer).toStrictEqual(expected);
1736
+ });
1737
+
1738
+ it.each([DataType.UINT40, DataType.DATA40, DataType.BITMAP40])("BuffaloZcl write uint40, data40, bitmap40", (type) => {
1739
+ const payload = 1099511627773;
1740
+ const buffer = Buffer.alloc(5);
1741
+ const expected = Buffer.from([253, 255, 255, 255, 255]);
1742
+ const buffalo = new BuffaloZcl(buffer);
1743
+ buffalo.write(type, payload, {});
1744
+ expect(buffalo.getPosition()).toBe(5);
1745
+ expect(buffer).toStrictEqual(expected);
1746
+ });
1747
+
1748
+ it.each([DataType.UINT48, DataType.DATA48, DataType.BITMAP48])("BuffaloZcl write uint48, data48, bitmap48", (type) => {
1749
+ const payload = 281474976710653;
1750
+ const buffer = Buffer.alloc(6);
1751
+ const expected = Buffer.from([253, 255, 255, 255, 255, 255]);
1752
+ const buffalo = new BuffaloZcl(buffer);
1753
+ buffalo.write(type, payload, {});
1754
+ expect(buffalo.getPosition()).toBe(6);
1755
+ expect(buffer).toStrictEqual(expected);
1756
+ });
1757
+
1758
+ it.each([DataType.UINT56, DataType.DATA56, DataType.BITMAP56])("BuffaloZcl write uint56, data56, bitmap56", (type) => {
1759
+ const payload = 1978047272322305n;
1760
+ const buffer = Buffer.alloc(7);
1761
+ const expected = Buffer.from([1, 5, 4, 5, 6, 7, 7]);
1762
+ const buffalo = new BuffaloZcl(buffer);
1763
+ buffalo.write(type, payload, {});
1764
+ expect(buffalo.getPosition()).toBe(7);
1765
+ expect(buffer).toStrictEqual(expected);
1766
+ });
1767
+
1768
+ it.each([DataType.UINT64, DataType.DATA64, DataType.BITMAP64])("BuffaloZcl write uint64, data64, bitmap64", (type) => {
1769
+ const payload = 0x0907070605040501n;
1770
+ const buffer = Buffer.alloc(8);
1771
+ const expected = Buffer.from([1, 5, 4, 5, 6, 7, 7, 9]);
1772
+ const buffalo = new BuffaloZcl(buffer);
1773
+ buffalo.write(type, payload, {});
1774
+ expect(buffalo.getPosition()).toBe(8);
1775
+ expect(buffer).toStrictEqual(expected);
1776
+ });
1777
+
1778
+ it("BuffaloZcl write int40", () => {
1779
+ const payload = 549755813886;
1780
+ const buffer = Buffer.alloc(5);
1781
+ const expected = Buffer.from([254, 255, 255, 255, 127]);
1782
+ const buffalo = new BuffaloZcl(buffer);
1783
+ buffalo.write(DataType.INT40, payload, {});
1784
+ expect(buffalo.getPosition()).toBe(5);
1785
+ expect(buffer).toStrictEqual(expected);
1786
+ });
1787
+
1788
+ it("BuffaloZcl write int56", () => {
1789
+ const payload = 1978047272322305n;
1790
+ const buffer = Buffer.alloc(7);
1791
+ const expected = Buffer.from([1, 5, 4, 5, 6, 7, 7]);
1792
+ const buffalo = new BuffaloZcl(buffer);
1793
+ buffalo.write(DataType.INT56, payload, {});
1794
+ expect(buffalo.getPosition()).toBe(7);
1795
+ expect(buffer).toStrictEqual(expected);
1796
+ });
1797
+
1798
+ it("BuffaloZcl write int64", () => {
1799
+ const payload = 650496393613673729n;
1800
+ const buffer = Buffer.alloc(8);
1801
+ const expected = Buffer.from([1, 5, 4, 5, 6, 7, 7, 9]);
1802
+ const buffalo = new BuffaloZcl(buffer);
1803
+ buffalo.write(DataType.INT64, payload, {});
1804
+ expect(buffalo.getPosition()).toBe(8);
1805
+ expect(buffer).toStrictEqual(expected);
1806
+ });
1807
+
1808
+ it("BuffaloZcl write array element type string", () => {
1809
+ const payload = {
1810
+ elementType: Zcl.DataType.OCTET_STR,
1811
+ elements: [
1812
+ [0, 13, 1, 6, 0, 2],
1813
+ [1, 13, 2, 6, 0, 2],
1814
+ [2, 13, 3, 6, 0, 2],
1815
+ [3, 13, 4, 6, 0, 2],
1816
+ ],
1817
+ };
1818
+ const expected = Buffer.from([0x41, 0x04, 0x00, 6, 0, 13, 1, 6, 0, 2, 6, 1, 13, 2, 6, 0, 2, 6, 2, 13, 3, 6, 0, 2, 6, 3, 13, 4, 6, 0, 2]);
1819
+ const buffer = Buffer.alloc(expected.length);
1820
+ const buffalo = new BuffaloZcl(buffer);
1821
+ buffalo.write(DataType.ARRAY, payload, {});
1822
+ expect(buffalo.getPosition()).toBe(expected.length);
1823
+ expect(buffer).toStrictEqual(expected);
1824
+ });
1825
+
1826
+ it("BuffaloZcl write array element type numeric", () => {
1827
+ const payload = {elementType: Zcl.DataType.DATA8, elements: [0, 0, 0, 0]};
1828
+ const expected = Buffer.from([0x08, 0x04, 0x00, 0, 0, 0, 0]);
1829
+ const buffer = Buffer.alloc(expected.length);
1830
+ const buffalo = new BuffaloZcl(buffer);
1831
+ buffalo.write(DataType.ARRAY, payload, {});
1832
+ expect(buffalo.getPosition()).toBe(expected.length);
1833
+ expect(buffer).toStrictEqual(expected);
1834
+ });
1835
+
1836
+ it("BuffaloZcl write array element type numeric passed as string of DataType", () => {
1837
+ const payload = {elementType: "DATA8", elements: [0, 0, 0, 0]};
1838
+ const expected = Buffer.from([0x08, 0x04, 0x00, 0, 0, 0, 0]);
1839
+ const buffer = Buffer.alloc(expected.length);
1840
+ const buffalo = new BuffaloZcl(buffer);
1841
+ buffalo.write(DataType.ARRAY, payload, {});
1842
+ expect(buffalo.getPosition()).toBe(expected.length);
1843
+ expect(buffer).toStrictEqual(expected);
1844
+ });
1845
+
1846
+ it("BuffaloZcl write struct", () => {
1847
+ const payload = [
1848
+ {elmType: Zcl.DataType.UINT8, elmVal: 3},
1849
+ {elmType: Zcl.DataType.CHAR_STR, elmVal: "a"},
1850
+ ];
1851
+ const expected = Buffer.from([2, 0, Zcl.DataType.UINT8, 3, Zcl.DataType.CHAR_STR, 1, 0x61]);
1852
+ const buffer = Buffer.alloc(expected.length);
1853
+ const buffalo = new BuffaloZcl(buffer);
1854
+ buffalo.write(DataType.STRUCT, payload, {});
1855
+ expect(buffalo.getPosition()).toBe(expected.length);
1856
+ expect(buffer).toStrictEqual(expected);
1857
+ });
1858
+
1859
+ it("BuffaloZcl write security key", () => {
1860
+ const payload = [0x09, 0x07, 0x07, 0x06, 0x05, 0x04, 0x05, 0x01, 0x09, 0x07, 0x07, 0x06, 0x05, 0x04, 0x05, 0x01];
1861
+ const buffer = Buffer.alloc(16);
1862
+ const expected = Buffer.from([0x09, 0x07, 0x07, 0x06, 0x05, 0x04, 0x05, 0x01, 0x09, 0x07, 0x07, 0x06, 0x05, 0x04, 0x05, 0x01]);
1863
+ const buffalo = new BuffaloZcl(buffer);
1864
+ buffalo.write(DataType.SEC_KEY, payload, {});
1865
+ expect(buffalo.getPosition()).toBe(16);
1866
+ expect(buffer).toStrictEqual(expected);
1867
+ });
1868
+
1869
+ it.each([
1870
+ ["no data point", [], Buffer.from([])],
1871
+ ["single data point", [{dp: 1, datatype: 4, data: Buffer.from([1])}], Buffer.from([1, 4, 0, 1, 1])],
1872
+ [
1873
+ "two data points",
1874
+ [
1875
+ {dp: 1, datatype: 4, data: Buffer.from([1])},
1876
+ {dp: 4, datatype: 2, data: Buffer.from([0, 0, 0, 90])},
1877
+ ],
1878
+ Buffer.from([1, 4, 0, 1, 1, 4, 2, 0, 4, 0, 0, 0, 90]),
1879
+ ],
1880
+ ])("BuffaloZcl writeListTuyaDataPointValues %s", (_name, payload, expected) => {
1881
+ const buffer = Buffer.alloc(expected.length);
1882
+ const buffalo = new BuffaloZcl(buffer);
1883
+ buffalo.write(BuffaloZclDataType.LIST_TUYA_DATAPOINT_VALUES, payload, {});
1884
+ expect(buffalo.getPosition()).toBe(expected.length);
1885
+ expect(buffer).toStrictEqual(expected);
1886
+ });
1887
+
1888
+ it("Zcl utils get cluster without manufacturerCode", () => {
1889
+ const cluster = Zcl.Utils.getCluster(0xfc00, undefined, {});
1890
+ expect(cluster.ID).toBe(0xfc00);
1891
+ expect(cluster.name).toBe("manuSpecificAssaDoorLock");
1892
+ });
1893
+
1894
+ it("Zcl utils get cluster with manufacturerCode", () => {
1895
+ const cluster = Zcl.Utils.getCluster(0xfc00, 0x100b, {});
1896
+ expect(cluster.ID).toBe(0xfc00);
1897
+ expect(cluster.name).toBe("manuSpecificPhilips");
1898
+ });
1899
+
1900
+ it("Zcl utils get cluster manufacturerCode", () => {
1901
+ const cluster = Zcl.Utils.getCluster(0xfc00, 0x10f2, {});
1902
+ expect(cluster.ID).toBe(0xfc00);
1903
+ expect(cluster.name).toBe("manuSpecificAssaDoorLock");
1904
+ });
1905
+
1906
+ it("Zcl utils get cluster manufacturerCode wrong", () => {
1907
+ const cluster = Zcl.Utils.getCluster(0xfc00, 123, {});
1908
+ expect(cluster.ID).toBe(0xfc00);
1909
+ expect(cluster.name).toBe("manuSpecificAssaDoorLock");
1910
+ });
1911
+
1912
+ it("Zcl utils get cluster attributes manufacturerCode", () => {
1913
+ const cluster = Zcl.Utils.getCluster("closuresWindowCovering", 0x1021, {});
1914
+ const attribute = cluster.getAttribute(0xf004);
1915
+ expect(attribute).toStrictEqual({ID: 0xf004, manufacturerCode: 0x1021, name: "stepPositionTilt", type: 48});
1916
+ });
1917
+
1918
+ it("Zcl utils get cluster attributes manufacturerCode wrong", () => {
1919
+ const cluster = Zcl.Utils.getCluster("closuresWindowCovering", 123, {});
1920
+ expect(() => cluster.getAttribute(0x1000)).toThrow("Cluster 'closuresWindowCovering' has no attribute '4096'");
1921
+ });
1922
+
1923
+ it("Zcl utils get command", () => {
1924
+ const cluster = Zcl.Utils.getCluster("genOnOff", undefined, {});
1925
+ const command = cluster.getCommand(0);
1926
+ expect(command.name).toEqual("off");
1927
+ expect(cluster.getCommand("off")).toEqual(command);
1928
+ });
1929
+
1930
+ it("Zcl utils get attribute", () => {
1931
+ const cluster = Zcl.Utils.getCluster("genOnOff", undefined, {});
1932
+ const command = cluster.getAttribute(16385);
1933
+ expect(command.name).toEqual("onTime");
1934
+ expect(cluster.getAttribute("onTime")).toEqual(command);
1935
+ });
1936
+
1937
+ it("Zcl utils get attribute non-existing", () => {
1938
+ const cluster = Zcl.Utils.getCluster("genOnOff", undefined, {});
1939
+ expect(() => cluster.getAttribute("notExisting")).toThrow("Cluster 'genOnOff' has no attribute 'notExisting'");
1940
+ });
1941
+
1942
+ it("Zcl utils get command non-existing", () => {
1943
+ const cluster = Zcl.Utils.getCluster("genOnOff", undefined, {});
1944
+ expect(() => cluster.getCommand("notExisting")).toThrow("Cluster 'genOnOff' has no command 'notExisting'");
1945
+ });
1946
+
1947
+ it("Zcl green power readGpd commissioning", () => {
1948
+ const buffer = [
1949
+ 0xff, // device
1950
+ 0x00, // options
1951
+ ];
1952
+ const frame = new BuffaloZcl(Buffer.from(buffer));
1953
+
1954
+ expect(
1955
+ frame.read(BuffaloZclDataType.GPD_FRAME, {
1956
+ payload: {
1957
+ commandID: 0xe0,
1958
+ },
1959
+ }),
1960
+ ).toStrictEqual({
1961
+ deviceID: 0xff,
1962
+ options: 0x00,
1963
+ extendedOptions: 0x00,
1964
+ securityKey: Buffer.alloc(16),
1965
+ keyMic: 0,
1966
+ outgoingCounter: 0,
1967
+ manufacturerID: 0,
1968
+ modelID: 0,
1969
+ numGpdCommands: 0,
1970
+ gpdCommandIdList: Buffer.alloc(0),
1971
+ numServerClusters: 0,
1972
+ numClientClusters: 0,
1973
+ gpdServerClusters: Buffer.alloc(0),
1974
+ gpdClientClusters: Buffer.alloc(0),
1975
+ applicationInfo: 0x00,
1976
+ genericSwitchConfig: 0,
1977
+ currentContactStatus: 0,
1978
+ });
1979
+ });
1980
+
1981
+ it("Zcl green power readGpd commissioning all options", () => {
1982
+ const buffer = [
1983
+ 0xff, // device
1984
+ 0x80 | 0x04, // options
1985
+ 0x20 | 0x40 | 0x80, // extended options
1986
+ 0,
1987
+ 0,
1988
+ 0,
1989
+ 0,
1990
+ 0,
1991
+ 0,
1992
+ 0,
1993
+ 0,
1994
+ 0,
1995
+ 0,
1996
+ 0,
1997
+ 0,
1998
+ 0,
1999
+ 0,
2000
+ 0,
2001
+ 0, // security key
2002
+ 0,
2003
+ 0,
2004
+ 0,
2005
+ 0, // key mic
2006
+ 0,
2007
+ 0,
2008
+ 0,
2009
+ 0, // outgoing counter
2010
+ 0x01 | 0x02 | 0x04 | 0x08 | 0x10, // application info
2011
+ 0,
2012
+ 0, // manufacturer ID
2013
+ 0,
2014
+ 0, // model ID
2015
+ 0, // num GPD commands + commands
2016
+ 0, // clusters
2017
+ 2, // switch info length
2018
+ 0, // generic switch config
2019
+ 1, // current contact status
2020
+ ];
2021
+ const frame = new BuffaloZcl(Buffer.from(buffer));
2022
+
2023
+ expect(
2024
+ frame.read(BuffaloZclDataType.GPD_FRAME, {
2025
+ payload: {
2026
+ commandID: 0xe0,
2027
+ },
2028
+ }),
2029
+ ).toStrictEqual({
2030
+ deviceID: 0xff,
2031
+ options: 0x80 | 0x04,
2032
+ extendedOptions: 0x20 | 0x40 | 0x80,
2033
+ securityKey: Buffer.alloc(16),
2034
+ keyMic: 0,
2035
+ outgoingCounter: 0,
2036
+ manufacturerID: 0,
2037
+ modelID: 0,
2038
+ numGpdCommands: 0,
2039
+ gpdCommandIdList: Buffer.alloc(0),
2040
+ numServerClusters: 0,
2041
+ numClientClusters: 0,
2042
+ gpdServerClusters: Buffer.alloc(0),
2043
+ gpdClientClusters: Buffer.alloc(0),
2044
+ applicationInfo: 0x01 | 0x02 | 0x04 | 0x08 | 0x10,
2045
+ genericSwitchConfig: 0,
2046
+ currentContactStatus: 1,
2047
+ });
2048
+ });
2049
+
2050
+ it("Zcl green power readGpd channel request", () => {
2051
+ const buffer = [0xfa];
2052
+ const frame = new BuffaloZcl(Buffer.from(buffer));
2053
+
2054
+ expect(
2055
+ frame.read(BuffaloZclDataType.GPD_FRAME, {
2056
+ payload: {
2057
+ commandID: 0xe3,
2058
+ },
2059
+ }),
2060
+ ).toStrictEqual({
2061
+ nextChannel: 0xa,
2062
+ nextNextChannel: 0xf,
2063
+ });
2064
+ });
2065
+
2066
+ it("Zcl green power readGpd attribute report", () => {
2067
+ const buffer = [
2068
+ 0x12,
2069
+ 0x34, // Manufacturer ID
2070
+ 0xff,
2071
+ 0xff, // Cluster ID
2072
+ 0x00,
2073
+ 0x00, // Attribute ID
2074
+ DataType.UINT32, // Attribute Type
2075
+ 0x00,
2076
+ 0x01,
2077
+ 0x02,
2078
+ 0x03,
2079
+ 0x01,
2080
+ 0x00,
2081
+ DataType.CHAR_STR,
2082
+ 0x06,
2083
+ 0x5a,
2084
+ 0x49,
2085
+ 0x47,
2086
+ 0x42,
2087
+ 0x45,
2088
+ 0x45,
2089
+ 0x02,
2090
+ 0x00,
2091
+ DataType.BOOLEAN,
2092
+ 0x01,
2093
+ ];
2094
+ const frame = new BuffaloZcl(Buffer.from(buffer));
2095
+
2096
+ expect(
2097
+ frame.read(BuffaloZclDataType.GPD_FRAME, {
2098
+ payload: {
2099
+ commandID: 0xa1,
2100
+ payloadSize: buffer.length,
2101
+ },
2102
+ }),
2103
+ ).toStrictEqual({
2104
+ manufacturerCode: 13330,
2105
+ clusterID: 65535,
2106
+ attributes: {
2107
+ "0": 50462976,
2108
+ "1": "ZIGBEE",
2109
+ "2": 1,
2110
+ },
2111
+ });
2112
+ });
2113
+
2114
+ it("Zcl green power writeGpd commissioning", () => {
2115
+ const expected = [
2116
+ 1, // length
2117
+ 0, // options
2118
+ ];
2119
+ const frame = new BuffaloZcl(Buffer.alloc(2));
2120
+
2121
+ frame.write(
2122
+ BuffaloZclDataType.GPD_FRAME,
2123
+ {
2124
+ commandID: 0xf0,
2125
+ options: 0,
2126
+ panID: 0,
2127
+ securityKey: Buffer.alloc(16),
2128
+ keyMic: 0,
2129
+ frameCounter: 0,
2130
+ },
2131
+ {},
2132
+ );
2133
+
2134
+ expect(frame.getWritten()).toStrictEqual(Buffer.from(expected));
2135
+ });
2136
+
2137
+ it("Zcl green power writeGpd commissioning all options", () => {
2138
+ const expected = [
2139
+ 27, // length
2140
+ 0b11111, // options
2141
+ 0xff,
2142
+ 0xff, // PAN ID
2143
+ 0,
2144
+ 0,
2145
+ 0,
2146
+ 0,
2147
+ 0,
2148
+ 0,
2149
+ 0,
2150
+ 0,
2151
+ 0,
2152
+ 0,
2153
+ 0,
2154
+ 0,
2155
+ 0,
2156
+ 0,
2157
+ 0,
2158
+ 0, // security key
2159
+ 0,
2160
+ 0,
2161
+ 0,
2162
+ 0, // key mic
2163
+ 0,
2164
+ 0,
2165
+ 0,
2166
+ 0, // frame counter
2167
+ ];
2168
+ const frame = new BuffaloZcl(Buffer.alloc(28));
2169
+
2170
+ frame.write(
2171
+ BuffaloZclDataType.GPD_FRAME,
2172
+ {
2173
+ commandID: 0xf0,
2174
+ options: 0b11111,
2175
+ panID: 0xffff,
2176
+ securityKey: Buffer.alloc(16),
2177
+ keyMic: 0,
2178
+ frameCounter: 0,
2179
+ },
2180
+ {},
2181
+ );
2182
+
2183
+ expect(frame.getWritten()).toStrictEqual(Buffer.from(expected));
2184
+ });
2185
+
2186
+ it("Zcl green power writeGpd custom reply", () => {
2187
+ const expected = [
2188
+ 6, // length
2189
+ 90,
2190
+ 73,
2191
+ 71,
2192
+ 66,
2193
+ 69,
2194
+ 69, // ZIGBEE
2195
+ ];
2196
+
2197
+ const frame = new BuffaloZcl(Buffer.alloc(7));
2198
+ frame.write(
2199
+ BuffaloZclDataType.GPD_FRAME,
2200
+ {
2201
+ commandID: 0xf4,
2202
+ buffer: Buffer.from("ZIGBEE"),
2203
+ },
2204
+ {},
2205
+ );
2206
+
2207
+ expect(frame.getWritten()).toStrictEqual(Buffer.from(expected));
2208
+ });
2209
+
2210
+ it("Zcl green power writeGpd unhandled command", () => {
2211
+ const frame = new BuffaloZcl(Buffer.alloc(7));
2212
+ frame.write(
2213
+ BuffaloZclDataType.GPD_FRAME,
2214
+ {
2215
+ commandID: 0x1ff,
2216
+ },
2217
+ {},
2218
+ );
2219
+
2220
+ expect(frame.getWritten()).toStrictEqual(Buffer.alloc(0));
2221
+ });
2222
+
2223
+ it("Zcl green power writeGpd channel configuration", () => {
2224
+ const expected = [
2225
+ 1, // length
2226
+ 0xf, // Channel 26
2227
+ ];
2228
+
2229
+ const frame = new BuffaloZcl(Buffer.alloc(2));
2230
+ frame.write(
2231
+ BuffaloZclDataType.GPD_FRAME,
2232
+ {
2233
+ commandID: 0xf3,
2234
+ operationalChannel: 0xf,
2235
+ basic: false,
2236
+ },
2237
+ {},
2238
+ );
2239
+
2240
+ expect(frame.getWritten()).toStrictEqual(Buffer.from(expected));
2241
+ });
2242
+
2243
+ it("Zcl green power writeGpd channel configuration basic", () => {
2244
+ const expected = [
2245
+ 1, // length
2246
+ 0x1f, // Channel 26 + Basic
2247
+ ];
2248
+
2249
+ const frame = new BuffaloZcl(Buffer.alloc(2));
2250
+ frame.write(
2251
+ BuffaloZclDataType.GPD_FRAME,
2252
+ {
2253
+ commandID: 0xf3,
2254
+ operationalChannel: 0xf,
2255
+ basic: true,
2256
+ },
2257
+ {},
2258
+ );
2259
+
2260
+ expect(frame.getWritten()).toStrictEqual(Buffer.from(expected));
2261
+ });
2262
+
2263
+ it("ZclFrame parse MiBoxer zone configuration command", () => {
2264
+ const zoneConfigPayload = Buffer.from([
2265
+ 0x11, 0x01, 0xf0, 0x08, 0x84, 0x2b, 0x01, 0x98, 0x2b, 0x02, 0xac, 0x2b, 0x03, 0xc0, 0x2b, 0x04, 0xd4, 0x2b, 0x05, 0xe8, 0x2b, 0x06, 0xfc,
2266
+ 0x2b, 0x07, 0x10, 0x2c, 0x08,
2267
+ ]);
2268
+ const zoneConfigFrame = Zcl.Frame.fromBuffer(Zcl.Clusters.genGroups.ID, Zcl.Header.fromBuffer(zoneConfigPayload)!, zoneConfigPayload, {});
2269
+ expect(zoneConfigFrame.payload.zones).toStrictEqual([
2270
+ {zoneNum: 1, groupId: 0x2b84},
2271
+ {zoneNum: 2, groupId: 0x2b98},
2272
+ {zoneNum: 3, groupId: 0x2bac},
2273
+ {zoneNum: 4, groupId: 0x2bc0},
2274
+ {zoneNum: 5, groupId: 0x2bd4},
2275
+ {zoneNum: 6, groupId: 0x2be8},
2276
+ {zoneNum: 7, groupId: 0x2bfc},
2277
+ {zoneNum: 8, groupId: 0x2c10},
2278
+ ]);
2279
+ });
2280
+ it("ZclFrame serialize MiBoxer zone configuration command", () => {
2281
+ const testZones = [
2282
+ {zoneNum: 1, groupId: 0x2b84},
2283
+ {zoneNum: 2, groupId: 0x2b98},
2284
+ {zoneNum: 3, groupId: 0x2bac},
2285
+ {zoneNum: 4, groupId: 0x2bc0},
2286
+ {zoneNum: 5, groupId: 0x2bd4},
2287
+ {zoneNum: 6, groupId: 0x2be8},
2288
+ {zoneNum: 7, groupId: 0x2bfc},
2289
+ {zoneNum: 8, groupId: 0x2c10},
2290
+ ];
2291
+ const zoneConfigFrame = Zcl.Frame.create(
2292
+ FrameType.SPECIFIC,
2293
+ Direction.CLIENT_TO_SERVER,
2294
+ true,
2295
+ undefined,
2296
+ 1,
2297
+ "miboxerSetZones",
2298
+ Zcl.Clusters.genGroups.ID,
2299
+ {zones: testZones},
2300
+ {},
2301
+ );
2302
+ expect(zoneConfigFrame.toBuffer()).toStrictEqual(
2303
+ Buffer.from([
2304
+ 0x11, 0x01, 0xf0, 0x08, 0x84, 0x2b, 0x01, 0x98, 0x2b, 0x02, 0xac, 0x2b, 0x03, 0xc0, 0x2b, 0x04, 0xd4, 0x2b, 0x05, 0xe8, 0x2b, 0x06,
2305
+ 0xfc, 0x2b, 0x07, 0x10, 0x2c, 0x08,
2306
+ ]),
2307
+ );
2308
+ });
2309
+
2310
+ it("BuffaloZcl read BIG_ENDIAN_UINT24", () => {
2311
+ const buffer = Buffer.from([0x01, 0x01, 0x86, 0xa0, 0x02]);
2312
+ const buffalo = new BuffaloZcl(buffer, 1);
2313
+ const value = buffalo.read(BuffaloZclDataType.BIG_ENDIAN_UINT24, {});
2314
+ expect(buffalo.getPosition()).toBe(4);
2315
+ expect(value).toStrictEqual(100000);
2316
+ });
2317
+
2318
+ it("BuffaloZcl write BIG_ENDIAN_UINT24", () => {
2319
+ const payload = 16777200;
2320
+ const buffer = Buffer.alloc(4);
2321
+ const expected = Buffer.from([0x00, 0xff, 0xff, 0xf0]);
2322
+ const buffalo = new BuffaloZcl(buffer, 1);
2323
+ buffalo.write(BuffaloZclDataType.BIG_ENDIAN_UINT24, payload, {});
2324
+ expect(buffalo.getPosition()).toBe(4);
2325
+ expect(buffer).toStrictEqual(expected);
2326
+ });
2327
+
2328
+ it("BuffaloZcl read BUFFER whole", () => {
2329
+ const buffer = Buffer.from([0x01, 0x02, 0x03, 0x04, 0x05]);
2330
+ const buffalo = new BuffaloZcl(buffer);
2331
+ const value = buffalo.read(BuffaloZclDataType.BUFFER, {});
2332
+ expect(value).toStrictEqual(Buffer.from([0x01, 0x02, 0x03, 0x04, 0x05]));
2333
+ });
2334
+
2335
+ it("BuffaloZcl read BUFFER with length", () => {
2336
+ const buffer = Buffer.from([0x01, 0x02, 0x03, 0x04, 0x05]);
2337
+ const buffalo = new BuffaloZcl(buffer);
2338
+ const value = buffalo.read(BuffaloZclDataType.BUFFER, {length: 3});
2339
+ expect(value).toStrictEqual(Buffer.from([0x01, 0x02, 0x03]));
2340
+ });
2341
+
2342
+ it("BuffaloZcl write BUFFER whole", () => {
2343
+ const buffer = Buffer.alloc(5);
2344
+ const expected = Buffer.from([0x01, 0x02, 0x03, 0x04, 0x05]);
2345
+ const buffalo = new BuffaloZcl(buffer);
2346
+ buffalo.write(BuffaloZclDataType.BUFFER, expected, {});
2347
+ expect(buffer).toStrictEqual(expected);
2348
+ });
2349
+
2350
+ it("BuffaloZcl write BUFFER always whole - length ignored", () => {
2351
+ const buffer = Buffer.alloc(5);
2352
+ const expected = Buffer.from([0x01, 0x02, 0x03, 0x04, 0x05]);
2353
+ const buffalo = new BuffaloZcl(buffer);
2354
+ buffalo.write(BuffaloZclDataType.BUFFER, expected, {length: 3});
2355
+ expect(buffer).toStrictEqual(expected);
2356
+ });
2357
+
2358
+ it("BuffaloZcl write non existing type", () => {
2359
+ expect(() => {
2360
+ const buffalo = new BuffaloZcl(Buffer.alloc(0));
2361
+ // @ts-expect-error invalid typing
2362
+ buffalo.write(9999, 1, {});
2363
+ }).toThrow(new Error("Write for '9999' not available"));
2364
+ });
2365
+
2366
+ it("BuffaloZcl read non existing type", () => {
2367
+ expect(() => {
2368
+ const buffalo = new BuffaloZcl(Buffer.alloc(0));
2369
+ // @ts-expect-error invalid typing
2370
+ buffalo.read(9999, {});
2371
+ }).toThrow(new Error("Read for '9999' not available"));
2372
+ });
2373
+
2374
+ it("BuffaloZcl write TOD", () => {
2375
+ const buffer = Buffer.alloc(4);
2376
+ const expected = Buffer.from([0, 59, 34, 88]);
2377
+ const buffalo = new BuffaloZcl(buffer);
2378
+ const payload = {hours: 0, minutes: 59, seconds: 34, hundredths: 88};
2379
+ buffalo.write(DataType.TOD, payload, {});
2380
+ expect(buffalo.getBuffer()).toStrictEqual(expected);
2381
+ });
2382
+
2383
+ it("BuffaloZcl read TOD", () => {
2384
+ const expected = {hours: 0, minutes: 59, seconds: 34, hundredths: 88};
2385
+ const buffalo = new BuffaloZcl(Buffer.from([0, 59, 34, 88]));
2386
+ const value = buffalo.read(DataType.TOD, {});
2387
+ expect(value).toStrictEqual(expected);
2388
+ });
2389
+
2390
+ it("BuffaloZcl write DATE", () => {
2391
+ const buffer = Buffer.alloc(4);
2392
+ const expected = Buffer.from([100, 8, 31, 3]);
2393
+ const buffalo = new BuffaloZcl(buffer);
2394
+ const payload = {year: 2000, month: 8, dayOfMonth: 31, dayOfWeek: 3};
2395
+ buffalo.write(DataType.DATE, payload, {});
2396
+ expect(buffalo.getBuffer()).toStrictEqual(expected);
2397
+ });
2398
+
2399
+ it("BuffaloZcl read DATE", () => {
2400
+ const expected = {year: 2000, month: 8, dayOfMonth: 31, dayOfWeek: 3};
2401
+ const buffalo = new BuffaloZcl(Buffer.from([100, 8, 31, 3]));
2402
+ const value = buffalo.read(DataType.DATE, {});
2403
+ expect(value).toStrictEqual(expected);
2404
+ });
2405
+
2406
+ it("BuffaloZcl write TOD non-value", () => {
2407
+ const buffer = Buffer.alloc(4);
2408
+ const expected = Buffer.from([0xff, 0xff, 0xff, 0xff]);
2409
+ const buffalo = new BuffaloZcl(buffer);
2410
+ const payload = {hours: undefined, minutes: undefined, seconds: undefined, hundredths: undefined};
2411
+ buffalo.write(DataType.TOD, payload, {});
2412
+ expect(buffalo.getBuffer()).toStrictEqual(expected);
2413
+ });
2414
+
2415
+ it("BuffaloZcl read DATE non-value", () => {
2416
+ const buffer = Buffer.alloc(4);
2417
+ const expected = Buffer.from([0xff, 0xff, 0xff, 0xff]);
2418
+ const buffalo = new BuffaloZcl(buffer);
2419
+ const payload = {year: undefined, month: undefined, dayOfMonth: undefined, dayOfWeek: undefined};
2420
+ buffalo.write(DataType.DATE, payload, {});
2421
+ expect(buffalo.getBuffer()).toStrictEqual(expected);
2422
+ });
2423
+
2424
+ it("BuffaloZcl read OCTET_STR non-value", () => {
2425
+ const buffalo = new BuffaloZcl(Buffer.from([0xff]));
2426
+ const value = buffalo.read(DataType.OCTET_STR, {});
2427
+ expect(value).toStrictEqual(Buffer.from([]));
2428
+ });
2429
+
2430
+ it("BuffaloZcl read CHAR_STR non-value", () => {
2431
+ const buffalo = new BuffaloZcl(Buffer.from([0xff]));
2432
+ const value = buffalo.read(DataType.CHAR_STR, {});
2433
+ expect(value).toStrictEqual("");
2434
+ });
2435
+
2436
+ it("BuffaloZcl read MI_STRUCT non-value", () => {
2437
+ const buffalo = new BuffaloZcl(Buffer.from([0xff]));
2438
+ const value = buffalo.read(BuffaloZclDataType.MI_STRUCT, {});
2439
+ expect(value).toStrictEqual({});
2440
+ });
2441
+
2442
+ it("BuffaloZcl read LONG_OCTET_STR non-value", () => {
2443
+ const buffalo = new BuffaloZcl(Buffer.from([0xff, 0xff]));
2444
+ const value = buffalo.read(DataType.LONG_OCTET_STR, {});
2445
+ expect(value).toStrictEqual(Buffer.from([]));
2446
+ });
2447
+
2448
+ it("BuffaloZcl read LONG_CHAR_STR non-value", () => {
2449
+ const buffalo = new BuffaloZcl(Buffer.from([0xff, 0xff]));
2450
+ const value = buffalo.read(DataType.LONG_CHAR_STR, {});
2451
+ expect(value).toStrictEqual("");
2452
+ });
2453
+
2454
+ it("BuffaloZcl read ARRAY non-value", () => {
2455
+ const buffalo = new BuffaloZcl(Buffer.from([DataType.UINT8, 0xff, 0xff]));
2456
+ const value = buffalo.read(DataType.ARRAY, {});
2457
+ expect(value).toStrictEqual([]);
2458
+ });
2459
+
2460
+ it("BuffaloZcl read STRUCT non-value", () => {
2461
+ const buffalo = new BuffaloZcl(Buffer.from([0xff, 0xff]));
2462
+ const value = buffalo.read(DataType.STRUCT, {});
2463
+ expect(value).toStrictEqual([]);
2464
+ });
2465
+
2466
+ it("BuffaloZcl write NO_DATA", () => {
2467
+ const buffalo = new BuffaloZcl(Buffer.alloc(2));
2468
+ const payload = null;
2469
+ buffalo.write(DataType.NO_DATA, payload, {});
2470
+ expect(buffalo.getPosition()).toStrictEqual(0);
2471
+ expect(buffalo.getBuffer()).toStrictEqual(Buffer.from([0x00, 0x00]));
2472
+ });
2473
+
2474
+ it("BuffaloZcl read NO_DATA", () => {
2475
+ const buffalo = new BuffaloZcl(Buffer.from([0x00, 0x00]), 1);
2476
+ const value = buffalo.read(DataType.NO_DATA, {});
2477
+ expect(buffalo.getPosition()).toStrictEqual(1);
2478
+ expect(value).toStrictEqual(undefined);
2479
+ });
2480
+
2481
+ it("BuffaloZcl write UNKNOWN", () => {
2482
+ const buffalo = new BuffaloZcl(Buffer.alloc(2));
2483
+ const payload = null;
2484
+ buffalo.write(DataType.UNKNOWN, payload, {});
2485
+ expect(buffalo.getPosition()).toStrictEqual(0);
2486
+ expect(buffalo.getBuffer()).toStrictEqual(Buffer.from([0x00, 0x00]));
2487
+ });
2488
+
2489
+ it("BuffaloZcl read UNKNOWN", () => {
2490
+ const buffalo = new BuffaloZcl(Buffer.from([0x00, 0x00]), 1);
2491
+ const value = buffalo.read(DataType.UNKNOWN, {});
2492
+ expect(buffalo.getPosition()).toStrictEqual(1);
2493
+ expect(value).toStrictEqual(undefined);
2494
+ });
2495
+
2496
+ it("ZclHeader return undefined when too short", () => {
2497
+ const header = Zcl.Header.fromBuffer(Buffer.from([0, 8]));
2498
+ expect(header).toStrictEqual(undefined);
2499
+ });
2500
+
2501
+ it("ZclHeader return undefined when too short manufacturer specific", () => {
2502
+ const header = Zcl.Header.fromBuffer(Buffer.from([4, 8, 3]));
2503
+ expect(header).toStrictEqual(undefined);
2504
+ });
2505
+
2506
+ describe("BuffaloZcl write passthrough to Buffalo", () => {
2507
+ let buffalo: BuffaloZcl;
2508
+
2509
+ beforeEach(() => {
2510
+ buffalo = new BuffaloZcl(Buffer.alloc(255));
2511
+ });
2512
+
2513
+ it("uint8", () => {
2514
+ const uint8Spy = vi.spyOn(buffalo, "writeUInt8");
2515
+ const types = [DataType.DATA8, DataType.BOOLEAN, DataType.BITMAP8, DataType.UINT8, DataType.ENUM8];
2516
+ let i = 0;
2517
+
2518
+ for (const type of types) {
2519
+ buffalo.write(type, 1, {});
2520
+ expect(uint8Spy).toHaveBeenCalledTimes(++i);
2521
+ }
2522
+ });
2523
+
2524
+ it("uint16", () => {
2525
+ const uint16Spy = vi.spyOn(buffalo, "writeUInt16");
2526
+ const types = [DataType.DATA16, DataType.BITMAP16, DataType.UINT16, DataType.ENUM16, DataType.CLUSTER_ID, DataType.ATTR_ID];
2527
+ let i = 0;
2528
+
2529
+ for (const type of types) {
2530
+ buffalo.write(type, 1, {});
2531
+ expect(uint16Spy).toHaveBeenCalledTimes(++i);
2532
+ }
2533
+ });
2534
+
2535
+ it("uint24", () => {
2536
+ const uint24Spy = vi.spyOn(buffalo, "writeUInt24");
2537
+ const types = [DataType.DATA24, DataType.BITMAP24, DataType.UINT24];
2538
+ let i = 0;
2539
+
2540
+ for (const type of types) {
2541
+ buffalo.write(type, 1, {});
2542
+ expect(uint24Spy).toHaveBeenCalledTimes(++i);
2543
+ }
2544
+ });
2545
+
2546
+ it("uint32", () => {
2547
+ const uint32Spy = vi.spyOn(buffalo, "writeUInt32");
2548
+ const types = [DataType.DATA32, DataType.BITMAP32, DataType.UINT32, DataType.UTC, DataType.BAC_OID];
2549
+ let i = 0;
2550
+
2551
+ for (const type of types) {
2552
+ buffalo.write(type, 1, {});
2553
+ expect(uint32Spy).toHaveBeenCalledTimes(++i);
2554
+ }
2555
+ });
2556
+
2557
+ it("int8", () => {
2558
+ const int8Spy = vi.spyOn(buffalo, "writeInt8");
2559
+ buffalo.write(DataType.INT8, 1, {});
2560
+ expect(int8Spy).toHaveBeenCalledTimes(1);
2561
+ });
2562
+
2563
+ it("int16", () => {
2564
+ const int16Spy = vi.spyOn(buffalo, "writeInt16");
2565
+ buffalo.write(DataType.INT16, 1, {});
2566
+ expect(int16Spy).toHaveBeenCalledTimes(1);
2567
+ });
2568
+
2569
+ it("int24", () => {
2570
+ const int24Spy = vi.spyOn(buffalo, "writeInt24");
2571
+ buffalo.write(DataType.INT24, 1, {});
2572
+ expect(int24Spy).toHaveBeenCalledTimes(1);
2573
+ });
2574
+
2575
+ it("int32", () => {
2576
+ const int32Spy = vi.spyOn(buffalo, "writeInt32");
2577
+ buffalo.write(DataType.INT32, 1, {});
2578
+ expect(int32Spy).toHaveBeenCalledTimes(1);
2579
+ });
2580
+
2581
+ it("int48", () => {
2582
+ const int48Spy = vi.spyOn(buffalo, "writeInt48");
2583
+ buffalo.write(DataType.INT48, 1, {});
2584
+ expect(int48Spy).toHaveBeenCalledTimes(1);
2585
+ });
2586
+
2587
+ it("list uint8", () => {
2588
+ const listuint8Spy = vi.spyOn(buffalo, "writeListUInt8");
2589
+ buffalo.write(BuffaloZclDataType.LIST_UINT8, [1], {});
2590
+ expect(listuint8Spy).toHaveBeenCalledTimes(1);
2591
+ });
2592
+
2593
+ it("list uint16", () => {
2594
+ const listuint16Spy = vi.spyOn(buffalo, "writeListUInt16");
2595
+ buffalo.write(BuffaloZclDataType.LIST_UINT16, [1], {});
2596
+ expect(listuint16Spy).toHaveBeenCalledTimes(1);
2597
+ });
2598
+
2599
+ it("list uint24", () => {
2600
+ const listuint24Spy = vi.spyOn(buffalo, "writeListUInt24");
2601
+ buffalo.write(BuffaloZclDataType.LIST_UINT24, [1], {});
2602
+ expect(listuint24Spy).toHaveBeenCalledTimes(1);
2603
+ });
2604
+
2605
+ it("list uint32", () => {
2606
+ const listuint32Spy = vi.spyOn(buffalo, "writeListUInt32");
2607
+ buffalo.write(BuffaloZclDataType.LIST_UINT32, [1], {});
2608
+ expect(listuint32Spy).toHaveBeenCalledTimes(1);
2609
+ });
2610
+
2611
+ // NOT SUPPORTED
2612
+ // it('semi prec', () => {
2613
+ // const semiPrecSpy = vi.spyOn(buffalo, 'writeSemiFloatLE');
2614
+ // buffalo.write(DataType.SEMI_PREC, 1, {});
2615
+ // expect(semiPrecSpy).toHaveBeenCalledTimes(1);
2616
+ // });
2617
+
2618
+ it("single prec", () => {
2619
+ const singlePrecSpy = vi.spyOn(buffalo, "writeFloatLE");
2620
+ buffalo.write(DataType.SINGLE_PREC, 1.1, {});
2621
+ expect(singlePrecSpy).toHaveBeenCalledTimes(1);
2622
+ });
2623
+
2624
+ it("double prec", () => {
2625
+ const doublePrecSpy = vi.spyOn(buffalo, "writeDoubleLE");
2626
+ buffalo.write(DataType.DOUBLE_PREC, 1.1, {});
2627
+ expect(doublePrecSpy).toHaveBeenCalledTimes(1);
2628
+ });
2629
+
2630
+ it("ieee add", () => {
2631
+ const doublePrecSpy = vi.spyOn(buffalo, "writeIeeeAddr");
2632
+ buffalo.write(DataType.IEEE_ADDR, "0xf1f1f1f1f1f1f1f1", {});
2633
+ expect(doublePrecSpy).toHaveBeenCalledTimes(1);
2634
+ });
2635
+ });
2636
+
2637
+ describe("BuffaloZcl read passthrough to Buffalo", () => {
2638
+ let buffalo: BuffaloZcl;
2639
+
2640
+ beforeEach(() => {
2641
+ buffalo = new BuffaloZcl(Buffer.alloc(255));
2642
+ });
2643
+
2644
+ it("uint8", () => {
2645
+ const uint8Spy = vi.spyOn(buffalo, "readUInt8");
2646
+ const types = [DataType.DATA8, DataType.BOOLEAN, DataType.BITMAP8, DataType.UINT8, DataType.ENUM8];
2647
+ let i = 0;
2648
+
2649
+ for (const type of types) {
2650
+ buffalo.read(type, {});
2651
+ expect(uint8Spy).toHaveBeenCalledTimes(++i);
2652
+ }
2653
+ });
2654
+
2655
+ it("uint16", () => {
2656
+ const uint16Spy = vi.spyOn(buffalo, "readUInt16");
2657
+ const types = [DataType.DATA16, DataType.BITMAP16, DataType.UINT16, DataType.ENUM16, DataType.CLUSTER_ID, DataType.ATTR_ID];
2658
+ let i = 0;
2659
+
2660
+ for (const type of types) {
2661
+ buffalo.read(type, {});
2662
+ expect(uint16Spy).toHaveBeenCalledTimes(++i);
2663
+ }
2664
+ });
2665
+
2666
+ it("uint24", () => {
2667
+ const uint24Spy = vi.spyOn(buffalo, "readUInt24");
2668
+ const types = [DataType.DATA24, DataType.BITMAP24, DataType.UINT24];
2669
+ let i = 0;
2670
+
2671
+ for (const type of types) {
2672
+ buffalo.read(type, {});
2673
+ expect(uint24Spy).toHaveBeenCalledTimes(++i);
2674
+ }
2675
+ });
2676
+
2677
+ it("uint32", () => {
2678
+ const uint32Spy = vi.spyOn(buffalo, "readUInt32");
2679
+ const types = [DataType.DATA32, DataType.BITMAP32, DataType.UINT32, DataType.UTC, DataType.BAC_OID];
2680
+ let i = 0;
2681
+
2682
+ for (const type of types) {
2683
+ buffalo.read(type, {});
2684
+ expect(uint32Spy).toHaveBeenCalledTimes(++i);
2685
+ }
2686
+ });
2687
+
2688
+ it("int8", () => {
2689
+ const int8Spy = vi.spyOn(buffalo, "readInt8");
2690
+ buffalo.read(DataType.INT8, {});
2691
+ expect(int8Spy).toHaveBeenCalledTimes(1);
2692
+ });
2693
+
2694
+ it("int16", () => {
2695
+ const int16Spy = vi.spyOn(buffalo, "readInt16");
2696
+ buffalo.read(DataType.INT16, {});
2697
+ expect(int16Spy).toHaveBeenCalledTimes(1);
2698
+ });
2699
+
2700
+ it("int24", () => {
2701
+ const int24Spy = vi.spyOn(buffalo, "readInt24");
2702
+ buffalo.read(DataType.INT24, {});
2703
+ expect(int24Spy).toHaveBeenCalledTimes(1);
2704
+ });
2705
+
2706
+ it("int32", () => {
2707
+ const int32Spy = vi.spyOn(buffalo, "readInt32");
2708
+ buffalo.read(DataType.INT32, {});
2709
+ expect(int32Spy).toHaveBeenCalledTimes(1);
2710
+ });
2711
+
2712
+ it("int48", () => {
2713
+ const int48Spy = vi.spyOn(buffalo, "readInt48");
2714
+ buffalo.read(DataType.INT48, {});
2715
+ expect(int48Spy).toHaveBeenCalledTimes(1);
2716
+ });
2717
+
2718
+ it("list uint8", () => {
2719
+ const listuint8Spy = vi.spyOn(buffalo, "readListUInt8");
2720
+ buffalo.read(BuffaloZclDataType.LIST_UINT8, {length: 1});
2721
+ expect(listuint8Spy).toHaveBeenCalledTimes(1);
2722
+ });
2723
+
2724
+ it("list uint16", () => {
2725
+ const listuint16Spy = vi.spyOn(buffalo, "readListUInt16");
2726
+ buffalo.read(BuffaloZclDataType.LIST_UINT16, {length: 1});
2727
+ expect(listuint16Spy).toHaveBeenCalledTimes(1);
2728
+ });
2729
+
2730
+ it("list uint24", () => {
2731
+ const listuint24Spy = vi.spyOn(buffalo, "readListUInt24");
2732
+ buffalo.read(BuffaloZclDataType.LIST_UINT24, {length: 1});
2733
+ expect(listuint24Spy).toHaveBeenCalledTimes(1);
2734
+ });
2735
+
2736
+ it("list uint32", () => {
2737
+ const listuint32Spy = vi.spyOn(buffalo, "readListUInt32");
2738
+ buffalo.read(BuffaloZclDataType.LIST_UINT32, {length: 1});
2739
+ expect(listuint32Spy).toHaveBeenCalledTimes(1);
2740
+ });
2741
+
2742
+ // NOT SUPPORTED
2743
+ // it('semi prec', () => {
2744
+ // const semiPrecSpy = vi.spyOn(buffalo, 'readSemiFloatLE');
2745
+ // buffalo.read(DataType.SEMI_PREC, {});
2746
+ // expect(semiPrecSpy).toHaveBeenCalledTimes(1);
2747
+ // });
2748
+
2749
+ it("single prec", () => {
2750
+ const singlePrecSpy = vi.spyOn(buffalo, "readFloatLE");
2751
+ buffalo.read(DataType.SINGLE_PREC, {});
2752
+ expect(singlePrecSpy).toHaveBeenCalledTimes(1);
2753
+ });
2754
+
2755
+ it("double prec", () => {
2756
+ const doublePrecSpy = vi.spyOn(buffalo, "readDoubleLE");
2757
+ buffalo.read(DataType.DOUBLE_PREC, {});
2758
+ expect(doublePrecSpy).toHaveBeenCalledTimes(1);
2759
+ });
2760
+
2761
+ it("ieee add", () => {
2762
+ const doublePrecSpy = vi.spyOn(buffalo, "readIeeeAddr");
2763
+ buffalo.read(DataType.IEEE_ADDR, {});
2764
+ expect(doublePrecSpy).toHaveBeenCalledTimes(1);
2765
+ });
2766
+ });
2767
+
2768
+ it.each([
2769
+ BuffaloZclDataType.LIST_UINT8,
2770
+ BuffaloZclDataType.LIST_UINT16,
2771
+ BuffaloZclDataType.LIST_UINT24,
2772
+ BuffaloZclDataType.LIST_UINT32,
2773
+ BuffaloZclDataType.LIST_ZONEINFO,
2774
+ ])("Throws when read is missing required length option - param %s", (type) => {
2775
+ expect(() => {
2776
+ const buffalo = new BuffaloZcl(Buffer.alloc(1));
2777
+ buffalo.read(type, {});
2778
+ }).toThrow(`Cannot read ${BuffaloZclDataType[type]} without length option specified`);
2779
+ });
2780
+
2781
+ it("Reads as buffer when USE_DATA_TYPE is missing dataType option", () => {
2782
+ const buffalo = new BuffaloZcl(Buffer.from([12, 34]));
2783
+ const value = buffalo.read(BuffaloZclDataType.USE_DATA_TYPE, {});
2784
+ expect(value).toStrictEqual(Buffer.from([12, 34]));
2785
+ // @ts-expect-error protected
2786
+ buffalo.position = 1;
2787
+ const value2 = buffalo.read(BuffaloZclDataType.USE_DATA_TYPE, {length: 1});
2788
+ expect(value2).toStrictEqual(Buffer.from([34]));
2789
+ });
2790
+
2791
+ it("Writes as buffer when USE_DATA_TYPE is missing dataType option", () => {
2792
+ const payload = Buffer.from([12, 34]);
2793
+ const buffer = Buffer.alloc(2);
2794
+ const buffalo = new BuffaloZcl(buffer);
2795
+ buffalo.write(BuffaloZclDataType.USE_DATA_TYPE, payload, {});
2796
+ expect(buffer).toStrictEqual(payload);
2797
+ });
2798
+
2799
+ it("Throws when write USE_DATA_TYPE is missing dataType option and value isnt buffer or number array", () => {
2800
+ expect(() => {
2801
+ const payload = "abcd";
2802
+ const buffalo = new BuffaloZcl(Buffer.alloc(2));
2803
+ buffalo.write(BuffaloZclDataType.USE_DATA_TYPE, payload, {});
2804
+ }).toThrow("Cannot write USE_DATA_TYPE without dataType option specified");
2805
+ });
2806
+
2807
+ it("Throws when read GPD_FRAME is missing payload.payloadSize option when payload.commandID is 0xA1", () => {
2808
+ expect(() => {
2809
+ const buffalo = new BuffaloZcl(Buffer.alloc(1));
2810
+ buffalo.read(BuffaloZclDataType.GPD_FRAME, {payload: {commandID: 0xa1}});
2811
+ }).toThrow("Cannot read GPD_FRAME with commandID=0xA1 without payloadSize options specified");
2812
+ });
2813
+
2814
+ it("Throws when read LIST_THERMO_TRANSITIONS is missing required payload options", () => {
2815
+ expect(() => {
2816
+ const buffalo = new BuffaloZcl(Buffer.alloc(1));
2817
+ buffalo.read(BuffaloZclDataType.LIST_THERMO_TRANSITIONS, {});
2818
+ }).toThrow("Cannot read LIST_THERMO_TRANSITIONS without required payload options specified");
2819
+ expect(() => {
2820
+ const buffalo = new BuffaloZcl(Buffer.alloc(1));
2821
+ buffalo.read(BuffaloZclDataType.LIST_THERMO_TRANSITIONS, {payload: {}});
2822
+ }).toThrow("Cannot read LIST_THERMO_TRANSITIONS without required payload options specified");
2823
+ expect(() => {
2824
+ const buffalo = new BuffaloZcl(Buffer.alloc(1));
2825
+ buffalo.read(BuffaloZclDataType.LIST_THERMO_TRANSITIONS, {payload: {mode: 1}});
2826
+ }).toThrow("Cannot read LIST_THERMO_TRANSITIONS without required payload options specified");
2827
+ expect(() => {
2828
+ const buffalo = new BuffaloZcl(Buffer.alloc(1));
2829
+ buffalo.read(BuffaloZclDataType.LIST_THERMO_TRANSITIONS, {payload: {numoftrans: 1}});
2830
+ }).toThrow("Cannot read LIST_THERMO_TRANSITIONS without required payload options specified");
2831
+ });
2832
+ });