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.
- package/.github/dependabot.yml +9 -3
- package/.github/workflows/ci.yml +2 -4
- package/.github/workflows/stale.yml +1 -1
- package/.release-please-manifest.json +1 -1
- package/.vscode/extensions.json +3 -0
- package/.vscode/settings.json +11 -0
- package/CHANGELOG.md +25 -0
- package/biome.json +89 -0
- package/dist/adapter/adapter.d.ts +11 -11
- package/dist/adapter/adapter.d.ts.map +1 -1
- package/dist/adapter/adapter.js +14 -14
- package/dist/adapter/adapterDiscovery.d.ts +6 -6
- package/dist/adapter/adapterDiscovery.d.ts.map +1 -1
- package/dist/adapter/adapterDiscovery.js +139 -141
- package/dist/adapter/adapterDiscovery.js.map +1 -1
- package/dist/adapter/const.d.ts +1 -1
- package/dist/adapter/const.js +2 -2
- package/dist/adapter/deconz/adapter/deconzAdapter.d.ts +16 -16
- package/dist/adapter/deconz/adapter/deconzAdapter.d.ts.map +1 -1
- package/dist/adapter/deconz/adapter/deconzAdapter.js +95 -100
- package/dist/adapter/deconz/adapter/deconzAdapter.js.map +1 -1
- package/dist/adapter/deconz/driver/constants.d.ts +5 -5
- package/dist/adapter/deconz/driver/constants.d.ts.map +1 -1
- package/dist/adapter/deconz/driver/driver.d.ts +9 -9
- package/dist/adapter/deconz/driver/driver.d.ts.map +1 -1
- package/dist/adapter/deconz/driver/driver.js +112 -106
- package/dist/adapter/deconz/driver/driver.js.map +1 -1
- package/dist/adapter/deconz/driver/frame.d.ts +1 -1
- package/dist/adapter/deconz/driver/frame.d.ts.map +1 -1
- package/dist/adapter/deconz/driver/frame.js +1 -2
- package/dist/adapter/deconz/driver/frame.js.map +1 -1
- package/dist/adapter/deconz/driver/frameParser.d.ts +1 -1
- package/dist/adapter/deconz/driver/frameParser.d.ts.map +1 -1
- package/dist/adapter/deconz/driver/frameParser.js +66 -70
- package/dist/adapter/deconz/driver/frameParser.js.map +1 -1
- package/dist/adapter/deconz/driver/parser.d.ts +1 -1
- package/dist/adapter/deconz/driver/parser.d.ts.map +1 -1
- package/dist/adapter/deconz/driver/parser.js +2 -2
- package/dist/adapter/deconz/driver/parser.js.map +1 -1
- package/dist/adapter/deconz/driver/writer.d.ts +2 -2
- package/dist/adapter/deconz/driver/writer.d.ts.map +1 -1
- package/dist/adapter/deconz/driver/writer.js +1 -1
- package/dist/adapter/ember/adapter/emberAdapter.d.ts +19 -19
- package/dist/adapter/ember/adapter/emberAdapter.d.ts.map +1 -1
- package/dist/adapter/ember/adapter/emberAdapter.js +117 -97
- package/dist/adapter/ember/adapter/emberAdapter.js.map +1 -1
- package/dist/adapter/ember/adapter/endpoints.d.ts +1 -1
- package/dist/adapter/ember/adapter/endpoints.d.ts.map +1 -1
- package/dist/adapter/ember/adapter/oneWaitress.d.ts +5 -5
- package/dist/adapter/ember/adapter/oneWaitress.d.ts.map +1 -1
- package/dist/adapter/ember/adapter/oneWaitress.js +2 -2
- package/dist/adapter/ember/adapter/oneWaitress.js.map +1 -1
- package/dist/adapter/ember/adapter/tokensManager.d.ts +3 -3
- package/dist/adapter/ember/adapter/tokensManager.d.ts.map +1 -1
- package/dist/adapter/ember/adapter/tokensManager.js +20 -23
- package/dist/adapter/ember/adapter/tokensManager.js.map +1 -1
- package/dist/adapter/ember/enums.d.ts +4 -4
- package/dist/adapter/ember/enums.d.ts.map +1 -1
- package/dist/adapter/ember/enums.js +4 -6
- package/dist/adapter/ember/enums.js.map +1 -1
- package/dist/adapter/ember/ezsp/buffalo.d.ts +4 -4
- package/dist/adapter/ember/ezsp/buffalo.d.ts.map +1 -1
- package/dist/adapter/ember/ezsp/buffalo.js +30 -32
- package/dist/adapter/ember/ezsp/buffalo.js.map +1 -1
- package/dist/adapter/ember/ezsp/ezsp.d.ts +46 -46
- package/dist/adapter/ember/ezsp/ezsp.d.ts.map +1 -1
- package/dist/adapter/ember/ezsp/ezsp.js +85 -111
- package/dist/adapter/ember/ezsp/ezsp.js.map +1 -1
- package/dist/adapter/ember/ezspError.d.ts +1 -1
- package/dist/adapter/ember/types.d.ts +14 -14
- package/dist/adapter/ember/types.d.ts.map +1 -1
- package/dist/adapter/ember/uart/ash.d.ts +5 -5
- package/dist/adapter/ember/uart/ash.d.ts.map +1 -1
- package/dist/adapter/ember/uart/ash.js +80 -71
- package/dist/adapter/ember/uart/ash.js.map +1 -1
- package/dist/adapter/ember/uart/parser.d.ts +2 -2
- package/dist/adapter/ember/uart/parser.d.ts.map +1 -1
- package/dist/adapter/ember/uart/parser.js +2 -1
- package/dist/adapter/ember/uart/parser.js.map +1 -1
- package/dist/adapter/ember/uart/queues.js +27 -29
- package/dist/adapter/ember/uart/queues.js.map +1 -1
- package/dist/adapter/ember/uart/writer.d.ts +1 -1
- package/dist/adapter/ember/uart/writer.d.ts.map +1 -1
- package/dist/adapter/ember/uart/writer.js +3 -5
- package/dist/adapter/ember/uart/writer.js.map +1 -1
- package/dist/adapter/ember/utils/initters.d.ts +2 -2
- package/dist/adapter/ember/utils/initters.d.ts.map +1 -1
- package/dist/adapter/ember/utils/initters.js +1 -1
- package/dist/adapter/ember/utils/math.js +1 -1
- package/dist/adapter/events.d.ts +1 -1
- package/dist/adapter/events.d.ts.map +1 -1
- package/dist/adapter/ezsp/adapter/backup.d.ts +3 -3
- package/dist/adapter/ezsp/adapter/backup.d.ts.map +1 -1
- package/dist/adapter/ezsp/adapter/backup.js +8 -10
- package/dist/adapter/ezsp/adapter/backup.js.map +1 -1
- package/dist/adapter/ezsp/adapter/ezspAdapter.d.ts +12 -12
- package/dist/adapter/ezsp/adapter/ezspAdapter.d.ts.map +1 -1
- package/dist/adapter/ezsp/adapter/ezspAdapter.js +45 -44
- package/dist/adapter/ezsp/adapter/ezspAdapter.js.map +1 -1
- package/dist/adapter/ezsp/driver/driver.d.ts +12 -12
- package/dist/adapter/ezsp/driver/driver.d.ts.map +1 -1
- package/dist/adapter/ezsp/driver/driver.js +148 -141
- package/dist/adapter/ezsp/driver/driver.js.map +1 -1
- package/dist/adapter/ezsp/driver/ezsp.d.ts +7 -7
- package/dist/adapter/ezsp/driver/ezsp.d.ts.map +1 -1
- package/dist/adapter/ezsp/driver/ezsp.js +61 -59
- package/dist/adapter/ezsp/driver/ezsp.js.map +1 -1
- package/dist/adapter/ezsp/driver/frame.js +2 -2
- package/dist/adapter/ezsp/driver/index.d.ts +2 -2
- package/dist/adapter/ezsp/driver/multicast.d.ts +8 -5
- package/dist/adapter/ezsp/driver/multicast.d.ts.map +1 -1
- package/dist/adapter/ezsp/driver/multicast.js +9 -9
- package/dist/adapter/ezsp/driver/multicast.js.map +1 -1
- package/dist/adapter/ezsp/driver/parser.d.ts +1 -1
- package/dist/adapter/ezsp/driver/parser.js +3 -3
- package/dist/adapter/ezsp/driver/types/basic.d.ts +5 -5
- package/dist/adapter/ezsp/driver/types/basic.d.ts.map +1 -1
- package/dist/adapter/ezsp/driver/types/basic.js +12 -33
- package/dist/adapter/ezsp/driver/types/basic.js.map +1 -1
- package/dist/adapter/ezsp/driver/types/index.d.ts +3 -3
- package/dist/adapter/ezsp/driver/types/index.d.ts.map +1 -1
- package/dist/adapter/ezsp/driver/types/index.js +8 -9
- package/dist/adapter/ezsp/driver/types/index.js.map +1 -1
- package/dist/adapter/ezsp/driver/types/named.d.ts +2 -2
- package/dist/adapter/ezsp/driver/types/named.d.ts.map +1 -1
- package/dist/adapter/ezsp/driver/types/named.js +8 -11
- package/dist/adapter/ezsp/driver/types/named.js.map +1 -1
- package/dist/adapter/ezsp/driver/types/struct.d.ts +2 -2
- package/dist/adapter/ezsp/driver/types/struct.d.ts.map +1 -1
- package/dist/adapter/ezsp/driver/types/struct.js +207 -214
- package/dist/adapter/ezsp/driver/types/struct.js.map +1 -1
- package/dist/adapter/ezsp/driver/uart.d.ts +2 -2
- package/dist/adapter/ezsp/driver/uart.d.ts.map +1 -1
- package/dist/adapter/ezsp/driver/uart.js +48 -37
- package/dist/adapter/ezsp/driver/uart.js.map +1 -1
- package/dist/adapter/ezsp/driver/utils/crc16ccitt.d.ts +3 -3
- package/dist/adapter/ezsp/driver/utils/crc16ccitt.d.ts.map +1 -1
- package/dist/adapter/ezsp/driver/utils/crc16ccitt.js +16 -34
- package/dist/adapter/ezsp/driver/utils/crc16ccitt.js.map +1 -1
- package/dist/adapter/ezsp/driver/utils/index.d.ts +4 -4
- package/dist/adapter/ezsp/driver/utils/index.d.ts.map +1 -1
- package/dist/adapter/ezsp/driver/utils/index.js +4 -4
- package/dist/adapter/ezsp/driver/utils/index.js.map +1 -1
- package/dist/adapter/ezsp/driver/writer.d.ts +1 -1
- package/dist/adapter/ezsp/driver/writer.js +2 -2
- package/dist/adapter/index.d.ts +3 -3
- package/dist/adapter/serialPort.d.ts +3 -3
- package/dist/adapter/serialPort.d.ts.map +1 -1
- package/dist/adapter/serialPort.js +1 -0
- package/dist/adapter/serialPort.js.map +1 -1
- package/dist/adapter/socketPortUtils.js +3 -3
- package/dist/adapter/tstype.d.ts +6 -6
- package/dist/adapter/z-stack/adapter/adapter-backup.d.ts +4 -4
- package/dist/adapter/z-stack/adapter/adapter-backup.d.ts.map +1 -1
- package/dist/adapter/z-stack/adapter/adapter-backup.js +106 -119
- package/dist/adapter/z-stack/adapter/adapter-backup.js.map +1 -1
- package/dist/adapter/z-stack/adapter/adapter-nv-memory.d.ts +10 -10
- package/dist/adapter/z-stack/adapter/adapter-nv-memory.d.ts.map +1 -1
- package/dist/adapter/z-stack/adapter/adapter-nv-memory.js +23 -24
- package/dist/adapter/z-stack/adapter/adapter-nv-memory.js.map +1 -1
- package/dist/adapter/z-stack/adapter/manager.d.ts +6 -6
- package/dist/adapter/z-stack/adapter/manager.d.ts.map +1 -1
- package/dist/adapter/z-stack/adapter/manager.js +115 -127
- package/dist/adapter/z-stack/adapter/manager.js.map +1 -1
- package/dist/adapter/z-stack/adapter/tstype.d.ts +3 -3
- package/dist/adapter/z-stack/adapter/tstype.js +3 -3
- package/dist/adapter/z-stack/adapter/zStackAdapter.d.ts +10 -10
- package/dist/adapter/z-stack/adapter/zStackAdapter.d.ts.map +1 -1
- package/dist/adapter/z-stack/adapter/zStackAdapter.js +125 -137
- package/dist/adapter/z-stack/adapter/zStackAdapter.js.map +1 -1
- package/dist/adapter/z-stack/constants/common.d.ts.map +1 -1
- package/dist/adapter/z-stack/constants/common.js +0 -3
- package/dist/adapter/z-stack/constants/common.js.map +1 -1
- package/dist/adapter/z-stack/constants/index.d.ts +10 -10
- package/dist/adapter/z-stack/constants/index.d.ts.map +1 -1
- package/dist/adapter/z-stack/constants/index.js +2 -2
- package/dist/adapter/z-stack/constants/index.js.map +1 -1
- package/dist/adapter/z-stack/constants/utils.d.ts +1 -1
- package/dist/adapter/z-stack/constants/utils.js +2 -2
- package/dist/adapter/z-stack/constants/utils.js.map +1 -1
- package/dist/adapter/z-stack/models/startup-options.d.ts +2 -2
- package/dist/adapter/z-stack/models/startup-options.d.ts.map +1 -1
- package/dist/adapter/z-stack/structs/entries/address-manager-entry.d.ts +1 -1
- package/dist/adapter/z-stack/structs/entries/address-manager-entry.d.ts.map +1 -1
- package/dist/adapter/z-stack/structs/entries/address-manager-entry.js +4 -5
- package/dist/adapter/z-stack/structs/entries/address-manager-entry.js.map +1 -1
- package/dist/adapter/z-stack/structs/entries/address-manager-table.d.ts +2 -2
- package/dist/adapter/z-stack/structs/entries/address-manager-table.d.ts.map +1 -1
- package/dist/adapter/z-stack/structs/entries/address-manager-table.js +3 -4
- package/dist/adapter/z-stack/structs/entries/address-manager-table.js.map +1 -1
- package/dist/adapter/z-stack/structs/entries/aps-link-key-data-entry.d.ts +1 -1
- package/dist/adapter/z-stack/structs/entries/aps-link-key-data-entry.d.ts.map +1 -1
- package/dist/adapter/z-stack/structs/entries/aps-link-key-data-entry.js +1 -2
- package/dist/adapter/z-stack/structs/entries/aps-link-key-data-entry.js.map +1 -1
- package/dist/adapter/z-stack/structs/entries/aps-link-key-data-table.d.ts +2 -2
- package/dist/adapter/z-stack/structs/entries/aps-link-key-data-table.d.ts.map +1 -1
- package/dist/adapter/z-stack/structs/entries/aps-link-key-data-table.js +3 -4
- package/dist/adapter/z-stack/structs/entries/aps-link-key-data-table.js.map +1 -1
- package/dist/adapter/z-stack/structs/entries/aps-tc-link-key-entry.d.ts +1 -1
- package/dist/adapter/z-stack/structs/entries/aps-tc-link-key-entry.d.ts.map +1 -1
- package/dist/adapter/z-stack/structs/entries/aps-tc-link-key-entry.js +6 -7
- package/dist/adapter/z-stack/structs/entries/aps-tc-link-key-entry.js.map +1 -1
- package/dist/adapter/z-stack/structs/entries/aps-tc-link-key-table.d.ts +2 -2
- package/dist/adapter/z-stack/structs/entries/aps-tc-link-key-table.d.ts.map +1 -1
- package/dist/adapter/z-stack/structs/entries/aps-tc-link-key-table.js +3 -4
- package/dist/adapter/z-stack/structs/entries/aps-tc-link-key-table.js.map +1 -1
- package/dist/adapter/z-stack/structs/entries/channel-list.d.ts +1 -1
- package/dist/adapter/z-stack/structs/entries/channel-list.d.ts.map +1 -1
- package/dist/adapter/z-stack/structs/entries/channel-list.js +1 -2
- package/dist/adapter/z-stack/structs/entries/channel-list.js.map +1 -1
- package/dist/adapter/z-stack/structs/entries/has-configured.d.ts +1 -1
- package/dist/adapter/z-stack/structs/entries/has-configured.d.ts.map +1 -1
- package/dist/adapter/z-stack/structs/entries/has-configured.js +2 -3
- package/dist/adapter/z-stack/structs/entries/has-configured.js.map +1 -1
- package/dist/adapter/z-stack/structs/entries/index.d.ts +16 -16
- package/dist/adapter/z-stack/structs/entries/nib.d.ts +1 -1
- package/dist/adapter/z-stack/structs/entries/nib.d.ts.map +1 -1
- package/dist/adapter/z-stack/structs/entries/nib.js +49 -50
- package/dist/adapter/z-stack/structs/entries/nib.js.map +1 -1
- package/dist/adapter/z-stack/structs/entries/nwk-key-descriptor.d.ts +1 -1
- package/dist/adapter/z-stack/structs/entries/nwk-key-descriptor.d.ts.map +1 -1
- package/dist/adapter/z-stack/structs/entries/nwk-key-descriptor.js +1 -2
- package/dist/adapter/z-stack/structs/entries/nwk-key-descriptor.js.map +1 -1
- package/dist/adapter/z-stack/structs/entries/nwk-key.d.ts +1 -1
- package/dist/adapter/z-stack/structs/entries/nwk-key.d.ts.map +1 -1
- package/dist/adapter/z-stack/structs/entries/nwk-key.js +1 -2
- package/dist/adapter/z-stack/structs/entries/nwk-key.js.map +1 -1
- package/dist/adapter/z-stack/structs/entries/nwk-pan-id.d.ts +1 -1
- package/dist/adapter/z-stack/structs/entries/nwk-pan-id.d.ts.map +1 -1
- package/dist/adapter/z-stack/structs/entries/nwk-pan-id.js +1 -2
- package/dist/adapter/z-stack/structs/entries/nwk-pan-id.js.map +1 -1
- package/dist/adapter/z-stack/structs/entries/nwk-sec-material-descriptor-entry.d.ts +1 -1
- package/dist/adapter/z-stack/structs/entries/nwk-sec-material-descriptor-entry.d.ts.map +1 -1
- package/dist/adapter/z-stack/structs/entries/nwk-sec-material-descriptor-entry.js +3 -4
- package/dist/adapter/z-stack/structs/entries/nwk-sec-material-descriptor-entry.js.map +1 -1
- package/dist/adapter/z-stack/structs/entries/nwk-sec-material-descriptor-table.d.ts +2 -2
- package/dist/adapter/z-stack/structs/entries/nwk-sec-material-descriptor-table.d.ts.map +1 -1
- package/dist/adapter/z-stack/structs/entries/nwk-sec-material-descriptor-table.js +3 -4
- package/dist/adapter/z-stack/structs/entries/nwk-sec-material-descriptor-table.js.map +1 -1
- package/dist/adapter/z-stack/structs/entries/security-manager-entry.d.ts +1 -1
- package/dist/adapter/z-stack/structs/entries/security-manager-entry.d.ts.map +1 -1
- package/dist/adapter/z-stack/structs/entries/security-manager-entry.js +4 -5
- package/dist/adapter/z-stack/structs/entries/security-manager-entry.js.map +1 -1
- package/dist/adapter/z-stack/structs/entries/security-manager-table.d.ts +2 -2
- package/dist/adapter/z-stack/structs/entries/security-manager-table.d.ts.map +1 -1
- package/dist/adapter/z-stack/structs/entries/security-manager-table.js +3 -4
- package/dist/adapter/z-stack/structs/entries/security-manager-table.js.map +1 -1
- package/dist/adapter/z-stack/structs/index.d.ts +4 -4
- package/dist/adapter/z-stack/structs/serializable-memory-object.d.ts +2 -2
- package/dist/adapter/z-stack/structs/serializable-memory-object.d.ts.map +1 -1
- package/dist/adapter/z-stack/structs/struct.d.ts +8 -8
- package/dist/adapter/z-stack/structs/struct.d.ts.map +1 -1
- package/dist/adapter/z-stack/structs/struct.js +42 -43
- package/dist/adapter/z-stack/structs/struct.js.map +1 -1
- package/dist/adapter/z-stack/structs/table.d.ts +3 -3
- package/dist/adapter/z-stack/structs/table.d.ts.map +1 -1
- package/dist/adapter/z-stack/structs/table.js +10 -10
- package/dist/adapter/z-stack/structs/table.js.map +1 -1
- package/dist/adapter/z-stack/unpi/frame.d.ts +1 -1
- package/dist/adapter/z-stack/unpi/frame.d.ts.map +1 -1
- package/dist/adapter/z-stack/unpi/frame.js +2 -4
- package/dist/adapter/z-stack/unpi/frame.js.map +1 -1
- package/dist/adapter/z-stack/unpi/index.d.ts +4 -4
- package/dist/adapter/z-stack/unpi/parser.d.ts +1 -1
- package/dist/adapter/z-stack/unpi/parser.js +3 -3
- package/dist/adapter/z-stack/unpi/parser.js.map +1 -1
- package/dist/adapter/z-stack/unpi/writer.d.ts +2 -2
- package/dist/adapter/z-stack/unpi/writer.d.ts.map +1 -1
- package/dist/adapter/z-stack/unpi/writer.js +1 -1
- package/dist/adapter/z-stack/utils/index.d.ts +2 -2
- package/dist/adapter/z-stack/utils/network-options.d.ts +1 -1
- package/dist/adapter/z-stack/utils/network-options.d.ts.map +1 -1
- package/dist/adapter/z-stack/znp/buffaloZnp.d.ts +3 -3
- package/dist/adapter/z-stack/znp/buffaloZnp.d.ts.map +1 -1
- package/dist/adapter/z-stack/znp/buffaloZnp.js +34 -20
- package/dist/adapter/z-stack/znp/buffaloZnp.js.map +1 -1
- package/dist/adapter/z-stack/znp/definition.d.ts +2 -2
- package/dist/adapter/z-stack/znp/definition.d.ts.map +1 -1
- package/dist/adapter/z-stack/znp/definition.js +1111 -1111
- package/dist/adapter/z-stack/znp/index.d.ts +2 -2
- package/dist/adapter/z-stack/znp/tstype.d.ts +7 -7
- package/dist/adapter/z-stack/znp/tstype.d.ts.map +1 -1
- package/dist/adapter/z-stack/znp/utils.d.ts +1 -1
- package/dist/adapter/z-stack/znp/utils.d.ts.map +1 -1
- package/dist/adapter/z-stack/znp/utils.js +2 -2
- package/dist/adapter/z-stack/znp/znp.d.ts +7 -7
- package/dist/adapter/z-stack/znp/znp.d.ts.map +1 -1
- package/dist/adapter/z-stack/znp/znp.js +46 -45
- package/dist/adapter/z-stack/znp/znp.js.map +1 -1
- package/dist/adapter/z-stack/znp/zpiObject.d.ts +8 -8
- package/dist/adapter/z-stack/znp/zpiObject.d.ts.map +1 -1
- package/dist/adapter/z-stack/znp/zpiObject.js +6 -6
- package/dist/adapter/z-stack/znp/zpiObject.js.map +1 -1
- package/dist/adapter/zboss/adapter/zbossAdapter.d.ts +11 -11
- package/dist/adapter/zboss/adapter/zbossAdapter.d.ts.map +1 -1
- package/dist/adapter/zboss/adapter/zbossAdapter.js +37 -36
- package/dist/adapter/zboss/adapter/zbossAdapter.js.map +1 -1
- package/dist/adapter/zboss/commands.d.ts +4 -6
- package/dist/adapter/zboss/commands.d.ts.map +1 -1
- package/dist/adapter/zboss/commands.js +321 -287
- package/dist/adapter/zboss/commands.js.map +1 -1
- package/dist/adapter/zboss/driver.d.ts +9 -9
- package/dist/adapter/zboss/driver.d.ts.map +1 -1
- package/dist/adapter/zboss/driver.js +25 -25
- package/dist/adapter/zboss/driver.js.map +1 -1
- package/dist/adapter/zboss/frame.d.ts +9 -9
- package/dist/adapter/zboss/frame.d.ts.map +1 -1
- package/dist/adapter/zboss/frame.js +15 -15
- package/dist/adapter/zboss/frame.js.map +1 -1
- package/dist/adapter/zboss/reader.d.ts +2 -2
- package/dist/adapter/zboss/reader.d.ts.map +1 -1
- package/dist/adapter/zboss/reader.js +6 -5
- package/dist/adapter/zboss/reader.js.map +1 -1
- package/dist/adapter/zboss/uart.d.ts +3 -3
- package/dist/adapter/zboss/uart.d.ts.map +1 -1
- package/dist/adapter/zboss/uart.js +36 -36
- package/dist/adapter/zboss/uart.js.map +1 -1
- package/dist/adapter/zboss/writer.d.ts +1 -1
- package/dist/adapter/zboss/writer.d.ts.map +1 -1
- package/dist/adapter/zboss/writer.js +3 -5
- package/dist/adapter/zboss/writer.js.map +1 -1
- package/dist/adapter/zigate/adapter/patchZdoBuffaloBE.js +2 -2
- package/dist/adapter/zigate/adapter/patchZdoBuffaloBE.js.map +1 -1
- package/dist/adapter/zigate/adapter/zigateAdapter.d.ts +14 -14
- package/dist/adapter/zigate/adapter/zigateAdapter.d.ts.map +1 -1
- package/dist/adapter/zigate/adapter/zigateAdapter.js +52 -53
- package/dist/adapter/zigate/adapter/zigateAdapter.js.map +1 -1
- package/dist/adapter/zigate/driver/buffaloZiGate.d.ts +6 -6
- package/dist/adapter/zigate/driver/buffaloZiGate.d.ts.map +1 -1
- package/dist/adapter/zigate/driver/buffaloZiGate.js +41 -23
- package/dist/adapter/zigate/driver/buffaloZiGate.js.map +1 -1
- package/dist/adapter/zigate/driver/commandType.d.ts +2 -2
- package/dist/adapter/zigate/driver/commandType.d.ts.map +1 -1
- package/dist/adapter/zigate/driver/commandType.js +37 -37
- package/dist/adapter/zigate/driver/commandType.js.map +1 -1
- package/dist/adapter/zigate/driver/constants.d.ts +27 -200
- package/dist/adapter/zigate/driver/constants.d.ts.map +1 -1
- package/dist/adapter/zigate/driver/constants.js +40 -236
- package/dist/adapter/zigate/driver/constants.js.map +1 -1
- package/dist/adapter/zigate/driver/frame.d.ts.map +1 -1
- package/dist/adapter/zigate/driver/frame.js +4 -3
- package/dist/adapter/zigate/driver/frame.js.map +1 -1
- package/dist/adapter/zigate/driver/messageType.d.ts +1 -1
- package/dist/adapter/zigate/driver/messageType.js +76 -76
- package/dist/adapter/zigate/driver/ziGateObject.d.ts +3 -3
- package/dist/adapter/zigate/driver/ziGateObject.d.ts.map +1 -1
- package/dist/adapter/zigate/driver/ziGateObject.js +7 -6
- package/dist/adapter/zigate/driver/ziGateObject.js.map +1 -1
- package/dist/adapter/zigate/driver/zigate.d.ts +8 -8
- package/dist/adapter/zigate/driver/zigate.d.ts.map +1 -1
- package/dist/adapter/zigate/driver/zigate.js +59 -54
- package/dist/adapter/zigate/driver/zigate.js.map +1 -1
- package/dist/adapter/zoh/adapter/utils.js +1 -1
- package/dist/adapter/zoh/adapter/zohAdapter.d.ts +13 -13
- package/dist/adapter/zoh/adapter/zohAdapter.d.ts.map +1 -1
- package/dist/adapter/zoh/adapter/zohAdapter.js +101 -67
- package/dist/adapter/zoh/adapter/zohAdapter.js.map +1 -1
- package/dist/buffalo/buffalo.d.ts +2 -2
- package/dist/buffalo/buffalo.js +4 -4
- package/dist/buffalo/buffalo.js.map +1 -1
- package/dist/buffalo/index.d.ts +1 -1
- package/dist/controller/controller.d.ts +7 -7
- package/dist/controller/controller.d.ts.map +1 -1
- package/dist/controller/controller.js +94 -98
- package/dist/controller/controller.js.map +1 -1
- package/dist/controller/database.d.ts +1 -1
- package/dist/controller/database.d.ts.map +1 -1
- package/dist/controller/database.js +9 -9
- package/dist/controller/database.js.map +1 -1
- package/dist/controller/events.d.ts +6 -6
- package/dist/controller/events.d.ts.map +1 -1
- package/dist/controller/greenPower.d.ts +21 -21
- package/dist/controller/greenPower.d.ts.map +1 -1
- package/dist/controller/greenPower.js +41 -41
- package/dist/controller/greenPower.js.map +1 -1
- package/dist/controller/helpers/index.d.ts +1 -1
- package/dist/controller/helpers/request.d.ts +2 -2
- package/dist/controller/helpers/request.d.ts.map +1 -1
- package/dist/controller/helpers/request.js +31 -27
- package/dist/controller/helpers/request.js.map +1 -1
- package/dist/controller/helpers/requestQueue.d.ts +3 -3
- package/dist/controller/helpers/requestQueue.d.ts.map +1 -1
- package/dist/controller/helpers/requestQueue.js +20 -20
- package/dist/controller/helpers/requestQueue.js.map +1 -1
- package/dist/controller/helpers/zclFrameConverter.d.ts +2 -2
- package/dist/controller/helpers/zclFrameConverter.d.ts.map +1 -1
- package/dist/controller/helpers/zclFrameConverter.js +1 -1
- package/dist/controller/helpers/zclFrameConverter.js.map +1 -1
- package/dist/controller/helpers/zclTransactionSequenceNumber.d.ts +6 -4
- package/dist/controller/helpers/zclTransactionSequenceNumber.d.ts.map +1 -1
- package/dist/controller/helpers/zclTransactionSequenceNumber.js +6 -5
- package/dist/controller/helpers/zclTransactionSequenceNumber.js.map +1 -1
- package/dist/controller/index.d.ts +1 -1
- package/dist/controller/model/device.d.ts +23 -19
- package/dist/controller/model/device.d.ts.map +1 -1
- package/dist/controller/model/device.js +153 -128
- package/dist/controller/model/device.js.map +1 -1
- package/dist/controller/model/endpoint.d.ts +11 -11
- package/dist/controller/model/endpoint.d.ts.map +1 -1
- package/dist/controller/model/endpoint.js +84 -67
- package/dist/controller/model/endpoint.js.map +1 -1
- package/dist/controller/model/entity.d.ts +3 -3
- package/dist/controller/model/entity.d.ts.map +1 -1
- package/dist/controller/model/group.d.ts +4 -4
- package/dist/controller/model/group.d.ts.map +1 -1
- package/dist/controller/model/group.js +21 -9
- package/dist/controller/model/group.js.map +1 -1
- package/dist/controller/model/index.d.ts +4 -4
- package/dist/controller/touchlink.d.ts +1 -1
- package/dist/controller/touchlink.d.ts.map +1 -1
- package/dist/controller/touchlink.js +11 -11
- package/dist/controller/tstype.d.ts +3 -3
- package/dist/index.d.ts +10 -10
- package/dist/models/backup-storage-legacy.d.ts +14 -16
- package/dist/models/backup-storage-legacy.d.ts.map +1 -1
- package/dist/models/backup-storage-unified.d.ts +1 -1
- package/dist/models/backup.d.ts +2 -2
- package/dist/models/backup.d.ts.map +1 -1
- package/dist/models/index.d.ts +4 -4
- package/dist/utils/backup.d.ts +1 -1
- package/dist/utils/backup.d.ts.map +1 -1
- package/dist/utils/backup.js +26 -26
- package/dist/utils/backup.js.map +1 -1
- package/dist/utils/index.d.ts +5 -5
- package/dist/utils/logger.js +3 -3
- package/dist/utils/patchBigIntSerialization.js +1 -1
- package/dist/utils/patchBigIntSerialization.js.map +1 -1
- package/dist/utils/queue.d.ts.map +1 -1
- package/dist/utils/queue.js +1 -0
- package/dist/utils/queue.js.map +1 -1
- package/dist/utils/utils.d.ts.map +1 -1
- package/dist/utils/utils.js +5 -4
- package/dist/utils/utils.js.map +1 -1
- package/dist/utils/waitress.d.ts +1 -1
- package/dist/utils/waitress.js +3 -3
- package/dist/zspec/consts.d.ts +1 -1
- package/dist/zspec/consts.d.ts.map +1 -1
- package/dist/zspec/consts.js +1 -1
- package/dist/zspec/index.d.ts +3 -3
- package/dist/zspec/tstypes.d.ts +1 -1
- package/dist/zspec/utils.d.ts +4 -4
- package/dist/zspec/utils.d.ts.map +1 -1
- package/dist/zspec/utils.js +9 -13
- package/dist/zspec/utils.js.map +1 -1
- package/dist/zspec/zcl/buffaloZcl.d.ts +3 -3
- package/dist/zspec/zcl/buffaloZcl.d.ts.map +1 -1
- package/dist/zspec/zcl/buffaloZcl.js +127 -84
- package/dist/zspec/zcl/buffaloZcl.js.map +1 -1
- package/dist/zspec/zcl/definition/cluster.d.ts +1 -1
- package/dist/zspec/zcl/definition/cluster.d.ts.map +1 -1
- package/dist/zspec/zcl/definition/cluster.js +894 -893
- package/dist/zspec/zcl/definition/cluster.js.map +1 -1
- package/dist/zspec/zcl/definition/consts.js +7 -7
- package/dist/zspec/zcl/definition/foundation.d.ts +3 -3
- package/dist/zspec/zcl/definition/foundation.d.ts.map +1 -1
- package/dist/zspec/zcl/definition/foundation.js +88 -89
- package/dist/zspec/zcl/definition/foundation.js.map +1 -1
- package/dist/zspec/zcl/definition/manufacturerCode.d.ts +1 -1
- package/dist/zspec/zcl/definition/manufacturerCode.js +1 -1
- package/dist/zspec/zcl/definition/manufacturerCode.js.map +1 -1
- package/dist/zspec/zcl/definition/status.d.ts +3 -3
- package/dist/zspec/zcl/definition/status.js +3 -3
- package/dist/zspec/zcl/definition/tstype.d.ts +3 -3
- package/dist/zspec/zcl/definition/tstype.d.ts.map +1 -1
- package/dist/zspec/zcl/index.d.ts +10 -10
- package/dist/zspec/zcl/utils.d.ts +3 -3
- package/dist/zspec/zcl/utils.d.ts.map +1 -1
- package/dist/zspec/zcl/utils.js +18 -21
- package/dist/zspec/zcl/utils.js.map +1 -1
- package/dist/zspec/zcl/zclFrame.d.ts +7 -7
- package/dist/zspec/zcl/zclFrame.d.ts.map +1 -1
- package/dist/zspec/zcl/zclFrame.js +38 -41
- package/dist/zspec/zcl/zclFrame.js.map +1 -1
- package/dist/zspec/zcl/zclHeader.d.ts +2 -2
- package/dist/zspec/zcl/zclHeader.d.ts.map +1 -1
- package/dist/zspec/zcl/zclHeader.js +3 -3
- package/dist/zspec/zcl/zclStatusError.d.ts +1 -1
- package/dist/zspec/zdo/buffaloZdo.d.ts +7 -7
- package/dist/zspec/zdo/buffaloZdo.d.ts.map +1 -1
- package/dist/zspec/zdo/buffaloZdo.js +4 -4
- package/dist/zspec/zdo/buffaloZdo.js.map +1 -1
- package/dist/zspec/zdo/definition/status.d.ts +1 -1
- package/dist/zspec/zdo/definition/status.js +1 -1
- package/dist/zspec/zdo/definition/tstypes.d.ts +48 -48
- package/dist/zspec/zdo/definition/tstypes.d.ts.map +1 -1
- package/dist/zspec/zdo/index.d.ts +7 -7
- package/dist/zspec/zdo/utils.d.ts +2 -2
- package/dist/zspec/zdo/utils.d.ts.map +1 -1
- package/dist/zspec/zdo/utils.js +1 -1
- package/dist/zspec/zdo/utils.js.map +1 -1
- package/dist/zspec/zdo/zdoStatusError.d.ts +1 -1
- package/examples/join-and-log.js +5 -5
- package/package.json +6 -13
- package/src/adapter/adapter.ts +189 -0
- package/src/adapter/adapterDiscovery.ts +653 -0
- package/src/adapter/const.ts +12 -0
- package/src/adapter/deconz/adapter/deconzAdapter.ts +768 -0
- package/src/adapter/deconz/driver/constants.ts +180 -0
- package/src/adapter/deconz/driver/driver.ts +900 -0
- package/src/adapter/deconz/driver/frame.ts +11 -0
- package/src/adapter/deconz/driver/frameParser.ts +557 -0
- package/src/adapter/deconz/driver/parser.ts +45 -0
- package/src/adapter/deconz/driver/writer.ts +22 -0
- package/src/adapter/deconz/types.d.ts +13 -0
- package/src/adapter/ember/adapter/emberAdapter.ts +2266 -0
- package/src/adapter/ember/adapter/endpoints.ts +86 -0
- package/src/adapter/ember/adapter/oneWaitress.ts +322 -0
- package/src/adapter/ember/adapter/tokensManager.ts +782 -0
- package/src/adapter/ember/consts.ts +178 -0
- package/src/adapter/ember/enums.ts +2123 -0
- package/src/adapter/ember/ezsp/buffalo.ts +1397 -0
- package/src/adapter/ember/ezsp/consts.ts +148 -0
- package/src/adapter/ember/ezsp/enums.ts +1087 -0
- package/src/adapter/ember/ezsp/ezsp.ts +8985 -0
- package/src/adapter/ember/ezspError.ts +10 -0
- package/src/adapter/ember/types.ts +866 -0
- package/src/adapter/ember/uart/ash.ts +1969 -0
- package/src/adapter/ember/uart/consts.ts +109 -0
- package/src/adapter/ember/uart/enums.ts +192 -0
- package/src/adapter/ember/uart/parser.ts +48 -0
- package/src/adapter/ember/uart/queues.ts +247 -0
- package/src/adapter/ember/uart/writer.ts +53 -0
- package/src/adapter/ember/utils/initters.ts +58 -0
- package/src/adapter/ember/utils/math.ts +73 -0
- package/src/adapter/events.ts +21 -0
- package/src/adapter/ezsp/adapter/backup.ts +109 -0
- package/src/adapter/ezsp/adapter/ezspAdapter.ts +614 -0
- package/src/adapter/ezsp/driver/commands.ts +2497 -0
- package/src/adapter/ezsp/driver/consts.ts +11 -0
- package/src/adapter/ezsp/driver/driver.ts +1002 -0
- package/src/adapter/ezsp/driver/ezsp.ts +802 -0
- package/src/adapter/ezsp/driver/frame.ts +101 -0
- package/src/adapter/ezsp/driver/index.ts +4 -0
- package/src/adapter/ezsp/driver/multicast.ts +78 -0
- package/src/adapter/ezsp/driver/parser.ts +81 -0
- package/src/adapter/ezsp/driver/types/basic.ts +201 -0
- package/src/adapter/ezsp/driver/types/index.ts +239 -0
- package/src/adapter/ezsp/driver/types/named.ts +2330 -0
- package/src/adapter/ezsp/driver/types/struct.ts +844 -0
- package/src/adapter/ezsp/driver/uart.ts +460 -0
- package/src/adapter/ezsp/driver/utils/crc16ccitt.ts +44 -0
- package/src/adapter/ezsp/driver/utils/index.ts +32 -0
- package/src/adapter/ezsp/driver/writer.ts +64 -0
- package/src/adapter/index.ts +3 -0
- package/src/adapter/serialPort.ts +58 -0
- package/src/adapter/socketPortUtils.ts +16 -0
- package/src/adapter/tstype.ts +78 -0
- package/src/adapter/z-stack/adapter/adapter-backup.ts +519 -0
- package/src/adapter/z-stack/adapter/adapter-nv-memory.ts +457 -0
- package/src/adapter/z-stack/adapter/endpoints.ts +57 -0
- package/src/adapter/z-stack/adapter/manager.ts +543 -0
- package/src/adapter/z-stack/adapter/tstype.ts +6 -0
- package/src/adapter/z-stack/adapter/zStackAdapter.ts +1190 -0
- package/src/adapter/z-stack/constants/af.ts +27 -0
- package/src/adapter/z-stack/constants/common.ts +285 -0
- package/src/adapter/z-stack/constants/dbg.ts +23 -0
- package/src/adapter/z-stack/constants/index.ts +11 -0
- package/src/adapter/z-stack/constants/mac.ts +128 -0
- package/src/adapter/z-stack/constants/sapi.ts +25 -0
- package/src/adapter/z-stack/constants/sys.ts +72 -0
- package/src/adapter/z-stack/constants/util.ts +82 -0
- package/src/adapter/z-stack/constants/utils.ts +14 -0
- package/src/adapter/z-stack/constants/zdo.ts +103 -0
- package/src/adapter/z-stack/models/startup-options.ts +13 -0
- package/src/adapter/z-stack/structs/entries/address-manager-entry.ts +44 -0
- package/src/adapter/z-stack/structs/entries/address-manager-table.ts +19 -0
- package/src/adapter/z-stack/structs/entries/aps-link-key-data-entry.ts +12 -0
- package/src/adapter/z-stack/structs/entries/aps-link-key-data-table.ts +21 -0
- package/src/adapter/z-stack/structs/entries/aps-tc-link-key-entry.ts +19 -0
- package/src/adapter/z-stack/structs/entries/aps-tc-link-key-table.ts +21 -0
- package/src/adapter/z-stack/structs/entries/channel-list.ts +8 -0
- package/src/adapter/z-stack/structs/entries/has-configured.ts +16 -0
- package/src/adapter/z-stack/structs/entries/index.ts +16 -0
- package/src/adapter/z-stack/structs/entries/nib.ts +66 -0
- package/src/adapter/z-stack/structs/entries/nwk-key-descriptor.ts +15 -0
- package/src/adapter/z-stack/structs/entries/nwk-key.ts +13 -0
- package/src/adapter/z-stack/structs/entries/nwk-pan-id.ts +8 -0
- package/src/adapter/z-stack/structs/entries/nwk-sec-material-descriptor-entry.ts +20 -0
- package/src/adapter/z-stack/structs/entries/nwk-sec-material-descriptor-table.ts +19 -0
- package/src/adapter/z-stack/structs/entries/security-manager-entry.ts +33 -0
- package/src/adapter/z-stack/structs/entries/security-manager-table.ts +22 -0
- package/src/adapter/z-stack/structs/index.ts +4 -0
- package/src/adapter/z-stack/structs/serializable-memory-object.ts +14 -0
- package/src/adapter/z-stack/structs/struct.ts +367 -0
- package/src/adapter/z-stack/structs/table.ts +198 -0
- package/src/adapter/z-stack/unpi/constants.ts +33 -0
- package/src/adapter/z-stack/unpi/frame.ts +62 -0
- package/src/adapter/z-stack/unpi/index.ts +4 -0
- package/src/adapter/z-stack/unpi/parser.ts +56 -0
- package/src/adapter/z-stack/unpi/writer.ts +21 -0
- package/src/adapter/z-stack/utils/channel-list.ts +40 -0
- package/src/adapter/z-stack/utils/index.ts +2 -0
- package/src/adapter/z-stack/utils/network-options.ts +26 -0
- package/src/adapter/z-stack/znp/buffaloZnp.ts +175 -0
- package/src/adapter/z-stack/znp/definition.ts +2713 -0
- package/src/adapter/z-stack/znp/index.ts +2 -0
- package/src/adapter/z-stack/znp/parameterType.ts +22 -0
- package/src/adapter/z-stack/znp/tstype.ts +44 -0
- package/src/adapter/z-stack/znp/utils.ts +10 -0
- package/src/adapter/z-stack/znp/znp.ts +342 -0
- package/src/adapter/z-stack/znp/zpiObject.ts +148 -0
- package/src/adapter/zboss/adapter/zbossAdapter.ts +527 -0
- package/src/adapter/zboss/commands.ts +1184 -0
- package/src/adapter/zboss/consts.ts +9 -0
- package/src/adapter/zboss/driver.ts +423 -0
- package/src/adapter/zboss/enums.ts +360 -0
- package/src/adapter/zboss/frame.ts +227 -0
- package/src/adapter/zboss/reader.ts +65 -0
- package/src/adapter/zboss/types.ts +0 -0
- package/src/adapter/zboss/uart.ts +428 -0
- package/src/adapter/zboss/utils.ts +58 -0
- package/src/adapter/zboss/writer.ts +49 -0
- package/src/adapter/zigate/adapter/patchZdoBuffaloBE.ts +27 -0
- package/src/adapter/zigate/adapter/zigateAdapter.ts +618 -0
- package/src/adapter/zigate/driver/LICENSE +17 -0
- package/src/adapter/zigate/driver/buffaloZiGate.ts +212 -0
- package/src/adapter/zigate/driver/commandType.ts +418 -0
- package/src/adapter/zigate/driver/constants.ts +150 -0
- package/src/adapter/zigate/driver/frame.ts +197 -0
- package/src/adapter/zigate/driver/messageType.ts +287 -0
- package/src/adapter/zigate/driver/parameterType.ts +32 -0
- package/src/adapter/zigate/driver/ziGateObject.ts +146 -0
- package/src/adapter/zigate/driver/zigate.ts +426 -0
- package/src/adapter/zoh/adapter/utils.ts +27 -0
- package/src/adapter/zoh/adapter/zohAdapter.ts +837 -0
- package/src/buffalo/buffalo.ts +335 -0
- package/src/buffalo/index.ts +1 -0
- package/src/controller/controller.ts +1048 -0
- package/src/controller/database.ts +124 -0
- package/src/controller/events.ts +51 -0
- package/src/controller/greenPower.ts +603 -0
- package/src/controller/helpers/index.ts +1 -0
- package/src/controller/helpers/request.ts +94 -0
- package/src/controller/helpers/requestQueue.ts +125 -0
- package/src/controller/helpers/zclFrameConverter.ts +51 -0
- package/src/controller/helpers/zclTransactionSequenceNumber.ts +19 -0
- package/src/controller/index.ts +6 -0
- package/src/controller/model/device.ts +1320 -0
- package/src/controller/model/endpoint.ts +1040 -0
- package/src/controller/model/entity.ts +23 -0
- package/src/controller/model/group.ts +333 -0
- package/src/controller/model/index.ts +4 -0
- package/src/controller/touchlink.ts +189 -0
- package/src/controller/tstype.ts +39 -0
- package/src/index.ts +12 -0
- package/src/models/backup-storage-legacy.ts +48 -0
- package/src/models/backup-storage-unified.ts +47 -0
- package/src/models/backup.ts +37 -0
- package/src/models/index.ts +5 -0
- package/src/models/network-options.ts +11 -0
- package/src/utils/backup.ts +152 -0
- package/src/utils/index.ts +5 -0
- package/src/utils/logger.ts +20 -0
- package/src/utils/patchBigIntSerialization.ts +8 -0
- package/src/utils/queue.ts +76 -0
- package/src/utils/types.d.ts +3 -0
- package/src/utils/utils.ts +20 -0
- package/src/utils/wait.ts +5 -0
- package/src/utils/waitress.ts +95 -0
- package/src/zspec/consts.ts +84 -0
- package/src/zspec/enums.ts +22 -0
- package/src/zspec/index.ts +3 -0
- package/src/zspec/tstypes.ts +18 -0
- package/src/zspec/utils.ts +308 -0
- package/src/zspec/zcl/buffaloZcl.ts +1133 -0
- package/src/zspec/zcl/definition/cluster.ts +5398 -0
- package/src/zspec/zcl/definition/consts.ts +24 -0
- package/src/zspec/zcl/definition/enums.ts +194 -0
- package/src/zspec/zcl/definition/foundation.ts +301 -0
- package/src/zspec/zcl/definition/manufacturerCode.ts +729 -0
- package/src/zspec/zcl/definition/status.ts +69 -0
- package/src/zspec/zcl/definition/tstype.ts +236 -0
- package/src/zspec/zcl/index.ts +10 -0
- package/src/zspec/zcl/utils.ts +342 -0
- package/src/zspec/zcl/zclFrame.ts +336 -0
- package/src/zspec/zcl/zclHeader.ts +102 -0
- package/src/zspec/zcl/zclStatusError.ts +10 -0
- package/src/zspec/zdo/buffaloZdo.ts +2345 -0
- package/src/zspec/zdo/definition/clusters.ts +722 -0
- package/src/zspec/zdo/definition/consts.ts +16 -0
- package/src/zspec/zdo/definition/enums.ts +99 -0
- package/src/zspec/zdo/definition/status.ts +105 -0
- package/src/zspec/zdo/definition/tstypes.ts +1062 -0
- package/src/zspec/zdo/index.ts +7 -0
- package/src/zspec/zdo/utils.ts +76 -0
- package/src/zspec/zdo/zdoStatusError.ts +10 -0
- package/test/adapter/adapter.test.ts +1062 -0
- package/test/adapter/ember/ash.test.ts +337 -0
- package/test/adapter/ember/consts.ts +131 -0
- package/test/adapter/ember/emberAdapter.test.ts +3449 -0
- package/test/adapter/ember/ezsp.test.ts +386 -0
- package/test/adapter/ember/ezspBuffalo.test.ts +92 -0
- package/test/adapter/ember/ezspError.test.ts +11 -0
- package/test/adapter/ember/math.test.ts +205 -0
- package/test/adapter/ezsp/frame.test.ts +29 -0
- package/test/adapter/ezsp/uart.test.ts +180 -0
- package/test/adapter/z-stack/adapter.test.ts +3985 -0
- package/test/adapter/z-stack/constants.test.ts +32 -0
- package/test/adapter/z-stack/structs.test.ts +114 -0
- package/test/adapter/z-stack/unpi.test.ts +212 -0
- package/test/adapter/z-stack/znp.test.ts +1284 -0
- package/test/adapter/zboss/fixZdoResponse.test.ts +178 -0
- package/test/adapter/zigate/patchZdoBuffaloBE.test.ts +80 -0
- package/test/adapter/zigate/zdo.test.ts +187 -0
- package/test/adapter/zoh/utils.test.ts +35 -0
- package/test/adapter/zoh/zohAdapter.test.ts +1306 -0
- package/test/buffalo.test.ts +430 -0
- package/test/controller.test.ts +10005 -0
- package/test/greenpower.test.ts +1421 -0
- package/test/mockAdapters.ts +65 -0
- package/test/mockDevices.ts +472 -0
- package/test/testUtils.ts +20 -0
- package/test/tsconfig.json +10 -0
- package/test/utils/math.ts +19 -0
- package/test/utils.test.ts +227 -0
- package/test/vitest.config.mts +25 -0
- package/test/zcl.test.ts +2832 -0
- package/test/zspec/utils.test.ts +131 -0
- package/test/zspec/zcl/buffalo.test.ts +1231 -0
- package/test/zspec/zcl/frame.test.ts +925 -0
- package/test/zspec/zcl/utils.test.ts +280 -0
- package/test/zspec/zdo/buffalo.test.ts +1849 -0
- package/test/zspec/zdo/utils.test.ts +240 -0
- package/.prettierignore +0 -2
- package/.prettierrc +0 -26
- package/eslint.config.mjs +0 -32
|
@@ -0,0 +1,1040 @@
|
|
|
1
|
+
import assert from "node:assert";
|
|
2
|
+
|
|
3
|
+
import type {Events as AdapterEvents} from "../../adapter";
|
|
4
|
+
import {logger} from "../../utils/logger";
|
|
5
|
+
import * as ZSpec from "../../zspec";
|
|
6
|
+
import {BroadcastAddress} from "../../zspec/enums";
|
|
7
|
+
import type {Eui64} from "../../zspec/tstypes";
|
|
8
|
+
import * as Zcl from "../../zspec/zcl";
|
|
9
|
+
import type * as ZclTypes from "../../zspec/zcl/definition/tstype";
|
|
10
|
+
import * as Zdo from "../../zspec/zdo";
|
|
11
|
+
import Request from "../helpers/request";
|
|
12
|
+
import RequestQueue from "../helpers/requestQueue";
|
|
13
|
+
import * as ZclFrameConverter from "../helpers/zclFrameConverter";
|
|
14
|
+
import zclTransactionSequenceNumber from "../helpers/zclTransactionSequenceNumber";
|
|
15
|
+
import type {KeyValue, SendPolicy} from "../tstype";
|
|
16
|
+
import Device from "./device";
|
|
17
|
+
import Entity from "./entity";
|
|
18
|
+
import Group from "./group";
|
|
19
|
+
|
|
20
|
+
const NS = "zh:controller:endpoint";
|
|
21
|
+
|
|
22
|
+
export interface ConfigureReportingItem {
|
|
23
|
+
attribute: string | number | {ID: number; type: number};
|
|
24
|
+
minimumReportInterval: number;
|
|
25
|
+
maximumReportInterval: number;
|
|
26
|
+
reportableChange: number;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
interface Options {
|
|
30
|
+
manufacturerCode?: number;
|
|
31
|
+
disableDefaultResponse?: boolean;
|
|
32
|
+
disableResponse?: boolean;
|
|
33
|
+
timeout?: number;
|
|
34
|
+
direction?: Zcl.Direction;
|
|
35
|
+
srcEndpoint?: number;
|
|
36
|
+
reservedBits?: number;
|
|
37
|
+
transactionSequenceNumber?: number;
|
|
38
|
+
disableRecovery?: boolean;
|
|
39
|
+
writeUndiv?: boolean;
|
|
40
|
+
sendPolicy?: SendPolicy;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
interface OptionsWithDefaults extends Options {
|
|
44
|
+
disableDefaultResponse: boolean;
|
|
45
|
+
disableResponse: boolean;
|
|
46
|
+
timeout: number;
|
|
47
|
+
direction: Zcl.Direction;
|
|
48
|
+
reservedBits: number;
|
|
49
|
+
disableRecovery: boolean;
|
|
50
|
+
writeUndiv: boolean;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
interface Clusters {
|
|
54
|
+
[cluster: string]: {
|
|
55
|
+
attributes: {[attribute: string]: number | string};
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
interface BindInternal {
|
|
60
|
+
cluster: number;
|
|
61
|
+
type: "endpoint" | "group";
|
|
62
|
+
deviceIeeeAddress?: string;
|
|
63
|
+
endpointID?: number;
|
|
64
|
+
groupID?: number;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
interface Bind {
|
|
68
|
+
cluster: ZclTypes.Cluster;
|
|
69
|
+
target: Endpoint | Group;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
interface ConfiguredReportingInternal {
|
|
73
|
+
cluster: number;
|
|
74
|
+
attrId: number;
|
|
75
|
+
minRepIntval: number;
|
|
76
|
+
maxRepIntval: number;
|
|
77
|
+
repChange: number;
|
|
78
|
+
manufacturerCode?: number | undefined;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
interface ConfiguredReporting {
|
|
82
|
+
cluster: ZclTypes.Cluster;
|
|
83
|
+
attribute: ZclTypes.Attribute;
|
|
84
|
+
minimumReportInterval: number;
|
|
85
|
+
maximumReportInterval: number;
|
|
86
|
+
reportableChange: number;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
export class Endpoint extends Entity {
|
|
90
|
+
public deviceID?: number;
|
|
91
|
+
public inputClusters: number[];
|
|
92
|
+
public outputClusters: number[];
|
|
93
|
+
public profileID?: number;
|
|
94
|
+
// biome-ignore lint/style/useNamingConvention: cross-repo impact
|
|
95
|
+
public readonly ID: number;
|
|
96
|
+
public readonly clusters: Clusters;
|
|
97
|
+
public deviceIeeeAddress: string;
|
|
98
|
+
public deviceNetworkAddress: number;
|
|
99
|
+
private _binds: BindInternal[];
|
|
100
|
+
private _configuredReportings: ConfiguredReportingInternal[];
|
|
101
|
+
public meta: KeyValue;
|
|
102
|
+
private pendingRequests: RequestQueue;
|
|
103
|
+
|
|
104
|
+
// Getters/setters
|
|
105
|
+
get binds(): Bind[] {
|
|
106
|
+
const binds: Bind[] = [];
|
|
107
|
+
|
|
108
|
+
for (const bind of this._binds) {
|
|
109
|
+
// XXX: properties assumed valid when associated to `type`
|
|
110
|
+
const target: Group | Endpoint | undefined =
|
|
111
|
+
// biome-ignore lint/style/noNonNullAssertion: ignored using `--suppress`
|
|
112
|
+
bind.type === "endpoint" ? Device.byIeeeAddr(bind.deviceIeeeAddress!)?.getEndpoint(bind.endpointID!) : Group.byGroupID(bind.groupID!);
|
|
113
|
+
|
|
114
|
+
if (target) {
|
|
115
|
+
binds.push({target, cluster: this.getCluster(bind.cluster)});
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
return binds;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
get configuredReportings(): ConfiguredReporting[] {
|
|
123
|
+
const device = this.getDevice();
|
|
124
|
+
|
|
125
|
+
return this._configuredReportings.map((entry, index) => {
|
|
126
|
+
const cluster = Zcl.Utils.getCluster(entry.cluster, entry.manufacturerCode, device.customClusters);
|
|
127
|
+
const attribute: ZclTypes.Attribute = cluster.hasAttribute(entry.attrId)
|
|
128
|
+
? cluster.getAttribute(entry.attrId)
|
|
129
|
+
: {ID: entry.attrId, name: `attr${index}`, type: Zcl.DataType.UNKNOWN, manufacturerCode: undefined};
|
|
130
|
+
|
|
131
|
+
return {
|
|
132
|
+
cluster,
|
|
133
|
+
attribute,
|
|
134
|
+
minimumReportInterval: entry.minRepIntval,
|
|
135
|
+
maximumReportInterval: entry.maxRepIntval,
|
|
136
|
+
reportableChange: entry.repChange,
|
|
137
|
+
};
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
private constructor(
|
|
142
|
+
id: number,
|
|
143
|
+
profileID: number | undefined,
|
|
144
|
+
deviceID: number | undefined,
|
|
145
|
+
inputClusters: number[],
|
|
146
|
+
outputClusters: number[],
|
|
147
|
+
deviceNetworkAddress: number,
|
|
148
|
+
deviceIeeeAddress: string,
|
|
149
|
+
clusters: Clusters,
|
|
150
|
+
binds: BindInternal[],
|
|
151
|
+
configuredReportings: ConfiguredReportingInternal[],
|
|
152
|
+
meta: KeyValue,
|
|
153
|
+
) {
|
|
154
|
+
super();
|
|
155
|
+
this.ID = id;
|
|
156
|
+
this.profileID = profileID;
|
|
157
|
+
this.deviceID = deviceID;
|
|
158
|
+
this.inputClusters = inputClusters;
|
|
159
|
+
this.outputClusters = outputClusters;
|
|
160
|
+
this.deviceNetworkAddress = deviceNetworkAddress;
|
|
161
|
+
this.deviceIeeeAddress = deviceIeeeAddress;
|
|
162
|
+
this.clusters = clusters;
|
|
163
|
+
this._binds = binds;
|
|
164
|
+
this._configuredReportings = configuredReportings;
|
|
165
|
+
this.meta = meta;
|
|
166
|
+
this.pendingRequests = new RequestQueue(this);
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
/**
|
|
170
|
+
* Get device of this endpoint
|
|
171
|
+
*/
|
|
172
|
+
public getDevice(): Device {
|
|
173
|
+
const device = Device.byIeeeAddr(this.deviceIeeeAddress);
|
|
174
|
+
|
|
175
|
+
if (!device) {
|
|
176
|
+
logger.error(`Tried to get unknown/deleted device ${this.deviceIeeeAddress} from endpoint ${this.ID}.`, NS);
|
|
177
|
+
// biome-ignore lint/style/noNonNullAssertion: ignored using `--suppress`
|
|
178
|
+
logger.debug(new Error().stack!, NS);
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
// biome-ignore lint/style/noNonNullAssertion: ignored using `--suppress`
|
|
182
|
+
return device!;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
/**
|
|
186
|
+
* @param {number|string} clusterKey
|
|
187
|
+
* @returns {boolean}
|
|
188
|
+
*/
|
|
189
|
+
public supportsInputCluster(clusterKey: number | string): boolean {
|
|
190
|
+
const cluster = this.getCluster(clusterKey);
|
|
191
|
+
return this.inputClusters.includes(cluster.ID);
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
/**
|
|
195
|
+
* @param {number|string} clusterKey
|
|
196
|
+
* @returns {boolean}
|
|
197
|
+
*/
|
|
198
|
+
public supportsOutputCluster(clusterKey: number | string): boolean {
|
|
199
|
+
const cluster = this.getCluster(clusterKey);
|
|
200
|
+
return this.outputClusters.includes(cluster.ID);
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
/**
|
|
204
|
+
* @returns {ZclTypes.Cluster[]}
|
|
205
|
+
*/
|
|
206
|
+
public getInputClusters(): ZclTypes.Cluster[] {
|
|
207
|
+
return this.clusterNumbersToClusters(this.inputClusters);
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
/**
|
|
211
|
+
* @returns {ZclTypes.Cluster[]}
|
|
212
|
+
*/
|
|
213
|
+
public getOutputClusters(): ZclTypes.Cluster[] {
|
|
214
|
+
return this.clusterNumbersToClusters(this.outputClusters);
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
private clusterNumbersToClusters(clusterNumbers: number[]): ZclTypes.Cluster[] {
|
|
218
|
+
return clusterNumbers.map((c) => this.getCluster(c));
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
/*
|
|
222
|
+
* CRUD
|
|
223
|
+
*/
|
|
224
|
+
|
|
225
|
+
public static fromDatabaseRecord(record: KeyValue, deviceNetworkAddress: number, deviceIeeeAddress: string): Endpoint {
|
|
226
|
+
// Migrate attrs to attributes
|
|
227
|
+
for (const entryKey in record.clusters) {
|
|
228
|
+
const entry = record.clusters[entryKey];
|
|
229
|
+
|
|
230
|
+
if (entry.attrs != null) {
|
|
231
|
+
entry.attributes = entry.attrs;
|
|
232
|
+
delete entry.attrs;
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
return new Endpoint(
|
|
237
|
+
record.epId,
|
|
238
|
+
record.profId,
|
|
239
|
+
record.devId,
|
|
240
|
+
record.inClusterList,
|
|
241
|
+
record.outClusterList,
|
|
242
|
+
deviceNetworkAddress,
|
|
243
|
+
deviceIeeeAddress,
|
|
244
|
+
record.clusters,
|
|
245
|
+
record.binds || [],
|
|
246
|
+
record.configuredReportings || [],
|
|
247
|
+
record.meta || {},
|
|
248
|
+
);
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
public toDatabaseRecord(): KeyValue {
|
|
252
|
+
return {
|
|
253
|
+
profId: this.profileID,
|
|
254
|
+
epId: this.ID,
|
|
255
|
+
devId: this.deviceID,
|
|
256
|
+
inClusterList: this.inputClusters,
|
|
257
|
+
outClusterList: this.outputClusters,
|
|
258
|
+
clusters: this.clusters,
|
|
259
|
+
binds: this._binds,
|
|
260
|
+
configuredReportings: this._configuredReportings,
|
|
261
|
+
meta: this.meta,
|
|
262
|
+
};
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
public static create(
|
|
266
|
+
id: number,
|
|
267
|
+
profileID: number | undefined,
|
|
268
|
+
deviceID: number | undefined,
|
|
269
|
+
inputClusters: number[],
|
|
270
|
+
outputClusters: number[],
|
|
271
|
+
deviceNetworkAddress: number,
|
|
272
|
+
deviceIeeeAddress: string,
|
|
273
|
+
): Endpoint {
|
|
274
|
+
return new Endpoint(id, profileID, deviceID, inputClusters, outputClusters, deviceNetworkAddress, deviceIeeeAddress, {}, [], [], {});
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
public saveClusterAttributeKeyValue(clusterKey: number | string, list: KeyValue): void {
|
|
278
|
+
const cluster = this.getCluster(clusterKey);
|
|
279
|
+
if (!this.clusters[cluster.name]) this.clusters[cluster.name] = {attributes: {}};
|
|
280
|
+
|
|
281
|
+
for (const [attribute, value] of Object.entries(list)) {
|
|
282
|
+
this.clusters[cluster.name].attributes[attribute] = value;
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
public getClusterAttributeValue(clusterKey: number | string, attributeKey: number | string): number | string | undefined {
|
|
287
|
+
const cluster = this.getCluster(clusterKey);
|
|
288
|
+
const attribute = cluster.getAttribute(attributeKey);
|
|
289
|
+
|
|
290
|
+
if (this.clusters[cluster.name] && this.clusters[cluster.name].attributes) {
|
|
291
|
+
return this.clusters[cluster.name].attributes[attribute.name];
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
return undefined;
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
public hasPendingRequests(): boolean {
|
|
298
|
+
return this.pendingRequests.size > 0;
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
public async sendPendingRequests(fastPolling: boolean): Promise<void> {
|
|
302
|
+
return await this.pendingRequests.send(fastPolling);
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
private async sendRequest(frame: Zcl.Frame, options: OptionsWithDefaults): Promise<AdapterEvents.ZclPayload>;
|
|
306
|
+
private async sendRequest<Type>(frame: Zcl.Frame, options: OptionsWithDefaults, func: (frame: Zcl.Frame) => Promise<Type>): Promise<Type>;
|
|
307
|
+
private async sendRequest<Type>(
|
|
308
|
+
frame: Zcl.Frame,
|
|
309
|
+
options: OptionsWithDefaults,
|
|
310
|
+
func: (d: Zcl.Frame) => Promise<Type> = (d: Zcl.Frame): Promise<Type> => {
|
|
311
|
+
// biome-ignore lint/style/noNonNullAssertion: ignored using `--suppress`
|
|
312
|
+
return Entity.adapter!.sendZclFrameToEndpoint(
|
|
313
|
+
this.deviceIeeeAddress,
|
|
314
|
+
this.deviceNetworkAddress,
|
|
315
|
+
this.ID,
|
|
316
|
+
d,
|
|
317
|
+
options.timeout,
|
|
318
|
+
options.disableResponse,
|
|
319
|
+
options.disableRecovery,
|
|
320
|
+
options.srcEndpoint,
|
|
321
|
+
) as Promise<Type>;
|
|
322
|
+
},
|
|
323
|
+
): Promise<Type> {
|
|
324
|
+
const logPrefix = `Request Queue (${this.deviceIeeeAddress}/${this.ID}): `;
|
|
325
|
+
const device = this.getDevice();
|
|
326
|
+
const request = new Request(func, frame, device.pendingRequestTimeout, options.sendPolicy);
|
|
327
|
+
|
|
328
|
+
if (request.sendPolicy !== "bulk") {
|
|
329
|
+
// Check if such a request is already in the queue and remove the old one(s) if necessary
|
|
330
|
+
this.pendingRequests.filter(request);
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
// send without queueing if sendPolicy is 'immediate' or if the device has no timeout set
|
|
334
|
+
if (request.sendPolicy === "immediate" || !device.pendingRequestTimeout) {
|
|
335
|
+
if (device.pendingRequestTimeout > 0) {
|
|
336
|
+
logger.debug(`${logPrefix}send ${frame.command.name} request immediately (sendPolicy=${options.sendPolicy})`, NS);
|
|
337
|
+
}
|
|
338
|
+
return await request.send();
|
|
339
|
+
}
|
|
340
|
+
// If this is a bulk message, we queue directly.
|
|
341
|
+
if (request.sendPolicy === "bulk") {
|
|
342
|
+
logger.debug(`${logPrefix}queue request (${this.pendingRequests.size})`, NS);
|
|
343
|
+
return await this.pendingRequests.queue(request);
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
try {
|
|
347
|
+
logger.debug(`${logPrefix}send request`, NS);
|
|
348
|
+
return await request.send();
|
|
349
|
+
} catch (error) {
|
|
350
|
+
// If we got a failed transaction, the device is likely sleeping.
|
|
351
|
+
// Queue for transmission later.
|
|
352
|
+
logger.debug(`${logPrefix}queue request (transaction failed) (${error})`, NS);
|
|
353
|
+
return await this.pendingRequests.queue(request);
|
|
354
|
+
}
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
/*
|
|
358
|
+
* Zigbee functions
|
|
359
|
+
*/
|
|
360
|
+
private checkStatus(payload: [{status: Zcl.Status}] | {cmdId: number; statusCode: number}): void {
|
|
361
|
+
const codes = Array.isArray(payload) ? payload.map((i) => i.status) : [payload.statusCode];
|
|
362
|
+
const invalid = codes.find((c) => c !== Zcl.Status.SUCCESS);
|
|
363
|
+
if (invalid) throw new Zcl.StatusError(invalid);
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
public async report(clusterKey: number | string, attributes: KeyValue, options?: Options): Promise<void> {
|
|
367
|
+
const cluster = this.getCluster(clusterKey);
|
|
368
|
+
const payload: {attrId: number; dataType: number; attrData: number | string | boolean}[] = [];
|
|
369
|
+
|
|
370
|
+
for (const [nameOrID, value] of Object.entries(attributes)) {
|
|
371
|
+
if (cluster.hasAttribute(nameOrID)) {
|
|
372
|
+
const attribute = cluster.getAttribute(nameOrID);
|
|
373
|
+
payload.push({attrId: attribute.ID, attrData: value, dataType: attribute.type});
|
|
374
|
+
} else if (!Number.isNaN(Number(nameOrID))) {
|
|
375
|
+
payload.push({attrId: Number(nameOrID), attrData: value.value, dataType: value.type});
|
|
376
|
+
} else {
|
|
377
|
+
throw new Error(`Unknown attribute '${nameOrID}', specify either an existing attribute or a number`);
|
|
378
|
+
}
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
await this.zclCommand(clusterKey, "report", payload, options, attributes);
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
public async write(clusterKey: number | string, attributes: KeyValue, options?: Options): Promise<void> {
|
|
385
|
+
const cluster = this.getCluster(clusterKey);
|
|
386
|
+
const optionsWithDefaults = this.getOptionsWithDefaults(options, true, Zcl.Direction.CLIENT_TO_SERVER, cluster.manufacturerCode);
|
|
387
|
+
optionsWithDefaults.manufacturerCode = this.ensureManufacturerCodeIsUniqueAndGet(
|
|
388
|
+
cluster,
|
|
389
|
+
Object.keys(attributes),
|
|
390
|
+
optionsWithDefaults.manufacturerCode,
|
|
391
|
+
"write",
|
|
392
|
+
);
|
|
393
|
+
|
|
394
|
+
const payload: {attrId: number; dataType: number; attrData: number | string | boolean}[] = [];
|
|
395
|
+
for (const [nameOrID, value] of Object.entries(attributes)) {
|
|
396
|
+
if (cluster.hasAttribute(nameOrID)) {
|
|
397
|
+
const attribute = cluster.getAttribute(nameOrID);
|
|
398
|
+
payload.push({attrId: attribute.ID, attrData: value, dataType: attribute.type});
|
|
399
|
+
} else if (!Number.isNaN(Number(nameOrID))) {
|
|
400
|
+
payload.push({attrId: Number(nameOrID), attrData: value.value, dataType: value.type});
|
|
401
|
+
} else {
|
|
402
|
+
throw new Error(`Unknown attribute '${nameOrID}', specify either an existing attribute or a number`);
|
|
403
|
+
}
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
await this.zclCommand(clusterKey, optionsWithDefaults.writeUndiv ? "writeUndiv" : "write", payload, optionsWithDefaults, attributes, true);
|
|
407
|
+
}
|
|
408
|
+
|
|
409
|
+
public async writeResponse(
|
|
410
|
+
clusterKey: number | string,
|
|
411
|
+
transactionSequenceNumber: number,
|
|
412
|
+
attributes: KeyValue,
|
|
413
|
+
options?: Options,
|
|
414
|
+
): Promise<void> {
|
|
415
|
+
assert(options?.transactionSequenceNumber === undefined, "Use parameter");
|
|
416
|
+
const cluster = this.getCluster(clusterKey);
|
|
417
|
+
const payload: {status: number; attrId: number}[] = [];
|
|
418
|
+
|
|
419
|
+
for (const [nameOrID, value] of Object.entries(attributes)) {
|
|
420
|
+
if (value.status !== undefined) {
|
|
421
|
+
if (cluster.hasAttribute(nameOrID)) {
|
|
422
|
+
const attribute = cluster.getAttribute(nameOrID);
|
|
423
|
+
payload.push({attrId: attribute.ID, status: value.status});
|
|
424
|
+
} else if (!Number.isNaN(Number(nameOrID))) {
|
|
425
|
+
payload.push({attrId: Number(nameOrID), status: value.status});
|
|
426
|
+
} else {
|
|
427
|
+
throw new Error(`Unknown attribute '${nameOrID}', specify either an existing attribute or a number`);
|
|
428
|
+
}
|
|
429
|
+
} else {
|
|
430
|
+
throw new Error(`Missing attribute 'status'`);
|
|
431
|
+
}
|
|
432
|
+
}
|
|
433
|
+
|
|
434
|
+
await this.zclCommand(
|
|
435
|
+
clusterKey,
|
|
436
|
+
"writeRsp",
|
|
437
|
+
payload,
|
|
438
|
+
{direction: Zcl.Direction.SERVER_TO_CLIENT, ...options, transactionSequenceNumber},
|
|
439
|
+
attributes,
|
|
440
|
+
);
|
|
441
|
+
}
|
|
442
|
+
|
|
443
|
+
public async read(clusterKey: number | string, attributes: (string | number)[], options?: Options): Promise<KeyValue> {
|
|
444
|
+
const device = this.getDevice();
|
|
445
|
+
const cluster = this.getCluster(clusterKey, device);
|
|
446
|
+
const optionsWithDefaults = this.getOptionsWithDefaults(options, true, Zcl.Direction.CLIENT_TO_SERVER, cluster.manufacturerCode);
|
|
447
|
+
optionsWithDefaults.manufacturerCode = this.ensureManufacturerCodeIsUniqueAndGet(
|
|
448
|
+
cluster,
|
|
449
|
+
attributes,
|
|
450
|
+
optionsWithDefaults.manufacturerCode,
|
|
451
|
+
"read",
|
|
452
|
+
);
|
|
453
|
+
|
|
454
|
+
const payload: {attrId: number}[] = [];
|
|
455
|
+
for (const attribute of attributes) {
|
|
456
|
+
payload.push({attrId: typeof attribute === "number" ? attribute : cluster.getAttribute(attribute).ID});
|
|
457
|
+
}
|
|
458
|
+
|
|
459
|
+
const resultFrame = await this.zclCommand(clusterKey, "read", payload, optionsWithDefaults, attributes, true);
|
|
460
|
+
|
|
461
|
+
if (resultFrame) {
|
|
462
|
+
return ZclFrameConverter.attributeKeyValue(resultFrame, device.manufacturerID, device.customClusters);
|
|
463
|
+
}
|
|
464
|
+
|
|
465
|
+
return {};
|
|
466
|
+
}
|
|
467
|
+
|
|
468
|
+
public async readResponse(
|
|
469
|
+
clusterKey: number | string,
|
|
470
|
+
transactionSequenceNumber: number,
|
|
471
|
+
attributes: KeyValue,
|
|
472
|
+
options?: Options,
|
|
473
|
+
): Promise<void> {
|
|
474
|
+
assert(options?.transactionSequenceNumber === undefined, "Use parameter");
|
|
475
|
+
|
|
476
|
+
const cluster = this.getCluster(clusterKey);
|
|
477
|
+
const payload: {attrId: number; status: number; dataType: number; attrData: number | string}[] = [];
|
|
478
|
+
for (const [nameOrID, value] of Object.entries(attributes)) {
|
|
479
|
+
if (cluster.hasAttribute(nameOrID)) {
|
|
480
|
+
const attribute = cluster.getAttribute(nameOrID);
|
|
481
|
+
payload.push({attrId: attribute.ID, attrData: value, dataType: attribute.type, status: 0});
|
|
482
|
+
} else if (!Number.isNaN(Number(nameOrID))) {
|
|
483
|
+
payload.push({attrId: Number(nameOrID), attrData: value.value, dataType: value.type, status: 0});
|
|
484
|
+
} else {
|
|
485
|
+
throw new Error(`Unknown attribute '${nameOrID}', specify either an existing attribute or a number`);
|
|
486
|
+
}
|
|
487
|
+
}
|
|
488
|
+
|
|
489
|
+
await this.zclCommand(
|
|
490
|
+
clusterKey,
|
|
491
|
+
"readRsp",
|
|
492
|
+
payload,
|
|
493
|
+
{direction: Zcl.Direction.SERVER_TO_CLIENT, ...options, transactionSequenceNumber},
|
|
494
|
+
attributes,
|
|
495
|
+
);
|
|
496
|
+
}
|
|
497
|
+
|
|
498
|
+
public async updateSimpleDescriptor(): Promise<void> {
|
|
499
|
+
const clusterId = Zdo.ClusterId.SIMPLE_DESCRIPTOR_REQUEST;
|
|
500
|
+
// biome-ignore lint/style/noNonNullAssertion: ignored using `--suppress`
|
|
501
|
+
const zdoPayload = Zdo.Buffalo.buildRequest(Entity.adapter!.hasZdoMessageOverhead, clusterId, this.deviceNetworkAddress, this.ID);
|
|
502
|
+
// biome-ignore lint/style/noNonNullAssertion: ignored using `--suppress`
|
|
503
|
+
const response = await Entity.adapter!.sendZdo(this.deviceIeeeAddress, this.deviceNetworkAddress, clusterId, zdoPayload, false);
|
|
504
|
+
|
|
505
|
+
if (!Zdo.Buffalo.checkStatus<Zdo.ClusterId.SIMPLE_DESCRIPTOR_RESPONSE>(response)) {
|
|
506
|
+
throw new Zdo.StatusError(response[0]);
|
|
507
|
+
}
|
|
508
|
+
|
|
509
|
+
const simpleDescriptor = response[1];
|
|
510
|
+
|
|
511
|
+
this.profileID = simpleDescriptor.profileId;
|
|
512
|
+
this.deviceID = simpleDescriptor.deviceId;
|
|
513
|
+
this.inputClusters = simpleDescriptor.inClusterList;
|
|
514
|
+
this.outputClusters = simpleDescriptor.outClusterList;
|
|
515
|
+
}
|
|
516
|
+
|
|
517
|
+
public hasBind(clusterId: number, target: Endpoint | Group): boolean {
|
|
518
|
+
return this.getBindIndex(clusterId, target) !== -1;
|
|
519
|
+
}
|
|
520
|
+
|
|
521
|
+
public getBindIndex(clusterId: number, target: Endpoint | Group): number {
|
|
522
|
+
return this.binds.findIndex((b) => b.cluster.ID === clusterId && b.target === target);
|
|
523
|
+
}
|
|
524
|
+
|
|
525
|
+
public addBinding(clusterKey: number | string, target: Endpoint | Group | number): void {
|
|
526
|
+
const cluster = this.getCluster(clusterKey);
|
|
527
|
+
|
|
528
|
+
if (typeof target === "number") {
|
|
529
|
+
target = Group.byGroupID(target) || Group.create(target);
|
|
530
|
+
}
|
|
531
|
+
|
|
532
|
+
this.addBindingInternal(cluster, target);
|
|
533
|
+
}
|
|
534
|
+
|
|
535
|
+
private addBindingInternal(cluster: ZclTypes.Cluster, target: Endpoint | Group): void {
|
|
536
|
+
if (!this.hasBind(cluster.ID, target)) {
|
|
537
|
+
if (target instanceof Group) {
|
|
538
|
+
this._binds.push({cluster: cluster.ID, groupID: target.groupID, type: "group"});
|
|
539
|
+
} else {
|
|
540
|
+
this._binds.push({
|
|
541
|
+
cluster: cluster.ID,
|
|
542
|
+
type: "endpoint",
|
|
543
|
+
deviceIeeeAddress: target.deviceIeeeAddress,
|
|
544
|
+
endpointID: target.ID,
|
|
545
|
+
});
|
|
546
|
+
}
|
|
547
|
+
|
|
548
|
+
this.save();
|
|
549
|
+
}
|
|
550
|
+
}
|
|
551
|
+
|
|
552
|
+
public async bind(clusterKey: number | string, target: Endpoint | Group | number): Promise<void> {
|
|
553
|
+
const cluster = this.getCluster(clusterKey);
|
|
554
|
+
|
|
555
|
+
if (typeof target === "number") {
|
|
556
|
+
target = Group.byGroupID(target) || Group.create(target);
|
|
557
|
+
}
|
|
558
|
+
|
|
559
|
+
const destinationAddress = target instanceof Endpoint ? target.deviceIeeeAddress : target.groupID;
|
|
560
|
+
|
|
561
|
+
const log = `Bind ${this.deviceIeeeAddress}/${this.ID} ${cluster.name} from '${target instanceof Endpoint ? `${destinationAddress}/${target.ID}` : destinationAddress}'`;
|
|
562
|
+
logger.debug(log, NS);
|
|
563
|
+
|
|
564
|
+
try {
|
|
565
|
+
const zdoClusterId = Zdo.ClusterId.BIND_REQUEST;
|
|
566
|
+
const zdoPayload = Zdo.Buffalo.buildRequest(
|
|
567
|
+
// biome-ignore lint/style/noNonNullAssertion: ignored using `--suppress`
|
|
568
|
+
Entity.adapter!.hasZdoMessageOverhead,
|
|
569
|
+
zdoClusterId,
|
|
570
|
+
this.deviceIeeeAddress as Eui64,
|
|
571
|
+
this.ID,
|
|
572
|
+
cluster.ID,
|
|
573
|
+
target instanceof Endpoint ? Zdo.UNICAST_BINDING : Zdo.MULTICAST_BINDING,
|
|
574
|
+
target instanceof Endpoint ? (target.deviceIeeeAddress as Eui64) : ZSpec.BLANK_EUI64,
|
|
575
|
+
target instanceof Group ? target.groupID : 0,
|
|
576
|
+
target instanceof Endpoint ? target.ID : 0xff,
|
|
577
|
+
);
|
|
578
|
+
|
|
579
|
+
// biome-ignore lint/style/noNonNullAssertion: ignored using `--suppress`
|
|
580
|
+
const response = await Entity.adapter!.sendZdo(this.deviceIeeeAddress, this.deviceNetworkAddress, zdoClusterId, zdoPayload, false);
|
|
581
|
+
|
|
582
|
+
if (!Zdo.Buffalo.checkStatus<Zdo.ClusterId.BIND_RESPONSE>(response)) {
|
|
583
|
+
throw new Zdo.StatusError(response[0]);
|
|
584
|
+
}
|
|
585
|
+
|
|
586
|
+
this.addBindingInternal(cluster, target);
|
|
587
|
+
} catch (error) {
|
|
588
|
+
const err = error as Error;
|
|
589
|
+
err.message = `${log} failed (${err.message})`;
|
|
590
|
+
// biome-ignore lint/style/noNonNullAssertion: ignored using `--suppress`
|
|
591
|
+
logger.debug(err.stack!, NS);
|
|
592
|
+
throw error;
|
|
593
|
+
}
|
|
594
|
+
}
|
|
595
|
+
|
|
596
|
+
public save(): void {
|
|
597
|
+
this.getDevice().save();
|
|
598
|
+
}
|
|
599
|
+
|
|
600
|
+
public async unbind(clusterKey: number | string, target: Endpoint | Group | number): Promise<void> {
|
|
601
|
+
const cluster = this.getCluster(clusterKey);
|
|
602
|
+
const action = `Unbind ${this.deviceIeeeAddress}/${this.ID} ${cluster.name}`;
|
|
603
|
+
|
|
604
|
+
if (typeof target === "number") {
|
|
605
|
+
const groupTarget = Group.byGroupID(target);
|
|
606
|
+
|
|
607
|
+
if (!groupTarget) {
|
|
608
|
+
throw new Error(`${action} invalid target '${target}' (no group with this ID exists).`);
|
|
609
|
+
}
|
|
610
|
+
|
|
611
|
+
target = groupTarget;
|
|
612
|
+
}
|
|
613
|
+
|
|
614
|
+
const destinationAddress = target instanceof Endpoint ? target.deviceIeeeAddress : target.groupID;
|
|
615
|
+
const log = `${action} from '${target instanceof Endpoint ? `${destinationAddress}/${target.ID}` : destinationAddress}'`;
|
|
616
|
+
const index = this.getBindIndex(cluster.ID, target);
|
|
617
|
+
|
|
618
|
+
if (index === -1) {
|
|
619
|
+
logger.debug(`${log} no bind present, skipping.`, NS);
|
|
620
|
+
return;
|
|
621
|
+
}
|
|
622
|
+
|
|
623
|
+
logger.debug(log, NS);
|
|
624
|
+
|
|
625
|
+
try {
|
|
626
|
+
const zdoClusterId = Zdo.ClusterId.UNBIND_REQUEST;
|
|
627
|
+
const zdoPayload = Zdo.Buffalo.buildRequest(
|
|
628
|
+
// biome-ignore lint/style/noNonNullAssertion: ignored using `--suppress`
|
|
629
|
+
Entity.adapter!.hasZdoMessageOverhead,
|
|
630
|
+
zdoClusterId,
|
|
631
|
+
this.deviceIeeeAddress as Eui64,
|
|
632
|
+
this.ID,
|
|
633
|
+
cluster.ID,
|
|
634
|
+
target instanceof Endpoint ? Zdo.UNICAST_BINDING : Zdo.MULTICAST_BINDING,
|
|
635
|
+
target instanceof Endpoint ? (target.deviceIeeeAddress as Eui64) : ZSpec.BLANK_EUI64,
|
|
636
|
+
target instanceof Group ? target.groupID : 0,
|
|
637
|
+
target instanceof Endpoint ? target.ID : 0xff,
|
|
638
|
+
);
|
|
639
|
+
|
|
640
|
+
// biome-ignore lint/style/noNonNullAssertion: ignored using `--suppress`
|
|
641
|
+
const response = await Entity.adapter!.sendZdo(this.deviceIeeeAddress, this.deviceNetworkAddress, zdoClusterId, zdoPayload, false);
|
|
642
|
+
|
|
643
|
+
if (!Zdo.Buffalo.checkStatus<Zdo.ClusterId.UNBIND_RESPONSE>(response)) {
|
|
644
|
+
if (response[0] === Zdo.Status.NO_ENTRY) {
|
|
645
|
+
logger.debug(`${log} no entry on device, removing entry from database.`, NS);
|
|
646
|
+
} else {
|
|
647
|
+
throw new Zdo.StatusError(response[0]);
|
|
648
|
+
}
|
|
649
|
+
}
|
|
650
|
+
|
|
651
|
+
this._binds.splice(index, 1);
|
|
652
|
+
this.save();
|
|
653
|
+
} catch (error) {
|
|
654
|
+
const err = error as Error;
|
|
655
|
+
err.message = `${log} failed (${err.message})`;
|
|
656
|
+
// biome-ignore lint/style/noNonNullAssertion: ignored using `--suppress`
|
|
657
|
+
logger.debug(err.stack!, NS);
|
|
658
|
+
throw error;
|
|
659
|
+
}
|
|
660
|
+
}
|
|
661
|
+
|
|
662
|
+
public async defaultResponse(
|
|
663
|
+
commandID: number,
|
|
664
|
+
status: number,
|
|
665
|
+
clusterID: number,
|
|
666
|
+
transactionSequenceNumber: number,
|
|
667
|
+
options?: Options,
|
|
668
|
+
): Promise<void> {
|
|
669
|
+
assert(options?.transactionSequenceNumber === undefined, "Use parameter");
|
|
670
|
+
const payload = {cmdId: commandID, statusCode: status};
|
|
671
|
+
await this.zclCommand(clusterID, "defaultRsp", payload, {direction: Zcl.Direction.SERVER_TO_CLIENT, ...options, transactionSequenceNumber});
|
|
672
|
+
}
|
|
673
|
+
|
|
674
|
+
public async configureReporting(clusterKey: number | string, items: ConfigureReportingItem[], options?: Options): Promise<void> {
|
|
675
|
+
const cluster = this.getCluster(clusterKey);
|
|
676
|
+
const optionsWithDefaults = this.getOptionsWithDefaults(options, true, Zcl.Direction.CLIENT_TO_SERVER, cluster.manufacturerCode);
|
|
677
|
+
optionsWithDefaults.manufacturerCode = this.ensureManufacturerCodeIsUniqueAndGet(
|
|
678
|
+
cluster,
|
|
679
|
+
items,
|
|
680
|
+
optionsWithDefaults.manufacturerCode,
|
|
681
|
+
"configureReporting",
|
|
682
|
+
);
|
|
683
|
+
|
|
684
|
+
const payload = items.map((item): KeyValue => {
|
|
685
|
+
let dataType: number | undefined;
|
|
686
|
+
let attrId: number | undefined;
|
|
687
|
+
|
|
688
|
+
if (typeof item.attribute === "object") {
|
|
689
|
+
dataType = item.attribute.type;
|
|
690
|
+
attrId = item.attribute.ID;
|
|
691
|
+
} else if (cluster.hasAttribute(item.attribute)) {
|
|
692
|
+
const attribute = cluster.getAttribute(item.attribute);
|
|
693
|
+
dataType = attribute.type;
|
|
694
|
+
attrId = attribute.ID;
|
|
695
|
+
}
|
|
696
|
+
|
|
697
|
+
return {
|
|
698
|
+
direction: Zcl.Direction.CLIENT_TO_SERVER,
|
|
699
|
+
attrId, // TODO: biome migration - can be undefined?
|
|
700
|
+
dataType, // TODO: biome migration - can be undefined?
|
|
701
|
+
minRepIntval: item.minimumReportInterval,
|
|
702
|
+
maxRepIntval: item.maximumReportInterval,
|
|
703
|
+
repChange: item.reportableChange,
|
|
704
|
+
};
|
|
705
|
+
});
|
|
706
|
+
|
|
707
|
+
await this.zclCommand(clusterKey, "configReport", payload, optionsWithDefaults, items, true);
|
|
708
|
+
|
|
709
|
+
for (const e of payload) {
|
|
710
|
+
this._configuredReportings = this._configuredReportings.filter(
|
|
711
|
+
(c) =>
|
|
712
|
+
!(
|
|
713
|
+
c.attrId === e.attrId &&
|
|
714
|
+
c.cluster === cluster.ID &&
|
|
715
|
+
(!("manufacturerCode" in c) || c.manufacturerCode === optionsWithDefaults.manufacturerCode)
|
|
716
|
+
),
|
|
717
|
+
);
|
|
718
|
+
}
|
|
719
|
+
|
|
720
|
+
for (const entry of payload) {
|
|
721
|
+
if (entry.maxRepIntval !== 0xffff) {
|
|
722
|
+
this._configuredReportings.push({
|
|
723
|
+
cluster: cluster.ID,
|
|
724
|
+
attrId: entry.attrId,
|
|
725
|
+
minRepIntval: entry.minRepIntval,
|
|
726
|
+
maxRepIntval: entry.maxRepIntval,
|
|
727
|
+
repChange: entry.repChange,
|
|
728
|
+
manufacturerCode: optionsWithDefaults.manufacturerCode,
|
|
729
|
+
});
|
|
730
|
+
}
|
|
731
|
+
}
|
|
732
|
+
|
|
733
|
+
this.save();
|
|
734
|
+
}
|
|
735
|
+
|
|
736
|
+
public async writeStructured(clusterKey: number | string, payload: KeyValue, options?: Options): Promise<void> {
|
|
737
|
+
await this.zclCommand(clusterKey, "writeStructured", payload, options);
|
|
738
|
+
// TODO: support `writeStructuredResponse`
|
|
739
|
+
}
|
|
740
|
+
|
|
741
|
+
public async command(
|
|
742
|
+
clusterKey: number | string,
|
|
743
|
+
commandKey: number | string,
|
|
744
|
+
payload: KeyValue,
|
|
745
|
+
options?: Options,
|
|
746
|
+
): Promise<undefined | KeyValue> {
|
|
747
|
+
const frame = await this.zclCommand(clusterKey, commandKey, payload, options, undefined, false, Zcl.FrameType.SPECIFIC);
|
|
748
|
+
if (frame) {
|
|
749
|
+
return frame.payload;
|
|
750
|
+
}
|
|
751
|
+
}
|
|
752
|
+
|
|
753
|
+
public async commandResponse(
|
|
754
|
+
clusterKey: number | string,
|
|
755
|
+
commandKey: number | string,
|
|
756
|
+
payload: KeyValue,
|
|
757
|
+
options?: Options,
|
|
758
|
+
transactionSequenceNumber?: number,
|
|
759
|
+
): Promise<void> {
|
|
760
|
+
assert(options?.transactionSequenceNumber === undefined, "Use parameter");
|
|
761
|
+
|
|
762
|
+
const device = this.getDevice();
|
|
763
|
+
const cluster = this.getCluster(clusterKey, device);
|
|
764
|
+
const command = cluster.getCommandResponse(commandKey);
|
|
765
|
+
transactionSequenceNumber = transactionSequenceNumber || zclTransactionSequenceNumber.next();
|
|
766
|
+
const optionsWithDefaults = this.getOptionsWithDefaults(options, true, Zcl.Direction.SERVER_TO_CLIENT, cluster.manufacturerCode);
|
|
767
|
+
|
|
768
|
+
const frame = Zcl.Frame.create(
|
|
769
|
+
Zcl.FrameType.SPECIFIC,
|
|
770
|
+
optionsWithDefaults.direction,
|
|
771
|
+
optionsWithDefaults.disableDefaultResponse,
|
|
772
|
+
optionsWithDefaults.manufacturerCode,
|
|
773
|
+
transactionSequenceNumber,
|
|
774
|
+
command.name,
|
|
775
|
+
cluster.name,
|
|
776
|
+
payload,
|
|
777
|
+
device.customClusters,
|
|
778
|
+
optionsWithDefaults.reservedBits,
|
|
779
|
+
);
|
|
780
|
+
|
|
781
|
+
const createLogMessage = (): string =>
|
|
782
|
+
`CommandResponse ${this.deviceIeeeAddress}/${this.ID} ` +
|
|
783
|
+
`${cluster.name}.${command.name}(${JSON.stringify(payload)}, ${JSON.stringify(optionsWithDefaults)})`;
|
|
784
|
+
logger.debug(createLogMessage, NS);
|
|
785
|
+
|
|
786
|
+
try {
|
|
787
|
+
await this.sendRequest(frame, optionsWithDefaults, async (f) => {
|
|
788
|
+
// Broadcast Green Power responses
|
|
789
|
+
if (this.ID === 242) {
|
|
790
|
+
// biome-ignore lint/style/noNonNullAssertion: ignored using `--suppress`
|
|
791
|
+
await Entity.adapter!.sendZclFrameToAll(242, f, 242, BroadcastAddress.RX_ON_WHEN_IDLE);
|
|
792
|
+
} else {
|
|
793
|
+
// biome-ignore lint/style/noNonNullAssertion: ignored using `--suppress`
|
|
794
|
+
await Entity.adapter!.sendZclFrameToEndpoint(
|
|
795
|
+
this.deviceIeeeAddress,
|
|
796
|
+
this.deviceNetworkAddress,
|
|
797
|
+
this.ID,
|
|
798
|
+
f,
|
|
799
|
+
optionsWithDefaults.timeout,
|
|
800
|
+
optionsWithDefaults.disableResponse,
|
|
801
|
+
optionsWithDefaults.disableRecovery,
|
|
802
|
+
optionsWithDefaults.srcEndpoint,
|
|
803
|
+
);
|
|
804
|
+
}
|
|
805
|
+
});
|
|
806
|
+
} catch (error) {
|
|
807
|
+
const err = error as Error;
|
|
808
|
+
err.message = `${createLogMessage()} failed (${err.message})`;
|
|
809
|
+
// biome-ignore lint/style/noNonNullAssertion: ignored using `--suppress`
|
|
810
|
+
logger.debug(err.stack!, NS);
|
|
811
|
+
throw error;
|
|
812
|
+
}
|
|
813
|
+
}
|
|
814
|
+
|
|
815
|
+
public waitForCommand(
|
|
816
|
+
clusterKey: number | string,
|
|
817
|
+
commandKey: number | string,
|
|
818
|
+
transactionSequenceNumber: number | undefined,
|
|
819
|
+
timeout: number,
|
|
820
|
+
): {promise: Promise<{header: Zcl.Header; payload: KeyValue}>; cancel: () => void} {
|
|
821
|
+
const device = this.getDevice();
|
|
822
|
+
const cluster = this.getCluster(clusterKey, device);
|
|
823
|
+
const command = cluster.getCommand(commandKey);
|
|
824
|
+
// biome-ignore lint/style/noNonNullAssertion: ignored using `--suppress`
|
|
825
|
+
const waiter = Entity.adapter!.waitFor(
|
|
826
|
+
this.deviceNetworkAddress,
|
|
827
|
+
this.ID,
|
|
828
|
+
Zcl.FrameType.SPECIFIC,
|
|
829
|
+
Zcl.Direction.CLIENT_TO_SERVER,
|
|
830
|
+
transactionSequenceNumber,
|
|
831
|
+
cluster.ID,
|
|
832
|
+
command.ID,
|
|
833
|
+
timeout,
|
|
834
|
+
);
|
|
835
|
+
|
|
836
|
+
const promise = new Promise<{header: Zcl.Header; payload: KeyValue}>((resolve, reject) => {
|
|
837
|
+
waiter.promise.then(
|
|
838
|
+
(payload) => {
|
|
839
|
+
const frame = Zcl.Frame.fromBuffer(payload.clusterID, payload.header, payload.data, device.customClusters);
|
|
840
|
+
resolve({header: frame.header, payload: frame.payload});
|
|
841
|
+
},
|
|
842
|
+
(error) => reject(error),
|
|
843
|
+
);
|
|
844
|
+
});
|
|
845
|
+
|
|
846
|
+
return {promise, cancel: waiter.cancel};
|
|
847
|
+
}
|
|
848
|
+
|
|
849
|
+
private getOptionsWithDefaults(
|
|
850
|
+
options: Options | undefined,
|
|
851
|
+
disableDefaultResponse: boolean,
|
|
852
|
+
direction: Zcl.Direction,
|
|
853
|
+
manufacturerCode: number | undefined,
|
|
854
|
+
): OptionsWithDefaults {
|
|
855
|
+
return {
|
|
856
|
+
timeout: 10000,
|
|
857
|
+
disableResponse: false,
|
|
858
|
+
disableRecovery: false,
|
|
859
|
+
disableDefaultResponse,
|
|
860
|
+
direction,
|
|
861
|
+
srcEndpoint: undefined,
|
|
862
|
+
reservedBits: 0,
|
|
863
|
+
manufacturerCode,
|
|
864
|
+
transactionSequenceNumber: undefined,
|
|
865
|
+
writeUndiv: false,
|
|
866
|
+
...(options || {}),
|
|
867
|
+
};
|
|
868
|
+
}
|
|
869
|
+
|
|
870
|
+
private ensureManufacturerCodeIsUniqueAndGet(
|
|
871
|
+
cluster: ZclTypes.Cluster,
|
|
872
|
+
attributes: (string | number)[] | ConfigureReportingItem[],
|
|
873
|
+
fallbackManufacturerCode: number | undefined, // XXX: problematic undefined for a "fallback"?
|
|
874
|
+
caller: string,
|
|
875
|
+
): number | undefined {
|
|
876
|
+
const manufacturerCodes = new Set(
|
|
877
|
+
attributes.map((nameOrID): number | undefined => {
|
|
878
|
+
let attributeID: number | string;
|
|
879
|
+
|
|
880
|
+
if (typeof nameOrID === "object") {
|
|
881
|
+
// ConfigureReportingItem
|
|
882
|
+
if (typeof nameOrID.attribute !== "object") {
|
|
883
|
+
attributeID = nameOrID.attribute;
|
|
884
|
+
} else {
|
|
885
|
+
return fallbackManufacturerCode;
|
|
886
|
+
}
|
|
887
|
+
} else {
|
|
888
|
+
// string || number
|
|
889
|
+
attributeID = nameOrID;
|
|
890
|
+
}
|
|
891
|
+
|
|
892
|
+
// we fall back to caller|cluster provided manufacturerCode
|
|
893
|
+
if (cluster.hasAttribute(attributeID)) {
|
|
894
|
+
const attribute = cluster.getAttribute(attributeID);
|
|
895
|
+
return attribute.manufacturerCode === undefined ? fallbackManufacturerCode : attribute.manufacturerCode;
|
|
896
|
+
}
|
|
897
|
+
|
|
898
|
+
// unknown attribute, we should not fail on this here
|
|
899
|
+
return fallbackManufacturerCode;
|
|
900
|
+
}),
|
|
901
|
+
);
|
|
902
|
+
|
|
903
|
+
if (manufacturerCodes.size === 1) {
|
|
904
|
+
return manufacturerCodes.values().next().value;
|
|
905
|
+
}
|
|
906
|
+
|
|
907
|
+
throw new Error(`Cannot have attributes with different manufacturerCode in single '${caller}' call`);
|
|
908
|
+
}
|
|
909
|
+
|
|
910
|
+
public async addToGroup(group: Group): Promise<void> {
|
|
911
|
+
await this.command("genGroups", "add", {groupid: group.groupID, groupname: ""});
|
|
912
|
+
group.addMember(this);
|
|
913
|
+
}
|
|
914
|
+
|
|
915
|
+
private getCluster(clusterKey: number | string, device: Device | undefined = undefined): ZclTypes.Cluster {
|
|
916
|
+
if (!device) {
|
|
917
|
+
device = this.getDevice();
|
|
918
|
+
}
|
|
919
|
+
|
|
920
|
+
return Zcl.Utils.getCluster(clusterKey, device.manufacturerID, device.customClusters);
|
|
921
|
+
}
|
|
922
|
+
|
|
923
|
+
/**
|
|
924
|
+
* Remove endpoint from a group, accepts both a Group and number as parameter.
|
|
925
|
+
* The number parameter type should only be used when removing from a group which is not known
|
|
926
|
+
* to zigbee-herdsman.
|
|
927
|
+
*/
|
|
928
|
+
public async removeFromGroup(group: Group | number): Promise<void> {
|
|
929
|
+
await this.command("genGroups", "remove", {groupid: group instanceof Group ? group.groupID : group});
|
|
930
|
+
if (group instanceof Group) {
|
|
931
|
+
group.removeMember(this);
|
|
932
|
+
}
|
|
933
|
+
}
|
|
934
|
+
|
|
935
|
+
public async removeFromAllGroups(): Promise<void> {
|
|
936
|
+
await this.command("genGroups", "removeAll", {}, {disableDefaultResponse: true});
|
|
937
|
+
this.removeFromAllGroupsDatabase();
|
|
938
|
+
}
|
|
939
|
+
|
|
940
|
+
public removeFromAllGroupsDatabase(): void {
|
|
941
|
+
for (const group of Group.allIterator()) {
|
|
942
|
+
if (group.hasMember(this)) {
|
|
943
|
+
group.removeMember(this);
|
|
944
|
+
}
|
|
945
|
+
}
|
|
946
|
+
}
|
|
947
|
+
|
|
948
|
+
public async zclCommand(
|
|
949
|
+
clusterKey: number | string,
|
|
950
|
+
commandKey: number | string,
|
|
951
|
+
payload: KeyValue,
|
|
952
|
+
options?: Options,
|
|
953
|
+
logPayload?: KeyValue,
|
|
954
|
+
checkStatus = false,
|
|
955
|
+
frameType: Zcl.FrameType = Zcl.FrameType.GLOBAL,
|
|
956
|
+
): Promise<undefined | Zcl.Frame> {
|
|
957
|
+
const device = this.getDevice();
|
|
958
|
+
const cluster = this.getCluster(clusterKey, device);
|
|
959
|
+
const command = frameType === Zcl.FrameType.GLOBAL ? Zcl.Utils.getGlobalCommand(commandKey) : cluster.getCommand(commandKey);
|
|
960
|
+
const hasResponse = frameType === Zcl.FrameType.GLOBAL ? true : command.response !== undefined;
|
|
961
|
+
const optionsWithDefaults = this.getOptionsWithDefaults(options, hasResponse, Zcl.Direction.CLIENT_TO_SERVER, cluster.manufacturerCode);
|
|
962
|
+
|
|
963
|
+
const frame = Zcl.Frame.create(
|
|
964
|
+
frameType,
|
|
965
|
+
optionsWithDefaults.direction,
|
|
966
|
+
optionsWithDefaults.disableDefaultResponse,
|
|
967
|
+
optionsWithDefaults.manufacturerCode,
|
|
968
|
+
optionsWithDefaults.transactionSequenceNumber ?? zclTransactionSequenceNumber.next(),
|
|
969
|
+
command.name,
|
|
970
|
+
cluster.name,
|
|
971
|
+
payload,
|
|
972
|
+
device.customClusters,
|
|
973
|
+
optionsWithDefaults.reservedBits,
|
|
974
|
+
);
|
|
975
|
+
|
|
976
|
+
const createLogMessage = (): string =>
|
|
977
|
+
`ZCL command ${this.deviceIeeeAddress}/${this.ID} ` +
|
|
978
|
+
`${cluster.name}.${command.name}(${JSON.stringify(logPayload ? logPayload : payload)}, ${JSON.stringify(optionsWithDefaults)})`;
|
|
979
|
+
logger.debug(createLogMessage, NS);
|
|
980
|
+
|
|
981
|
+
try {
|
|
982
|
+
const result = await this.sendRequest(frame, optionsWithDefaults);
|
|
983
|
+
|
|
984
|
+
if (result) {
|
|
985
|
+
const resultFrame = Zcl.Frame.fromBuffer(result.clusterID, result.header, result.data, device.customClusters);
|
|
986
|
+
if (result && checkStatus && !optionsWithDefaults.disableResponse) {
|
|
987
|
+
this.checkStatus(resultFrame.payload);
|
|
988
|
+
}
|
|
989
|
+
return resultFrame;
|
|
990
|
+
}
|
|
991
|
+
} catch (error) {
|
|
992
|
+
const err = error as Error;
|
|
993
|
+
err.message = `${createLogMessage()} failed (${err.message})`;
|
|
994
|
+
// biome-ignore lint/style/noNonNullAssertion: ignored using `--suppress`
|
|
995
|
+
logger.debug(err.stack!, NS);
|
|
996
|
+
throw error;
|
|
997
|
+
}
|
|
998
|
+
}
|
|
999
|
+
|
|
1000
|
+
public async zclCommandBroadcast(
|
|
1001
|
+
endpoint: number,
|
|
1002
|
+
destination: BroadcastAddress,
|
|
1003
|
+
clusterKey: number | string,
|
|
1004
|
+
commandKey: number | string,
|
|
1005
|
+
payload: unknown,
|
|
1006
|
+
options?: Options,
|
|
1007
|
+
): Promise<void> {
|
|
1008
|
+
const device = this.getDevice();
|
|
1009
|
+
const cluster = this.getCluster(clusterKey, device);
|
|
1010
|
+
const command = cluster.getCommand(commandKey);
|
|
1011
|
+
const optionsWithDefaults = this.getOptionsWithDefaults(options, true, Zcl.Direction.CLIENT_TO_SERVER, cluster.manufacturerCode);
|
|
1012
|
+
const sourceEndpoint = optionsWithDefaults.srcEndpoint ?? this.ID;
|
|
1013
|
+
|
|
1014
|
+
const frame = Zcl.Frame.create(
|
|
1015
|
+
Zcl.FrameType.SPECIFIC,
|
|
1016
|
+
optionsWithDefaults.direction,
|
|
1017
|
+
true,
|
|
1018
|
+
optionsWithDefaults.manufacturerCode,
|
|
1019
|
+
optionsWithDefaults.transactionSequenceNumber ?? zclTransactionSequenceNumber.next(),
|
|
1020
|
+
command.name,
|
|
1021
|
+
cluster.name,
|
|
1022
|
+
payload,
|
|
1023
|
+
device.customClusters,
|
|
1024
|
+
optionsWithDefaults.reservedBits,
|
|
1025
|
+
);
|
|
1026
|
+
|
|
1027
|
+
logger.debug(
|
|
1028
|
+
() =>
|
|
1029
|
+
`ZCL command broadcast ${this.deviceIeeeAddress}/${sourceEndpoint} to ${destination}/${endpoint} ` +
|
|
1030
|
+
`${cluster.name}.${command.name}(${JSON.stringify({payload, optionsWithDefaults})})`,
|
|
1031
|
+
NS,
|
|
1032
|
+
);
|
|
1033
|
+
|
|
1034
|
+
// if endpoint===0xFF ("broadcast endpoint"), deliver to all endpoints supporting cluster, should be avoided whenever possible
|
|
1035
|
+
// biome-ignore lint/style/noNonNullAssertion: ignored using `--suppress`
|
|
1036
|
+
await Entity.adapter!.sendZclFrameToAll(endpoint, frame, sourceEndpoint, destination);
|
|
1037
|
+
}
|
|
1038
|
+
}
|
|
1039
|
+
|
|
1040
|
+
export default Endpoint;
|