zigbee-clusters 2.8.2 → 2.9.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/index.d.ts +84 -0
- package/index.js +5 -0
- package/lib/constants.js +97 -0
- package/package.json +1 -1
- package/scripts/generate-types.js +36 -2
package/index.d.ts
CHANGED
|
@@ -1829,6 +1829,87 @@ export const WindowCoveringCluster: {
|
|
|
1829
1829
|
COMMANDS: unknown;
|
|
1830
1830
|
};
|
|
1831
1831
|
|
|
1832
|
+
export const ZIGBEE_PROFILE_ID: {
|
|
1833
|
+
INDUSTRIAL_PLANT_MONITORING: 257;
|
|
1834
|
+
HOME_AUTOMATION: 260;
|
|
1835
|
+
COMMERCIAL_BUILDING_AUTOMATION: 261;
|
|
1836
|
+
TELECOM_APPLICATIONS: 263;
|
|
1837
|
+
PERSONAL_HOME_AND_HOSPITAL_CARE: 264;
|
|
1838
|
+
ADVANCED_METERING_INITIATIVE: 265;
|
|
1839
|
+
};
|
|
1840
|
+
|
|
1841
|
+
export const ZIGBEE_DEVICE_ID: {
|
|
1842
|
+
GENERIC: {
|
|
1843
|
+
ON_OFF_SWITCH: 0;
|
|
1844
|
+
LEVEL_CONTROL_SWITCH: 1;
|
|
1845
|
+
ON_OFF_OUTPUT: 2;
|
|
1846
|
+
LEVEL_CONTROLLABLE_OUTPUT: 3;
|
|
1847
|
+
SCENE_SELECTOR: 4;
|
|
1848
|
+
CONFIGURATION_TOOL: 5;
|
|
1849
|
+
REMOTE_CONTROL: 6;
|
|
1850
|
+
COMBINED_INTERFACE: 7;
|
|
1851
|
+
RANGE_EXTENDER: 8;
|
|
1852
|
+
MAINS_POWER_OUTLET: 9;
|
|
1853
|
+
DOOR_LOCK: 10;
|
|
1854
|
+
DOOR_LOCK_CONTROLLER: 11;
|
|
1855
|
+
SIMPLE_SENSOR: 12;
|
|
1856
|
+
CONSUMPTION_AWARENESS_DEVICE: 13;
|
|
1857
|
+
HOME_GATEWAY: 80;
|
|
1858
|
+
SMART_PLUG: 81;
|
|
1859
|
+
WHITE_GOODS: 82;
|
|
1860
|
+
METER_INTERFACE: 83;
|
|
1861
|
+
};
|
|
1862
|
+
LIGHTING: {
|
|
1863
|
+
ON_OFF_LIGHT: 256;
|
|
1864
|
+
DIMMABLE_LIGHT: 257;
|
|
1865
|
+
COLOR_DIMMABLE_LIGHT: 258;
|
|
1866
|
+
ON_OFF_LIGHT_SWITCH: 259;
|
|
1867
|
+
DIMMER_SWITCH: 260;
|
|
1868
|
+
COLOR_DIMMER_SWITCH: 261;
|
|
1869
|
+
LIGHT_SENSOR: 262;
|
|
1870
|
+
OCCUPANCY_SENSOR: 263;
|
|
1871
|
+
};
|
|
1872
|
+
CLOSURES: {
|
|
1873
|
+
SHADE: 512;
|
|
1874
|
+
SHADE_CONTROLLER: 513;
|
|
1875
|
+
WINDOW_COVERING_DEVICE: 514;
|
|
1876
|
+
WINDOW_COVERING_CONTROLLER: 515;
|
|
1877
|
+
};
|
|
1878
|
+
HVAC: {
|
|
1879
|
+
HEATING_COOLING_UNIT: 768;
|
|
1880
|
+
THERMOSTAT: 769;
|
|
1881
|
+
TEMPERATURE_SENSOR: 770;
|
|
1882
|
+
PUMP: 771;
|
|
1883
|
+
PUMP_CONTROLLER: 772;
|
|
1884
|
+
PRESSURE_SENSOR: 773;
|
|
1885
|
+
FLOW_SENSOR: 774;
|
|
1886
|
+
};
|
|
1887
|
+
INTRUDER_ALARM_SYSTEMS: {
|
|
1888
|
+
IAS_CONTROL_INDICATING_EQUIPMENT: 1024;
|
|
1889
|
+
IAS_ANCILLARY_CONTROL_EQUIPMENT: 1025;
|
|
1890
|
+
IAS_ZONE: 1026;
|
|
1891
|
+
IAS_WARNING_DEVICE: 1027;
|
|
1892
|
+
};
|
|
1893
|
+
};
|
|
1894
|
+
|
|
1895
|
+
export const IAS_ZONE_TYPE: {
|
|
1896
|
+
STANDARD_CIE: 0;
|
|
1897
|
+
MOTION_SENSOR: 13;
|
|
1898
|
+
CONTACT_SWITCH: 21;
|
|
1899
|
+
FIRE_SENSOR: 40;
|
|
1900
|
+
WATER_SENSOR: 42;
|
|
1901
|
+
CARBON_MONOXIDE_SENSOR: 43;
|
|
1902
|
+
PERSONAL_EMERGENCY_DEVICE: 44;
|
|
1903
|
+
VIBRATION_MOVEMENT_SENSOR: 45;
|
|
1904
|
+
REMOTE_CONTROL: 271;
|
|
1905
|
+
KEY_FOB: 277;
|
|
1906
|
+
KEYPAD: 541;
|
|
1907
|
+
STANDARD_WARNING_DEVICE: 549;
|
|
1908
|
+
GLASS_BREAK_SENSOR: 550;
|
|
1909
|
+
SECURITY_REPEATER: 553;
|
|
1910
|
+
INVALID_ZONE_TYPE: 65535;
|
|
1911
|
+
};
|
|
1912
|
+
|
|
1832
1913
|
declare const _default: {
|
|
1833
1914
|
ZCLNode: typeof ZCLNode;
|
|
1834
1915
|
CLUSTER: typeof CLUSTER;
|
|
@@ -1878,5 +1959,8 @@ declare const _default: {
|
|
|
1878
1959
|
TimeCluster: typeof TimeCluster;
|
|
1879
1960
|
TouchLinkCluster: typeof TouchLinkCluster;
|
|
1880
1961
|
WindowCoveringCluster: typeof WindowCoveringCluster;
|
|
1962
|
+
ZIGBEE_PROFILE_ID: typeof ZIGBEE_PROFILE_ID;
|
|
1963
|
+
ZIGBEE_DEVICE_ID: typeof ZIGBEE_DEVICE_ID;
|
|
1964
|
+
IAS_ZONE_TYPE: typeof IAS_ZONE_TYPE;
|
|
1881
1965
|
};
|
|
1882
1966
|
export default _default;
|
package/index.js
CHANGED
|
@@ -44,6 +44,8 @@ const {
|
|
|
44
44
|
ZCLStruct,
|
|
45
45
|
} = zclTypes;
|
|
46
46
|
|
|
47
|
+
const { ZIGBEE_PROFILE_ID, ZIGBEE_DEVICE_ID, IAS_ZONE_TYPE } = require('./lib/constants');
|
|
48
|
+
|
|
47
49
|
module.exports = {
|
|
48
50
|
Cluster,
|
|
49
51
|
BoundCluster,
|
|
@@ -55,4 +57,7 @@ module.exports = {
|
|
|
55
57
|
ZCLStruct,
|
|
56
58
|
...Clusters,
|
|
57
59
|
debug,
|
|
60
|
+
ZIGBEE_PROFILE_ID,
|
|
61
|
+
ZIGBEE_DEVICE_ID,
|
|
62
|
+
IAS_ZONE_TYPE,
|
|
58
63
|
};
|
package/lib/constants.js
ADDED
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Zigbee Profile IDs from the ZCL specification.
|
|
5
|
+
*/
|
|
6
|
+
const ZIGBEE_PROFILE_ID = {
|
|
7
|
+
INDUSTRIAL_PLANT_MONITORING: 0x0101,
|
|
8
|
+
HOME_AUTOMATION: 0x0104,
|
|
9
|
+
COMMERCIAL_BUILDING_AUTOMATION: 0x0105,
|
|
10
|
+
TELECOM_APPLICATIONS: 0x0107,
|
|
11
|
+
PERSONAL_HOME_AND_HOSPITAL_CARE: 0x0108,
|
|
12
|
+
ADVANCED_METERING_INITIATIVE: 0x0109,
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Zigbee Device IDs from the ZCL specification.
|
|
17
|
+
*/
|
|
18
|
+
const ZIGBEE_DEVICE_ID = {
|
|
19
|
+
GENERIC: {
|
|
20
|
+
ON_OFF_SWITCH: 0x0000,
|
|
21
|
+
LEVEL_CONTROL_SWITCH: 0x0001,
|
|
22
|
+
ON_OFF_OUTPUT: 0x0002,
|
|
23
|
+
LEVEL_CONTROLLABLE_OUTPUT: 0x0003,
|
|
24
|
+
SCENE_SELECTOR: 0x0004,
|
|
25
|
+
CONFIGURATION_TOOL: 0x0005,
|
|
26
|
+
REMOTE_CONTROL: 0x0006,
|
|
27
|
+
COMBINED_INTERFACE: 0x0007,
|
|
28
|
+
RANGE_EXTENDER: 0x0008,
|
|
29
|
+
MAINS_POWER_OUTLET: 0x0009,
|
|
30
|
+
DOOR_LOCK: 0x000a,
|
|
31
|
+
DOOR_LOCK_CONTROLLER: 0x000b,
|
|
32
|
+
SIMPLE_SENSOR: 0x000c,
|
|
33
|
+
CONSUMPTION_AWARENESS_DEVICE: 0x000d,
|
|
34
|
+
HOME_GATEWAY: 0x0050,
|
|
35
|
+
SMART_PLUG: 0x0051,
|
|
36
|
+
WHITE_GOODS: 0x0052,
|
|
37
|
+
METER_INTERFACE: 0x0053,
|
|
38
|
+
},
|
|
39
|
+
LIGHTING: {
|
|
40
|
+
ON_OFF_LIGHT: 0x0100,
|
|
41
|
+
DIMMABLE_LIGHT: 0x0101,
|
|
42
|
+
COLOR_DIMMABLE_LIGHT: 0x0102,
|
|
43
|
+
ON_OFF_LIGHT_SWITCH: 0x0103,
|
|
44
|
+
DIMMER_SWITCH: 0x0104,
|
|
45
|
+
COLOR_DIMMER_SWITCH: 0x0105,
|
|
46
|
+
LIGHT_SENSOR: 0x0106,
|
|
47
|
+
OCCUPANCY_SENSOR: 0x0107,
|
|
48
|
+
},
|
|
49
|
+
CLOSURES: {
|
|
50
|
+
SHADE: 0x0200,
|
|
51
|
+
SHADE_CONTROLLER: 0x0201,
|
|
52
|
+
WINDOW_COVERING_DEVICE: 0x0202,
|
|
53
|
+
WINDOW_COVERING_CONTROLLER: 0x0203,
|
|
54
|
+
},
|
|
55
|
+
HVAC: {
|
|
56
|
+
HEATING_COOLING_UNIT: 0x0300,
|
|
57
|
+
THERMOSTAT: 0x0301,
|
|
58
|
+
TEMPERATURE_SENSOR: 0x0302,
|
|
59
|
+
PUMP: 0x0303,
|
|
60
|
+
PUMP_CONTROLLER: 0x0304,
|
|
61
|
+
PRESSURE_SENSOR: 0x0305,
|
|
62
|
+
FLOW_SENSOR: 0x0306,
|
|
63
|
+
},
|
|
64
|
+
INTRUDER_ALARM_SYSTEMS: {
|
|
65
|
+
IAS_CONTROL_INDICATING_EQUIPMENT: 0x0400,
|
|
66
|
+
IAS_ANCILLARY_CONTROL_EQUIPMENT: 0x0401,
|
|
67
|
+
IAS_ZONE: 0x0402,
|
|
68
|
+
IAS_WARNING_DEVICE: 0x0403,
|
|
69
|
+
},
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* IAS Zone Type values from the ZCL specification (IAS Zone cluster, zoneType attribute).
|
|
74
|
+
*/
|
|
75
|
+
const IAS_ZONE_TYPE = {
|
|
76
|
+
STANDARD_CIE: 0x0000,
|
|
77
|
+
MOTION_SENSOR: 0x000d,
|
|
78
|
+
CONTACT_SWITCH: 0x0015,
|
|
79
|
+
FIRE_SENSOR: 0x0028,
|
|
80
|
+
WATER_SENSOR: 0x002a,
|
|
81
|
+
CARBON_MONOXIDE_SENSOR: 0x002b,
|
|
82
|
+
PERSONAL_EMERGENCY_DEVICE: 0x002c,
|
|
83
|
+
VIBRATION_MOVEMENT_SENSOR: 0x002d,
|
|
84
|
+
REMOTE_CONTROL: 0x010f,
|
|
85
|
+
KEY_FOB: 0x0115,
|
|
86
|
+
KEYPAD: 0x021d,
|
|
87
|
+
STANDARD_WARNING_DEVICE: 0x0225,
|
|
88
|
+
GLASS_BREAK_SENSOR: 0x0226,
|
|
89
|
+
SECURITY_REPEATER: 0x0229,
|
|
90
|
+
INVALID_ZONE_TYPE: 0xffff,
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
module.exports = {
|
|
94
|
+
ZIGBEE_PROFILE_ID,
|
|
95
|
+
ZIGBEE_DEVICE_ID,
|
|
96
|
+
IAS_ZONE_TYPE,
|
|
97
|
+
};
|
package/package.json
CHANGED
|
@@ -217,7 +217,22 @@ function generateClusterInterface(cluster) {
|
|
|
217
217
|
* }>} clusterDefinitions - Array of CLUSTER definitions used to generate typed CLUSTER exports
|
|
218
218
|
* @returns {string} Complete TypeScript definitions file
|
|
219
219
|
*/
|
|
220
|
-
function
|
|
220
|
+
function generateConstantObject(obj, indent = 2) {
|
|
221
|
+
const lines = [];
|
|
222
|
+
const pad = ' '.repeat(indent);
|
|
223
|
+
for (const [key, value] of Object.entries(obj)) {
|
|
224
|
+
if (typeof value === 'object' && value !== null) {
|
|
225
|
+
lines.push(`${pad}${key}: {`);
|
|
226
|
+
lines.push(generateConstantObject(value, indent + 2));
|
|
227
|
+
lines.push(`${pad}};`);
|
|
228
|
+
} else {
|
|
229
|
+
lines.push(`${pad}${key}: ${typeof value === 'number' ? value : JSON.stringify(value)};`);
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
return lines.join('\n');
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
function generateTypesFile(clusters, clusterDefinitions, constants) {
|
|
221
236
|
const lines = [];
|
|
222
237
|
|
|
223
238
|
// Header
|
|
@@ -400,6 +415,16 @@ export const CLUSTER: {
|
|
|
400
415
|
lines.push('};');
|
|
401
416
|
}
|
|
402
417
|
|
|
418
|
+
// Export constants
|
|
419
|
+
if (constants) {
|
|
420
|
+
for (const [name, value] of Object.entries(constants)) {
|
|
421
|
+
lines.push('');
|
|
422
|
+
lines.push(`export const ${name}: {`);
|
|
423
|
+
lines.push(generateConstantObject(value));
|
|
424
|
+
lines.push('};');
|
|
425
|
+
}
|
|
426
|
+
}
|
|
427
|
+
|
|
403
428
|
lines.push('');
|
|
404
429
|
lines.push('declare const _default: {');
|
|
405
430
|
lines.push(' ZCLNode: typeof ZCLNode;');
|
|
@@ -408,6 +433,11 @@ export const CLUSTER: {
|
|
|
408
433
|
const exportName = cluster.exportName || toInterfaceName(cluster);
|
|
409
434
|
lines.push(` ${exportName}: typeof ${exportName};`);
|
|
410
435
|
}
|
|
436
|
+
if (constants) {
|
|
437
|
+
for (const name of Object.keys(constants)) {
|
|
438
|
+
lines.push(` ${name}: typeof ${name};`);
|
|
439
|
+
}
|
|
440
|
+
}
|
|
411
441
|
lines.push('};');
|
|
412
442
|
lines.push('export default _default;');
|
|
413
443
|
|
|
@@ -448,8 +478,12 @@ function main() {
|
|
|
448
478
|
}))
|
|
449
479
|
.sort((a, b) => a.constantName.localeCompare(b.constantName));
|
|
450
480
|
|
|
481
|
+
// Load constants
|
|
482
|
+
const { ZIGBEE_PROFILE_ID, ZIGBEE_DEVICE_ID, IAS_ZONE_TYPE } = require('../lib/constants');
|
|
483
|
+
const constants = { ZIGBEE_PROFILE_ID, ZIGBEE_DEVICE_ID, IAS_ZONE_TYPE };
|
|
484
|
+
|
|
451
485
|
console.log(`\nGenerating ${OUTPUT_FILE}...`);
|
|
452
|
-
const output = generateTypesFile(clusters, clusterDefinitions);
|
|
486
|
+
const output = generateTypesFile(clusters, clusterDefinitions, constants);
|
|
453
487
|
fs.writeFileSync(OUTPUT_FILE, output);
|
|
454
488
|
|
|
455
489
|
console.log(`Done! Generated types for ${clusters.length} clusters.`);
|