From 16c222d3b33da6ed720d96d0630123a34fecdebb Mon Sep 17 00:00:00 2001 From: Koen Kanters Date: Tue, 4 Dec 2018 20:09:52 +0100 Subject: [PATCH] Support iAS cluster. (#654) * Implement zapp-cie. https://github.com/Koenkk/zigbee2mqtt/issues/507 * Cleanup cie app. https://github.com/Koenkk/zigbee2mqtt/issues/507 * Update package.json * Update zigbee.js --- lib/zapp/cie.js | 57 ++++++++++++++++++++++++++++ lib/zigbee.js | 10 +++++ npm-shrinkwrap.json | 91 ++++++++++++++++++++++----------------------- package.json | 4 +- 4 files changed, 114 insertions(+), 48 deletions(-) create mode 100644 lib/zapp/cie.js diff --git a/lib/zapp/cie.js b/lib/zapp/cie.js new file mode 100644 index 000000000..295db139f --- /dev/null +++ b/lib/zapp/cie.js @@ -0,0 +1,57 @@ +/** + * This is a fake cie app which makes it possible for some iAS devices to join the network. + * Based on: https://github.com/zigbeer/zapp-cie + */ + +const Ziee = require('ziee'); +const Zive = require('zive'); +const cieClusters = new Ziee(); + +cieClusters.init('genBasic', 'dir', {value: 1}); // Server Side(Input) +cieClusters.init('ssIasAce', 'dir', {value: 1}); // Server Side(Input) +cieClusters.init('ssIasZone', 'dir', {value: 2}); // Client Side(Output) +cieClusters.init('ssIasWd', 'dir', {value: 2}); // Client Side(Output) +cieClusters.init('genIdentify', 'dir', {value: 3}); // Server and Client Side(Input/Output) + +// Init Attributes Access Control +cieClusters.init('genBasic', 'acls', { + zclVersion: 'R', + hwVersion: 'R', + manufacturerName: 'R', + modelId: 'R', + dateCode: 'R', + powerSource: 'R', + locationDesc: 'RW', + physicalEnv: 'RW', + deviceEnabled: 'RW', +}); + +cieClusters.init('genIdentify', 'acls', { + identifyTime: 'RW', +}); + +// Init Attributes Value +cieClusters.init('genBasic', 'attrs', { + zclVersion: 1, + hwVersion: 1, + manufacturerName: 'sivann inc.', + modelId: 'hiver0001', + dateCode: '20170407', + powerSource: 1, + locationDesc: ' ', + physicalEnv: 0, + deviceEnabled: 1, +}); + +cieClusters.init('genIdentify', 'attrs', { + identifyTime: 0, +}); + +// Init Command Response Handler +cieClusters.init('ssIasZone', 'cmdRsps', { + enrollReq: (zapp, argObj, cb) => {}, + statusChangeNotification: (zapp, argObj, cb) => {}, +}); + +const cieApp = new Zive({profId: 0x0104, devId: 0x0400, discCmds: []}, cieClusters); +module.exports = cieApp; diff --git a/lib/zigbee.js b/lib/zigbee.js index 3918a25cc..72c3e058c 100644 --- a/lib/zigbee.js +++ b/lib/zigbee.js @@ -3,6 +3,7 @@ const logger = require('./util/logger'); const settings = require('./util/settings'); const data = require('./util/data'); const utils = require('./util/utils'); +const cieApp = require('./zapp/cie'); const advancedSettings = settings.get().advanced; const shepherdSettings = { @@ -82,6 +83,15 @@ class Zigbee { } onReady() { + // Mount cieApp + this.shepherd.mount(cieApp, (err, epId) => { + if (!err) { + logger.debug(`Mounted the cieApp (epId {epId})`); + } else { + logger.error(`Failed to mount the cieApp`); + } + }); + // Check if we have to turn off the led if (settings.get().serial.disable_led) { this.shepherd.controller.request('UTIL', 'ledControl', {ledid: 3, mode: 0}); diff --git a/npm-shrinkwrap.json b/npm-shrinkwrap.json index 4b601db50..0e4d85d8d 100644 --- a/npm-shrinkwrap.json +++ b/npm-shrinkwrap.json @@ -207,9 +207,9 @@ } }, "@sinonjs/samsam": { - "version": "2.1.2", - "resolved": "https://registry.npmjs.org/@sinonjs/samsam/-/samsam-2.1.2.tgz", - "integrity": "sha512-ZwTHAlC9akprWDinwEPD4kOuwaYZlyMwVJIANsKNC3QVp0AHB04m7RnB4eqeWfgmxw8MGTzS9uMaw93Z3QcZbw==", + "version": "2.1.3", + "resolved": "https://registry.npmjs.org/@sinonjs/samsam/-/samsam-2.1.3.tgz", + "integrity": "sha512-8zNeBkSKhU9a5cRNbpCKau2WWPfan+Q2zDlcXvXyhn9EsMqgYs4qzo0XHNVlXC6ABQL8fT6nV+zzo5RTHJzyXw==", "dev": true }, "acorn": { @@ -1586,9 +1586,9 @@ "integrity": "sha512-RZY5huIKCMRWDUqZlEi72f/lmXKMvuszcMBduliQ3nnWbx9X/ZBQO7DijMEYS9EhHBb2qacRUMtC7svLwe0lcw==" }, "inquirer": { - "version": "6.2.0", - "resolved": "https://registry.npmjs.org/inquirer/-/inquirer-6.2.0.tgz", - "integrity": "sha512-QIEQG4YyQ2UYZGDC4srMZ7BjHOmNk1lR2JQj5UknBapklm6WHA+VVH7N+sUdX3A7NeCfGF8o4X1S3Ao7nAcIeg==", + "version": "6.2.1", + "resolved": "https://registry.npmjs.org/inquirer/-/inquirer-6.2.1.tgz", + "integrity": "sha512-088kl3DRT2dLU5riVMKKr1DlImd6X7smDhpXUCkJDCKvTEJeRiXh0G132HG9u5a+6Ylw9plFRY7RuTnwohYSpg==", "dev": true, "requires": { "ansi-escapes": "^3.0.0", @@ -1602,7 +1602,7 @@ "run-async": "^2.2.0", "rxjs": "^6.1.0", "string-width": "^2.1.0", - "strip-ansi": "^4.0.0", + "strip-ansi": "^5.0.0", "through": "^2.3.6" }, "dependencies": { @@ -1626,15 +1626,34 @@ "requires": { "is-fullwidth-code-point": "^2.0.0", "strip-ansi": "^4.0.0" + }, + "dependencies": { + "strip-ansi": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-4.0.0.tgz", + "integrity": "sha1-qEeQIusaw2iocTibY1JixQXuNo8=", + "dev": true, + "requires": { + "ansi-regex": "^3.0.0" + } + } } }, "strip-ansi": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-4.0.0.tgz", - "integrity": "sha1-qEeQIusaw2iocTibY1JixQXuNo8=", + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-5.0.0.tgz", + "integrity": "sha512-Uu7gQyZI7J7gn5qLn1Np3G9vcYGTVqB+lFTytnDJv83dd8T22aGH451P3jueT2/QemInJDfxHB5Tde5OzgG1Ow==", "dev": true, "requires": { - "ansi-regex": "^3.0.0" + "ansi-regex": "^4.0.0" + }, + "dependencies": { + "ansi-regex": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-4.0.0.tgz", + "integrity": "sha512-iB5Dda8t/UqpPI/IjsejXu5jOGDrzn41wJyljwPH65VCIbk6+1BzFIMJGFwTNrYXT1CrD+B4l19U7awiQ8rk7w==", + "dev": true + } } } } @@ -4745,9 +4764,9 @@ "integrity": "sha1-pcbVMr5lbiPbgg77lDofBJmNY68=" }, "zcl-id": { - "version": "0.3.2", - "resolved": "https://registry.npmjs.org/zcl-id/-/zcl-id-0.3.2.tgz", - "integrity": "sha1-O6v7HsvMgpujuy6/gyf2iQIxDsI=", + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/zcl-id/-/zcl-id-0.2.0.tgz", + "integrity": "sha1-E5nV5ba6SbZtDVpQYgCGXTcRfo0=", "requires": { "busyman": "^0.3.0", "enum": "^2.3.0" @@ -4761,17 +4780,6 @@ "dissolve-chunks": "^1.3.0", "enum": "^2.3.0", "zcl-id": "^0.2.0" - }, - "dependencies": { - "zcl-id": { - "version": "0.2.0", - "resolved": "https://registry.npmjs.org/zcl-id/-/zcl-id-0.2.0.tgz", - "integrity": "sha1-E5nV5ba6SbZtDVpQYgCGXTcRfo0=", - "requires": { - "busyman": "^0.3.0", - "enum": "^2.3.0" - } - } } }, "ziee": { @@ -4781,17 +4789,6 @@ "requires": { "busyman": "^0.3.0", "zcl-id": "^0.2.0" - }, - "dependencies": { - "zcl-id": { - "version": "0.2.0", - "resolved": "https://registry.npmjs.org/zcl-id/-/zcl-id-0.2.0.tgz", - "integrity": "sha1-E5nV5ba6SbZtDVpQYgCGXTcRfo0=", - "requires": { - "busyman": "^0.3.0", - "enum": "^2.3.0" - } - } } }, "zigbee-shepherd": { @@ -4810,6 +4807,17 @@ "ziee": "^0.3.0", "zive": "^0.2.2", "zstack-constants": "^0.2.0" + }, + "dependencies": { + "zcl-id": { + "version": "0.3.2", + "resolved": "https://registry.npmjs.org/zcl-id/-/zcl-id-0.3.2.tgz", + "integrity": "sha1-O6v7HsvMgpujuy6/gyf2iQIxDsI=", + "requires": { + "busyman": "^0.3.0", + "enum": "^2.3.0" + } + } } }, "zigbee-shepherd-converters": { @@ -5684,17 +5692,6 @@ "requires": { "busyman": "^0.3.0", "zcl-id": "^0.2.0" - }, - "dependencies": { - "zcl-id": { - "version": "0.2.0", - "resolved": "https://registry.npmjs.org/zcl-id/-/zcl-id-0.2.0.tgz", - "integrity": "sha1-E5nV5ba6SbZtDVpQYgCGXTcRfo0=", - "requires": { - "busyman": "^0.3.0", - "enum": "^2.3.0" - } - } } }, "zstack-constants": { diff --git a/package.json b/package.json index b98a93f25..0b81d3a10 100644 --- a/package.json +++ b/package.json @@ -44,7 +44,9 @@ "rimraf": "*", "winston": "2.4.2", "zigbee-shepherd": "git+https://github.com/Koenkk/zigbee-shepherd.git#ce52ac4131e2a505af6197b4a26d2b5360e4eb80", - "zigbee-shepherd-converters": "6.0.7" + "zigbee-shepherd-converters": "6.0.7", + "ziee": "*", + "zive": "*" }, "devDependencies": { "chai": "*",