@zwave-js/cc 13.10.1 → 14.0.0-beta.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/build/cc/AlarmSensorCC.d.ts +31 -20
- package/build/cc/AlarmSensorCC.d.ts.map +1 -1
- package/build/cc/AlarmSensorCC.js +106 -87
- package/build/cc/AlarmSensorCC.js.map +1 -1
- package/build/cc/AssociationCC.d.ts +38 -32
- package/build/cc/AssociationCC.d.ts.map +1 -1
- package/build/cc/AssociationCC.js +193 -176
- package/build/cc/AssociationCC.js.map +1 -1
- package/build/cc/AssociationGroupInfoCC.d.ts +42 -36
- package/build/cc/AssociationGroupInfoCC.d.ts.map +1 -1
- package/build/cc/AssociationGroupInfoCC.js +218 -200
- package/build/cc/AssociationGroupInfoCC.js.map +1 -1
- package/build/cc/BarrierOperatorCC.d.ts +41 -24
- package/build/cc/BarrierOperatorCC.d.ts.map +1 -1
- package/build/cc/BarrierOperatorCC.js +143 -109
- package/build/cc/BarrierOperatorCC.js.map +1 -1
- package/build/cc/BasicCC.d.ts +22 -23
- package/build/cc/BasicCC.d.ts.map +1 -1
- package/build/cc/BasicCC.js +83 -77
- package/build/cc/BasicCC.js.map +1 -1
- package/build/cc/BatteryCC.d.ts +22 -14
- package/build/cc/BatteryCC.d.ts.map +1 -1
- package/build/cc/BatteryCC.js +116 -87
- package/build/cc/BatteryCC.js.map +1 -1
- package/build/cc/BinarySensorCC.d.ts +22 -19
- package/build/cc/BinarySensorCC.d.ts.map +1 -1
- package/build/cc/BinarySensorCC.js +103 -93
- package/build/cc/BinarySensorCC.js.map +1 -1
- package/build/cc/BinarySwitchCC.d.ts +20 -20
- package/build/cc/BinarySwitchCC.d.ts.map +1 -1
- package/build/cc/BinarySwitchCC.js +71 -59
- package/build/cc/BinarySwitchCC.js.map +1 -1
- package/build/cc/CRC16CC.d.ts +9 -9
- package/build/cc/CRC16CC.d.ts.map +1 -1
- package/build/cc/CRC16CC.js +36 -36
- package/build/cc/CRC16CC.js.map +1 -1
- package/build/cc/CentralSceneCC.d.ts +34 -16
- package/build/cc/CentralSceneCC.d.ts.map +1 -1
- package/build/cc/CentralSceneCC.js +116 -79
- package/build/cc/CentralSceneCC.js.map +1 -1
- package/build/cc/ClimateControlScheduleCC.d.ts +38 -21
- package/build/cc/ClimateControlScheduleCC.d.ts.map +1 -1
- package/build/cc/ClimateControlScheduleCC.js +113 -81
- package/build/cc/ClimateControlScheduleCC.js.map +1 -1
- package/build/cc/ClockCC.d.ts +18 -11
- package/build/cc/ClockCC.d.ts.map +1 -1
- package/build/cc/ClockCC.js +57 -43
- package/build/cc/ClockCC.js.map +1 -1
- package/build/cc/ColorSwitchCC.d.ts +37 -33
- package/build/cc/ColorSwitchCC.d.ts.map +1 -1
- package/build/cc/ColorSwitchCC.js +216 -189
- package/build/cc/ColorSwitchCC.js.map +1 -1
- package/build/cc/ConfigurationCC.d.ts +89 -74
- package/build/cc/ConfigurationCC.d.ts.map +1 -1
- package/build/cc/ConfigurationCC.js +541 -485
- package/build/cc/ConfigurationCC.js.map +1 -1
- package/build/cc/DeviceResetLocallyCC.d.ts +3 -3
- package/build/cc/DeviceResetLocallyCC.d.ts.map +1 -1
- package/build/cc/DeviceResetLocallyCC.js +14 -14
- package/build/cc/DeviceResetLocallyCC.js.map +1 -1
- package/build/cc/DoorLockCC.d.ts +66 -27
- package/build/cc/DoorLockCC.d.ts.map +1 -1
- package/build/cc/DoorLockCC.js +288 -197
- package/build/cc/DoorLockCC.js.map +1 -1
- package/build/cc/DoorLockLoggingCC.d.ts +23 -13
- package/build/cc/DoorLockLoggingCC.d.ts.map +1 -1
- package/build/cc/DoorLockLoggingCC.js +81 -63
- package/build/cc/DoorLockLoggingCC.js.map +1 -1
- package/build/cc/EnergyProductionCC.d.ts +16 -14
- package/build/cc/EnergyProductionCC.d.ts.map +1 -1
- package/build/cc/EnergyProductionCC.js +58 -52
- package/build/cc/EnergyProductionCC.js.map +1 -1
- package/build/cc/EntryControlCC.d.ts +44 -18
- package/build/cc/EntryControlCC.d.ts.map +1 -1
- package/build/cc/EntryControlCC.js +163 -112
- package/build/cc/EntryControlCC.js.map +1 -1
- package/build/cc/FirmwareUpdateMetaDataCC.d.ts +69 -34
- package/build/cc/FirmwareUpdateMetaDataCC.d.ts.map +1 -1
- package/build/cc/FirmwareUpdateMetaDataCC.js +311 -245
- package/build/cc/FirmwareUpdateMetaDataCC.js.map +1 -1
- package/build/cc/HumidityControlModeCC.d.ts +24 -16
- package/build/cc/HumidityControlModeCC.d.ts.map +1 -1
- package/build/cc/HumidityControlModeCC.js +80 -65
- package/build/cc/HumidityControlModeCC.js.map +1 -1
- package/build/cc/HumidityControlOperatingStateCC.d.ts +11 -7
- package/build/cc/HumidityControlOperatingStateCC.d.ts.map +1 -1
- package/build/cc/HumidityControlOperatingStateCC.js +31 -22
- package/build/cc/HumidityControlOperatingStateCC.js.map +1 -1
- package/build/cc/HumidityControlSetpointCC.d.ts +68 -49
- package/build/cc/HumidityControlSetpointCC.d.ts.map +1 -1
- package/build/cc/HumidityControlSetpointCC.js +203 -181
- package/build/cc/HumidityControlSetpointCC.js.map +1 -1
- package/build/cc/InclusionControllerCC.d.ts +13 -11
- package/build/cc/InclusionControllerCC.d.ts.map +1 -1
- package/build/cc/InclusionControllerCC.js +49 -42
- package/build/cc/InclusionControllerCC.js.map +1 -1
- package/build/cc/IndicatorCC.d.ts +46 -39
- package/build/cc/IndicatorCC.d.ts.map +1 -1
- package/build/cc/IndicatorCC.js +298 -277
- package/build/cc/IndicatorCC.js.map +1 -1
- package/build/cc/IrrigationCC.d.ts +127 -57
- package/build/cc/IrrigationCC.d.ts.map +1 -1
- package/build/cc/IrrigationCC.js +496 -352
- package/build/cc/IrrigationCC.js.map +1 -1
- package/build/cc/LanguageCC.d.ts +17 -11
- package/build/cc/LanguageCC.d.ts.map +1 -1
- package/build/cc/LanguageCC.js +54 -44
- package/build/cc/LanguageCC.js.map +1 -1
- package/build/cc/LockCC.d.ts +16 -11
- package/build/cc/LockCC.d.ts.map +1 -1
- package/build/cc/LockCC.js +48 -38
- package/build/cc/LockCC.js.map +1 -1
- package/build/cc/ManufacturerProprietaryCC.d.ts +12 -11
- package/build/cc/ManufacturerProprietaryCC.d.ts.map +1 -1
- package/build/cc/ManufacturerProprietaryCC.js +45 -50
- package/build/cc/ManufacturerProprietaryCC.js.map +1 -1
- package/build/cc/ManufacturerSpecificCC.d.ts +20 -13
- package/build/cc/ManufacturerSpecificCC.d.ts.map +1 -1
- package/build/cc/ManufacturerSpecificCC.js +79 -63
- package/build/cc/ManufacturerSpecificCC.js.map +1 -1
- package/build/cc/MeterCC.d.ts +30 -26
- package/build/cc/MeterCC.d.ts.map +1 -1
- package/build/cc/MeterCC.js +236 -204
- package/build/cc/MeterCC.js.map +1 -1
- package/build/cc/MultiChannelAssociationCC.d.ts +31 -26
- package/build/cc/MultiChannelAssociationCC.d.ts.map +1 -1
- package/build/cc/MultiChannelAssociationCC.js +177 -168
- package/build/cc/MultiChannelAssociationCC.js.map +1 -1
- package/build/cc/MultiChannelCC.d.ts +70 -49
- package/build/cc/MultiChannelCC.d.ts.map +1 -1
- package/build/cc/MultiChannelCC.js +377 -318
- package/build/cc/MultiChannelCC.js.map +1 -1
- package/build/cc/MultiCommandCC.d.ts +9 -9
- package/build/cc/MultiCommandCC.d.ts.map +1 -1
- package/build/cc/MultiCommandCC.js +35 -36
- package/build/cc/MultiCommandCC.js.map +1 -1
- package/build/cc/MultilevelSensorCC.d.ts +38 -33
- package/build/cc/MultilevelSensorCC.d.ts.map +1 -1
- package/build/cc/MultilevelSensorCC.js +172 -152
- package/build/cc/MultilevelSensorCC.js.map +1 -1
- package/build/cc/MultilevelSwitchCC.d.ts +29 -25
- package/build/cc/MultilevelSwitchCC.d.ts.map +1 -1
- package/build/cc/MultilevelSwitchCC.js +147 -127
- package/build/cc/MultilevelSwitchCC.js.map +1 -1
- package/build/cc/NoOperationCC.d.ts +0 -8
- package/build/cc/NoOperationCC.d.ts.map +1 -1
- package/build/cc/NoOperationCC.js +2 -11
- package/build/cc/NoOperationCC.js.map +1 -1
- package/build/cc/NodeNamingCC.d.ts +27 -17
- package/build/cc/NodeNamingCC.d.ts.map +1 -1
- package/build/cc/NodeNamingCC.js +86 -69
- package/build/cc/NodeNamingCC.js.map +1 -1
- package/build/cc/NotificationCC.d.ts +46 -43
- package/build/cc/NotificationCC.d.ts.map +1 -1
- package/build/cc/NotificationCC.js +317 -303
- package/build/cc/NotificationCC.js.map +1 -1
- package/build/cc/PowerlevelCC.d.ts +22 -18
- package/build/cc/PowerlevelCC.d.ts.map +1 -1
- package/build/cc/PowerlevelCC.js +125 -95
- package/build/cc/PowerlevelCC.js.map +1 -1
- package/build/cc/ProtectionCC.d.ts +49 -26
- package/build/cc/ProtectionCC.d.ts.map +1 -1
- package/build/cc/ProtectionCC.js +172 -126
- package/build/cc/ProtectionCC.js.map +1 -1
- package/build/cc/SceneActivationCC.d.ts +8 -7
- package/build/cc/SceneActivationCC.d.ts.map +1 -1
- package/build/cc/SceneActivationCC.js +28 -23
- package/build/cc/SceneActivationCC.js.map +1 -1
- package/build/cc/SceneActuatorConfigurationCC.d.ts +23 -15
- package/build/cc/SceneActuatorConfigurationCC.d.ts.map +1 -1
- package/build/cc/SceneActuatorConfigurationCC.js +79 -62
- package/build/cc/SceneActuatorConfigurationCC.js.map +1 -1
- package/build/cc/SceneControllerConfigurationCC.d.ts +25 -17
- package/build/cc/SceneControllerConfigurationCC.d.ts.map +1 -1
- package/build/cc/SceneControllerConfigurationCC.js +92 -78
- package/build/cc/SceneControllerConfigurationCC.js.map +1 -1
- package/build/cc/ScheduleEntryLockCC.d.ts +86 -72
- package/build/cc/ScheduleEntryLockCC.d.ts.map +1 -1
- package/build/cc/ScheduleEntryLockCC.js +607 -455
- package/build/cc/ScheduleEntryLockCC.js.map +1 -1
- package/build/cc/Security2CC.d.ts +78 -87
- package/build/cc/Security2CC.d.ts.map +1 -1
- package/build/cc/Security2CC.js +798 -765
- package/build/cc/Security2CC.js.map +1 -1
- package/build/cc/SecurityCC.d.ts +47 -42
- package/build/cc/SecurityCC.d.ts.map +1 -1
- package/build/cc/SecurityCC.js +240 -218
- package/build/cc/SecurityCC.js.map +1 -1
- package/build/cc/SoundSwitchCC.d.ts +36 -29
- package/build/cc/SoundSwitchCC.d.ts.map +1 -1
- package/build/cc/SoundSwitchCC.js +180 -157
- package/build/cc/SoundSwitchCC.js.map +1 -1
- package/build/cc/SupervisionCC.d.ts +17 -14
- package/build/cc/SupervisionCC.d.ts.map +1 -1
- package/build/cc/SupervisionCC.js +86 -66
- package/build/cc/SupervisionCC.js.map +1 -1
- package/build/cc/ThermostatFanModeCC.d.ts +25 -15
- package/build/cc/ThermostatFanModeCC.d.ts.map +1 -1
- package/build/cc/ThermostatFanModeCC.js +79 -60
- package/build/cc/ThermostatFanModeCC.js.map +1 -1
- package/build/cc/ThermostatFanStateCC.d.ts +11 -7
- package/build/cc/ThermostatFanStateCC.d.ts.map +1 -1
- package/build/cc/ThermostatFanStateCC.js +31 -22
- package/build/cc/ThermostatFanStateCC.js.map +1 -1
- package/build/cc/ThermostatModeCC.d.ts +24 -21
- package/build/cc/ThermostatModeCC.d.ts.map +1 -1
- package/build/cc/ThermostatModeCC.js +106 -90
- package/build/cc/ThermostatModeCC.js.map +1 -1
- package/build/cc/ThermostatOperatingStateCC.d.ts +11 -7
- package/build/cc/ThermostatOperatingStateCC.d.ts.map +1 -1
- package/build/cc/ThermostatOperatingStateCC.js +31 -22
- package/build/cc/ThermostatOperatingStateCC.js.map +1 -1
- package/build/cc/ThermostatSetbackCC.d.ts +14 -13
- package/build/cc/ThermostatSetbackCC.d.ts.map +1 -1
- package/build/cc/ThermostatSetbackCC.js +64 -57
- package/build/cc/ThermostatSetbackCC.js.map +1 -1
- package/build/cc/ThermostatSetpointCC.d.ts +38 -57
- package/build/cc/ThermostatSetpointCC.d.ts.map +1 -1
- package/build/cc/ThermostatSetpointCC.js +200 -264
- package/build/cc/ThermostatSetpointCC.js.map +1 -1
- package/build/cc/TimeCC.d.ts +24 -20
- package/build/cc/TimeCC.d.ts.map +1 -1
- package/build/cc/TimeCC.js +119 -108
- package/build/cc/TimeCC.js.map +1 -1
- package/build/cc/TimeParametersCC.d.ts +18 -14
- package/build/cc/TimeParametersCC.d.ts.map +1 -1
- package/build/cc/TimeParametersCC.js +77 -69
- package/build/cc/TimeParametersCC.js.map +1 -1
- package/build/cc/TransportServiceCC.d.ts +29 -32
- package/build/cc/TransportServiceCC.d.ts.map +1 -1
- package/build/cc/TransportServiceCC.js +159 -161
- package/build/cc/TransportServiceCC.js.map +1 -1
- package/build/cc/UserCodeCC.d.ts +83 -66
- package/build/cc/UserCodeCC.d.ts.map +1 -1
- package/build/cc/UserCodeCC.js +449 -402
- package/build/cc/UserCodeCC.js.map +1 -1
- package/build/cc/VersionCC.d.ts +36 -20
- package/build/cc/VersionCC.d.ts.map +1 -1
- package/build/cc/VersionCC.js +190 -149
- package/build/cc/VersionCC.js.map +1 -1
- package/build/cc/WakeUpCC.d.ts +27 -13
- package/build/cc/WakeUpCC.d.ts.map +1 -1
- package/build/cc/WakeUpCC.js +105 -77
- package/build/cc/WakeUpCC.js.map +1 -1
- package/build/cc/WindowCoveringCC.d.ts +39 -27
- package/build/cc/WindowCoveringCC.d.ts.map +1 -1
- package/build/cc/WindowCoveringCC.js +169 -137
- package/build/cc/WindowCoveringCC.js.map +1 -1
- package/build/cc/ZWavePlusCC.d.ts +8 -7
- package/build/cc/ZWavePlusCC.d.ts.map +1 -1
- package/build/cc/ZWavePlusCC.js +44 -37
- package/build/cc/ZWavePlusCC.js.map +1 -1
- package/build/cc/ZWaveProtocolCC.d.ts +111 -84
- package/build/cc/ZWaveProtocolCC.d.ts.map +1 -1
- package/build/cc/ZWaveProtocolCC.js +583 -508
- package/build/cc/ZWaveProtocolCC.js.map +1 -1
- package/build/cc/index.d.ts +37 -34
- package/build/cc/index.d.ts.map +1 -1
- package/build/cc/index.js +6 -7
- package/build/cc/index.js.map +1 -1
- package/build/cc/manufacturerProprietary/FibaroCC.d.ts +29 -24
- package/build/cc/manufacturerProprietary/FibaroCC.d.ts.map +1 -1
- package/build/cc/manufacturerProprietary/FibaroCC.js +109 -112
- package/build/cc/manufacturerProprietary/FibaroCC.js.map +1 -1
- package/build/index.d.ts +0 -1
- package/build/index.d.ts.map +1 -1
- package/build/index.js +0 -1
- package/build/index.js.map +1 -1
- package/build/lib/API.d.ts +21 -18
- package/build/lib/API.d.ts.map +1 -1
- package/build/lib/API.js +25 -49
- package/build/lib/API.js.map +1 -1
- package/build/lib/CommandClass.d.ts +51 -89
- package/build/lib/CommandClass.d.ts.map +1 -1
- package/build/lib/CommandClass.js +177 -249
- package/build/lib/CommandClass.js.map +1 -1
- package/build/lib/EncapsulatingCommandClass.d.ts +1 -15
- package/build/lib/EncapsulatingCommandClass.d.ts.map +1 -1
- package/build/lib/EncapsulatingCommandClass.js.map +1 -1
- package/build/lib/ICommandClassContainer.d.ts +1 -8
- package/build/lib/ICommandClassContainer.d.ts.map +1 -1
- package/build/lib/ICommandClassContainer.js +0 -8
- package/build/lib/ICommandClassContainer.js.map +1 -1
- package/build/lib/Values.d.ts +3 -3
- package/build/lib/Values.d.ts.map +1 -1
- package/build/lib/_Types.d.ts.map +1 -1
- package/build/lib/_Types.js +1 -0
- package/build/lib/_Types.js.map +1 -1
- package/build/lib/utils.d.ts +14 -13
- package/build/lib/utils.d.ts.map +1 -1
- package/build/lib/utils.js +94 -92
- package/build/lib/utils.js.map +1 -1
- package/package.json +4 -5
package/build/cc/MeterCC.js
CHANGED
|
@@ -5,6 +5,7 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
5
5
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
6
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
7
|
};
|
|
8
|
+
var MeterCCReport_1, MeterCCGet_1, MeterCCSupportedReport_1, MeterCCReset_1;
|
|
8
9
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
10
|
exports.MeterCCReset = exports.MeterCCSupportedGet = exports.MeterCCSupportedReport = exports.MeterCCGet = exports.MeterCCReport = exports.MeterCC = exports.MeterCCAPI = exports.MeterCCValues = void 0;
|
|
10
11
|
exports.isAccumulatedValue = isAccumulatedValue;
|
|
@@ -415,22 +416,28 @@ function isAccumulatedValue(meterType, scale) {
|
|
|
415
416
|
// FIXME: We should probably move the meter definitions into code
|
|
416
417
|
switch (meterType) {
|
|
417
418
|
case 0x01: // Electric
|
|
418
|
-
return (
|
|
419
|
+
return (
|
|
420
|
+
// kVarh
|
|
421
|
+
// Pulse count
|
|
422
|
+
scale === 0x00 // kWh
|
|
419
423
|
|| scale === 0x01 // kVAh
|
|
420
|
-
|| scale === 0x03
|
|
421
|
-
|| scale === 0x08
|
|
422
|
-
);
|
|
424
|
+
|| scale === 0x03
|
|
425
|
+
|| scale === 0x08);
|
|
423
426
|
case 0x02: // Gas
|
|
424
|
-
return (
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
427
|
+
return (
|
|
428
|
+
// Pulse count
|
|
429
|
+
// ft³
|
|
430
|
+
scale === 0x00 // m³
|
|
431
|
+
|| scale === 0x01
|
|
432
|
+
|| scale === 0x03);
|
|
428
433
|
case 0x03: // Water
|
|
429
|
-
return (
|
|
434
|
+
return (
|
|
435
|
+
// Pulse count
|
|
436
|
+
// US gallons
|
|
437
|
+
scale === 0x00 // m³
|
|
430
438
|
|| scale === 0x01 // ft³
|
|
431
|
-
|| scale === 0x02
|
|
432
|
-
|| scale === 0x03
|
|
433
|
-
);
|
|
439
|
+
|| scale === 0x02
|
|
440
|
+
|| scale === 0x03);
|
|
434
441
|
case 0x04: // Heating
|
|
435
442
|
return scale === 0x00; // kWh
|
|
436
443
|
case 0x05: // Cooling
|
|
@@ -484,12 +491,12 @@ let MeterCCAPI = class MeterCCAPI extends API_1.PhysicalCCAPI {
|
|
|
484
491
|
async get(options) {
|
|
485
492
|
__assertType("options", "(optional) MeterCCGetOptions", __assertType__optional_MeterCCGetOptions.bind(void 0, options));
|
|
486
493
|
this.assertSupportsCommand(_Types_1.MeterCommand, _Types_1.MeterCommand.Get);
|
|
487
|
-
const cc = new MeterCCGet(
|
|
494
|
+
const cc = new MeterCCGet({
|
|
488
495
|
nodeId: this.endpoint.nodeId,
|
|
489
|
-
|
|
496
|
+
endpointIndex: this.endpoint.index,
|
|
490
497
|
...options,
|
|
491
498
|
});
|
|
492
|
-
const response = await this.
|
|
499
|
+
const response = await this.host.sendCommand(cc, this.commandOptions);
|
|
493
500
|
if (response) {
|
|
494
501
|
return {
|
|
495
502
|
type: response.type,
|
|
@@ -507,12 +514,12 @@ let MeterCCAPI = class MeterCCAPI extends API_1.PhysicalCCAPI {
|
|
|
507
514
|
async sendReport(options) {
|
|
508
515
|
__assertType("options", "MeterCCReportOptions", __assertType__MeterCCReportOptions.bind(void 0, options));
|
|
509
516
|
this.assertSupportsCommand(_Types_1.MeterCommand, _Types_1.MeterCommand.Report);
|
|
510
|
-
const cc = new MeterCCReport(
|
|
517
|
+
const cc = new MeterCCReport({
|
|
511
518
|
nodeId: this.endpoint.nodeId,
|
|
512
|
-
|
|
519
|
+
endpointIndex: this.endpoint.index,
|
|
513
520
|
...options,
|
|
514
521
|
});
|
|
515
|
-
return this.
|
|
522
|
+
return this.host.sendCommand(cc, this.commandOptions);
|
|
516
523
|
}
|
|
517
524
|
async getAll(accumulatedOnly = false) {
|
|
518
525
|
__assertType("accumulatedOnly", "(optional) boolean", __assertType__optional_boolean.bind(void 0, accumulatedOnly));
|
|
@@ -551,11 +558,11 @@ let MeterCCAPI = class MeterCCAPI extends API_1.PhysicalCCAPI {
|
|
|
551
558
|
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
|
|
552
559
|
async getSupported() {
|
|
553
560
|
this.assertSupportsCommand(_Types_1.MeterCommand, _Types_1.MeterCommand.SupportedGet);
|
|
554
|
-
const cc = new MeterCCSupportedGet(
|
|
561
|
+
const cc = new MeterCCSupportedGet({
|
|
555
562
|
nodeId: this.endpoint.nodeId,
|
|
556
|
-
|
|
563
|
+
endpointIndex: this.endpoint.index,
|
|
557
564
|
});
|
|
558
|
-
const response = await this.
|
|
565
|
+
const response = await this.host.sendCommand(cc, this.commandOptions);
|
|
559
566
|
if (response) {
|
|
560
567
|
return (0, safe_2.pick)(response, [
|
|
561
568
|
"type",
|
|
@@ -568,22 +575,22 @@ let MeterCCAPI = class MeterCCAPI extends API_1.PhysicalCCAPI {
|
|
|
568
575
|
async sendSupportedReport(options) {
|
|
569
576
|
__assertType("options", "MeterCCSupportedReportOptions", __assertType__MeterCCSupportedReportOptions.bind(void 0, options));
|
|
570
577
|
this.assertSupportsCommand(_Types_1.MeterCommand, _Types_1.MeterCommand.SupportedReport);
|
|
571
|
-
const cc = new MeterCCSupportedReport(
|
|
578
|
+
const cc = new MeterCCSupportedReport({
|
|
572
579
|
nodeId: this.endpoint.nodeId,
|
|
573
|
-
|
|
580
|
+
endpointIndex: this.endpoint.index,
|
|
574
581
|
...options,
|
|
575
582
|
});
|
|
576
|
-
await this.
|
|
583
|
+
await this.host.sendCommand(cc, this.commandOptions);
|
|
577
584
|
}
|
|
578
585
|
async reset(options) {
|
|
579
586
|
__assertType("options", "(optional) MeterCCResetOptions", __assertType__optional_MeterCCResetOptions.bind(void 0, options));
|
|
580
587
|
this.assertSupportsCommand(_Types_1.MeterCommand, _Types_1.MeterCommand.Reset);
|
|
581
|
-
const cc = new MeterCCReset(
|
|
588
|
+
const cc = new MeterCCReset({
|
|
582
589
|
nodeId: this.endpoint.nodeId,
|
|
583
|
-
|
|
590
|
+
endpointIndex: this.endpoint.index,
|
|
584
591
|
...options,
|
|
585
592
|
});
|
|
586
|
-
return this.
|
|
593
|
+
return this.host.sendCommand(cc, this.commandOptions);
|
|
587
594
|
}
|
|
588
595
|
get [API_1.SET_VALUE]() {
|
|
589
596
|
return async function ({ property, propertyKey }, value) {
|
|
@@ -680,19 +687,19 @@ exports.MeterCCAPI = MeterCCAPI = __decorate([
|
|
|
680
687
|
(0, CommandClassDecorators_1.API)(safe_1.CommandClasses.Meter)
|
|
681
688
|
], MeterCCAPI);
|
|
682
689
|
let MeterCC = class MeterCC extends CommandClass_1.CommandClass {
|
|
683
|
-
async interview(
|
|
684
|
-
const node = this.getNode(
|
|
685
|
-
const endpoint = this.getEndpoint(
|
|
686
|
-
const api = API_1.CCAPI.create(safe_1.CommandClasses.Meter,
|
|
690
|
+
async interview(ctx) {
|
|
691
|
+
const node = this.getNode(ctx);
|
|
692
|
+
const endpoint = this.getEndpoint(ctx);
|
|
693
|
+
const api = API_1.CCAPI.create(safe_1.CommandClasses.Meter, ctx, endpoint).withOptions({
|
|
687
694
|
priority: safe_1.MessagePriority.NodeQuery,
|
|
688
695
|
});
|
|
689
|
-
|
|
696
|
+
ctx.logNode(node.id, {
|
|
690
697
|
endpoint: this.endpointIndex,
|
|
691
698
|
message: `Interviewing ${this.ccName}...`,
|
|
692
699
|
direction: "none",
|
|
693
700
|
});
|
|
694
|
-
if (
|
|
695
|
-
|
|
701
|
+
if (api.version >= 2) {
|
|
702
|
+
ctx.logNode(node.id, {
|
|
696
703
|
endpoint: this.endpointIndex,
|
|
697
704
|
message: "querying meter support...",
|
|
698
705
|
direction: "outbound",
|
|
@@ -711,14 +718,14 @@ supported rate types: ${suppResp.supportedRateTypes
|
|
|
711
718
|
.map((label) => `\n· ${label}`)
|
|
712
719
|
.join("")}
|
|
713
720
|
supports reset: ${suppResp.supportsReset}`;
|
|
714
|
-
|
|
721
|
+
ctx.logNode(node.id, {
|
|
715
722
|
endpoint: this.endpointIndex,
|
|
716
723
|
message: logMessage,
|
|
717
724
|
direction: "inbound",
|
|
718
725
|
});
|
|
719
726
|
}
|
|
720
727
|
else {
|
|
721
|
-
|
|
728
|
+
ctx.logNode(node.id, {
|
|
722
729
|
endpoint: this.endpointIndex,
|
|
723
730
|
message: "Querying meter support timed out, skipping interview...",
|
|
724
731
|
level: "warn",
|
|
@@ -727,18 +734,18 @@ supports reset: ${suppResp.supportsReset}`;
|
|
|
727
734
|
}
|
|
728
735
|
}
|
|
729
736
|
// Query current meter values
|
|
730
|
-
await this.refreshValues(
|
|
737
|
+
await this.refreshValues(ctx);
|
|
731
738
|
// Remember that the interview is complete
|
|
732
|
-
this.setInterviewComplete(
|
|
739
|
+
this.setInterviewComplete(ctx, true);
|
|
733
740
|
}
|
|
734
|
-
async refreshValues(
|
|
735
|
-
const node = this.getNode(
|
|
736
|
-
const endpoint = this.getEndpoint(
|
|
737
|
-
const api = API_1.CCAPI.create(safe_1.CommandClasses.Meter,
|
|
741
|
+
async refreshValues(ctx) {
|
|
742
|
+
const node = this.getNode(ctx);
|
|
743
|
+
const endpoint = this.getEndpoint(ctx);
|
|
744
|
+
const api = API_1.CCAPI.create(safe_1.CommandClasses.Meter, ctx, endpoint).withOptions({
|
|
738
745
|
priority: safe_1.MessagePriority.NodeQuery,
|
|
739
746
|
});
|
|
740
|
-
if (
|
|
741
|
-
|
|
747
|
+
if (api.version === 1) {
|
|
748
|
+
ctx.logNode(node.id, {
|
|
742
749
|
endpoint: this.endpointIndex,
|
|
743
750
|
message: `querying default meter value...`,
|
|
744
751
|
direction: "outbound",
|
|
@@ -746,16 +753,16 @@ supports reset: ${suppResp.supportsReset}`;
|
|
|
746
753
|
await api.get();
|
|
747
754
|
}
|
|
748
755
|
else {
|
|
749
|
-
const type = this.getValue(
|
|
756
|
+
const type = this.getValue(ctx, exports.MeterCCValues.type)
|
|
750
757
|
?? 0;
|
|
751
|
-
const supportedScales = this.getValue(
|
|
752
|
-
const supportedRateTypes = this.getValue(
|
|
758
|
+
const supportedScales = this.getValue(ctx, exports.MeterCCValues.supportedScales) ?? [];
|
|
759
|
+
const supportedRateTypes = this.getValue(ctx, exports.MeterCCValues.supportedRateTypes) ?? [];
|
|
753
760
|
const rateTypes = supportedRateTypes.length
|
|
754
761
|
? supportedRateTypes
|
|
755
762
|
: [undefined];
|
|
756
763
|
for (const rateType of rateTypes) {
|
|
757
764
|
for (const scale of supportedScales) {
|
|
758
|
-
|
|
765
|
+
ctx.logNode(node.id, {
|
|
759
766
|
endpoint: this.endpointIndex,
|
|
760
767
|
message: `querying meter value (type = ${(0, core_1.getMeterName)(type)}, scale = ${((0, core_1.getMeterScale)(type, scale)
|
|
761
768
|
?? (0, core_1.getUnknownMeterScale)(scale)).label}${rateType != undefined
|
|
@@ -768,14 +775,14 @@ supports reset: ${suppResp.supportsReset}`;
|
|
|
768
775
|
}
|
|
769
776
|
}
|
|
770
777
|
}
|
|
771
|
-
shouldRefreshValues(
|
|
778
|
+
shouldRefreshValues(ctx) {
|
|
772
779
|
// Poll the device when all of the supported values were last updated longer than 6 hours ago.
|
|
773
780
|
// This may lead to some values not being updated, but the user may have disabled some unnecessary
|
|
774
781
|
// reports to reduce traffic.
|
|
775
|
-
const valueDB =
|
|
782
|
+
const valueDB = ctx.tryGetValueDB(this.nodeId);
|
|
776
783
|
if (!valueDB)
|
|
777
784
|
return true;
|
|
778
|
-
const values = this.getDefinedValueIDs(
|
|
785
|
+
const values = this.getDefinedValueIDs(ctx).filter((v) => exports.MeterCCValues.value.is(v));
|
|
779
786
|
return values.every((v) => {
|
|
780
787
|
const lastUpdated = valueDB.getTimestamp(v);
|
|
781
788
|
return (lastUpdated == undefined
|
|
@@ -786,8 +793,8 @@ supports reset: ${suppResp.supportsReset}`;
|
|
|
786
793
|
* Returns which type this meter has.
|
|
787
794
|
* This only works AFTER the interview process
|
|
788
795
|
*/
|
|
789
|
-
static getMeterTypeCached(
|
|
790
|
-
return
|
|
796
|
+
static getMeterTypeCached(ctx, endpoint) {
|
|
797
|
+
return ctx
|
|
791
798
|
.getValueDB(endpoint.nodeId)
|
|
792
799
|
.getValue(exports.MeterCCValues.type.endpoint(endpoint.index));
|
|
793
800
|
}
|
|
@@ -795,8 +802,8 @@ supports reset: ${suppResp.supportsReset}`;
|
|
|
795
802
|
* Returns which scales are supported by this meter.
|
|
796
803
|
* This only works AFTER the interview process
|
|
797
804
|
*/
|
|
798
|
-
static getSupportedScalesCached(
|
|
799
|
-
return
|
|
805
|
+
static getSupportedScalesCached(ctx, endpoint) {
|
|
806
|
+
return ctx
|
|
800
807
|
.getValueDB(endpoint.nodeId)
|
|
801
808
|
.getValue(exports.MeterCCValues.supportedScales.endpoint(endpoint.index));
|
|
802
809
|
}
|
|
@@ -804,8 +811,8 @@ supports reset: ${suppResp.supportsReset}`;
|
|
|
804
811
|
* Returns whether reset is supported by this meter.
|
|
805
812
|
* This only works AFTER the interview process
|
|
806
813
|
*/
|
|
807
|
-
static supportsResetCached(
|
|
808
|
-
return
|
|
814
|
+
static supportsResetCached(ctx, endpoint) {
|
|
815
|
+
return ctx
|
|
809
816
|
.getValueDB(endpoint.nodeId)
|
|
810
817
|
.getValue(exports.MeterCCValues.supportsReset.endpoint(endpoint.index));
|
|
811
818
|
}
|
|
@@ -813,12 +820,12 @@ supports reset: ${suppResp.supportsReset}`;
|
|
|
813
820
|
* Returns which rate types are supported by this meter.
|
|
814
821
|
* This only works AFTER the interview process
|
|
815
822
|
*/
|
|
816
|
-
static getSupportedRateTypesCached(
|
|
817
|
-
return
|
|
823
|
+
static getSupportedRateTypesCached(ctx, endpoint) {
|
|
824
|
+
return ctx
|
|
818
825
|
.getValueDB(endpoint.nodeId)
|
|
819
826
|
.getValue(exports.MeterCCValues.supportedRateTypes.endpoint(endpoint.index));
|
|
820
827
|
}
|
|
821
|
-
translatePropertyKey(
|
|
828
|
+
translatePropertyKey(ctx, property, propertyKey) {
|
|
822
829
|
if (property === "value" && typeof propertyKey === "number") {
|
|
823
830
|
const { meterType, rateType, scale } = splitPropertyKey(propertyKey);
|
|
824
831
|
let ret;
|
|
@@ -837,7 +844,7 @@ supports reset: ${suppResp.supportsReset}`;
|
|
|
837
844
|
else if (property === "reset" && typeof propertyKey === "number") {
|
|
838
845
|
return (0, core_1.getMeterName)(propertyKey);
|
|
839
846
|
}
|
|
840
|
-
return super.translatePropertyKey(
|
|
847
|
+
return super.translatePropertyKey(ctx, property, propertyKey);
|
|
841
848
|
}
|
|
842
849
|
};
|
|
843
850
|
exports.MeterCC = MeterCC;
|
|
@@ -846,80 +853,87 @@ exports.MeterCC = MeterCC = __decorate([
|
|
|
846
853
|
(0, CommandClassDecorators_1.implementedVersion)(6),
|
|
847
854
|
(0, CommandClassDecorators_1.ccValues)(exports.MeterCCValues)
|
|
848
855
|
], MeterCC);
|
|
849
|
-
let MeterCCReport = class MeterCCReport extends MeterCC {
|
|
850
|
-
constructor(
|
|
851
|
-
super(
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
// This float is split in the payload
|
|
871
|
-
Buffer.concat([
|
|
872
|
-
Buffer.from([this.payload[1]]),
|
|
873
|
-
this.payload.subarray(offset),
|
|
874
|
-
]));
|
|
875
|
-
offset += floatSize;
|
|
876
|
-
this.previousValue = prevValue;
|
|
877
|
-
}
|
|
856
|
+
let MeterCCReport = MeterCCReport_1 = class MeterCCReport extends MeterCC {
|
|
857
|
+
constructor(options) {
|
|
858
|
+
super(options);
|
|
859
|
+
this.type = options.type;
|
|
860
|
+
this.scale = options.scale;
|
|
861
|
+
this.value = options.value;
|
|
862
|
+
this.previousValue = options.previousValue;
|
|
863
|
+
this.rateType = options.rateType ?? _Types_1.RateType.Unspecified;
|
|
864
|
+
this.deltaTime = options.deltaTime ?? safe_1.UNKNOWN_STATE;
|
|
865
|
+
}
|
|
866
|
+
static from(raw, ctx) {
|
|
867
|
+
const { type, rateType, scale1, value, bytesRead } = parseMeterValueAndInfo(raw.payload, 0);
|
|
868
|
+
let offset = bytesRead;
|
|
869
|
+
const floatSize = bytesRead - 2;
|
|
870
|
+
let deltaTime;
|
|
871
|
+
let previousValue;
|
|
872
|
+
if (raw.payload.length >= offset + 2) {
|
|
873
|
+
deltaTime = raw.payload.readUInt16BE(offset);
|
|
874
|
+
offset += 2;
|
|
875
|
+
if (deltaTime === 0xffff) {
|
|
876
|
+
deltaTime = safe_1.UNKNOWN_STATE;
|
|
878
877
|
}
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
878
|
+
if (
|
|
879
|
+
// Previous value is included only if delta time is not 0
|
|
880
|
+
deltaTime !== 0
|
|
881
|
+
&& raw.payload.length >= offset + floatSize) {
|
|
882
|
+
const { value: prevValue } = (0, safe_1.parseFloatWithScale)(
|
|
883
|
+
// This float is split in the payload
|
|
884
|
+
Buffer.concat([
|
|
885
|
+
Buffer.from([raw.payload[1]]),
|
|
886
|
+
raw.payload.subarray(offset),
|
|
887
|
+
]));
|
|
888
|
+
offset += floatSize;
|
|
889
|
+
previousValue = prevValue;
|
|
882
890
|
}
|
|
883
|
-
this.scale = parseScale(scale1, this.payload, offset);
|
|
884
891
|
}
|
|
885
892
|
else {
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
+
// 0 means that no previous value is included
|
|
894
|
+
deltaTime = 0;
|
|
895
|
+
}
|
|
896
|
+
const scale = parseScale(scale1, raw.payload, offset);
|
|
897
|
+
return new MeterCCReport_1({
|
|
898
|
+
nodeId: ctx.sourceNodeId,
|
|
899
|
+
type,
|
|
900
|
+
rateType,
|
|
901
|
+
value,
|
|
902
|
+
deltaTime,
|
|
903
|
+
previousValue,
|
|
904
|
+
scale,
|
|
905
|
+
});
|
|
893
906
|
}
|
|
894
|
-
persistValues(
|
|
895
|
-
if (!super.persistValues(
|
|
907
|
+
persistValues(ctx) {
|
|
908
|
+
if (!super.persistValues(ctx))
|
|
896
909
|
return false;
|
|
910
|
+
const ccVersion = (0, CommandClass_1.getEffectiveCCVersion)(ctx, this);
|
|
897
911
|
const meter = (0, core_1.getMeter)(this.type);
|
|
898
912
|
const scale = (0, core_1.getMeterScale)(this.type, this.scale)
|
|
899
913
|
?? (0, core_1.getUnknownMeterScale)(this.scale);
|
|
900
914
|
// Filter out unknown meter types and scales, unless the strict validation is disabled
|
|
901
|
-
const measurementValidation = !
|
|
915
|
+
const measurementValidation = !ctx.getDeviceConfig?.(this.nodeId)?.compat?.disableStrictMeasurementValidation;
|
|
902
916
|
if (measurementValidation) {
|
|
903
917
|
safe_1.validatePayload.withReason(`Unknown meter type ${(0, safe_2.num2hex)(this.type)} or corrupted data`)(!!meter);
|
|
904
918
|
safe_1.validatePayload.withReason(`Unknown meter scale ${(0, safe_2.num2hex)(this.scale)} or corrupted data`)(scale.label !== (0, core_1.getUnknownMeterScale)(this.scale).label);
|
|
905
919
|
// Filter out unsupported meter types, scales and rate types if possible
|
|
906
|
-
if (
|
|
907
|
-
const expectedType = this.getValue(
|
|
920
|
+
if (ccVersion >= 2) {
|
|
921
|
+
const expectedType = this.getValue(ctx, exports.MeterCCValues.type);
|
|
908
922
|
if (expectedType != undefined) {
|
|
909
923
|
safe_1.validatePayload.withReason("Unexpected meter type or corrupted data")(this.type === expectedType);
|
|
910
924
|
}
|
|
911
|
-
const supportedScales = this.getValue(
|
|
925
|
+
const supportedScales = this.getValue(ctx, exports.MeterCCValues.supportedScales);
|
|
912
926
|
if (supportedScales?.length) {
|
|
913
927
|
safe_1.validatePayload.withReason(`Unsupported meter scale ${scale.label} or corrupted data`)(supportedScales.includes(this.scale));
|
|
914
928
|
}
|
|
915
|
-
const supportedRateTypes = this.getValue(
|
|
929
|
+
const supportedRateTypes = this.getValue(ctx, exports.MeterCCValues.supportedRateTypes);
|
|
916
930
|
if (supportedRateTypes?.length) {
|
|
917
931
|
safe_1.validatePayload.withReason(`Unsupported rate type ${(0, safe_2.getEnumMemberName)(_Types_1.RateType, this.rateType)} or corrupted data`)(supportedRateTypes.includes(this.rateType));
|
|
918
932
|
}
|
|
919
933
|
}
|
|
920
934
|
}
|
|
921
935
|
const valueValue = exports.MeterCCValues.value(this.type, this.rateType, this.scale);
|
|
922
|
-
this.setMetadata(
|
|
936
|
+
this.setMetadata(ctx, valueValue, {
|
|
923
937
|
...valueValue.meta,
|
|
924
938
|
label: getValueLabel(this.type, this.scale, this.rateType),
|
|
925
939
|
unit: scale.unit,
|
|
@@ -929,7 +943,7 @@ let MeterCCReport = class MeterCCReport extends MeterCC {
|
|
|
929
943
|
rateType: this.rateType,
|
|
930
944
|
},
|
|
931
945
|
});
|
|
932
|
-
this.setValue(
|
|
946
|
+
this.setValue(ctx, valueValue, this.value);
|
|
933
947
|
return true;
|
|
934
948
|
}
|
|
935
949
|
type;
|
|
@@ -938,7 +952,7 @@ let MeterCCReport = class MeterCCReport extends MeterCC {
|
|
|
938
952
|
previousValue;
|
|
939
953
|
rateType;
|
|
940
954
|
deltaTime;
|
|
941
|
-
serialize() {
|
|
955
|
+
serialize(ctx) {
|
|
942
956
|
const { data: typeAndValue, floatParams, scale2 } = encodeMeterValueAndInfo(this.type, this.rateType, this.scale, this.value);
|
|
943
957
|
const deltaTime = this.deltaTime ?? 0xffff;
|
|
944
958
|
const deltaTimeBytes = Buffer.allocUnsafe(2);
|
|
@@ -962,9 +976,9 @@ let MeterCCReport = class MeterCCReport extends MeterCC {
|
|
|
962
976
|
Buffer.from([scale2]),
|
|
963
977
|
]);
|
|
964
978
|
}
|
|
965
|
-
return super.serialize();
|
|
979
|
+
return super.serialize(ctx);
|
|
966
980
|
}
|
|
967
|
-
toLogEntry(
|
|
981
|
+
toLogEntry(ctx) {
|
|
968
982
|
const scale = (0, core_1.getMeterScale)(this.type, this.scale)
|
|
969
983
|
?? (0, core_1.getUnknownMeterScale)(this.scale);
|
|
970
984
|
const message = {
|
|
@@ -980,13 +994,13 @@ let MeterCCReport = class MeterCCReport extends MeterCC {
|
|
|
980
994
|
message["prev. value"] = this.previousValue;
|
|
981
995
|
}
|
|
982
996
|
return {
|
|
983
|
-
...super.toLogEntry(
|
|
997
|
+
...super.toLogEntry(ctx),
|
|
984
998
|
message,
|
|
985
999
|
};
|
|
986
1000
|
}
|
|
987
1001
|
};
|
|
988
1002
|
exports.MeterCCReport = MeterCCReport;
|
|
989
|
-
exports.MeterCCReport = MeterCCReport = __decorate([
|
|
1003
|
+
exports.MeterCCReport = MeterCCReport = MeterCCReport_1 = __decorate([
|
|
990
1004
|
(0, CommandClassDecorators_1.CCCommand)(_Types_1.MeterCommand.Report)
|
|
991
1005
|
], MeterCCReport);
|
|
992
1006
|
function testResponseForMeterGet(sent, received) {
|
|
@@ -995,43 +1009,49 @@ function testResponseForMeterGet(sent, received) {
|
|
|
995
1009
|
return ((sent.scale == undefined || sent.scale === received.scale)
|
|
996
1010
|
&& (sent.rateType == undefined || sent.rateType == received.rateType));
|
|
997
1011
|
}
|
|
998
|
-
let MeterCCGet = class MeterCCGet extends MeterCC {
|
|
999
|
-
constructor(
|
|
1000
|
-
super(
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1012
|
+
let MeterCCGet = MeterCCGet_1 = class MeterCCGet extends MeterCC {
|
|
1013
|
+
constructor(options) {
|
|
1014
|
+
super(options);
|
|
1015
|
+
this.rateType = options.rateType;
|
|
1016
|
+
this.scale = options.scale;
|
|
1017
|
+
}
|
|
1018
|
+
static from(raw, ctx) {
|
|
1019
|
+
let rateType;
|
|
1020
|
+
let scale;
|
|
1021
|
+
if (raw.payload.length >= 1) {
|
|
1022
|
+
rateType = (raw.payload[0] & 0b11_000_000) >>> 6;
|
|
1023
|
+
scale = (raw.payload[0] & 0b00_111_000) >>> 3;
|
|
1024
|
+
if (scale === 7) {
|
|
1025
|
+
(0, safe_1.validatePayload)(raw.payload.length >= 2);
|
|
1026
|
+
scale += raw.payload[1];
|
|
1009
1027
|
}
|
|
1010
1028
|
}
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1029
|
+
return new MeterCCGet_1({
|
|
1030
|
+
nodeId: ctx.sourceNodeId,
|
|
1031
|
+
rateType,
|
|
1032
|
+
scale,
|
|
1033
|
+
});
|
|
1015
1034
|
}
|
|
1016
1035
|
rateType;
|
|
1017
1036
|
scale;
|
|
1018
|
-
serialize() {
|
|
1037
|
+
serialize(ctx) {
|
|
1019
1038
|
let scale1;
|
|
1020
1039
|
let scale2;
|
|
1021
1040
|
let bufferLength = 0;
|
|
1041
|
+
const ccVersion = (0, CommandClass_1.getEffectiveCCVersion)(ctx, this);
|
|
1022
1042
|
if (this.scale == undefined) {
|
|
1023
1043
|
scale1 = 0;
|
|
1024
1044
|
}
|
|
1025
|
-
else if (
|
|
1045
|
+
else if (ccVersion >= 4 && this.scale >= 7) {
|
|
1026
1046
|
scale1 = 7;
|
|
1027
1047
|
scale2 = this.scale >>> 3;
|
|
1028
1048
|
bufferLength = 2;
|
|
1029
1049
|
}
|
|
1030
|
-
else if (
|
|
1050
|
+
else if (ccVersion >= 3) {
|
|
1031
1051
|
scale1 = this.scale & 0b111;
|
|
1032
1052
|
bufferLength = 1;
|
|
1033
1053
|
}
|
|
1034
|
-
else if (
|
|
1054
|
+
else if (ccVersion >= 2) {
|
|
1035
1055
|
scale1 = this.scale & 0b11;
|
|
1036
1056
|
bufferLength = 1;
|
|
1037
1057
|
}
|
|
@@ -1039,7 +1059,7 @@ let MeterCCGet = class MeterCCGet extends MeterCC {
|
|
|
1039
1059
|
scale1 = 0;
|
|
1040
1060
|
}
|
|
1041
1061
|
let rateTypeFlags = 0;
|
|
1042
|
-
if (
|
|
1062
|
+
if (ccVersion >= 4 && this.rateType != undefined) {
|
|
1043
1063
|
rateTypeFlags = this.rateType & 0b11;
|
|
1044
1064
|
bufferLength = Math.max(bufferLength, 1);
|
|
1045
1065
|
}
|
|
@@ -1047,17 +1067,17 @@ let MeterCCGet = class MeterCCGet extends MeterCC {
|
|
|
1047
1067
|
this.payload[0] = (rateTypeFlags << 6) | (scale1 << 3);
|
|
1048
1068
|
if (scale2)
|
|
1049
1069
|
this.payload[1] = scale2;
|
|
1050
|
-
return super.serialize();
|
|
1070
|
+
return super.serialize(ctx);
|
|
1051
1071
|
}
|
|
1052
|
-
toLogEntry(
|
|
1072
|
+
toLogEntry(ctx) {
|
|
1053
1073
|
const message = {};
|
|
1054
1074
|
if (this.rateType != undefined) {
|
|
1055
1075
|
message["rate type"] = (0, safe_2.getEnumMemberName)(_Types_1.RateType, this.rateType);
|
|
1056
1076
|
}
|
|
1057
1077
|
if (this.scale != undefined) {
|
|
1058
|
-
if (
|
|
1078
|
+
if (ctx) {
|
|
1059
1079
|
// Try to lookup the meter type to translate the scale
|
|
1060
|
-
const type = this.getValue(
|
|
1080
|
+
const type = this.getValue(ctx, exports.MeterCCValues.type);
|
|
1061
1081
|
if (type != undefined) {
|
|
1062
1082
|
message.scale = ((0, core_1.getMeterScale)(type, this.scale)
|
|
1063
1083
|
?? (0, core_1.getUnknownMeterScale)(this.scale)).label;
|
|
@@ -1068,62 +1088,69 @@ let MeterCCGet = class MeterCCGet extends MeterCC {
|
|
|
1068
1088
|
}
|
|
1069
1089
|
}
|
|
1070
1090
|
return {
|
|
1071
|
-
...super.toLogEntry(
|
|
1091
|
+
...super.toLogEntry(ctx),
|
|
1072
1092
|
message,
|
|
1073
1093
|
};
|
|
1074
1094
|
}
|
|
1075
1095
|
};
|
|
1076
1096
|
exports.MeterCCGet = MeterCCGet;
|
|
1077
|
-
exports.MeterCCGet = MeterCCGet = __decorate([
|
|
1097
|
+
exports.MeterCCGet = MeterCCGet = MeterCCGet_1 = __decorate([
|
|
1078
1098
|
(0, CommandClassDecorators_1.CCCommand)(_Types_1.MeterCommand.Get),
|
|
1079
1099
|
(0, CommandClassDecorators_1.expectedCCResponse)(MeterCCReport, testResponseForMeterGet)
|
|
1080
1100
|
], MeterCCGet);
|
|
1081
|
-
let MeterCCSupportedReport = class MeterCCSupportedReport extends MeterCC {
|
|
1082
|
-
constructor(
|
|
1083
|
-
super(
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
this.supportedRateTypes = (0, safe_1.parseBitMask)(Buffer.from([(this.payload[0] & 0b0_11_00000) >>> 5]), 1);
|
|
1101
|
+
let MeterCCSupportedReport = MeterCCSupportedReport_1 = class MeterCCSupportedReport extends MeterCC {
|
|
1102
|
+
constructor(options) {
|
|
1103
|
+
super(options);
|
|
1104
|
+
this.type = options.type;
|
|
1105
|
+
this.supportsReset = options.supportsReset;
|
|
1106
|
+
this.supportedScales = options.supportedScales;
|
|
1107
|
+
this.supportedRateTypes = options.supportedRateTypes;
|
|
1108
|
+
}
|
|
1109
|
+
static from(raw, ctx) {
|
|
1110
|
+
(0, safe_1.validatePayload)(raw.payload.length >= 2);
|
|
1111
|
+
const type = raw.payload[0] & 0b0_00_11111;
|
|
1112
|
+
const supportsReset = !!(raw.payload[0] & 0b1_00_00000);
|
|
1113
|
+
const hasMoreScales = !!(raw.payload[1] & 0b1_0000000);
|
|
1114
|
+
let supportedScales;
|
|
1115
|
+
if (hasMoreScales) {
|
|
1116
|
+
// The bitmask is spread out
|
|
1117
|
+
(0, safe_1.validatePayload)(raw.payload.length >= 3);
|
|
1118
|
+
const extraBytes = raw.payload[2];
|
|
1119
|
+
(0, safe_1.validatePayload)(raw.payload.length >= 3 + extraBytes);
|
|
1120
|
+
// The bitmask is the original payload byte plus all following bytes
|
|
1121
|
+
// Since the first byte only has 7 bits, we need to reduce all following bits by 1
|
|
1122
|
+
supportedScales = (0, safe_1.parseBitMask)(Buffer.concat([
|
|
1123
|
+
Buffer.from([raw.payload[1] & 0b0_1111111]),
|
|
1124
|
+
raw.payload.subarray(3, 3 + extraBytes),
|
|
1125
|
+
]), 0).map((scale) => (scale >= 8 ? scale - 1 : scale));
|
|
1107
1126
|
}
|
|
1108
1127
|
else {
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1128
|
+
// only 7 bits in the bitmask. Bit 7 is 0, so no need to mask it out
|
|
1129
|
+
supportedScales = (0, safe_1.parseBitMask)(Buffer.from([raw.payload[1]]), 0);
|
|
1130
|
+
}
|
|
1131
|
+
// This is only present in V4+
|
|
1132
|
+
const supportedRateTypes = (0, safe_1.parseBitMask)(Buffer.from([(raw.payload[0] & 0b0_11_00000) >>> 5]), 1);
|
|
1133
|
+
return new MeterCCSupportedReport_1({
|
|
1134
|
+
nodeId: ctx.sourceNodeId,
|
|
1135
|
+
type,
|
|
1136
|
+
supportsReset,
|
|
1137
|
+
supportedScales,
|
|
1138
|
+
supportedRateTypes,
|
|
1139
|
+
});
|
|
1114
1140
|
}
|
|
1115
1141
|
type;
|
|
1116
1142
|
supportsReset;
|
|
1117
1143
|
supportedScales;
|
|
1118
1144
|
supportedRateTypes;
|
|
1119
|
-
persistValues(
|
|
1120
|
-
if (!super.persistValues(
|
|
1145
|
+
persistValues(ctx) {
|
|
1146
|
+
if (!super.persistValues(ctx))
|
|
1121
1147
|
return false;
|
|
1122
1148
|
if (!this.supportsReset)
|
|
1123
1149
|
return true;
|
|
1150
|
+
const ccVersion = (0, CommandClass_1.getEffectiveCCVersion)(ctx, this);
|
|
1124
1151
|
// Create reset values
|
|
1125
|
-
if (
|
|
1126
|
-
this.ensureMetadata(
|
|
1152
|
+
if (ccVersion < 6) {
|
|
1153
|
+
this.ensureMetadata(ctx, exports.MeterCCValues.resetAll);
|
|
1127
1154
|
}
|
|
1128
1155
|
else {
|
|
1129
1156
|
for (const scale of this.supportedScales) {
|
|
@@ -1132,7 +1159,7 @@ let MeterCCSupportedReport = class MeterCCSupportedReport extends MeterCC {
|
|
|
1132
1159
|
continue;
|
|
1133
1160
|
for (const rateType of this.supportedRateTypes) {
|
|
1134
1161
|
const resetSingleValue = exports.MeterCCValues.resetSingle(this.type, rateType, scale);
|
|
1135
|
-
this.ensureMetadata(
|
|
1162
|
+
this.ensureMetadata(ctx, resetSingleValue, {
|
|
1136
1163
|
...resetSingleValue.meta,
|
|
1137
1164
|
label: `Reset ${getValueLabel(this.type, scale, rateType)}`,
|
|
1138
1165
|
});
|
|
@@ -1141,7 +1168,7 @@ let MeterCCSupportedReport = class MeterCCSupportedReport extends MeterCC {
|
|
|
1141
1168
|
}
|
|
1142
1169
|
return true;
|
|
1143
1170
|
}
|
|
1144
|
-
serialize() {
|
|
1171
|
+
serialize(ctx) {
|
|
1145
1172
|
const typeByte = (this.type & 0b0_00_11111)
|
|
1146
1173
|
| (this.supportedRateTypes.includes(_Types_1.RateType.Consumed)
|
|
1147
1174
|
? 0b0_01_00000
|
|
@@ -1168,9 +1195,9 @@ let MeterCCSupportedReport = class MeterCCSupportedReport extends MeterCC {
|
|
|
1168
1195
|
Buffer.from(supportedScales.subarray(1)),
|
|
1169
1196
|
]);
|
|
1170
1197
|
}
|
|
1171
|
-
return super.serialize();
|
|
1198
|
+
return super.serialize(ctx);
|
|
1172
1199
|
}
|
|
1173
|
-
toLogEntry(
|
|
1200
|
+
toLogEntry(ctx) {
|
|
1174
1201
|
const message = {
|
|
1175
1202
|
"meter type": (0, core_1.getMeterName)(this.type),
|
|
1176
1203
|
"supports reset": this.supportsReset,
|
|
@@ -1183,7 +1210,7 @@ let MeterCCSupportedReport = class MeterCCSupportedReport extends MeterCC {
|
|
|
1183
1210
|
.join(", "),
|
|
1184
1211
|
};
|
|
1185
1212
|
return {
|
|
1186
|
-
...super.toLogEntry(
|
|
1213
|
+
...super.toLogEntry(ctx),
|
|
1187
1214
|
message,
|
|
1188
1215
|
};
|
|
1189
1216
|
}
|
|
@@ -1201,7 +1228,7 @@ __decorate([
|
|
|
1201
1228
|
__decorate([
|
|
1202
1229
|
(0, CommandClassDecorators_1.ccValue)(exports.MeterCCValues.supportedRateTypes)
|
|
1203
1230
|
], MeterCCSupportedReport.prototype, "supportedRateTypes", void 0);
|
|
1204
|
-
exports.MeterCCSupportedReport = MeterCCSupportedReport = __decorate([
|
|
1231
|
+
exports.MeterCCSupportedReport = MeterCCSupportedReport = MeterCCSupportedReport_1 = __decorate([
|
|
1205
1232
|
(0, CommandClassDecorators_1.CCCommand)(_Types_1.MeterCommand.SupportedReport)
|
|
1206
1233
|
], MeterCCSupportedReport);
|
|
1207
1234
|
let MeterCCSupportedGet = class MeterCCSupportedGet extends MeterCC {
|
|
@@ -1211,30 +1238,35 @@ exports.MeterCCSupportedGet = MeterCCSupportedGet = __decorate([
|
|
|
1211
1238
|
(0, CommandClassDecorators_1.CCCommand)(_Types_1.MeterCommand.SupportedGet),
|
|
1212
1239
|
(0, CommandClassDecorators_1.expectedCCResponse)(MeterCCSupportedReport)
|
|
1213
1240
|
], MeterCCSupportedGet);
|
|
1214
|
-
let MeterCCReset = class MeterCCReset extends MeterCC {
|
|
1215
|
-
constructor(
|
|
1216
|
-
super(
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
this.type = options.type;
|
|
1228
|
-
this.scale = options.scale;
|
|
1229
|
-
this.rateType = options.rateType;
|
|
1230
|
-
this.targetValue = options.targetValue;
|
|
1241
|
+
let MeterCCReset = MeterCCReset_1 = class MeterCCReset extends MeterCC {
|
|
1242
|
+
constructor(options) {
|
|
1243
|
+
super(options);
|
|
1244
|
+
this.type = options.type;
|
|
1245
|
+
this.scale = options.scale;
|
|
1246
|
+
this.rateType = options.rateType;
|
|
1247
|
+
this.targetValue = options.targetValue;
|
|
1248
|
+
}
|
|
1249
|
+
static from(raw, ctx) {
|
|
1250
|
+
if (raw.payload.length === 0) {
|
|
1251
|
+
return new MeterCCReset_1({
|
|
1252
|
+
nodeId: ctx.sourceNodeId,
|
|
1253
|
+
});
|
|
1231
1254
|
}
|
|
1255
|
+
const { type, rateType, scale1, value: targetValue, bytesRead: scale2Offset, } = parseMeterValueAndInfo(raw.payload, 0);
|
|
1256
|
+
const scale = parseScale(scale1, raw.payload, scale2Offset);
|
|
1257
|
+
return new MeterCCReset_1({
|
|
1258
|
+
nodeId: ctx.sourceNodeId,
|
|
1259
|
+
type,
|
|
1260
|
+
rateType,
|
|
1261
|
+
targetValue,
|
|
1262
|
+
scale,
|
|
1263
|
+
});
|
|
1232
1264
|
}
|
|
1233
1265
|
type;
|
|
1234
1266
|
scale;
|
|
1235
1267
|
rateType;
|
|
1236
1268
|
targetValue;
|
|
1237
|
-
serialize() {
|
|
1269
|
+
serialize(ctx) {
|
|
1238
1270
|
if (this.type != undefined
|
|
1239
1271
|
&& this.scale != undefined
|
|
1240
1272
|
&& this.rateType != undefined
|
|
@@ -1248,9 +1280,9 @@ let MeterCCReset = class MeterCCReset extends MeterCC {
|
|
|
1248
1280
|
]);
|
|
1249
1281
|
}
|
|
1250
1282
|
}
|
|
1251
|
-
return super.serialize();
|
|
1283
|
+
return super.serialize(ctx);
|
|
1252
1284
|
}
|
|
1253
|
-
toLogEntry(
|
|
1285
|
+
toLogEntry(ctx) {
|
|
1254
1286
|
const message = {};
|
|
1255
1287
|
if (this.type != undefined) {
|
|
1256
1288
|
message.type = (0, core_1.getMeterName)(this.type);
|
|
@@ -1266,13 +1298,13 @@ let MeterCCReset = class MeterCCReset extends MeterCC {
|
|
|
1266
1298
|
message["target value"] = this.targetValue;
|
|
1267
1299
|
}
|
|
1268
1300
|
return {
|
|
1269
|
-
...super.toLogEntry(
|
|
1301
|
+
...super.toLogEntry(ctx),
|
|
1270
1302
|
message,
|
|
1271
1303
|
};
|
|
1272
1304
|
}
|
|
1273
1305
|
};
|
|
1274
1306
|
exports.MeterCCReset = MeterCCReset;
|
|
1275
|
-
exports.MeterCCReset = MeterCCReset = __decorate([
|
|
1307
|
+
exports.MeterCCReset = MeterCCReset = MeterCCReset_1 = __decorate([
|
|
1276
1308
|
(0, CommandClassDecorators_1.CCCommand)(_Types_1.MeterCommand.Reset),
|
|
1277
1309
|
(0, CommandClassDecorators_1.useSupervision)()
|
|
1278
1310
|
], MeterCCReset);
|