zigbee-clusters 2.0.1 → 2.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.d.ts CHANGED
@@ -11,14 +11,168 @@ type ConstructorOptions = {
11
11
  sendFrame: (endpointId: number, clusterId: number, frame: Buffer) => Promise<void>;
12
12
  };
13
13
  type ZCLNodeCluster = EventEmitter & {
14
- readAttributes: (
14
+ /**
15
+ * Command which requests the remote cluster to report its generated commands. Generated
16
+ * commands are commands which may be sent by the remote cluster.
17
+ *
18
+ * TODO: handle the case where `lastResponse===false`. It might be possible that there are
19
+ * more commands to be reported than can be transmitted in one report (in practice very
20
+ * unlikely though). If `lastResponse===false` invoke `discoverCommandsGenerated` again
21
+ * starting from the index where the previous invocation stopped (`maxResults`).
22
+ *
23
+ * TODO: The manufacturer-specific sub-field SHALL be set to 0 to discover standard commands
24
+ * in a ZigBee cluster or 1 to discover manufacturer-specific commands in either a standard or
25
+ * a manufacturer-specific cluster. A manufacturer ID in this field of 0xffff (wildcard) will
26
+ * discover any manufacture- specific
27
+ * commands.
28
+ *
29
+ * @param {object} [opts=]
30
+ * @param {number} [opts.startValue=0]
31
+ * @param {number} [opts.maxResults=250]
32
+ * @returns {Promise<number[]>}
33
+ */
34
+ discoverCommandsGenerated({
35
+ startValue,
36
+ maxResults,
37
+ }?: {
38
+ startValue?: number;
39
+ maxResults?: number;
40
+ }): Promise<number[]>;
41
+ /**
42
+ * Command which requests the remote cluster to report its received commands. Received
43
+ * commands are commands which may be received by the remote cluster.
44
+ *
45
+ * TODO: handle the case where `lastResponse===false`. It might be possible that there are
46
+ * more commands to be reported than can be transmitted in one report (in practice very
47
+ * unlikely though). If `lastResponse===false` invoke `discoverCommandsGenerated` again
48
+ * starting from the index where the previous invocation stopped (`maxResults`).
49
+ *
50
+ * TODO: The manufacturer-specific sub-field SHALL be set to 0 to discover standard commands
51
+ * in a ZigBee cluster or 1 to discover manufacturer-specific commands in either a standard or
52
+ * a manufacturer-specific cluster. A manufacturer ID in this field of 0xffff (wildcard) will
53
+ * discover any manufacture- specific commands.
54
+ *
55
+ * @param {object} [opts=]
56
+ * @param {number} [opts.startValue=0]
57
+ * @param {number} [opts.maxResults=255]
58
+ * @returns {Promise<number[]>}
59
+ */
60
+ discoverCommandsReceived({
61
+ startValue,
62
+ maxResults,
63
+ }?: {
64
+ startValue?: number;
65
+ maxResults?: number;
66
+ }): Promise<number[]>;
67
+ /**
68
+ * Command which reads a given set of attributes from the remote cluster.
69
+ * Note: do not mix regular and manufacturer specific attributes.
70
+ * @param {string[]} attributeNames
71
+ * @param {{timeout: number}} [opts=]
72
+ * @returns {Promise<Object.<string, unknown>>} - Object with values (e.g. `{ onOff: true }`)
73
+ */
74
+ readAttributes(
15
75
  attributeNames: string[],
16
- opts: { timeout: number }
17
- ) => Promise<{ [attributeName: string]: any }>;
18
- writeAttributes: (attributes: {
19
- [attributeName: string]: any;
20
- }) => Promise<{ [attributeName: string]: { id: number; status: "SUCCESS" | "FAILURE" } }>;
76
+ opts?: {
77
+ timeout: number;
78
+ }
79
+ ): Promise<{
80
+ [x: string]: unknown;
81
+ }>;
82
+ /**
83
+ * Command which writes a given set of attribute key-value pairs to the remote cluster.
84
+ * Note: do not mix regular and manufacturer specific attributes.
85
+ * @param {object} attributes - Object with attribute names as keys and their values (e.g. `{
86
+ * onOff: true, fakeAttributeName: 10 }`.
87
+ * @returns {Promise<*|{attributes: *}>}
88
+ */
89
+ writeAttributes(attributes?: object): Promise<
90
+ | any
91
+ | {
92
+ attributes: any;
93
+ }
94
+ >;
95
+ /**
96
+ * Command which configures attribute reporting for the given `attributes` on the remote cluster.
97
+ * Note: do not mix regular and manufacturer specific attributes.
98
+ * @param {object} attributes - Attribute reporting configuration (e.g. `{ onOff: {
99
+ * minInterval: 0, maxInterval: 300, minChange: 1 } }`)
100
+ * @returns {Promise<void>}
101
+ */
102
+ configureReporting(attributes?: object): Promise<void>;
103
+ /**
104
+ * @typedef {object} ReadReportingConfiguration
105
+ * @property {ZCLDataTypes.enum8Status} status
106
+ * @property {'reported'|'received'} direction
107
+ * @property {number} attributeId
108
+ * @property {ZCLDataType.id} [attributeDataType]
109
+ * @property {number} [minInterval]
110
+ * @property {number} [maxInterval]
111
+ * @property {number} [minChange]
112
+ * @property {number} [timeoutPeriod]
113
+ */
114
+ /**
115
+ * Command which retrieves the reporting configurations for the given `attributes` from the
116
+ * remote cluster. Currently this only takes the 'reported' into account, this represents the
117
+ * reports the remote cluster would sent out, instead of receive (which is likely the most
118
+ * interesting).
119
+ * Note: do not mix regular and manufacturer specific attributes.
120
+ * @param {Array} attributes - Array with number/strings (either attribute id, or attribute name).
121
+ * @returns {Promise<ReadReportingConfiguration[]>} - Returns array with
122
+ * ReadReportingConfiguration objects per attribute.
123
+ */
124
+ readReportingConfiguration(attributes?: any[]): Promise<
125
+ {
126
+ status: any;
127
+ direction: "reported" | "received";
128
+ attributeId: number;
129
+ attributeDataType?: ZCLDataType.id;
130
+ minInterval?: number;
131
+ maxInterval?: number;
132
+ minChange?: number;
133
+ timeoutPeriod?: number;
134
+ }[]
135
+ >;
136
+ /**
137
+ * Command which discovers the implemented attributes on the remote cluster.
138
+ *
139
+ * TODO: handle the case where `lastResponse===false`. It might be possible that there are
140
+ * more commands to be reported than can be transmitted in one report (in practice very
141
+ * unlikely though). If `lastResponse===false` invoke `discoverCommandsGenerated` again
142
+ * starting from the index where the previous invocation stopped (`maxResults`).
143
+ *
144
+ * TODO: The manufacturer specific sub-field SHALL be set to 0 to discover standard attributes
145
+ * in a ZigBee cluster or 1 to discover manufacturer specific attributes in either a standard
146
+ * or a manufacturer specific cluster.
147
+ *
148
+ * @returns {Promise<Array>} - Array with string or number values (depending on if the
149
+ * attribute
150
+ * is implemented in zigbee-clusters or not).
151
+ */
152
+ discoverAttributes(): Promise<any[]>;
153
+ /**
154
+ * Command which discovers the implemented attributes on the remote cluster, the difference with
155
+ * `discoverAttributes` is that this command also reports the access control field of the
156
+ * attribute (whether it is readable/writable/reportable).
157
+ *
158
+ * TODO: handle the case where `lastResponse===false`. It might be possible that there are
159
+ * more commands to be reported than can be transmitted in one report (in practice very
160
+ * unlikely though). If `lastResponse===false` invoke `discoverCommandsGenerated` again
161
+ * starting from the index where the previous invocation stopped (`maxResults`).
162
+ *
163
+ * TODO: The manufacturer-specific sub-field SHALL be set to 0 to discover standard attributes
164
+ * in a ZigBee cluster or 1 to discover manufacturer-specific attributes in either a standard
165
+ * or a manufacturer- specific cluster. A manufacturer ID in this field of 0xffff (wildcard)
166
+ * will discover any manufacture-specific attributes.
167
+ *
168
+ * @returns {Promise<Array>} - Returns an array with objects with attribute names as keys and
169
+ * following object as values: `{name: string, id: number, acl: { readable: boolean, writable:
170
+ * boolean, reportable: boolean } }`. Note that `name` is optional based on whether the
171
+ * attribute is implemented in zigbee-clusters.
172
+ */
173
+ discoverAttributesExtended(): Promise<any[]>;
21
174
  };
175
+
22
176
  type ZCLNodeEndpoint = {
23
177
  clusters: { [clusterName: string]: ZCLNodeCluster };
24
178
  };
@@ -40,4 +194,5 @@ declare module "zigbee-clusters" {
40
194
  export const CLUSTER: {
41
195
  [key: string]: { ID: number; NAME: string; ATTRIBUTES: any; COMMANDS: any };
42
196
  };
197
+ export var ZCLNodeCluster;
43
198
  }
package/lib/Cluster.js CHANGED
@@ -340,8 +340,9 @@ class Cluster extends EventEmitter {
340
340
  * discover any manufacture- specific
341
341
  * commands.
342
342
  *
343
- * @param {number} [startValue=0]
344
- * @param {number} [maxResults=250]
343
+ * @param {object} [opts=]
344
+ * @param {number} [opts.startValue=0]
345
+ * @param {number} [opts.maxResults=250]
345
346
  * @returns {Promise<number[]>}
346
347
  */
347
348
  async discoverCommandsGenerated({ startValue = 0, maxResults = 250 } = {}) {
@@ -374,8 +375,9 @@ class Cluster extends EventEmitter {
374
375
  * a manufacturer-specific cluster. A manufacturer ID in this field of 0xffff (wildcard) will
375
376
  * discover any manufacture- specific commands.
376
377
  *
377
- * @param {number} [startValue=0]
378
- * @param {number} [maxResults=250]
378
+ * @param {object} [opts=]
379
+ * @param {number} [opts.startValue=0]
380
+ * @param {number} [opts.maxResults=255]
379
381
  * @returns {Promise<number[]>}
380
382
  */
381
383
  async discoverCommandsReceived({ startValue = 0, maxResults = 255 } = {}) {
@@ -398,8 +400,8 @@ class Cluster extends EventEmitter {
398
400
  * Command which reads a given set of attributes from the remote cluster.
399
401
  * Note: do not mix regular and manufacturer specific attributes.
400
402
  * @param {string[]} attributeNames
401
- * @param {{timeout: number}} opts
402
- * @returns {Promise<{}>} - Object with attribute values (e.g. `{ onOff: true }`)
403
+ * @param {{timeout: number}} [opts=]
404
+ * @returns {Promise<Object.<string, unknown>>} - Object with values (e.g. `{ onOff: true }`)
403
405
  */
404
406
  async readAttributes(attributeNames, opts) {
405
407
  if (attributeNames instanceof Array === false) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zigbee-clusters",
3
- "version": "2.0.1",
3
+ "version": "2.1.1",
4
4
  "description": "Zigbee Cluster Library for Node.js",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
package/tsconfig.json ADDED
@@ -0,0 +1,21 @@
1
+ {
2
+ // Change this to match your project
3
+ "include": ["lib/**/*", "index.js"],
4
+ "compilerOptions": {
5
+ // Tells TypeScript to read JS files, as
6
+ // normally they are ignored as source files
7
+ "allowJs": true,
8
+ // Generate d.ts files
9
+ "declaration": true,
10
+ // This compiler run should
11
+ // only output d.ts files
12
+ "emitDeclarationOnly": true,
13
+ // Types should go into this directory.
14
+ // Removing this would place the .d.ts files
15
+ // next to the .js files
16
+ "outDir": "dist",
17
+ // go to js file when using IDE functions like
18
+ // "Go to Definition" in VSCode
19
+ "declarationMap": true
20
+ }
21
+ }