zigbee-clusters 2.8.2 → 2.9.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 +86 -22
- package/index.js +5 -0
- package/lib/clusters/metering.js +41 -21
- package/lib/constants.js +97 -0
- package/package.json +1 -1
- package/scripts/generate-types.js +36 -2
package/index.d.ts
CHANGED
|
@@ -579,32 +579,22 @@ export interface MeteringClusterAttributes {
|
|
|
579
579
|
currentTier3SummationReceived?: number;
|
|
580
580
|
currentTier4SummationDelivered?: number;
|
|
581
581
|
currentTier4SummationReceived?: number;
|
|
582
|
-
status?:
|
|
582
|
+
status?: Partial<{ checkMeter: boolean; lowBattery: boolean; tamperDetect: boolean; powerFailure: boolean; powerQuality: boolean; leakDetect: boolean; serviceDisconnect: boolean }>;
|
|
583
583
|
remainingBatteryLife?: number;
|
|
584
584
|
hoursInOperation?: number;
|
|
585
585
|
hoursInFault?: number;
|
|
586
|
-
extendedStatus?: unknown;
|
|
587
586
|
unitOfMeasure?: unknown;
|
|
588
587
|
multiplier?: number;
|
|
589
588
|
divisor?: number;
|
|
590
|
-
summationFormatting?: unknown;
|
|
591
|
-
demandFormatting?: unknown;
|
|
592
|
-
historicalConsumptionFormatting?: unknown;
|
|
593
|
-
meteringDeviceType?: unknown;
|
|
594
589
|
siteId?: Buffer;
|
|
595
590
|
meterSerialNumber?: Buffer;
|
|
596
591
|
energyCarrierUnitOfMeasure?: unknown;
|
|
597
|
-
energyCarrierSummationFormatting?: unknown;
|
|
598
|
-
energyCarrierDemandFormatting?: unknown;
|
|
599
592
|
temperatureUnitOfMeasure?: unknown;
|
|
600
|
-
temperatureFormatting?: unknown;
|
|
601
593
|
moduleSerialNumber?: Buffer;
|
|
602
594
|
operatingTariffLabelDelivered?: Buffer;
|
|
603
595
|
operatingTariffLabelReceived?: Buffer;
|
|
604
596
|
customerIdNumber?: Buffer;
|
|
605
597
|
alternativeUnitOfMeasure?: unknown;
|
|
606
|
-
alternativeDemandFormatting?: unknown;
|
|
607
|
-
alternativeConsumptionFormatting?: unknown;
|
|
608
598
|
instantaneousDemand?: number;
|
|
609
599
|
currentDayConsumptionDelivered?: number;
|
|
610
600
|
currentDayConsumptionReceived?: number;
|
|
@@ -714,14 +704,6 @@ export interface MeteringClusterAttributes {
|
|
|
714
704
|
currentTier4Block14SummationDelivered?: number;
|
|
715
705
|
currentTier4Block15SummationDelivered?: number;
|
|
716
706
|
currentTier4Block16SummationDelivered?: number;
|
|
717
|
-
genericAlarmMask?: unknown;
|
|
718
|
-
electricityAlarmMask?: unknown;
|
|
719
|
-
genericFlowPressureAlarmMask?: unknown;
|
|
720
|
-
waterSpecificAlarmMask?: unknown;
|
|
721
|
-
heatAndCoolingSpecificAlarmMask?: unknown;
|
|
722
|
-
gasSpecificAlarmMask?: unknown;
|
|
723
|
-
extendedGenericAlarmMask?: unknown;
|
|
724
|
-
manufacturerAlarmMask?: unknown;
|
|
725
707
|
currentNoTierBlock1SummationReceived?: number;
|
|
726
708
|
currentNoTierBlock2SummationReceived?: number;
|
|
727
709
|
currentNoTierBlock3SummationReceived?: number;
|
|
@@ -742,12 +724,10 @@ export interface MeteringClusterAttributes {
|
|
|
742
724
|
billToDateTimeStampDelivered?: number;
|
|
743
725
|
projectedBillDelivered?: number;
|
|
744
726
|
projectedBillTimeStampDelivered?: number;
|
|
745
|
-
billDeliveredTrailingDigit?: unknown;
|
|
746
727
|
billToDateReceived?: number;
|
|
747
728
|
billToDateTimeStampReceived?: number;
|
|
748
729
|
projectedBillReceived?: number;
|
|
749
730
|
projectedBillTimeStampReceived?: number;
|
|
750
|
-
billReceivedTrailingDigit?: unknown;
|
|
751
731
|
proposedChangeSupplyImplementationTime?: number;
|
|
752
732
|
proposedChangeSupplyStatus?: unknown;
|
|
753
733
|
uncontrolledFlowThreshold?: number;
|
|
@@ -759,7 +739,7 @@ export interface MeteringClusterAttributes {
|
|
|
759
739
|
}
|
|
760
740
|
|
|
761
741
|
export interface MeteringCluster extends ZCLNodeCluster {
|
|
762
|
-
readAttributes<K extends 'currentSummationDelivered' | 'currentSummationReceived' | 'currentMaxDemandDelivered' | 'currentMaxDemandReceived' | 'dftSummation' | 'dailyFreezeTime' | 'powerFactor' | 'readingSnapShotTime' | 'currentMaxDemandDeliveredTime' | 'currentMaxDemandReceivedTime' | 'defaultUpdatePeriod' | 'fastPollUpdatePeriod' | 'currentBlockPeriodConsumptionDelivered' | 'dailyConsumptionTarget' | 'currentBlock' | 'profileIntervalPeriod' | 'currentTier1SummationDelivered' | 'currentTier1SummationReceived' | 'currentTier2SummationDelivered' | 'currentTier2SummationReceived' | 'currentTier3SummationDelivered' | 'currentTier3SummationReceived' | 'currentTier4SummationDelivered' | 'currentTier4SummationReceived' | 'status' | 'remainingBatteryLife' | 'hoursInOperation' | 'hoursInFault' | '
|
|
742
|
+
readAttributes<K extends 'currentSummationDelivered' | 'currentSummationReceived' | 'currentMaxDemandDelivered' | 'currentMaxDemandReceived' | 'dftSummation' | 'dailyFreezeTime' | 'powerFactor' | 'readingSnapShotTime' | 'currentMaxDemandDeliveredTime' | 'currentMaxDemandReceivedTime' | 'defaultUpdatePeriod' | 'fastPollUpdatePeriod' | 'currentBlockPeriodConsumptionDelivered' | 'dailyConsumptionTarget' | 'currentBlock' | 'profileIntervalPeriod' | 'currentTier1SummationDelivered' | 'currentTier1SummationReceived' | 'currentTier2SummationDelivered' | 'currentTier2SummationReceived' | 'currentTier3SummationDelivered' | 'currentTier3SummationReceived' | 'currentTier4SummationDelivered' | 'currentTier4SummationReceived' | 'status' | 'remainingBatteryLife' | 'hoursInOperation' | 'hoursInFault' | 'unitOfMeasure' | 'multiplier' | 'divisor' | 'siteId' | 'meterSerialNumber' | 'energyCarrierUnitOfMeasure' | 'temperatureUnitOfMeasure' | 'moduleSerialNumber' | 'operatingTariffLabelDelivered' | 'operatingTariffLabelReceived' | 'customerIdNumber' | 'alternativeUnitOfMeasure' | 'instantaneousDemand' | 'currentDayConsumptionDelivered' | 'currentDayConsumptionReceived' | 'previousDayConsumptionDelivered' | 'previousDayConsumptionReceived' | 'currentPartialProfileIntervalStartTimeDelivered' | 'currentPartialProfileIntervalStartTimeReceived' | 'currentPartialProfileIntervalValueDelivered' | 'currentPartialProfileIntervalValueReceived' | 'currentDayMaxPressure' | 'currentDayMinPressure' | 'previousDayMaxPressure' | 'previousDayMinPressure' | 'currentDayMaxDemand' | 'previousDayMaxDemand' | 'currentMonthMaxDemand' | 'currentYearMaxDemand' | 'currentDayMaxEnergyCarrierDemand' | 'previousDayMaxEnergyCarrierDemand' | 'currentMonthMaxEnergyCarrierDemand' | 'currentMonthMinEnergyCarrierDemand' | 'currentYearMaxEnergyCarrierDemand' | 'currentYearMinEnergyCarrierDemand' | 'maxNumberOfPeriodsDelivered' | 'currentDemandDelivered' | 'demandLimit' | 'demandIntegrationPeriod' | 'numberOfDemandSubintervals' | 'demandLimitArmDuration' | 'currentNoTierBlock1SummationDelivered' | 'currentNoTierBlock2SummationDelivered' | 'currentNoTierBlock3SummationDelivered' | 'currentNoTierBlock4SummationDelivered' | 'currentNoTierBlock5SummationDelivered' | 'currentNoTierBlock6SummationDelivered' | 'currentNoTierBlock7SummationDelivered' | 'currentNoTierBlock8SummationDelivered' | 'currentNoTierBlock9SummationDelivered' | 'currentNoTierBlock10SummationDelivered' | 'currentNoTierBlock11SummationDelivered' | 'currentNoTierBlock12SummationDelivered' | 'currentNoTierBlock13SummationDelivered' | 'currentNoTierBlock14SummationDelivered' | 'currentNoTierBlock15SummationDelivered' | 'currentNoTierBlock16SummationDelivered' | 'currentTier1Block1SummationDelivered' | 'currentTier1Block2SummationDelivered' | 'currentTier1Block3SummationDelivered' | 'currentTier1Block4SummationDelivered' | 'currentTier1Block5SummationDelivered' | 'currentTier1Block6SummationDelivered' | 'currentTier1Block7SummationDelivered' | 'currentTier1Block8SummationDelivered' | 'currentTier1Block9SummationDelivered' | 'currentTier1Block10SummationDelivered' | 'currentTier1Block11SummationDelivered' | 'currentTier1Block12SummationDelivered' | 'currentTier1Block13SummationDelivered' | 'currentTier1Block14SummationDelivered' | 'currentTier1Block15SummationDelivered' | 'currentTier1Block16SummationDelivered' | 'currentTier2Block1SummationDelivered' | 'currentTier2Block2SummationDelivered' | 'currentTier2Block3SummationDelivered' | 'currentTier2Block4SummationDelivered' | 'currentTier2Block5SummationDelivered' | 'currentTier2Block6SummationDelivered' | 'currentTier2Block7SummationDelivered' | 'currentTier2Block8SummationDelivered' | 'currentTier2Block9SummationDelivered' | 'currentTier2Block10SummationDelivered' | 'currentTier2Block11SummationDelivered' | 'currentTier2Block12SummationDelivered' | 'currentTier2Block13SummationDelivered' | 'currentTier2Block14SummationDelivered' | 'currentTier2Block15SummationDelivered' | 'currentTier2Block16SummationDelivered' | 'currentTier3Block1SummationDelivered' | 'currentTier3Block2SummationDelivered' | 'currentTier3Block3SummationDelivered' | 'currentTier3Block4SummationDelivered' | 'currentTier3Block5SummationDelivered' | 'currentTier3Block6SummationDelivered' | 'currentTier3Block7SummationDelivered' | 'currentTier3Block8SummationDelivered' | 'currentTier3Block9SummationDelivered' | 'currentTier3Block10SummationDelivered' | 'currentTier3Block11SummationDelivered' | 'currentTier3Block12SummationDelivered' | 'currentTier3Block13SummationDelivered' | 'currentTier3Block14SummationDelivered' | 'currentTier3Block15SummationDelivered' | 'currentTier3Block16SummationDelivered' | 'currentTier4Block1SummationDelivered' | 'currentTier4Block2SummationDelivered' | 'currentTier4Block3SummationDelivered' | 'currentTier4Block4SummationDelivered' | 'currentTier4Block5SummationDelivered' | 'currentTier4Block6SummationDelivered' | 'currentTier4Block7SummationDelivered' | 'currentTier4Block8SummationDelivered' | 'currentTier4Block9SummationDelivered' | 'currentTier4Block10SummationDelivered' | 'currentTier4Block11SummationDelivered' | 'currentTier4Block12SummationDelivered' | 'currentTier4Block13SummationDelivered' | 'currentTier4Block14SummationDelivered' | 'currentTier4Block15SummationDelivered' | 'currentTier4Block16SummationDelivered' | 'currentNoTierBlock1SummationReceived' | 'currentNoTierBlock2SummationReceived' | 'currentNoTierBlock3SummationReceived' | 'currentNoTierBlock4SummationReceived' | 'currentNoTierBlock5SummationReceived' | 'currentNoTierBlock6SummationReceived' | 'currentNoTierBlock7SummationReceived' | 'currentNoTierBlock8SummationReceived' | 'currentNoTierBlock9SummationReceived' | 'currentNoTierBlock10SummationReceived' | 'currentNoTierBlock11SummationReceived' | 'currentNoTierBlock12SummationReceived' | 'currentNoTierBlock13SummationReceived' | 'currentNoTierBlock14SummationReceived' | 'currentNoTierBlock15SummationReceived' | 'currentNoTierBlock16SummationReceived' | 'billToDateDelivered' | 'billToDateTimeStampDelivered' | 'projectedBillDelivered' | 'projectedBillTimeStampDelivered' | 'billToDateReceived' | 'billToDateTimeStampReceived' | 'projectedBillReceived' | 'projectedBillTimeStampReceived' | 'proposedChangeSupplyImplementationTime' | 'proposedChangeSupplyStatus' | 'uncontrolledFlowThreshold' | 'uncontrolledFlowThresholdUnitOfMeasure' | 'uncontrolledFlowMultiplier' | 'uncontrolledFlowDivisor' | 'flowStabilisationPeriod' | 'flowMeasurementPeriod'>(attributeNames: K[], opts?: { timeout?: number }): Promise<Pick<MeteringClusterAttributes, K>>;
|
|
763
743
|
readAttributes(attributeNames: Array<keyof MeteringClusterAttributes | number>, opts?: { timeout?: number }): Promise<Partial<MeteringClusterAttributes> & Record<number, unknown>>;
|
|
764
744
|
writeAttributes(attributes: Partial<MeteringClusterAttributes>, opts?: { timeout?: number }): Promise<unknown>;
|
|
765
745
|
on<K extends keyof MeteringClusterAttributes & string>(eventName: `attr.${K}`, listener: (value: MeteringClusterAttributes[K]) => void): this;
|
|
@@ -1829,6 +1809,87 @@ export const WindowCoveringCluster: {
|
|
|
1829
1809
|
COMMANDS: unknown;
|
|
1830
1810
|
};
|
|
1831
1811
|
|
|
1812
|
+
export const ZIGBEE_PROFILE_ID: {
|
|
1813
|
+
INDUSTRIAL_PLANT_MONITORING: 257;
|
|
1814
|
+
HOME_AUTOMATION: 260;
|
|
1815
|
+
COMMERCIAL_BUILDING_AUTOMATION: 261;
|
|
1816
|
+
TELECOM_APPLICATIONS: 263;
|
|
1817
|
+
PERSONAL_HOME_AND_HOSPITAL_CARE: 264;
|
|
1818
|
+
ADVANCED_METERING_INITIATIVE: 265;
|
|
1819
|
+
};
|
|
1820
|
+
|
|
1821
|
+
export const ZIGBEE_DEVICE_ID: {
|
|
1822
|
+
GENERIC: {
|
|
1823
|
+
ON_OFF_SWITCH: 0;
|
|
1824
|
+
LEVEL_CONTROL_SWITCH: 1;
|
|
1825
|
+
ON_OFF_OUTPUT: 2;
|
|
1826
|
+
LEVEL_CONTROLLABLE_OUTPUT: 3;
|
|
1827
|
+
SCENE_SELECTOR: 4;
|
|
1828
|
+
CONFIGURATION_TOOL: 5;
|
|
1829
|
+
REMOTE_CONTROL: 6;
|
|
1830
|
+
COMBINED_INTERFACE: 7;
|
|
1831
|
+
RANGE_EXTENDER: 8;
|
|
1832
|
+
MAINS_POWER_OUTLET: 9;
|
|
1833
|
+
DOOR_LOCK: 10;
|
|
1834
|
+
DOOR_LOCK_CONTROLLER: 11;
|
|
1835
|
+
SIMPLE_SENSOR: 12;
|
|
1836
|
+
CONSUMPTION_AWARENESS_DEVICE: 13;
|
|
1837
|
+
HOME_GATEWAY: 80;
|
|
1838
|
+
SMART_PLUG: 81;
|
|
1839
|
+
WHITE_GOODS: 82;
|
|
1840
|
+
METER_INTERFACE: 83;
|
|
1841
|
+
};
|
|
1842
|
+
LIGHTING: {
|
|
1843
|
+
ON_OFF_LIGHT: 256;
|
|
1844
|
+
DIMMABLE_LIGHT: 257;
|
|
1845
|
+
COLOR_DIMMABLE_LIGHT: 258;
|
|
1846
|
+
ON_OFF_LIGHT_SWITCH: 259;
|
|
1847
|
+
DIMMER_SWITCH: 260;
|
|
1848
|
+
COLOR_DIMMER_SWITCH: 261;
|
|
1849
|
+
LIGHT_SENSOR: 262;
|
|
1850
|
+
OCCUPANCY_SENSOR: 263;
|
|
1851
|
+
};
|
|
1852
|
+
CLOSURES: {
|
|
1853
|
+
SHADE: 512;
|
|
1854
|
+
SHADE_CONTROLLER: 513;
|
|
1855
|
+
WINDOW_COVERING_DEVICE: 514;
|
|
1856
|
+
WINDOW_COVERING_CONTROLLER: 515;
|
|
1857
|
+
};
|
|
1858
|
+
HVAC: {
|
|
1859
|
+
HEATING_COOLING_UNIT: 768;
|
|
1860
|
+
THERMOSTAT: 769;
|
|
1861
|
+
TEMPERATURE_SENSOR: 770;
|
|
1862
|
+
PUMP: 771;
|
|
1863
|
+
PUMP_CONTROLLER: 772;
|
|
1864
|
+
PRESSURE_SENSOR: 773;
|
|
1865
|
+
FLOW_SENSOR: 774;
|
|
1866
|
+
};
|
|
1867
|
+
INTRUDER_ALARM_SYSTEMS: {
|
|
1868
|
+
IAS_CONTROL_INDICATING_EQUIPMENT: 1024;
|
|
1869
|
+
IAS_ANCILLARY_CONTROL_EQUIPMENT: 1025;
|
|
1870
|
+
IAS_ZONE: 1026;
|
|
1871
|
+
IAS_WARNING_DEVICE: 1027;
|
|
1872
|
+
};
|
|
1873
|
+
};
|
|
1874
|
+
|
|
1875
|
+
export const IAS_ZONE_TYPE: {
|
|
1876
|
+
STANDARD_CIE: 0;
|
|
1877
|
+
MOTION_SENSOR: 13;
|
|
1878
|
+
CONTACT_SWITCH: 21;
|
|
1879
|
+
FIRE_SENSOR: 40;
|
|
1880
|
+
WATER_SENSOR: 42;
|
|
1881
|
+
CARBON_MONOXIDE_SENSOR: 43;
|
|
1882
|
+
PERSONAL_EMERGENCY_DEVICE: 44;
|
|
1883
|
+
VIBRATION_MOVEMENT_SENSOR: 45;
|
|
1884
|
+
REMOTE_CONTROL: 271;
|
|
1885
|
+
KEY_FOB: 277;
|
|
1886
|
+
KEYPAD: 541;
|
|
1887
|
+
STANDARD_WARNING_DEVICE: 549;
|
|
1888
|
+
GLASS_BREAK_SENSOR: 550;
|
|
1889
|
+
SECURITY_REPEATER: 553;
|
|
1890
|
+
INVALID_ZONE_TYPE: 65535;
|
|
1891
|
+
};
|
|
1892
|
+
|
|
1832
1893
|
declare const _default: {
|
|
1833
1894
|
ZCLNode: typeof ZCLNode;
|
|
1834
1895
|
CLUSTER: typeof CLUSTER;
|
|
@@ -1878,5 +1939,8 @@ declare const _default: {
|
|
|
1878
1939
|
TimeCluster: typeof TimeCluster;
|
|
1879
1940
|
TouchLinkCluster: typeof TouchLinkCluster;
|
|
1880
1941
|
WindowCoveringCluster: typeof WindowCoveringCluster;
|
|
1942
|
+
ZIGBEE_PROFILE_ID: typeof ZIGBEE_PROFILE_ID;
|
|
1943
|
+
ZIGBEE_DEVICE_ID: typeof ZIGBEE_DEVICE_ID;
|
|
1944
|
+
IAS_ZONE_TYPE: typeof IAS_ZONE_TYPE;
|
|
1881
1945
|
};
|
|
1882
1946
|
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/clusters/metering.js
CHANGED
|
@@ -33,34 +33,51 @@ const ATTRIBUTES = {
|
|
|
33
33
|
currentTier4SummationReceived: { id: 0x0107, type: ZCLDataTypes.uint48 }, // 263, Optional
|
|
34
34
|
|
|
35
35
|
// Meter Status (0x0200 - 0x02FF)
|
|
36
|
-
status: {
|
|
36
|
+
status: { // 512, Optional
|
|
37
|
+
id: 0x0200,
|
|
38
|
+
type: ZCLDataTypes.map8(
|
|
39
|
+
'checkMeter',
|
|
40
|
+
'lowBattery',
|
|
41
|
+
'tamperDetect',
|
|
42
|
+
'powerFailure',
|
|
43
|
+
'powerQuality',
|
|
44
|
+
'leakDetect',
|
|
45
|
+
'serviceDisconnect',
|
|
46
|
+
),
|
|
47
|
+
},
|
|
37
48
|
remainingBatteryLife: { id: 0x0201, type: ZCLDataTypes.uint8 }, // 513, Optional
|
|
38
49
|
hoursInOperation: { id: 0x0202, type: ZCLDataTypes.uint24 }, // 514, Optional
|
|
39
50
|
hoursInFault: { id: 0x0203, type: ZCLDataTypes.uint24 }, // 515, Optional
|
|
40
|
-
|
|
51
|
+
// TODO: map64 bitmap with general flags (bits 0-13) and meter-type-specific flags (bits 24+)
|
|
52
|
+
// extendedStatus: { id: 0x0204, type: ZCLDataTypes.map64() }, // 516, Optional
|
|
41
53
|
|
|
42
54
|
// Formatting Set (0x0300 - 0x03FF)
|
|
43
55
|
unitOfMeasure: { id: 0x0300, type: ZCLDataTypes.enum8 }, // 768, Mandatory
|
|
44
56
|
multiplier: { id: 0x0301, type: ZCLDataTypes.uint24 }, // 769, Optional
|
|
45
57
|
divisor: { id: 0x0302, type: ZCLDataTypes.uint24 }, // 770, Optional
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
58
|
+
// TODO: map8 packed fields — bits 0-2: right digits, 3-6: left digits, 7: suppress zeros
|
|
59
|
+
// summationFormatting: { id: 0x0303, type: ZCLDataTypes.map8() }, // 771, Mandatory
|
|
60
|
+
// demandFormatting: { id: 0x0304, type: ZCLDataTypes.map8() }, // 772, Optional
|
|
61
|
+
// historicalConsumptionFormatting: { id: 0x0305, type: ZCLDataTypes.map8() }, // 773, Optional
|
|
62
|
+
// TODO: ZCL spec says enum values, but wire type is map8 for backwards compat
|
|
63
|
+
// meteringDeviceType: { id: 0x0306, type: ZCLDataTypes.map8() }, // 774, Mandatory
|
|
50
64
|
siteId: { id: 0x0307, type: ZCLDataTypes.octstr }, // 775, Optional
|
|
51
65
|
meterSerialNumber: { id: 0x0308, type: ZCLDataTypes.octstr }, // 776, Optional
|
|
52
66
|
energyCarrierUnitOfMeasure: { id: 0x0309, type: ZCLDataTypes.enum8 }, // 777, Optional
|
|
53
|
-
|
|
54
|
-
|
|
67
|
+
// TODO: map8 packed fields — bits 0-2: right digits, 3-6: left digits, 7: suppress zeros
|
|
68
|
+
// energyCarrierSummationFormatting: { id: 0x030A, type: ZCLDataTypes.map8() }, // 778, Optional
|
|
69
|
+
// energyCarrierDemandFormatting: { id: 0x030B, type: ZCLDataTypes.map8() }, // 779, Optional
|
|
55
70
|
temperatureUnitOfMeasure: { id: 0x030C, type: ZCLDataTypes.enum8 }, // 780, Optional
|
|
56
|
-
|
|
71
|
+
// TODO: map8 packed fields — bits 0-2: right digits, 3-6: left digits, 7: suppress zeros
|
|
72
|
+
// temperatureFormatting: { id: 0x030D, type: ZCLDataTypes.map8() }, // 781, Optional
|
|
57
73
|
moduleSerialNumber: { id: 0x030E, type: ZCLDataTypes.octstr }, // 782, Optional
|
|
58
74
|
operatingTariffLabelDelivered: { id: 0x030F, type: ZCLDataTypes.octstr }, // 783, Optional
|
|
59
75
|
operatingTariffLabelReceived: { id: 0x0310, type: ZCLDataTypes.octstr }, // 784, Optional
|
|
60
76
|
customerIdNumber: { id: 0x0311, type: ZCLDataTypes.octstr }, // 785, Optional
|
|
61
77
|
alternativeUnitOfMeasure: { id: 0x0312, type: ZCLDataTypes.enum8 }, // 786, Optional
|
|
62
|
-
|
|
63
|
-
|
|
78
|
+
// TODO: map8 packed fields — bits 0-2: right digits, 3-6: left digits, 7: suppress zeros
|
|
79
|
+
// alternativeDemandFormatting: { id: 0x0313, type: ZCLDataTypes.map8() }, // 787, Optional
|
|
80
|
+
// alternativeConsumptionFormatting: { id: 0x0314, type: ZCLDataTypes.map8() }, // 788, Optional
|
|
64
81
|
|
|
65
82
|
// Historical Consumption (0x0400 - 0x04FF)
|
|
66
83
|
instantaneousDemand: { id: 0x0400, type: ZCLDataTypes.int24 }, // 1024, Optional
|
|
@@ -193,14 +210,15 @@ const ATTRIBUTES = {
|
|
|
193
210
|
currentTier4Block16SummationDelivered: { id: 0x074F, type: ZCLDataTypes.uint48 },
|
|
194
211
|
|
|
195
212
|
// Alarms (0x0800 - 0x08FF)
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
213
|
+
// TODO: map16/32/48 alarm masks — bits map to alarm codes in their group (spec 10.4.2.2.9.1)
|
|
214
|
+
// genericAlarmMask: { id: 0x0800, type: ZCLDataTypes.map16() }, // 2048, Optional
|
|
215
|
+
// electricityAlarmMask: { id: 0x0801, type: ZCLDataTypes.map32() }, // 2049, Optional
|
|
216
|
+
// genericFlowPressureAlarmMask: { id: 0x0802, type: ZCLDataTypes.map16() }, // 2050, Optional
|
|
217
|
+
// waterSpecificAlarmMask: { id: 0x0803, type: ZCLDataTypes.map16() }, // 2051, Optional
|
|
218
|
+
// heatAndCoolingSpecificAlarmMask: { id: 0x0804, type: ZCLDataTypes.map16() }, // 2052, Optional
|
|
219
|
+
// gasSpecificAlarmMask: { id: 0x0805, type: ZCLDataTypes.map16() }, // 2053, Optional
|
|
220
|
+
// extendedGenericAlarmMask: { id: 0x0806, type: ZCLDataTypes.map48() }, // 2054, Optional
|
|
221
|
+
// manufacturerAlarmMask: { id: 0x0807, type: ZCLDataTypes.map16() }, // 2055, Optional
|
|
204
222
|
|
|
205
223
|
// Block Information Received (0x0900 - 0x09FF)
|
|
206
224
|
// All attributes in this section are Optional
|
|
@@ -226,12 +244,14 @@ const ATTRIBUTES = {
|
|
|
226
244
|
billToDateTimeStampDelivered: { id: 0x0A01, type: ZCLDataTypes.uint32 }, // 2561, Optional
|
|
227
245
|
projectedBillDelivered: { id: 0x0A02, type: ZCLDataTypes.uint32 }, // 2562, Optional
|
|
228
246
|
projectedBillTimeStampDelivered: { id: 0x0A03, type: ZCLDataTypes.uint32 }, // 2563, Optional
|
|
229
|
-
|
|
247
|
+
// TODO: map8 packed field — most significant nibble = digits right of decimal
|
|
248
|
+
// billDeliveredTrailingDigit: { id: 0x0A04, type: ZCLDataTypes.map8() }, // 2564, Optional
|
|
230
249
|
billToDateReceived: { id: 0x0A10, type: ZCLDataTypes.uint32 }, // 2576, Optional
|
|
231
250
|
billToDateTimeStampReceived: { id: 0x0A11, type: ZCLDataTypes.uint32 }, // 2577, Optional
|
|
232
251
|
projectedBillReceived: { id: 0x0A12, type: ZCLDataTypes.uint32 }, // 2578, Optional
|
|
233
252
|
projectedBillTimeStampReceived: { id: 0x0A13, type: ZCLDataTypes.uint32 }, // 2579, Optional
|
|
234
|
-
|
|
253
|
+
// TODO: map8 packed field — most significant nibble = digits right of decimal
|
|
254
|
+
// billReceivedTrailingDigit: { id: 0x0A14, type: ZCLDataTypes.map8() }, // 2580, Optional
|
|
235
255
|
|
|
236
256
|
// Supply Control (0x0B00 - 0x0BFF)
|
|
237
257
|
proposedChangeSupplyImplementationTime: { // Optional
|
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.`);
|