@zwave-js/cc 12.12.3 → 13.0.0-beta.3
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 +49 -35
- package/build/cc/AlarmSensorCC.d.ts.map +1 -1
- package/build/cc/AlarmSensorCC.js +6 -6
- package/build/cc/AlarmSensorCC.js.map +1 -1
- package/build/cc/AssociationCC.d.ts +41 -32
- package/build/cc/AssociationCC.d.ts.map +1 -1
- package/build/cc/AssociationCC.js +12 -12
- package/build/cc/AssociationCC.js.map +1 -1
- package/build/cc/AssociationGroupInfoCC.d.ts +52 -38
- package/build/cc/AssociationGroupInfoCC.d.ts.map +1 -1
- package/build/cc/AssociationGroupInfoCC.js +12 -12
- package/build/cc/AssociationGroupInfoCC.js.map +1 -1
- package/build/cc/BarrierOperatorCC.d.ts +33 -29
- package/build/cc/BarrierOperatorCC.d.ts.map +1 -1
- package/build/cc/BarrierOperatorCC.js +12 -12
- package/build/cc/BarrierOperatorCC.js.map +1 -1
- package/build/cc/BasicCC.d.ts +18 -19
- package/build/cc/BasicCC.d.ts.map +1 -1
- package/build/cc/BasicCC.js +4 -4
- package/build/cc/BasicCC.js.map +1 -1
- package/build/cc/BatteryCC.d.ts +39 -40
- package/build/cc/BatteryCC.d.ts.map +1 -1
- package/build/cc/BatteryCC.js +4 -4
- package/build/cc/BatteryCC.js.map +1 -1
- package/build/cc/BinarySensorCC.d.ts +19 -16
- package/build/cc/BinarySensorCC.d.ts.map +1 -1
- package/build/cc/BinarySensorCC.js +6 -6
- package/build/cc/BinarySensorCC.js.map +1 -1
- package/build/cc/BinarySwitchCC.d.ts +12 -13
- package/build/cc/BinarySwitchCC.d.ts.map +1 -1
- package/build/cc/BinarySwitchCC.js +4 -4
- package/build/cc/BinarySwitchCC.js.map +1 -1
- package/build/cc/CRC16CC.d.ts +2 -3
- package/build/cc/CRC16CC.d.ts.map +1 -1
- package/build/cc/CRC16CC.js +2 -2
- package/build/cc/CRC16CC.js.map +1 -1
- package/build/cc/CentralSceneCC.d.ts +31 -27
- package/build/cc/CentralSceneCC.d.ts.map +1 -1
- package/build/cc/CentralSceneCC.js +8 -8
- package/build/cc/CentralSceneCC.js.map +1 -1
- package/build/cc/ClimateControlScheduleCC.d.ts +27 -23
- package/build/cc/ClimateControlScheduleCC.d.ts.map +1 -1
- package/build/cc/ClimateControlScheduleCC.js +12 -12
- package/build/cc/ClimateControlScheduleCC.js.map +1 -1
- package/build/cc/ClockCC.d.ts +3 -4
- package/build/cc/ClockCC.d.ts.map +1 -1
- package/build/cc/ClockCC.js +4 -4
- package/build/cc/ClockCC.js.map +1 -1
- package/build/cc/ColorSwitchCC.d.ts +53 -44
- package/build/cc/ColorSwitchCC.d.ts.map +1 -1
- package/build/cc/ColorSwitchCC.js +12 -12
- package/build/cc/ColorSwitchCC.js.map +1 -1
- package/build/cc/ConfigurationCC.d.ts +31 -27
- package/build/cc/ConfigurationCC.d.ts.map +1 -1
- package/build/cc/ConfigurationCC.js +24 -24
- package/build/cc/ConfigurationCC.js.map +1 -1
- package/build/cc/DoorLockCC.d.ts +91 -92
- package/build/cc/DoorLockCC.d.ts.map +1 -1
- package/build/cc/DoorLockCC.js +10 -10
- package/build/cc/DoorLockCC.js.map +1 -1
- package/build/cc/DoorLockLoggingCC.d.ts +7 -8
- package/build/cc/DoorLockLoggingCC.d.ts.map +1 -1
- package/build/cc/DoorLockLoggingCC.js +6 -6
- package/build/cc/DoorLockLoggingCC.js.map +1 -1
- package/build/cc/EnergyProductionCC.d.ts +17 -13
- package/build/cc/EnergyProductionCC.d.ts.map +1 -1
- package/build/cc/EnergyProductionCC.js +4 -4
- package/build/cc/EnergyProductionCC.js.map +1 -1
- package/build/cc/EntryControlCC.d.ts +21 -22
- package/build/cc/EntryControlCC.d.ts.map +1 -1
- package/build/cc/EntryControlCC.js +10 -10
- package/build/cc/EntryControlCC.js.map +1 -1
- package/build/cc/FirmwareUpdateMetaDataCC.d.ts +23 -24
- package/build/cc/FirmwareUpdateMetaDataCC.d.ts.map +1 -1
- package/build/cc/FirmwareUpdateMetaDataCC.js +20 -20
- package/build/cc/FirmwareUpdateMetaDataCC.js.map +1 -1
- package/build/cc/HumidityControlModeCC.d.ts +10 -11
- package/build/cc/HumidityControlModeCC.d.ts.map +1 -1
- package/build/cc/HumidityControlModeCC.js +6 -6
- package/build/cc/HumidityControlModeCC.js.map +1 -1
- package/build/cc/HumidityControlOperatingStateCC.d.ts +5 -5
- package/build/cc/HumidityControlOperatingStateCC.d.ts.map +1 -1
- package/build/cc/HumidityControlOperatingStateCC.js +2 -2
- package/build/cc/HumidityControlOperatingStateCC.js.map +1 -1
- package/build/cc/HumidityControlSetpointCC.d.ts +41 -33
- package/build/cc/HumidityControlSetpointCC.d.ts.map +1 -1
- package/build/cc/HumidityControlSetpointCC.js +33 -34
- package/build/cc/HumidityControlSetpointCC.js.map +1 -1
- package/build/cc/InclusionControllerCC.d.ts +3 -4
- package/build/cc/InclusionControllerCC.d.ts.map +1 -1
- package/build/cc/InclusionControllerCC.js +4 -4
- package/build/cc/InclusionControllerCC.js.map +1 -1
- package/build/cc/IndicatorCC.d.ts +60 -47
- package/build/cc/IndicatorCC.d.ts.map +1 -1
- package/build/cc/IndicatorCC.js +29 -29
- package/build/cc/IndicatorCC.js.map +1 -1
- package/build/cc/IrrigationCC.d.ts +330 -246
- package/build/cc/IrrigationCC.d.ts.map +1 -1
- package/build/cc/IrrigationCC.js +30 -30
- package/build/cc/IrrigationCC.js.map +1 -1
- package/build/cc/LanguageCC.d.ts +9 -10
- package/build/cc/LanguageCC.d.ts.map +1 -1
- package/build/cc/LanguageCC.js +4 -4
- package/build/cc/LanguageCC.js.map +1 -1
- package/build/cc/LockCC.d.ts +6 -7
- package/build/cc/LockCC.d.ts.map +1 -1
- package/build/cc/LockCC.js +4 -4
- package/build/cc/LockCC.js.map +1 -1
- package/build/cc/ManufacturerProprietaryCC.d.ts +0 -1
- package/build/cc/ManufacturerProprietaryCC.d.ts.map +1 -1
- package/build/cc/ManufacturerSpecificCC.d.ts +27 -23
- package/build/cc/ManufacturerSpecificCC.d.ts.map +1 -1
- package/build/cc/ManufacturerSpecificCC.js +6 -6
- package/build/cc/ManufacturerSpecificCC.js.map +1 -1
- package/build/cc/MeterCC.d.ts +76 -53
- package/build/cc/MeterCC.d.ts.map +1 -1
- package/build/cc/MeterCC.js +550 -137
- package/build/cc/MeterCC.js.map +1 -1
- package/build/cc/MultiChannelAssociationCC.d.ts +51 -37
- package/build/cc/MultiChannelAssociationCC.d.ts.map +1 -1
- package/build/cc/MultiChannelAssociationCC.js +12 -12
- package/build/cc/MultiChannelAssociationCC.js.map +1 -1
- package/build/cc/MultiChannelCC.d.ts +48 -45
- package/build/cc/MultiChannelCC.d.ts.map +1 -1
- package/build/cc/MultiChannelCC.js +30 -34
- package/build/cc/MultiChannelCC.js.map +1 -1
- package/build/cc/MultiCommandCC.d.ts +2 -3
- package/build/cc/MultiCommandCC.d.ts.map +1 -1
- package/build/cc/MultiCommandCC.js +2 -2
- package/build/cc/MultiCommandCC.js.map +1 -1
- package/build/cc/MultilevelSensorCC.d.ts +36 -29
- package/build/cc/MultilevelSensorCC.d.ts.map +1 -1
- package/build/cc/MultilevelSensorCC.js +82 -51
- package/build/cc/MultilevelSensorCC.js.map +1 -1
- package/build/cc/MultilevelSwitchCC.d.ts +51 -44
- package/build/cc/MultilevelSwitchCC.d.ts.map +1 -1
- package/build/cc/MultilevelSwitchCC.js +8 -8
- package/build/cc/MultilevelSwitchCC.js.map +1 -1
- package/build/cc/NoOperationCC.js +2 -2
- package/build/cc/NoOperationCC.js.map +1 -1
- package/build/cc/NodeNamingCC.d.ts +11 -12
- package/build/cc/NodeNamingCC.d.ts.map +1 -1
- package/build/cc/NodeNamingCC.js +8 -8
- package/build/cc/NodeNamingCC.js.map +1 -1
- package/build/cc/NotificationCC.d.ts +89 -75
- package/build/cc/NotificationCC.d.ts.map +1 -1
- package/build/cc/NotificationCC.js +64 -88
- package/build/cc/NotificationCC.js.map +1 -1
- package/build/cc/PowerlevelCC.d.ts +5 -6
- package/build/cc/PowerlevelCC.d.ts.map +1 -1
- package/build/cc/PowerlevelCC.js +8 -8
- package/build/cc/PowerlevelCC.js.map +1 -1
- package/build/cc/ProtectionCC.d.ts +32 -33
- package/build/cc/ProtectionCC.d.ts.map +1 -1
- package/build/cc/ProtectionCC.js +14 -14
- package/build/cc/ProtectionCC.js.map +1 -1
- package/build/cc/SceneActivationCC.d.ts +8 -9
- package/build/cc/SceneActivationCC.d.ts.map +1 -1
- package/build/cc/SceneActivationCC.js +2 -2
- package/build/cc/SceneActivationCC.js.map +1 -1
- package/build/cc/SceneActuatorConfigurationCC.d.ts +32 -23
- package/build/cc/SceneActuatorConfigurationCC.d.ts.map +1 -1
- package/build/cc/SceneActuatorConfigurationCC.js +6 -6
- package/build/cc/SceneActuatorConfigurationCC.js.map +1 -1
- package/build/cc/SceneControllerConfigurationCC.d.ts +32 -23
- package/build/cc/SceneControllerConfigurationCC.d.ts.map +1 -1
- package/build/cc/SceneControllerConfigurationCC.js +6 -6
- package/build/cc/SceneControllerConfigurationCC.js.map +1 -1
- package/build/cc/ScheduleEntryLockCC.d.ts +66 -52
- package/build/cc/ScheduleEntryLockCC.d.ts.map +1 -1
- package/build/cc/ScheduleEntryLockCC.js +28 -28
- package/build/cc/ScheduleEntryLockCC.js.map +1 -1
- package/build/cc/Security2CC.d.ts +12 -13
- package/build/cc/Security2CC.d.ts.map +1 -1
- package/build/cc/Security2CC.js +22 -22
- package/build/cc/Security2CC.js.map +1 -1
- package/build/cc/SecurityCC.d.ts +6 -7
- package/build/cc/SecurityCC.d.ts.map +1 -1
- package/build/cc/SecurityCC.js +10 -10
- package/build/cc/SecurityCC.js.map +1 -1
- package/build/cc/SoundSwitchCC.d.ts +20 -21
- package/build/cc/SoundSwitchCC.d.ts.map +1 -1
- package/build/cc/SoundSwitchCC.js +14 -14
- package/build/cc/SoundSwitchCC.js.map +1 -1
- package/build/cc/SupervisionCC.d.ts +17 -13
- package/build/cc/SupervisionCC.d.ts.map +1 -1
- package/build/cc/SupervisionCC.js +4 -4
- package/build/cc/SupervisionCC.js.map +1 -1
- package/build/cc/ThermostatFanModeCC.d.ts +13 -14
- package/build/cc/ThermostatFanModeCC.d.ts.map +1 -1
- package/build/cc/ThermostatFanModeCC.js +6 -6
- package/build/cc/ThermostatFanModeCC.js.map +1 -1
- package/build/cc/ThermostatFanStateCC.d.ts +5 -5
- package/build/cc/ThermostatFanStateCC.d.ts.map +1 -1
- package/build/cc/ThermostatFanStateCC.js +2 -2
- package/build/cc/ThermostatFanStateCC.js.map +1 -1
- package/build/cc/ThermostatModeCC.d.ts +13 -14
- package/build/cc/ThermostatModeCC.d.ts.map +1 -1
- package/build/cc/ThermostatModeCC.js +6 -6
- package/build/cc/ThermostatModeCC.js.map +1 -1
- package/build/cc/ThermostatOperatingStateCC.d.ts +5 -5
- package/build/cc/ThermostatOperatingStateCC.d.ts.map +1 -1
- package/build/cc/ThermostatOperatingStateCC.js +2 -2
- package/build/cc/ThermostatOperatingStateCC.js.map +1 -1
- package/build/cc/ThermostatSetbackCC.d.ts +9 -10
- package/build/cc/ThermostatSetbackCC.d.ts.map +1 -1
- package/build/cc/ThermostatSetbackCC.js +4 -4
- package/build/cc/ThermostatSetbackCC.js.map +1 -1
- package/build/cc/ThermostatSetpointCC.d.ts +42 -34
- package/build/cc/ThermostatSetpointCC.d.ts.map +1 -1
- package/build/cc/ThermostatSetpointCC.js +27 -27
- package/build/cc/ThermostatSetpointCC.js.map +1 -1
- package/build/cc/TimeCC.d.ts +5 -6
- package/build/cc/TimeCC.d.ts.map +1 -1
- package/build/cc/TimeCC.js +8 -8
- package/build/cc/TimeCC.js.map +1 -1
- package/build/cc/TimeParametersCC.d.ts +6 -7
- package/build/cc/TimeParametersCC.d.ts.map +1 -1
- package/build/cc/TimeParametersCC.js +4 -4
- package/build/cc/TimeParametersCC.js.map +1 -1
- package/build/cc/TransportServiceCC.d.ts +6 -7
- package/build/cc/TransportServiceCC.d.ts.map +1 -1
- package/build/cc/TransportServiceCC.js +12 -12
- package/build/cc/TransportServiceCC.js.map +1 -1
- package/build/cc/UserCodeCC.d.ts +78 -69
- package/build/cc/UserCodeCC.d.ts.map +1 -1
- package/build/cc/UserCodeCC.js +28 -28
- package/build/cc/UserCodeCC.js.map +1 -1
- package/build/cc/VersionCC.d.ts +48 -49
- package/build/cc/VersionCC.d.ts.map +1 -1
- package/build/cc/VersionCC.js +10 -10
- package/build/cc/VersionCC.js.map +1 -1
- package/build/cc/WakeUpCC.d.ts +13 -14
- package/build/cc/WakeUpCC.d.ts.map +1 -1
- package/build/cc/WakeUpCC.js +6 -6
- package/build/cc/WakeUpCC.js.map +1 -1
- package/build/cc/WindowCoveringCC.d.ts +80 -56
- package/build/cc/WindowCoveringCC.d.ts.map +1 -1
- package/build/cc/WindowCoveringCC.js +12 -12
- package/build/cc/WindowCoveringCC.js.map +1 -1
- package/build/cc/ZWavePlusCC.d.ts +17 -18
- package/build/cc/ZWavePlusCC.d.ts.map +1 -1
- package/build/cc/ZWavePlusCC.js +2 -2
- package/build/cc/ZWavePlusCC.js.map +1 -1
- package/build/cc/ZWaveProtocolCC.d.ts +4 -5
- package/build/cc/ZWaveProtocolCC.d.ts.map +1 -1
- package/build/cc/ZWaveProtocolCC.js.map +1 -1
- package/build/cc/index.d.ts +1 -1
- package/build/cc/index.d.ts.map +1 -1
- package/build/cc/index.js.map +1 -1
- package/build/cc/manufacturerProprietary/Decorators.js +2 -2
- package/build/cc/manufacturerProprietary/Decorators.js.map +1 -1
- package/build/cc/manufacturerProprietary/FibaroCC.d.ts +3 -4
- package/build/cc/manufacturerProprietary/FibaroCC.d.ts.map +1 -1
- package/build/cc/manufacturerProprietary/FibaroCC.js +9 -9
- package/build/cc/manufacturerProprietary/FibaroCC.js.map +1 -1
- package/build/lib/API.js +6 -6
- package/build/lib/API.js.map +1 -1
- package/build/lib/CommandClass.d.ts +14 -15
- package/build/lib/CommandClass.d.ts.map +1 -1
- package/build/lib/CommandClass.js +27 -27
- package/build/lib/CommandClass.js.map +1 -1
- package/build/lib/CommandClassDecorators.js +12 -12
- package/build/lib/CommandClassDecorators.js.map +1 -1
- package/build/lib/EncapsulatingCommandClass.js +3 -4
- package/build/lib/EncapsulatingCommandClass.js.map +1 -1
- package/build/lib/ICommandClassContainer.js +1 -2
- package/build/lib/ICommandClassContainer.js.map +1 -1
- package/build/lib/NotificationEventPayload.d.ts +0 -1
- package/build/lib/NotificationEventPayload.d.ts.map +1 -1
- package/build/lib/NotificationEventPayload.js +1 -2
- package/build/lib/NotificationEventPayload.js.map +1 -1
- package/build/lib/Security2/Extension.d.ts +0 -1
- package/build/lib/Security2/Extension.d.ts.map +1 -1
- package/build/lib/Security2/Extension.js +5 -5
- package/build/lib/Security2/Extension.js.map +1 -1
- package/build/lib/SetValueResult.js +5 -5
- package/build/lib/SetValueResult.js.map +1 -1
- package/build/lib/Values.d.ts +21 -21
- package/build/lib/Values.d.ts.map +1 -1
- package/build/lib/_Types.d.ts +16 -3
- package/build/lib/_Types.d.ts.map +1 -1
- package/build/lib/_Types.js +24 -8
- package/build/lib/_Types.js.map +1 -1
- package/build/lib/serializers.d.ts +0 -1
- package/build/lib/serializers.d.ts.map +1 -1
- package/build/lib/serializers.js +7 -7
- package/build/lib/serializers.js.map +1 -1
- package/build/lib/utils.d.ts +2 -2
- package/build/lib/utils.d.ts.map +1 -1
- package/build/lib/utils.js +54 -35
- package/build/lib/utils.js.map +1 -1
- package/package.json +16 -13
package/build/cc/MeterCC.js
CHANGED
|
@@ -7,6 +7,7 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
7
7
|
};
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
9
|
exports.MeterCCReset = exports.MeterCCSupportedGet = exports.MeterCCSupportedReport = exports.MeterCCGet = exports.MeterCCReport = exports.MeterCC = exports.MeterCCAPI = exports.MeterCCValues = void 0;
|
|
10
|
+
exports.isAccumulatedValue = isAccumulatedValue;
|
|
10
11
|
function __assertType(argName, typeName, boundHasError) {
|
|
11
12
|
const { ZWaveError, ZWaveErrorCodes } = require("@zwave-js/core");
|
|
12
13
|
if (boundHasError()) {
|
|
@@ -45,29 +46,125 @@ const __assertType__optional_MeterCCGetOptions = $o => {
|
|
|
45
46
|
}
|
|
46
47
|
return optional__0($o);
|
|
47
48
|
};
|
|
48
|
-
const
|
|
49
|
+
const __assertType__MeterCCReportOptions = $o => {
|
|
50
|
+
function _number($o) {
|
|
51
|
+
return typeof $o !== "number" ? {} : null;
|
|
52
|
+
}
|
|
49
53
|
function _undefined($o) {
|
|
50
54
|
return $o !== undefined ? {} : null;
|
|
51
55
|
}
|
|
52
|
-
function
|
|
56
|
+
function su__undefined__number_eu($o) {
|
|
57
|
+
const conditions = [_undefined, _number];
|
|
58
|
+
for (const condition of conditions) {
|
|
59
|
+
const error = condition($o);
|
|
60
|
+
if (!error)
|
|
61
|
+
return null;
|
|
62
|
+
}
|
|
63
|
+
return {};
|
|
64
|
+
}
|
|
65
|
+
function su__5__6__7_eu($o) {
|
|
66
|
+
return ![0, 1, 2].includes($o) ? {} : null;
|
|
67
|
+
}
|
|
68
|
+
function _null($o) {
|
|
69
|
+
return $o !== null ? {} : null;
|
|
70
|
+
}
|
|
71
|
+
function su__null__number_eu($o) {
|
|
72
|
+
const conditions = [_null, _number];
|
|
73
|
+
for (const condition of conditions) {
|
|
74
|
+
const error = condition($o);
|
|
75
|
+
if (!error)
|
|
76
|
+
return null;
|
|
77
|
+
}
|
|
78
|
+
return {};
|
|
79
|
+
}
|
|
80
|
+
function _0($o) {
|
|
53
81
|
if (typeof $o !== "object" || $o === null || Array.isArray($o))
|
|
54
82
|
return {};
|
|
55
83
|
if ("type" in $o && $o["type"] !== undefined) {
|
|
56
|
-
const error =
|
|
84
|
+
const error = _number($o["type"]);
|
|
57
85
|
if (error)
|
|
58
86
|
return error;
|
|
59
87
|
}
|
|
60
|
-
|
|
61
|
-
|
|
88
|
+
else
|
|
89
|
+
return {};
|
|
90
|
+
if ("scale" in $o && $o["scale"] !== undefined) {
|
|
91
|
+
const error = _number($o["scale"]);
|
|
92
|
+
if (error)
|
|
93
|
+
return error;
|
|
94
|
+
}
|
|
95
|
+
else
|
|
96
|
+
return {};
|
|
97
|
+
if ("value" in $o && $o["value"] !== undefined) {
|
|
98
|
+
const error = _number($o["value"]);
|
|
99
|
+
if (error)
|
|
100
|
+
return error;
|
|
101
|
+
}
|
|
102
|
+
else
|
|
103
|
+
return {};
|
|
104
|
+
if ("previousValue" in $o && $o["previousValue"] !== undefined) {
|
|
105
|
+
const error = su__undefined__number_eu($o["previousValue"]);
|
|
106
|
+
if (error)
|
|
107
|
+
return error;
|
|
108
|
+
}
|
|
109
|
+
if ("rateType" in $o && $o["rateType"] !== undefined) {
|
|
110
|
+
const error = su__5__6__7_eu($o["rateType"]);
|
|
111
|
+
if (error)
|
|
112
|
+
return error;
|
|
113
|
+
}
|
|
114
|
+
if ("deltaTime" in $o && $o["deltaTime"] !== undefined) {
|
|
115
|
+
const error = su__null__number_eu($o["deltaTime"]);
|
|
62
116
|
if (error)
|
|
63
117
|
return error;
|
|
64
118
|
}
|
|
65
119
|
return null;
|
|
66
120
|
}
|
|
121
|
+
return _0($o);
|
|
122
|
+
};
|
|
123
|
+
const __assertType__optional_boolean = $o => {
|
|
124
|
+
function _boolean($o) {
|
|
125
|
+
return typeof $o !== "boolean" ? {} : null;
|
|
126
|
+
}
|
|
127
|
+
function optional__boolean($o) {
|
|
128
|
+
if ($o !== undefined) {
|
|
129
|
+
const error = _boolean($o);
|
|
130
|
+
if (error)
|
|
131
|
+
return error;
|
|
132
|
+
}
|
|
133
|
+
return null;
|
|
134
|
+
}
|
|
135
|
+
return optional__boolean($o);
|
|
136
|
+
};
|
|
137
|
+
const __assertType__MeterCCSupportedReportOptions = $o => {
|
|
67
138
|
function _number($o) {
|
|
68
139
|
return typeof $o !== "number" ? {} : null;
|
|
69
140
|
}
|
|
70
|
-
function
|
|
141
|
+
function _boolean($o) {
|
|
142
|
+
return typeof $o !== "boolean" ? {} : null;
|
|
143
|
+
}
|
|
144
|
+
function sa__number_ea_3($o) {
|
|
145
|
+
if (!Array.isArray($o))
|
|
146
|
+
return {};
|
|
147
|
+
for (let i = 0; i < $o.length; i++) {
|
|
148
|
+
const error = _number($o[i]);
|
|
149
|
+
if (error)
|
|
150
|
+
return error;
|
|
151
|
+
}
|
|
152
|
+
return null;
|
|
153
|
+
}
|
|
154
|
+
function su__5__6__7_eu($o) {
|
|
155
|
+
return ![0, 1, 2].includes($o) ? {} : null;
|
|
156
|
+
}
|
|
157
|
+
function sa_su__5__6__7_eu_ea_4($o) {
|
|
158
|
+
if (!Array.isArray($o))
|
|
159
|
+
return {};
|
|
160
|
+
for (let i = 0; i < $o.length; i++) {
|
|
161
|
+
const error = su__5__6__7_eu($o[i]);
|
|
162
|
+
if (error)
|
|
163
|
+
return error;
|
|
164
|
+
}
|
|
165
|
+
return null;
|
|
166
|
+
}
|
|
167
|
+
function _0($o) {
|
|
71
168
|
if (typeof $o !== "object" || $o === null || Array.isArray($o))
|
|
72
169
|
return {};
|
|
73
170
|
if ("type" in $o && $o["type"] !== undefined) {
|
|
@@ -75,6 +172,62 @@ const __assertType__optional_MeterCCResetOptions = $o => {
|
|
|
75
172
|
if (error)
|
|
76
173
|
return error;
|
|
77
174
|
}
|
|
175
|
+
else
|
|
176
|
+
return {};
|
|
177
|
+
if ("supportsReset" in $o && $o["supportsReset"] !== undefined) {
|
|
178
|
+
const error = _boolean($o["supportsReset"]);
|
|
179
|
+
if (error)
|
|
180
|
+
return error;
|
|
181
|
+
}
|
|
182
|
+
else
|
|
183
|
+
return {};
|
|
184
|
+
if ("supportedScales" in $o && $o["supportedScales"] !== undefined) {
|
|
185
|
+
const error = sa__number_ea_3($o["supportedScales"]);
|
|
186
|
+
if (error)
|
|
187
|
+
return error;
|
|
188
|
+
}
|
|
189
|
+
else
|
|
190
|
+
return {};
|
|
191
|
+
if ("supportedRateTypes" in $o && $o["supportedRateTypes"] !== undefined) {
|
|
192
|
+
const error = sa_su__5__6__7_eu_ea_4($o["supportedRateTypes"]);
|
|
193
|
+
if (error)
|
|
194
|
+
return error;
|
|
195
|
+
}
|
|
196
|
+
else
|
|
197
|
+
return {};
|
|
198
|
+
return null;
|
|
199
|
+
}
|
|
200
|
+
return _0($o);
|
|
201
|
+
};
|
|
202
|
+
const __assertType__optional_MeterCCResetOptions = $o => {
|
|
203
|
+
function _number($o) {
|
|
204
|
+
return typeof $o !== "number" ? {} : null;
|
|
205
|
+
}
|
|
206
|
+
function su__4__5__6_eu($o) {
|
|
207
|
+
return ![0, 1, 2].includes($o) ? {} : null;
|
|
208
|
+
}
|
|
209
|
+
function _1($o) {
|
|
210
|
+
if (typeof $o !== "object" || $o === null || Array.isArray($o))
|
|
211
|
+
return {};
|
|
212
|
+
if ("type" in $o && $o["type"] !== undefined) {
|
|
213
|
+
const error = _number($o["type"]);
|
|
214
|
+
if (error)
|
|
215
|
+
return error;
|
|
216
|
+
}
|
|
217
|
+
else
|
|
218
|
+
return {};
|
|
219
|
+
if ("scale" in $o && $o["scale"] !== undefined) {
|
|
220
|
+
const error = _number($o["scale"]);
|
|
221
|
+
if (error)
|
|
222
|
+
return error;
|
|
223
|
+
}
|
|
224
|
+
else
|
|
225
|
+
return {};
|
|
226
|
+
if ("rateType" in $o && $o["rateType"] !== undefined) {
|
|
227
|
+
const error = su__4__5__6_eu($o["rateType"]);
|
|
228
|
+
if (error)
|
|
229
|
+
return error;
|
|
230
|
+
}
|
|
78
231
|
else
|
|
79
232
|
return {};
|
|
80
233
|
if ("targetValue" in $o && $o["targetValue"] !== undefined) {
|
|
@@ -86,6 +239,34 @@ const __assertType__optional_MeterCCResetOptions = $o => {
|
|
|
86
239
|
return {};
|
|
87
240
|
return null;
|
|
88
241
|
}
|
|
242
|
+
function _undefined($o) {
|
|
243
|
+
return $o !== undefined ? {} : null;
|
|
244
|
+
}
|
|
245
|
+
function _2($o) {
|
|
246
|
+
if (typeof $o !== "object" || $o === null || Array.isArray($o))
|
|
247
|
+
return {};
|
|
248
|
+
if ("type" in $o && $o["type"] !== undefined) {
|
|
249
|
+
const error = _undefined($o["type"]);
|
|
250
|
+
if (error)
|
|
251
|
+
return error;
|
|
252
|
+
}
|
|
253
|
+
if ("scale" in $o && $o["scale"] !== undefined) {
|
|
254
|
+
const error = _undefined($o["scale"]);
|
|
255
|
+
if (error)
|
|
256
|
+
return error;
|
|
257
|
+
}
|
|
258
|
+
if ("rateType" in $o && $o["rateType"] !== undefined) {
|
|
259
|
+
const error = _undefined($o["rateType"]);
|
|
260
|
+
if (error)
|
|
261
|
+
return error;
|
|
262
|
+
}
|
|
263
|
+
if ("targetValue" in $o && $o["targetValue"] !== undefined) {
|
|
264
|
+
const error = _undefined($o["targetValue"]);
|
|
265
|
+
if (error)
|
|
266
|
+
return error;
|
|
267
|
+
}
|
|
268
|
+
return null;
|
|
269
|
+
}
|
|
89
270
|
function su__1__2_eu($o) {
|
|
90
271
|
const conditions = [_1, _2];
|
|
91
272
|
for (const condition of conditions) {
|
|
@@ -105,7 +286,6 @@ const __assertType__optional_MeterCCResetOptions = $o => {
|
|
|
105
286
|
}
|
|
106
287
|
return optional_su__1__2_eu($o);
|
|
107
288
|
};
|
|
108
|
-
const config_1 = require("@zwave-js/config");
|
|
109
289
|
const core_1 = require("@zwave-js/core");
|
|
110
290
|
const safe_1 = require("@zwave-js/core/safe");
|
|
111
291
|
const safe_2 = require("@zwave-js/shared/safe");
|
|
@@ -131,15 +311,23 @@ exports.MeterCCValues = Object.freeze({
|
|
|
131
311
|
}),
|
|
132
312
|
}),
|
|
133
313
|
...Values_1.V.defineDynamicCCValues(safe_1.CommandClasses.Meter, {
|
|
134
|
-
...Values_1.V.dynamicPropertyAndKeyWithName("resetSingle", "reset",
|
|
314
|
+
...Values_1.V.dynamicPropertyAndKeyWithName("resetSingle", "reset", toPropertyKey, ({ property, propertyKey }) => property === "reset" && typeof propertyKey === "number", (meterType, rateType, scale) => ({
|
|
135
315
|
...safe_1.ValueMetadata.WriteOnlyBoolean,
|
|
136
316
|
// This is only a placeholder label. A config manager is needed to
|
|
137
317
|
// determine the actual label.
|
|
138
|
-
label: `Reset (${
|
|
318
|
+
label: `Reset (${rateType === _Types_1.RateType.Consumed
|
|
319
|
+
? "Consumption, "
|
|
320
|
+
: rateType === _Types_1.RateType.Produced
|
|
321
|
+
? "Production, "
|
|
322
|
+
: ""}${(0, safe_2.num2hex)(scale)})`,
|
|
139
323
|
states: {
|
|
140
324
|
true: "Reset",
|
|
141
325
|
},
|
|
142
|
-
ccSpecific: {
|
|
326
|
+
ccSpecific: {
|
|
327
|
+
meterType,
|
|
328
|
+
rateType,
|
|
329
|
+
scale,
|
|
330
|
+
},
|
|
143
331
|
})),
|
|
144
332
|
...Values_1.V.dynamicPropertyAndKeyWithName("value", "value", toPropertyKey, ({ property, propertyKey }) => property === "value" && typeof propertyKey === "number", (meterType, rateType, scale) => ({
|
|
145
333
|
...safe_1.ValueMetadata.ReadOnlyNumber,
|
|
@@ -162,32 +350,102 @@ function splitPropertyKey(key) {
|
|
|
162
350
|
meterType: key >>> 16,
|
|
163
351
|
};
|
|
164
352
|
}
|
|
165
|
-
function
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
function getValueLabel(configManager, meterType, scale, rateType, suffix) {
|
|
169
|
-
let ret = getMeterTypeName(configManager, meterType);
|
|
353
|
+
function getValueLabel(meterType, scale, rateType, suffix) {
|
|
354
|
+
let ret = (0, core_1.getMeterName)(meterType);
|
|
355
|
+
const scaleLabel = ((0, core_1.getMeterScale)(meterType, scale) ?? (0, core_1.getUnknownMeterScale)(scale)).label;
|
|
170
356
|
switch (rateType) {
|
|
171
357
|
case _Types_1.RateType.Consumed:
|
|
172
|
-
ret += ` Consumption [${
|
|
358
|
+
ret += ` Consumption [${scaleLabel}]`;
|
|
173
359
|
break;
|
|
174
360
|
case _Types_1.RateType.Produced:
|
|
175
|
-
ret += ` Production [${
|
|
361
|
+
ret += ` Production [${scaleLabel}]`;
|
|
176
362
|
break;
|
|
177
363
|
default:
|
|
178
|
-
ret += ` [${
|
|
364
|
+
ret += ` [${scaleLabel}]`;
|
|
179
365
|
}
|
|
180
366
|
if (suffix) {
|
|
181
367
|
ret += ` (${suffix})`;
|
|
182
368
|
}
|
|
183
369
|
return ret;
|
|
184
370
|
}
|
|
371
|
+
function parseMeterValueAndInfo(data, offset) {
|
|
372
|
+
(0, safe_1.validatePayload)(data.length >= offset + 1);
|
|
373
|
+
const type = data[offset] & 0b0_00_11111;
|
|
374
|
+
const rateType = (data[offset] & 0b0_11_00000) >>> 5;
|
|
375
|
+
const scale1Bit2 = (data[offset] & 0b1_00_00000) >>> 7;
|
|
376
|
+
const { scale: scale1Bits10, value, bytesRead, } = (0, safe_1.parseFloatWithScale)(data.subarray(offset + 1));
|
|
377
|
+
return {
|
|
378
|
+
type,
|
|
379
|
+
rateType,
|
|
380
|
+
// The scale is composed of two fields
|
|
381
|
+
scale1: (scale1Bit2 << 2) | scale1Bits10,
|
|
382
|
+
value,
|
|
383
|
+
// We've read one byte more than the float contains
|
|
384
|
+
bytesRead: bytesRead + 1,
|
|
385
|
+
};
|
|
386
|
+
}
|
|
387
|
+
function encodeMeterValueAndInfo(type, rateType, scale, value) {
|
|
388
|
+
// We need at least 2 bytes
|
|
389
|
+
const scale1 = scale >= 7 ? 7 : scale & 0b111;
|
|
390
|
+
const scale1Bits10 = scale1 & 0b11;
|
|
391
|
+
const scale1Bit2 = scale1 >>> 2;
|
|
392
|
+
const scale2 = scale >= 7 ? scale - 7 : undefined;
|
|
393
|
+
const typeByte = (type & 0b0_00_11111)
|
|
394
|
+
| ((rateType & 0b11) << 5)
|
|
395
|
+
| (scale1Bit2 << 7);
|
|
396
|
+
const floatParams = (0, core_1.getFloatParameters)(value);
|
|
397
|
+
const valueBytes = (0, core_1.encodeFloatWithScale)(value, scale1Bits10, floatParams);
|
|
398
|
+
return {
|
|
399
|
+
data: Buffer.concat([Buffer.from([typeByte]), valueBytes]),
|
|
400
|
+
floatParams: (0, safe_2.pick)(floatParams, ["precision", "size"]),
|
|
401
|
+
scale2,
|
|
402
|
+
};
|
|
403
|
+
}
|
|
404
|
+
function parseScale(scale1, data, scale2Offset) {
|
|
405
|
+
if (scale1 === 7) {
|
|
406
|
+
(0, safe_1.validatePayload)(data.length >= scale2Offset + 1);
|
|
407
|
+
const scale2 = data[scale2Offset];
|
|
408
|
+
return scale1 + scale2;
|
|
409
|
+
}
|
|
410
|
+
else {
|
|
411
|
+
return scale1;
|
|
412
|
+
}
|
|
413
|
+
}
|
|
414
|
+
function isAccumulatedValue(meterType, scale) {
|
|
415
|
+
// FIXME: We should probably move the meter definitions into code
|
|
416
|
+
switch (meterType) {
|
|
417
|
+
case 0x01: // Electric
|
|
418
|
+
return (scale === 0x00 // kWh
|
|
419
|
+
|| scale === 0x01 // kVAh
|
|
420
|
+
|| scale === 0x03 // Pulse count
|
|
421
|
+
|| scale === 0x08 // kVarh
|
|
422
|
+
);
|
|
423
|
+
case 0x02: // Gas
|
|
424
|
+
return (scale === 0x00 // m³
|
|
425
|
+
|| scale === 0x01 // ft³
|
|
426
|
+
|| scale === 0x03 // Pulse count
|
|
427
|
+
);
|
|
428
|
+
case 0x03: // Water
|
|
429
|
+
return (scale === 0x00 // m³
|
|
430
|
+
|| scale === 0x01 // ft³
|
|
431
|
+
|| scale === 0x02 // US gallons
|
|
432
|
+
|| scale === 0x03 // Pulse count
|
|
433
|
+
);
|
|
434
|
+
case 0x04: // Heating
|
|
435
|
+
return scale === 0x00; // kWh
|
|
436
|
+
case 0x05: // Cooling
|
|
437
|
+
return scale === 0x00; // kWh
|
|
438
|
+
}
|
|
439
|
+
return false;
|
|
440
|
+
}
|
|
185
441
|
let MeterCCAPI = class MeterCCAPI extends API_1.PhysicalCCAPI {
|
|
186
442
|
supportsCommand(cmd) {
|
|
187
443
|
switch (cmd) {
|
|
188
444
|
case _Types_1.MeterCommand.Get:
|
|
445
|
+
case _Types_1.MeterCommand.Report:
|
|
189
446
|
return true; // This is mandatory
|
|
190
447
|
case _Types_1.MeterCommand.SupportedGet:
|
|
448
|
+
case _Types_1.MeterCommand.SupportedReport:
|
|
191
449
|
return this.version >= 2;
|
|
192
450
|
case _Types_1.MeterCommand.Reset: {
|
|
193
451
|
const ret = this.tryGetValueDB()?.getValue({
|
|
@@ -235,7 +493,8 @@ let MeterCCAPI = class MeterCCAPI extends API_1.PhysicalCCAPI {
|
|
|
235
493
|
if (response) {
|
|
236
494
|
return {
|
|
237
495
|
type: response.type,
|
|
238
|
-
scale:
|
|
496
|
+
scale: (0, core_1.getMeterScale)(response.type, response.scale)
|
|
497
|
+
?? (0, core_1.getUnknownMeterScale)(response.scale),
|
|
239
498
|
...(0, safe_2.pick)(response, [
|
|
240
499
|
"value",
|
|
241
500
|
"previousValue",
|
|
@@ -245,10 +504,21 @@ let MeterCCAPI = class MeterCCAPI extends API_1.PhysicalCCAPI {
|
|
|
245
504
|
};
|
|
246
505
|
}
|
|
247
506
|
}
|
|
248
|
-
|
|
249
|
-
|
|
507
|
+
async sendReport(options) {
|
|
508
|
+
__assertType("options", "MeterCCReportOptions", __assertType__MeterCCReportOptions.bind(void 0, options));
|
|
509
|
+
this.assertSupportsCommand(_Types_1.MeterCommand, _Types_1.MeterCommand.Report);
|
|
510
|
+
const cc = new MeterCCReport(this.applHost, {
|
|
511
|
+
nodeId: this.endpoint.nodeId,
|
|
512
|
+
endpoint: this.endpoint.index,
|
|
513
|
+
...options,
|
|
514
|
+
});
|
|
515
|
+
return this.applHost.sendCommand(cc, this.commandOptions);
|
|
516
|
+
}
|
|
517
|
+
async getAll(accumulatedOnly = false) {
|
|
518
|
+
__assertType("accumulatedOnly", "(optional) boolean", __assertType__optional_boolean.bind(void 0, accumulatedOnly));
|
|
250
519
|
const valueDB = this.tryGetValueDB();
|
|
251
520
|
if (this.version >= 2) {
|
|
521
|
+
const meterType = valueDB?.getValue(exports.MeterCCValues.type.endpoint(this.endpoint.index));
|
|
252
522
|
const supportedScales = valueDB?.getValue(exports.MeterCCValues.supportedScales.endpoint(this.endpoint.index)) ?? [];
|
|
253
523
|
const supportedRateTypes = valueDB?.getValue(exports.MeterCCValues.supportedRateTypes.endpoint(this.endpoint.index)) ?? [];
|
|
254
524
|
const rateTypes = supportedRateTypes.length
|
|
@@ -257,6 +527,12 @@ let MeterCCAPI = class MeterCCAPI extends API_1.PhysicalCCAPI {
|
|
|
257
527
|
const ret = [];
|
|
258
528
|
for (const rateType of rateTypes) {
|
|
259
529
|
for (const scale of supportedScales) {
|
|
530
|
+
// Skip non-accumulated values if requested
|
|
531
|
+
if (accumulatedOnly
|
|
532
|
+
&& meterType != undefined
|
|
533
|
+
&& !isAccumulatedValue(meterType, scale)) {
|
|
534
|
+
continue;
|
|
535
|
+
}
|
|
260
536
|
const response = await this.get({
|
|
261
537
|
scale,
|
|
262
538
|
rateType,
|
|
@@ -289,6 +565,16 @@ let MeterCCAPI = class MeterCCAPI extends API_1.PhysicalCCAPI {
|
|
|
289
565
|
]);
|
|
290
566
|
}
|
|
291
567
|
}
|
|
568
|
+
async sendSupportedReport(options) {
|
|
569
|
+
__assertType("options", "MeterCCSupportedReportOptions", __assertType__MeterCCSupportedReportOptions.bind(void 0, options));
|
|
570
|
+
this.assertSupportsCommand(_Types_1.MeterCommand, _Types_1.MeterCommand.SupportedReport);
|
|
571
|
+
const cc = new MeterCCSupportedReport(this.applHost, {
|
|
572
|
+
nodeId: this.endpoint.nodeId,
|
|
573
|
+
endpoint: this.endpoint.index,
|
|
574
|
+
...options,
|
|
575
|
+
});
|
|
576
|
+
await this.applHost.sendCommand(cc, this.commandOptions);
|
|
577
|
+
}
|
|
292
578
|
async reset(options) {
|
|
293
579
|
__assertType("options", "(optional) MeterCCResetOptions", __assertType__optional_MeterCCResetOptions.bind(void 0, options));
|
|
294
580
|
this.assertSupportsCommand(_Types_1.MeterCommand, _Types_1.MeterCommand.Reset);
|
|
@@ -311,18 +597,83 @@ let MeterCCAPI = class MeterCCAPI extends API_1.PhysicalCCAPI {
|
|
|
311
597
|
else if (value !== true) {
|
|
312
598
|
(0, API_1.throwWrongValueType)(this.ccId, property, "true", value === false ? "false" : typeof value);
|
|
313
599
|
}
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
600
|
+
if (typeof propertyKey === "number") {
|
|
601
|
+
const { meterType, scale, rateType } = splitPropertyKey(propertyKey);
|
|
602
|
+
return this.reset({
|
|
603
|
+
type: meterType,
|
|
604
|
+
scale,
|
|
605
|
+
rateType,
|
|
317
606
|
targetValue: 0,
|
|
318
|
-
}
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
607
|
+
});
|
|
608
|
+
}
|
|
609
|
+
else {
|
|
610
|
+
return this.reset();
|
|
611
|
+
}
|
|
323
612
|
return undefined;
|
|
324
613
|
};
|
|
325
614
|
}
|
|
615
|
+
[API_1.SET_VALUE_HOOKS] = ({ property, propertyKey }, _value, _options) => {
|
|
616
|
+
if (property !== "reset")
|
|
617
|
+
return;
|
|
618
|
+
if (typeof propertyKey === "number") {
|
|
619
|
+
// Reset single
|
|
620
|
+
const { meterType, rateType, scale } = splitPropertyKey(propertyKey);
|
|
621
|
+
const readingValueId = exports.MeterCCValues.value(meterType, rateType, scale).endpoint(this.endpoint.index);
|
|
622
|
+
return {
|
|
623
|
+
optimisticallyUpdateRelatedValues: (supervisedAndSuccessful) => {
|
|
624
|
+
if (!supervisedAndSuccessful)
|
|
625
|
+
return;
|
|
626
|
+
// After resetting a single reading with supervision, store zero
|
|
627
|
+
// in the corresponding value
|
|
628
|
+
const valueDB = this.tryGetValueDB();
|
|
629
|
+
if (!valueDB)
|
|
630
|
+
return;
|
|
631
|
+
if (isAccumulatedValue(meterType, scale)) {
|
|
632
|
+
valueDB.setValue({
|
|
633
|
+
commandClass: this.ccId,
|
|
634
|
+
endpoint: this.endpoint.index,
|
|
635
|
+
property,
|
|
636
|
+
propertyKey,
|
|
637
|
+
}, 0);
|
|
638
|
+
}
|
|
639
|
+
},
|
|
640
|
+
verifyChanges: () => {
|
|
641
|
+
this.schedulePoll(readingValueId, 0, { transition: "fast" });
|
|
642
|
+
},
|
|
643
|
+
};
|
|
644
|
+
}
|
|
645
|
+
else {
|
|
646
|
+
// Reset all
|
|
647
|
+
const valueDB = this.tryGetValueDB();
|
|
648
|
+
if (!valueDB)
|
|
649
|
+
return;
|
|
650
|
+
const accumulatedValues = valueDB.findValues((vid) => vid.commandClass === this.ccId
|
|
651
|
+
&& vid.endpoint === this.endpoint.index
|
|
652
|
+
&& exports.MeterCCValues.value.is(vid)).filter(({ propertyKey }) => {
|
|
653
|
+
if (typeof propertyKey !== "number")
|
|
654
|
+
return false;
|
|
655
|
+
const { meterType, scale } = splitPropertyKey(propertyKey);
|
|
656
|
+
return isAccumulatedValue(meterType, scale);
|
|
657
|
+
});
|
|
658
|
+
return {
|
|
659
|
+
optimisticallyUpdateRelatedValues: (supervisedAndSuccessful) => {
|
|
660
|
+
if (!supervisedAndSuccessful)
|
|
661
|
+
return;
|
|
662
|
+
// After setting the reset all value with supervision,
|
|
663
|
+
// reset all accumulated values, since we know they are now zero.
|
|
664
|
+
for (const value of accumulatedValues) {
|
|
665
|
+
valueDB.setValue(value, 0);
|
|
666
|
+
}
|
|
667
|
+
},
|
|
668
|
+
verifyChanges: () => {
|
|
669
|
+
// Poll all accumulated values, unless they were updated by the device
|
|
670
|
+
for (const valueID of accumulatedValues) {
|
|
671
|
+
this.schedulePoll(valueID, 0, { transition: "fast" });
|
|
672
|
+
}
|
|
673
|
+
},
|
|
674
|
+
};
|
|
675
|
+
}
|
|
676
|
+
};
|
|
326
677
|
};
|
|
327
678
|
exports.MeterCCAPI = MeterCCAPI;
|
|
328
679
|
exports.MeterCCAPI = MeterCCAPI = __decorate([
|
|
@@ -349,9 +700,10 @@ let MeterCC = class MeterCC extends CommandClass_1.CommandClass {
|
|
|
349
700
|
const suppResp = await api.getSupported();
|
|
350
701
|
if (suppResp) {
|
|
351
702
|
const logMessage = `received meter support:
|
|
352
|
-
type: ${
|
|
703
|
+
type: ${(0, core_1.getMeterName)(suppResp.type)}
|
|
353
704
|
supported scales: ${suppResp.supportedScales
|
|
354
|
-
.map((s) =>
|
|
705
|
+
.map((s) => ((0, core_1.getMeterScale)(suppResp.type, s)
|
|
706
|
+
?? (0, core_1.getUnknownMeterScale)(s)).label)
|
|
355
707
|
.map((label) => `\n· ${label}`)
|
|
356
708
|
.join("")}
|
|
357
709
|
supported rate types: ${suppResp.supportedRateTypes
|
|
@@ -405,8 +757,8 @@ supports reset: ${suppResp.supportsReset}`;
|
|
|
405
757
|
for (const scale of supportedScales) {
|
|
406
758
|
applHost.controllerLog.logNode(node.id, {
|
|
407
759
|
endpoint: this.endpointIndex,
|
|
408
|
-
message: `querying meter value (type = ${
|
|
409
|
-
.label}${rateType != undefined
|
|
760
|
+
message: `querying meter value (type = ${(0, core_1.getMeterName)(type)}, scale = ${((0, core_1.getMeterScale)(type, scale)
|
|
761
|
+
?? (0, core_1.getUnknownMeterScale)(scale)).label}${rateType != undefined
|
|
410
762
|
? `, rate type = ${(0, safe_2.getEnumMemberName)(_Types_1.RateType, rateType)}`
|
|
411
763
|
: ""})...`,
|
|
412
764
|
direction: "outbound",
|
|
@@ -471,8 +823,8 @@ supports reset: ${suppResp.supportsReset}`;
|
|
|
471
823
|
const { meterType, rateType, scale } = splitPropertyKey(propertyKey);
|
|
472
824
|
let ret;
|
|
473
825
|
if (meterType !== 0) {
|
|
474
|
-
ret = `${
|
|
475
|
-
.label}`;
|
|
826
|
+
ret = `${(0, core_1.getMeterName)(meterType)}_${((0, core_1.getMeterScale)(meterType, scale)
|
|
827
|
+
?? (0, core_1.getUnknownMeterScale)(scale)).label}`;
|
|
476
828
|
}
|
|
477
829
|
else {
|
|
478
830
|
ret = "default";
|
|
@@ -483,7 +835,7 @@ supports reset: ${suppResp.supportsReset}`;
|
|
|
483
835
|
return ret;
|
|
484
836
|
}
|
|
485
837
|
else if (property === "reset" && typeof propertyKey === "number") {
|
|
486
|
-
return
|
|
838
|
+
return (0, core_1.getMeterName)(propertyKey);
|
|
487
839
|
}
|
|
488
840
|
return super.translatePropertyKey(applHost, property, propertyKey);
|
|
489
841
|
}
|
|
@@ -498,46 +850,37 @@ let MeterCCReport = class MeterCCReport extends MeterCC {
|
|
|
498
850
|
constructor(host, options) {
|
|
499
851
|
super(host, options);
|
|
500
852
|
if ((0, CommandClass_1.gotDeserializationOptions)(options)) {
|
|
501
|
-
|
|
502
|
-
this.type =
|
|
503
|
-
this.rateType =
|
|
504
|
-
const scale1Bit2 = (this.payload[0] & 0b1_00_00000) >>> 7;
|
|
505
|
-
const { scale: scale1Bits10, value, bytesRead, } = (0, safe_1.parseFloatWithScale)(this.payload.subarray(1));
|
|
506
|
-
let offset = 2 + (bytesRead - 1);
|
|
507
|
-
// The scale is composed of two fields (see SDS13781)
|
|
508
|
-
const scale1 = (scale1Bit2 << 2) | scale1Bits10;
|
|
509
|
-
let scale2 = 0;
|
|
853
|
+
const { type, rateType, scale1, value, bytesRead } = parseMeterValueAndInfo(this.payload, 0);
|
|
854
|
+
this.type = type;
|
|
855
|
+
this.rateType = rateType;
|
|
510
856
|
this.value = value;
|
|
511
|
-
|
|
857
|
+
let offset = bytesRead;
|
|
858
|
+
const floatSize = bytesRead - 2;
|
|
859
|
+
if (this.payload.length >= offset + 2) {
|
|
512
860
|
this.deltaTime = this.payload.readUInt16BE(offset);
|
|
513
861
|
offset += 2;
|
|
514
862
|
if (this.deltaTime === 0xffff) {
|
|
515
863
|
this.deltaTime = safe_1.UNKNOWN_STATE;
|
|
516
864
|
}
|
|
517
865
|
if (
|
|
518
|
-
//
|
|
866
|
+
// Previous value is included only if delta time is not 0
|
|
519
867
|
this.deltaTime !== 0
|
|
520
|
-
&& this.payload.length >= offset +
|
|
868
|
+
&& this.payload.length >= offset + floatSize) {
|
|
521
869
|
const { value: prevValue } = (0, safe_1.parseFloatWithScale)(
|
|
522
870
|
// This float is split in the payload
|
|
523
871
|
Buffer.concat([
|
|
524
872
|
Buffer.from([this.payload[1]]),
|
|
525
873
|
this.payload.subarray(offset),
|
|
526
874
|
]));
|
|
527
|
-
offset +=
|
|
875
|
+
offset += floatSize;
|
|
528
876
|
this.previousValue = prevValue;
|
|
529
877
|
}
|
|
530
|
-
if (this.version >= 4
|
|
531
|
-
&& scale1 === 7
|
|
532
|
-
&& this.payload.length >= offset + 1) {
|
|
533
|
-
scale2 = this.payload[offset];
|
|
534
|
-
}
|
|
535
878
|
}
|
|
536
879
|
else {
|
|
537
880
|
// 0 means that no previous value is included
|
|
538
881
|
this.deltaTime = 0;
|
|
539
882
|
}
|
|
540
|
-
this.scale = scale1
|
|
883
|
+
this.scale = parseScale(scale1, this.payload, offset);
|
|
541
884
|
}
|
|
542
885
|
else {
|
|
543
886
|
this.type = options.type;
|
|
@@ -551,13 +894,14 @@ let MeterCCReport = class MeterCCReport extends MeterCC {
|
|
|
551
894
|
persistValues(applHost) {
|
|
552
895
|
if (!super.persistValues(applHost))
|
|
553
896
|
return false;
|
|
554
|
-
const
|
|
555
|
-
const scale =
|
|
897
|
+
const meter = (0, core_1.getMeter)(this.type);
|
|
898
|
+
const scale = (0, core_1.getMeterScale)(this.type, this.scale)
|
|
899
|
+
?? (0, core_1.getUnknownMeterScale)(this.scale);
|
|
556
900
|
// Filter out unknown meter types and scales, unless the strict validation is disabled
|
|
557
901
|
const measurementValidation = !this.host.getDeviceConfig?.(this.nodeId)?.compat?.disableStrictMeasurementValidation;
|
|
558
902
|
if (measurementValidation) {
|
|
559
|
-
safe_1.validatePayload.withReason(`Unknown meter type ${(0, safe_2.num2hex)(this.type)} or corrupted data`)(!!
|
|
560
|
-
safe_1.validatePayload.withReason(`Unknown meter scale ${(0, safe_2.num2hex)(this.scale)} or corrupted data`)(scale.label !== (0,
|
|
903
|
+
safe_1.validatePayload.withReason(`Unknown meter type ${(0, safe_2.num2hex)(this.type)} or corrupted data`)(!!meter);
|
|
904
|
+
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);
|
|
561
905
|
// Filter out unsupported meter types, scales and rate types if possible
|
|
562
906
|
if (this.version >= 2) {
|
|
563
907
|
const expectedType = this.getValue(applHost, exports.MeterCCValues.type);
|
|
@@ -577,7 +921,7 @@ let MeterCCReport = class MeterCCReport extends MeterCC {
|
|
|
577
921
|
const valueValue = exports.MeterCCValues.value(this.type, this.rateType, this.scale);
|
|
578
922
|
this.setMetadata(applHost, valueValue, {
|
|
579
923
|
...valueValue.meta,
|
|
580
|
-
label: getValueLabel(
|
|
924
|
+
label: getValueLabel(this.type, this.scale, this.rateType),
|
|
581
925
|
unit: scale.label,
|
|
582
926
|
ccSpecific: {
|
|
583
927
|
meterType: this.type,
|
|
@@ -595,35 +939,36 @@ let MeterCCReport = class MeterCCReport extends MeterCC {
|
|
|
595
939
|
rateType;
|
|
596
940
|
deltaTime;
|
|
597
941
|
serialize() {
|
|
598
|
-
const
|
|
599
|
-
const scale1Bits10 = scale1 & 0b11;
|
|
600
|
-
const scale1Bit2 = scale1 >>> 2;
|
|
601
|
-
const scale2 = this.scale >= 7 ? this.scale - 7 : 0;
|
|
602
|
-
const typeByte = (this.type & 0b0_00_11111)
|
|
603
|
-
| ((this.rateType & 0b11) << 5)
|
|
604
|
-
| (scale1Bit2 << 7);
|
|
605
|
-
const floatParams = (0, core_1.getFloatParameters)(this.value);
|
|
606
|
-
const valueBytes = (0, core_1.encodeFloatWithScale)(this.value, scale1Bits10, floatParams);
|
|
607
|
-
const prevValueBytes = this.previousValue != undefined
|
|
608
|
-
? (0, core_1.encodeFloatWithScale)(this.previousValue, scale1Bits10, floatParams)
|
|
609
|
-
: Buffer.from([]);
|
|
942
|
+
const { data: typeAndValue, floatParams, scale2 } = encodeMeterValueAndInfo(this.type, this.rateType, this.scale, this.value);
|
|
610
943
|
const deltaTime = this.deltaTime ?? 0xffff;
|
|
611
944
|
const deltaTimeBytes = Buffer.allocUnsafe(2);
|
|
612
945
|
deltaTimeBytes.writeUInt16BE(deltaTime, 0);
|
|
613
946
|
this.payload = Buffer.concat([
|
|
614
|
-
|
|
615
|
-
valueBytes,
|
|
947
|
+
typeAndValue,
|
|
616
948
|
deltaTimeBytes,
|
|
617
|
-
prevValueBytes,
|
|
618
|
-
Buffer.from([scale2]),
|
|
619
949
|
]);
|
|
950
|
+
if (this.deltaTime !== 0 && this.previousValue != undefined) {
|
|
951
|
+
// Encode the float, but only keep the value bytes
|
|
952
|
+
const prevValueBytes = (0, core_1.encodeFloatWithScale)(this.previousValue, 0, // we discard the scale anyways
|
|
953
|
+
floatParams).subarray(1);
|
|
954
|
+
this.payload = Buffer.concat([
|
|
955
|
+
this.payload,
|
|
956
|
+
prevValueBytes,
|
|
957
|
+
]);
|
|
958
|
+
}
|
|
959
|
+
if (scale2 != undefined) {
|
|
960
|
+
this.payload = Buffer.concat([
|
|
961
|
+
this.payload,
|
|
962
|
+
Buffer.from([scale2]),
|
|
963
|
+
]);
|
|
964
|
+
}
|
|
620
965
|
return super.serialize();
|
|
621
966
|
}
|
|
622
|
-
toLogEntry(
|
|
623
|
-
const
|
|
624
|
-
|
|
967
|
+
toLogEntry(host) {
|
|
968
|
+
const scale = (0, core_1.getMeterScale)(this.type, this.scale)
|
|
969
|
+
?? (0, core_1.getUnknownMeterScale)(this.scale);
|
|
625
970
|
const message = {
|
|
626
|
-
type:
|
|
971
|
+
"meter type": (0, core_1.getMeterName)(this.type),
|
|
627
972
|
scale: scale.label,
|
|
628
973
|
"rate type": (0, safe_2.getEnumMemberName)(_Types_1.RateType, this.rateType),
|
|
629
974
|
value: this.value,
|
|
@@ -635,7 +980,7 @@ let MeterCCReport = class MeterCCReport extends MeterCC {
|
|
|
635
980
|
message["prev. value"] = this.previousValue;
|
|
636
981
|
}
|
|
637
982
|
return {
|
|
638
|
-
...super.toLogEntry(
|
|
983
|
+
...super.toLogEntry(host),
|
|
639
984
|
message,
|
|
640
985
|
};
|
|
641
986
|
}
|
|
@@ -654,8 +999,14 @@ let MeterCCGet = class MeterCCGet extends MeterCC {
|
|
|
654
999
|
constructor(host, options) {
|
|
655
1000
|
super(host, options);
|
|
656
1001
|
if ((0, CommandClass_1.gotDeserializationOptions)(options)) {
|
|
657
|
-
|
|
658
|
-
|
|
1002
|
+
if (this.payload.length >= 1) {
|
|
1003
|
+
this.rateType = (this.payload[0] & 0b11_000_000) >>> 6;
|
|
1004
|
+
this.scale = (this.payload[0] & 0b00_111_000) >>> 3;
|
|
1005
|
+
if (this.scale === 7) {
|
|
1006
|
+
(0, safe_1.validatePayload)(this.payload.length >= 2);
|
|
1007
|
+
this.scale += this.payload[1];
|
|
1008
|
+
}
|
|
1009
|
+
}
|
|
659
1010
|
}
|
|
660
1011
|
else {
|
|
661
1012
|
this.rateType = options.rateType;
|
|
@@ -698,20 +1049,26 @@ let MeterCCGet = class MeterCCGet extends MeterCC {
|
|
|
698
1049
|
this.payload[1] = scale2;
|
|
699
1050
|
return super.serialize();
|
|
700
1051
|
}
|
|
701
|
-
toLogEntry(
|
|
1052
|
+
toLogEntry(host) {
|
|
702
1053
|
const message = {};
|
|
703
1054
|
if (this.rateType != undefined) {
|
|
704
1055
|
message["rate type"] = (0, safe_2.getEnumMemberName)(_Types_1.RateType, this.rateType);
|
|
705
1056
|
}
|
|
706
1057
|
if (this.scale != undefined) {
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
1058
|
+
if (host) {
|
|
1059
|
+
// Try to lookup the meter type to translate the scale
|
|
1060
|
+
const type = this.getValue(host, exports.MeterCCValues.type);
|
|
1061
|
+
if (type != undefined) {
|
|
1062
|
+
message.scale = ((0, core_1.getMeterScale)(type, this.scale)
|
|
1063
|
+
?? (0, core_1.getUnknownMeterScale)(this.scale)).label;
|
|
1064
|
+
}
|
|
1065
|
+
}
|
|
1066
|
+
else {
|
|
1067
|
+
message.scale = this.scale;
|
|
711
1068
|
}
|
|
712
1069
|
}
|
|
713
1070
|
return {
|
|
714
|
-
...super.toLogEntry(
|
|
1071
|
+
...super.toLogEntry(host),
|
|
715
1072
|
message,
|
|
716
1073
|
};
|
|
717
1074
|
}
|
|
@@ -724,28 +1081,36 @@ exports.MeterCCGet = MeterCCGet = __decorate([
|
|
|
724
1081
|
let MeterCCSupportedReport = class MeterCCSupportedReport extends MeterCC {
|
|
725
1082
|
constructor(host, options) {
|
|
726
1083
|
super(host, options);
|
|
727
|
-
(0,
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
1084
|
+
if ((0, CommandClass_1.gotDeserializationOptions)(options)) {
|
|
1085
|
+
(0, safe_1.validatePayload)(this.payload.length >= 2);
|
|
1086
|
+
this.type = this.payload[0] & 0b0_00_11111;
|
|
1087
|
+
this.supportsReset = !!(this.payload[0] & 0b1_00_00000);
|
|
1088
|
+
const hasMoreScales = !!(this.payload[1] & 0b1_0000000);
|
|
1089
|
+
if (hasMoreScales) {
|
|
1090
|
+
// The bitmask is spread out
|
|
1091
|
+
(0, safe_1.validatePayload)(this.payload.length >= 3);
|
|
1092
|
+
const extraBytes = this.payload[2];
|
|
1093
|
+
(0, safe_1.validatePayload)(this.payload.length >= 3 + extraBytes);
|
|
1094
|
+
// The bitmask is the original payload byte plus all following bytes
|
|
1095
|
+
// Since the first byte only has 7 bits, we need to reduce all following bits by 1
|
|
1096
|
+
this.supportedScales = (0, safe_1.parseBitMask)(Buffer.concat([
|
|
1097
|
+
Buffer.from([this.payload[1] & 0b0_1111111]),
|
|
1098
|
+
this.payload.subarray(3, 3 + extraBytes),
|
|
1099
|
+
]), 0).map((scale) => (scale >= 8 ? scale - 1 : scale));
|
|
1100
|
+
}
|
|
1101
|
+
else {
|
|
1102
|
+
// only 7 bits in the bitmask. Bit 7 is 0, so no need to mask it out
|
|
1103
|
+
this.supportedScales = (0, safe_1.parseBitMask)(Buffer.from([this.payload[1]]), 0);
|
|
1104
|
+
}
|
|
1105
|
+
// This is only present in V4+
|
|
1106
|
+
this.supportedRateTypes = (0, safe_1.parseBitMask)(Buffer.from([(this.payload[0] & 0b0_11_00000) >>> 5]), 1);
|
|
742
1107
|
}
|
|
743
1108
|
else {
|
|
744
|
-
|
|
745
|
-
this.
|
|
1109
|
+
this.type = options.type;
|
|
1110
|
+
this.supportsReset = options.supportsReset;
|
|
1111
|
+
this.supportedScales = options.supportedScales;
|
|
1112
|
+
this.supportedRateTypes = options.supportedRateTypes;
|
|
746
1113
|
}
|
|
747
|
-
// This is only present in V4+
|
|
748
|
-
this.supportedRateTypes = (0, safe_1.parseBitMask)(Buffer.from([(this.payload[0] & 0b0_11_00000) >>> 5]), 1);
|
|
749
1114
|
}
|
|
750
1115
|
type;
|
|
751
1116
|
supportsReset;
|
|
@@ -761,29 +1126,64 @@ let MeterCCSupportedReport = class MeterCCSupportedReport extends MeterCC {
|
|
|
761
1126
|
this.ensureMetadata(applHost, exports.MeterCCValues.resetAll);
|
|
762
1127
|
}
|
|
763
1128
|
else {
|
|
764
|
-
const
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
1129
|
+
for (const scale of this.supportedScales) {
|
|
1130
|
+
// Only accumulated values can be reset
|
|
1131
|
+
if (!isAccumulatedValue(this.type, scale))
|
|
1132
|
+
continue;
|
|
1133
|
+
for (const rateType of this.supportedRateTypes) {
|
|
1134
|
+
const resetSingleValue = exports.MeterCCValues.resetSingle(this.type, rateType, scale);
|
|
1135
|
+
this.ensureMetadata(applHost, resetSingleValue, {
|
|
1136
|
+
...resetSingleValue.meta,
|
|
1137
|
+
label: `Reset ${getValueLabel(this.type, scale, rateType)}`,
|
|
1138
|
+
});
|
|
1139
|
+
}
|
|
1140
|
+
}
|
|
769
1141
|
}
|
|
770
1142
|
return true;
|
|
771
1143
|
}
|
|
772
|
-
|
|
1144
|
+
serialize() {
|
|
1145
|
+
const typeByte = (this.type & 0b0_00_11111)
|
|
1146
|
+
| (this.supportedRateTypes.includes(_Types_1.RateType.Consumed)
|
|
1147
|
+
? 0b0_01_00000
|
|
1148
|
+
: 0)
|
|
1149
|
+
| (this.supportedRateTypes.includes(_Types_1.RateType.Produced)
|
|
1150
|
+
? 0b0_10_00000
|
|
1151
|
+
: 0)
|
|
1152
|
+
| (this.supportsReset ? 0b1_00_00000 : 0);
|
|
1153
|
+
const supportedScales = (0, core_1.encodeBitMask)(this.supportedScales, undefined,
|
|
1154
|
+
// The first byte only has 7 bits for the bitmask,
|
|
1155
|
+
// so we add a fake bit for the value -1 and later shift
|
|
1156
|
+
// the first byte one to the right
|
|
1157
|
+
-1);
|
|
1158
|
+
const scalesByte1 = (supportedScales[0] >>> 1)
|
|
1159
|
+
| (supportedScales.length > 1 ? 0b1000_0000 : 0);
|
|
1160
|
+
this.payload = Buffer.from([
|
|
1161
|
+
typeByte,
|
|
1162
|
+
scalesByte1,
|
|
1163
|
+
]);
|
|
1164
|
+
if (supportedScales.length > 1) {
|
|
1165
|
+
this.payload = Buffer.concat([
|
|
1166
|
+
this.payload,
|
|
1167
|
+
Buffer.from([supportedScales.length - 1]),
|
|
1168
|
+
Buffer.from(supportedScales.subarray(1)),
|
|
1169
|
+
]);
|
|
1170
|
+
}
|
|
1171
|
+
return super.serialize();
|
|
1172
|
+
}
|
|
1173
|
+
toLogEntry(host) {
|
|
773
1174
|
const message = {
|
|
774
|
-
type:
|
|
775
|
-
?? `Unknown (${(0, safe_2.num2hex)(this.type)})`}`,
|
|
1175
|
+
"meter type": (0, core_1.getMeterName)(this.type),
|
|
776
1176
|
"supports reset": this.supportsReset,
|
|
777
1177
|
"supported scales": `${this.supportedScales
|
|
778
1178
|
.map((scale) => `
|
|
779
|
-
· ${
|
|
1179
|
+
· ${((0, core_1.getMeterScale)(this.type, scale) ?? (0, core_1.getUnknownMeterScale)(scale)).label}`)
|
|
780
1180
|
.join("")}`,
|
|
781
1181
|
"supported rate types": this.supportedRateTypes
|
|
782
1182
|
.map((rt) => (0, safe_2.getEnumMemberName)(_Types_1.RateType, rt))
|
|
783
1183
|
.join(", "),
|
|
784
1184
|
};
|
|
785
1185
|
return {
|
|
786
|
-
...super.toLogEntry(
|
|
1186
|
+
...super.toLogEntry(host),
|
|
787
1187
|
message,
|
|
788
1188
|
};
|
|
789
1189
|
}
|
|
@@ -815,45 +1215,58 @@ let MeterCCReset = class MeterCCReset extends MeterCC {
|
|
|
815
1215
|
constructor(host, options) {
|
|
816
1216
|
super(host, options);
|
|
817
1217
|
if ((0, CommandClass_1.gotDeserializationOptions)(options)) {
|
|
818
|
-
|
|
819
|
-
|
|
1218
|
+
if (this.payload.length > 0) {
|
|
1219
|
+
const { type, rateType, scale1, value, bytesRead: scale2Offset, } = parseMeterValueAndInfo(this.payload, 0);
|
|
1220
|
+
this.type = type;
|
|
1221
|
+
this.rateType = rateType;
|
|
1222
|
+
this.targetValue = value;
|
|
1223
|
+
this.scale = parseScale(scale1, this.payload, scale2Offset);
|
|
1224
|
+
}
|
|
820
1225
|
}
|
|
821
1226
|
else {
|
|
822
1227
|
this.type = options.type;
|
|
1228
|
+
this.scale = options.scale;
|
|
1229
|
+
this.rateType = options.rateType;
|
|
823
1230
|
this.targetValue = options.targetValue;
|
|
824
|
-
// Test if this is a valid target value
|
|
825
|
-
if (this.targetValue != undefined
|
|
826
|
-
&& !(0, safe_1.getMinIntegerSize)(this.targetValue, true)) {
|
|
827
|
-
throw new safe_1.ZWaveError(`${this.targetValue} is not a valid target value!`, safe_1.ZWaveErrorCodes.Argument_Invalid);
|
|
828
|
-
}
|
|
829
1231
|
}
|
|
830
1232
|
}
|
|
831
1233
|
type;
|
|
1234
|
+
scale;
|
|
1235
|
+
rateType;
|
|
832
1236
|
targetValue;
|
|
833
1237
|
serialize() {
|
|
834
|
-
if (this.
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
this.payload.
|
|
1238
|
+
if (this.type != undefined
|
|
1239
|
+
&& this.scale != undefined
|
|
1240
|
+
&& this.rateType != undefined
|
|
1241
|
+
&& this.targetValue != undefined) {
|
|
1242
|
+
const { data: typeAndValue, scale2 } = encodeMeterValueAndInfo(this.type, this.rateType, this.scale, this.targetValue);
|
|
1243
|
+
this.payload = typeAndValue;
|
|
1244
|
+
if (scale2 != undefined) {
|
|
1245
|
+
this.payload = Buffer.concat([
|
|
1246
|
+
this.payload,
|
|
1247
|
+
Buffer.from([scale2]),
|
|
1248
|
+
]);
|
|
842
1249
|
}
|
|
843
1250
|
}
|
|
844
1251
|
return super.serialize();
|
|
845
1252
|
}
|
|
846
|
-
toLogEntry(
|
|
1253
|
+
toLogEntry(host) {
|
|
847
1254
|
const message = {};
|
|
848
1255
|
if (this.type != undefined) {
|
|
849
|
-
message.type =
|
|
850
|
-
|
|
1256
|
+
message.type = (0, core_1.getMeterName)(this.type);
|
|
1257
|
+
}
|
|
1258
|
+
if (this.rateType != undefined) {
|
|
1259
|
+
message["rate type"] = (0, safe_2.getEnumMemberName)(_Types_1.RateType, this.rateType);
|
|
1260
|
+
}
|
|
1261
|
+
if (this.type != undefined && this.scale != undefined) {
|
|
1262
|
+
message.scale = ((0, core_1.getMeterScale)(this.type, this.scale)
|
|
1263
|
+
?? (0, core_1.getUnknownMeterScale)(this.scale)).label;
|
|
851
1264
|
}
|
|
852
1265
|
if (this.targetValue != undefined) {
|
|
853
1266
|
message["target value"] = this.targetValue;
|
|
854
1267
|
}
|
|
855
1268
|
return {
|
|
856
|
-
...super.toLogEntry(
|
|
1269
|
+
...super.toLogEntry(host),
|
|
857
1270
|
message,
|
|
858
1271
|
};
|
|
859
1272
|
}
|