zigbee-clusters 1.3.1 → 1.5.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/README.md CHANGED
@@ -207,7 +207,7 @@ zclNode.endpoints[1].bind(CLUSTER.LEVEL_CONTROL.NAME, new LevelControlBoundClust
207
207
  ```
208
208
 
209
209
  ### Implementing a custom cluster
210
- There are cases where it is required to implement a custom cluster, for example to handle manufacturer specific cluster implementations. Often these manufacturer specific cluster implementations are extensions of existing clusters. An example is the `IkeaSpecificSceneCluster` ([complete implementation](https://github.com/athombv/com.ikea.tradfri/tree/master/lib/IkeaSpecificSceneCluster.js)):
210
+ There are cases where it is required to implement a custom cluster, for example to handle manufacturer specific cluster implementations. Often these manufacturer specific cluster implementations are extensions of existing clusters. An example is the `IkeaSpecificSceneCluster` ([complete implementation](https://github.com/athombv/com.ikea.tradfri-example/tree/master/lib/IkeaSpecificSceneCluster.js)):
211
211
 
212
212
  `lib/IkeaSpecificSceneCluster.js`
213
213
  ```js
@@ -267,7 +267,7 @@ zclNode.endpoints[1].clusters['scenes'].ikeaSceneMove({mode: 0, transitionTime:
267
267
 
268
268
  ```
269
269
 
270
- This also works for `BoundClusters`, if a node sends commands to Homey using a custom cluster it is necessary to implement a custom `BoundCluster` and bind it to the `ZCLNode` instance. For an example check the implementation in the `com.ikea.tradfri` driver [remote_control](https://github.com/athombv/com.ikea.tradfri/tree/master/drivers/remote_control/device.js).
270
+ This also works for `BoundClusters`, if a node sends commands to Homey using a custom cluster it is necessary to implement a custom `BoundCluster` and bind it to the `ZCLNode` instance. For an example check the implementation in the `com.ikea.tradfri` driver [remote_control](https://github.com/athombv/com.ikea.tradfri-example/tree/master/drivers/remote_control/device.js).
271
271
 
272
272
  ## Contributing
273
273
  Great if you'd like to contribute to this project, a few things to take note of before submitting a PR:
package/lib/Endpoint.js CHANGED
@@ -44,6 +44,7 @@ class Endpoint extends EventEmitter {
44
44
  * Returns log id string for this endpoint.
45
45
  * @param {number} clusterId
46
46
  * @returns {string}
47
+ * @private
47
48
  */
48
49
  getLogId(clusterId) {
49
50
  const cluster = Cluster.getCluster(clusterId) || {};
package/lib/Node.js CHANGED
@@ -56,9 +56,12 @@ class Node extends EventEmitter {
56
56
  };
57
57
 
58
58
  this.endpoints = {};
59
- node.endpointDescriptors.forEach(ep => {
60
- this.endpoints[ep.endpointId] = new Endpoint(this, ep);
61
- });
59
+
60
+ if (Array.isArray(node.endpointDescriptors)) {
61
+ node.endpointDescriptors.forEach(ep => {
62
+ this.endpoints[ep.endpointId] = new Endpoint(this, ep);
63
+ });
64
+ }
62
65
  }
63
66
 
64
67
  /**
@@ -66,6 +69,7 @@ class Node extends EventEmitter {
66
69
  * @param {number} endpointId
67
70
  * @param {number} clusterId
68
71
  * @returns {string}
72
+ * @private
69
73
  */
70
74
  getLogId(endpointId, clusterId) {
71
75
  const cluster = Cluster.getCluster(clusterId);
@@ -1,11 +1,63 @@
1
1
  'use strict';
2
2
 
3
3
  const Cluster = require('../Cluster');
4
+ const { ZCLDataTypes } = require('../zclTypes');
5
+
6
+ const ZONE_STATUS_DATA_TYPE = ZCLDataTypes.map16('alarm1', 'alarm2', 'tamper', 'battery', 'supervisionReports', 'restoreReports', 'trouble', 'acMains', 'test', 'batteryDefect');
4
7
 
5
8
  const ATTRIBUTES = {
9
+ zoneState: {
10
+ id: 0,
11
+ type: ZCLDataTypes.enum8({
12
+ notEnrolled: 0,
13
+ enrolled: 1,
14
+ }),
15
+ },
16
+ zoneType: {
17
+ id: 1,
18
+ type: ZCLDataTypes.enum16({
19
+ standardCIE: 0,
20
+ motionSensor: 13,
21
+ contactSwitch: 21,
22
+ fireSensor: 40,
23
+ waterSensor: 42,
24
+ cabonMonoxideSensor: 43,
25
+ personalEmergencyDevice: 44,
26
+ vibrationMovementSensor: 45,
27
+ remoteControl: 271,
28
+ keyfob: 277,
29
+ keypad: 541,
30
+ standardWarningDevice: 549,
31
+ glassBreakSensor: 550,
32
+ securityRepeater: 553,
33
+ invalidZoneType: 65535,
34
+ }),
35
+ },
36
+ zoneStatus: {
37
+ id: 2,
38
+ type: ZONE_STATUS_DATA_TYPE,
39
+ },
40
+ iasCIEAddress: {
41
+ id: 16,
42
+ type: ZCLDataTypes.EUI64,
43
+ },
44
+ zoneId: {
45
+ id: 17,
46
+ type: ZCLDataTypes.uint8,
47
+ },
6
48
  };
7
49
 
8
- const COMMANDS = {};
50
+ const COMMANDS = {
51
+ zoneStatusChangeNotification: {
52
+ id: 0,
53
+ args: {
54
+ zoneStatus: ZONE_STATUS_DATA_TYPE,
55
+ extendedStatus: ZCLDataTypes.uint8,
56
+ zoneId: ZCLDataTypes.uint8,
57
+ delay: ZCLDataTypes.uint16,
58
+ },
59
+ },
60
+ };
9
61
 
10
62
  class IASZoneCluster extends Cluster {
11
63
 
@@ -1,10 +1,43 @@
1
1
  'use strict';
2
2
 
3
3
  const Cluster = require('../Cluster');
4
+ const { ZCLDataTypes } = require('../zclTypes');
4
5
 
5
- const ATTRIBUTES = {};
6
+ const ATTRIBUTES = {
7
+ identifyTime: { id: 0, type: ZCLDataTypes.uint16 },
8
+ };
6
9
 
7
- const COMMANDS = {};
10
+ const COMMANDS = {
11
+ identify: {
12
+ id: 0,
13
+ args: {
14
+ identifyTime: ZCLDataTypes.uint16,
15
+ },
16
+ },
17
+ identifyQuery: {
18
+ id: 1,
19
+ response: {
20
+ id: 0,
21
+ args: {
22
+ timeout: ZCLDataTypes.uint16,
23
+ },
24
+ },
25
+ },
26
+ triggerEffect: {
27
+ id: 64,
28
+ args: {
29
+ effectIdentifier: ZCLDataTypes.enum8({
30
+ blink: 0,
31
+ breathe: 1,
32
+ okay: 2,
33
+ channelChange: 11,
34
+ finish: 254,
35
+ stop: 255,
36
+ }),
37
+ effectVariant: ZCLDataTypes.uint16,
38
+ },
39
+ },
40
+ };
8
41
 
9
42
  class IdentifyCluster extends Cluster {
10
43
 
@@ -24,6 +24,42 @@ const ATTRIBUTES = {
24
24
  batteryQuantity: { id: 51, type: ZCLDataTypes.uint8 },
25
25
  batteryRatedVoltage: { id: 52, type: ZCLDataTypes.uint8 },
26
26
  batteryVoltageMinThreshold: { id: 54, type: ZCLDataTypes.uint8 },
27
+ batteryAlarmState: {
28
+ id: 62,
29
+ type: ZCLDataTypes.map32(
30
+ 'batteryThresholdBatterySource1',
31
+ 'batteryThreshold1BatterySource1',
32
+ 'batteryThreshold2BatterySource1',
33
+ 'batteryThreshold3BatterySource1',
34
+ 'reserved4',
35
+ 'reserved5',
36
+ 'reserved6',
37
+ 'reserved7',
38
+ 'reserved8',
39
+ 'reserved9',
40
+ 'batteryThresholdBatterySource2',
41
+ 'batteryThreshold1BatterySource2',
42
+ 'batteryThreshold2BatterySource2',
43
+ 'batteryThreshold3BatterySource2',
44
+ 'reserved14',
45
+ 'reserved15',
46
+ 'reserved16',
47
+ 'reserved17',
48
+ 'reserved18',
49
+ 'reserved19',
50
+ 'batteryThresholdBatterySource3',
51
+ 'batteryThreshold1BatterySource3',
52
+ 'batteryThreshold2BatterySource3',
53
+ 'batteryThreshold3BatterySource3',
54
+ 'reserved24',
55
+ 'reserved25',
56
+ 'reserved26',
57
+ 'reserved27',
58
+ 'reserved28',
59
+ 'reserved29',
60
+ 'mainsPowerSupplyLostUnavailable',
61
+ ),
62
+ },
27
63
  };
28
64
 
29
65
  const COMMANDS = {};
package/package.json CHANGED
@@ -1,15 +1,15 @@
1
1
  {
2
2
  "name": "zigbee-clusters",
3
- "version": "1.3.1",
3
+ "version": "1.5.0",
4
4
  "description": "Zigbee Cluster Library for Node.js",
5
5
  "main": "index.js",
6
6
  "scripts": {
7
7
  "test": "mocha --reporter list",
8
8
  "lint": "eslint .",
9
- "serve": "concurrently \"serve build/docs/\" \"npm run jsdoc:watch\"",
10
- "build": "npm run jsdoc",
11
- "jsdoc": "cd docs; jsdoc -c jsdoc.json",
12
- "jsdoc:watch": "npm-watch jsdoc"
9
+ "serve": "concurrently \"serve build/\" \"npm run build:watch\"",
10
+ "build": "jsdoc --configure ./docs/jsdoc.json",
11
+ "build:clean": "rm -rf ./build",
12
+ "build:watch": "watch \"npm run build:clean && npm run build\" lib docs \"node_modules/homey-jsdoc-template\""
13
13
  },
14
14
  "repository": {
15
15
  "type": "git",
@@ -30,27 +30,18 @@
30
30
  },
31
31
  "homepage": "https://github.com/athombv/node-zigbee-clusters#readme",
32
32
  "devDependencies": {
33
- "braintree-jsdoc-template": "^3.3.0",
34
33
  "concurrently": "^5.2.0",
35
34
  "eslint": "^6.8.0",
36
35
  "eslint-config-athom": "^2.1.0",
37
- "jsdoc": "^3.6.4",
36
+ "homey-jsdoc-template": "github:athombv/homey-jsdoc-template#1.4",
37
+ "jsdoc": "^3.6.7",
38
+ "jsdoc-ts-utils": "^2.0.0",
38
39
  "mocha": "^7.2.0",
39
- "npm-watch": "^0.6.0",
40
- "serve": "^11.3.1"
40
+ "serve": "^11.3.1",
41
+ "watch": "^1.0.2"
41
42
  },
42
43
  "dependencies": {
43
44
  "@athombv/data-types": "^1.0.4",
44
45
  "debug": "^4.1.1"
45
- },
46
- "watch": {
47
- "jsdoc": {
48
- "patterns": [
49
- "lib"
50
- ],
51
- "extensions": [
52
- "js"
53
- ]
54
- }
55
46
  }
56
47
  }