@zwave-js/cc 9.3.1-0-pr-4662-79458fb
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 +54 -0
- package/build/cc/AlarmSensorCC.d.ts.map +1 -0
- package/build/cc/AlarmSensorCC.js +378 -0
- package/build/cc/AlarmSensorCC.js.map +1 -0
- package/build/cc/AssociationCC.d.ts +123 -0
- package/build/cc/AssociationCC.d.ts.map +1 -0
- package/build/cc/AssociationCC.js +615 -0
- package/build/cc/AssociationCC.js.map +1 -0
- package/build/cc/AssociationGroupInfoCC.d.ts +97 -0
- package/build/cc/AssociationGroupInfoCC.d.ts.map +1 -0
- package/build/cc/AssociationGroupInfoCC.js +530 -0
- package/build/cc/AssociationGroupInfoCC.js.map +1 -0
- package/build/cc/BarrierOperatorCC.d.ts +75 -0
- package/build/cc/BarrierOperatorCC.d.ts.map +1 -0
- package/build/cc/BarrierOperatorCC.js +492 -0
- package/build/cc/BarrierOperatorCC.js.map +1 -0
- package/build/cc/BasicCC.d.ts +51 -0
- package/build/cc/BasicCC.d.ts.map +1 -0
- package/build/cc/BasicCC.js +344 -0
- package/build/cc/BasicCC.js.map +1 -0
- package/build/cc/BatteryCC.d.ts +56 -0
- package/build/cc/BatteryCC.d.ts.map +1 -0
- package/build/cc/BatteryCC.js +417 -0
- package/build/cc/BatteryCC.js.map +1 -0
- package/build/cc/BinarySensorCC.d.ts +52 -0
- package/build/cc/BinarySensorCC.d.ts.map +1 -0
- package/build/cc/BinarySensorCC.js +321 -0
- package/build/cc/BinarySensorCC.js.map +1 -0
- package/build/cc/BinarySwitchCC.d.ts +55 -0
- package/build/cc/BinarySwitchCC.d.ts.map +1 -0
- package/build/cc/BinarySwitchCC.js +327 -0
- package/build/cc/BinarySwitchCC.js.map +1 -0
- package/build/cc/CRC16CC.d.ts +28 -0
- package/build/cc/CRC16CC.d.ts.map +1 -0
- package/build/cc/CRC16CC.js +109 -0
- package/build/cc/CRC16CC.js.map +1 -0
- package/build/cc/CentralSceneCC.d.ts +69 -0
- package/build/cc/CentralSceneCC.d.ts.map +1 -0
- package/build/cc/CentralSceneCC.js +443 -0
- package/build/cc/CentralSceneCC.js.map +1 -0
- package/build/cc/ClimateControlScheduleCC.d.ts +78 -0
- package/build/cc/ClimateControlScheduleCC.d.ts.map +1 -0
- package/build/cc/ClimateControlScheduleCC.js +417 -0
- package/build/cc/ClimateControlScheduleCC.js.map +1 -0
- package/build/cc/ClockCC.d.ts +40 -0
- package/build/cc/ClockCC.d.ts.map +1 -0
- package/build/cc/ClockCC.js +185 -0
- package/build/cc/ClockCC.js.map +1 -0
- package/build/cc/ColorSwitchCC.d.ts +98 -0
- package/build/cc/ColorSwitchCC.d.ts.map +1 -0
- package/build/cc/ColorSwitchCC.js +1045 -0
- package/build/cc/ColorSwitchCC.js.map +1 -0
- package/build/cc/ConfigurationCC.d.ts +315 -0
- package/build/cc/ConfigurationCC.d.ts.map +1 -0
- package/build/cc/ConfigurationCC.js +2257 -0
- package/build/cc/ConfigurationCC.js.map +1 -0
- package/build/cc/DeviceResetLocallyCC.d.ts +9 -0
- package/build/cc/DeviceResetLocallyCC.d.ts.map +1 -0
- package/build/cc/DeviceResetLocallyCC.js +28 -0
- package/build/cc/DeviceResetLocallyCC.js.map +1 -0
- package/build/cc/DoorLockCC.d.ts +116 -0
- package/build/cc/DoorLockCC.d.ts.map +1 -0
- package/build/cc/DoorLockCC.js +1112 -0
- package/build/cc/DoorLockCC.js.map +1 -0
- package/build/cc/DoorLockLoggingCC.d.ts +41 -0
- package/build/cc/DoorLockLoggingCC.d.ts.map +1 -0
- package/build/cc/DoorLockLoggingCC.js +288 -0
- package/build/cc/DoorLockLoggingCC.js.map +1 -0
- package/build/cc/EntryControlCC.d.ts +71 -0
- package/build/cc/EntryControlCC.d.ts.map +1 -0
- package/build/cc/EntryControlCC.js +492 -0
- package/build/cc/EntryControlCC.js.map +1 -0
- package/build/cc/FirmwareUpdateMetaDataCC.d.ts +148 -0
- package/build/cc/FirmwareUpdateMetaDataCC.d.ts.map +1 -0
- package/build/cc/FirmwareUpdateMetaDataCC.js +727 -0
- package/build/cc/FirmwareUpdateMetaDataCC.js.map +1 -0
- package/build/cc/HailCC.d.ts +6 -0
- package/build/cc/HailCC.d.ts.map +1 -0
- package/build/cc/HailCC.js +23 -0
- package/build/cc/HailCC.js.map +1 -0
- package/build/cc/HumidityControlModeCC.d.ts +47 -0
- package/build/cc/HumidityControlModeCC.d.ts.map +1 -0
- package/build/cc/HumidityControlModeCC.js +288 -0
- package/build/cc/HumidityControlModeCC.js.map +1 -0
- package/build/cc/HumidityControlOperatingStateCC.d.ts +24 -0
- package/build/cc/HumidityControlOperatingStateCC.d.ts.map +1 -0
- package/build/cc/HumidityControlOperatingStateCC.js +129 -0
- package/build/cc/HumidityControlOperatingStateCC.js.map +1 -0
- package/build/cc/HumidityControlSetpointCC.d.ts +103 -0
- package/build/cc/HumidityControlSetpointCC.d.ts.map +1 -0
- package/build/cc/HumidityControlSetpointCC.js +626 -0
- package/build/cc/HumidityControlSetpointCC.js.map +1 -0
- package/build/cc/IndicatorCC.d.ts +88 -0
- package/build/cc/IndicatorCC.d.ts.map +1 -0
- package/build/cc/IndicatorCC.js +758 -0
- package/build/cc/IndicatorCC.js.map +1 -0
- package/build/cc/IrrigationCC.d.ts +278 -0
- package/build/cc/IrrigationCC.d.ts.map +1 -0
- package/build/cc/IrrigationCC.js +2062 -0
- package/build/cc/IrrigationCC.js.map +1 -0
- package/build/cc/LanguageCC.d.ts +41 -0
- package/build/cc/LanguageCC.d.ts.map +1 -0
- package/build/cc/LanguageCC.js +220 -0
- package/build/cc/LanguageCC.js.map +1 -0
- package/build/cc/LockCC.d.ts +41 -0
- package/build/cc/LockCC.d.ts.map +1 -0
- package/build/cc/LockCC.js +185 -0
- package/build/cc/LockCC.js.map +1 -0
- package/build/cc/ManufacturerProprietaryCC.d.ts +31 -0
- package/build/cc/ManufacturerProprietaryCC.d.ts.map +1 -0
- package/build/cc/ManufacturerProprietaryCC.js +275 -0
- package/build/cc/ManufacturerProprietaryCC.js.map +1 -0
- package/build/cc/ManufacturerSpecificCC.d.ts +59 -0
- package/build/cc/ManufacturerSpecificCC.d.ts.map +1 -0
- package/build/cc/ManufacturerSpecificCC.js +285 -0
- package/build/cc/ManufacturerSpecificCC.js.map +1 -0
- package/build/cc/MeterCC.d.ts +100 -0
- package/build/cc/MeterCC.d.ts.map +1 -0
- package/build/cc/MeterCC.js +820 -0
- package/build/cc/MeterCC.js.map +1 -0
- package/build/cc/MultiChannelAssociationCC.d.ts +127 -0
- package/build/cc/MultiChannelAssociationCC.d.ts.map +1 -0
- package/build/cc/MultiChannelAssociationCC.js +883 -0
- package/build/cc/MultiChannelAssociationCC.js.map +1 -0
- package/build/cc/MultiChannelCC.d.ts +164 -0
- package/build/cc/MultiChannelCC.d.ts.map +1 -0
- package/build/cc/MultiChannelCC.js +1004 -0
- package/build/cc/MultiChannelCC.js.map +1 -0
- package/build/cc/MultiCommandCC.d.ts +28 -0
- package/build/cc/MultiCommandCC.d.ts.map +1 -0
- package/build/cc/MultiCommandCC.js +137 -0
- package/build/cc/MultiCommandCC.js.map +1 -0
- package/build/cc/MultilevelSensorCC.d.ts +83 -0
- package/build/cc/MultilevelSensorCC.d.ts.map +1 -0
- package/build/cc/MultilevelSensorCC.js +633 -0
- package/build/cc/MultilevelSensorCC.js.map +1 -0
- package/build/cc/MultilevelSwitchCC.d.ts +86 -0
- package/build/cc/MultilevelSwitchCC.d.ts.map +1 -0
- package/build/cc/MultilevelSwitchCC.js +774 -0
- package/build/cc/MultilevelSwitchCC.js.map +1 -0
- package/build/cc/NoOperationCC.d.ts +17 -0
- package/build/cc/NoOperationCC.d.ts.map +1 -0
- package/build/cc/NoOperationCC.js +50 -0
- package/build/cc/NoOperationCC.js.map +1 -0
- package/build/cc/NodeNamingCC.d.ts +57 -0
- package/build/cc/NodeNamingCC.d.ts.map +1 -0
- package/build/cc/NodeNamingCC.js +313 -0
- package/build/cc/NodeNamingCC.js.map +1 -0
- package/build/cc/NotificationCC.d.ts +127 -0
- package/build/cc/NotificationCC.d.ts.map +1 -0
- package/build/cc/NotificationCC.js +1193 -0
- package/build/cc/NotificationCC.js.map +1 -0
- package/build/cc/PowerlevelCC.d.ts +63 -0
- package/build/cc/PowerlevelCC.d.ts.map +1 -0
- package/build/cc/PowerlevelCC.js +262 -0
- package/build/cc/PowerlevelCC.js.map +1 -0
- package/build/cc/ProtectionCC.d.ts +94 -0
- package/build/cc/ProtectionCC.d.ts.map +1 -0
- package/build/cc/ProtectionCC.js +630 -0
- package/build/cc/ProtectionCC.js.map +1 -0
- package/build/cc/SceneActivationCC.d.ts +34 -0
- package/build/cc/SceneActivationCC.d.ts.map +1 -0
- package/build/cc/SceneActivationCC.js +170 -0
- package/build/cc/SceneActivationCC.js.map +1 -0
- package/build/cc/SceneActuatorConfigurationCC.d.ts +52 -0
- package/build/cc/SceneActuatorConfigurationCC.d.ts.map +1 -0
- package/build/cc/SceneActuatorConfigurationCC.js +368 -0
- package/build/cc/SceneActuatorConfigurationCC.js.map +1 -0
- package/build/cc/SceneControllerConfigurationCC.d.ts +61 -0
- package/build/cc/SceneControllerConfigurationCC.d.ts.map +1 -0
- package/build/cc/SceneControllerConfigurationCC.js +444 -0
- package/build/cc/SceneControllerConfigurationCC.js.map +1 -0
- package/build/cc/Security2CC.d.ts +213 -0
- package/build/cc/Security2CC.d.ts.map +1 -0
- package/build/cc/Security2CC.js +1124 -0
- package/build/cc/Security2CC.js.map +1 -0
- package/build/cc/SecurityCC.d.ts +109 -0
- package/build/cc/SecurityCC.d.ts.map +1 -0
- package/build/cc/SecurityCC.js +609 -0
- package/build/cc/SecurityCC.js.map +1 -0
- package/build/cc/SoundSwitchCC.d.ts +87 -0
- package/build/cc/SoundSwitchCC.d.ts.map +1 -0
- package/build/cc/SoundSwitchCC.js +548 -0
- package/build/cc/SoundSwitchCC.js.map +1 -0
- package/build/cc/SupervisionCC.d.ts +63 -0
- package/build/cc/SupervisionCC.d.ts.map +1 -0
- package/build/cc/SupervisionCC.js +239 -0
- package/build/cc/SupervisionCC.js.map +1 -0
- package/build/cc/ThermostatFanModeCC.d.ts +53 -0
- package/build/cc/ThermostatFanModeCC.d.ts.map +1 -0
- package/build/cc/ThermostatFanModeCC.js +359 -0
- package/build/cc/ThermostatFanModeCC.js.map +1 -0
- package/build/cc/ThermostatFanStateCC.d.ts +24 -0
- package/build/cc/ThermostatFanStateCC.d.ts.map +1 -0
- package/build/cc/ThermostatFanStateCC.js +131 -0
- package/build/cc/ThermostatFanStateCC.js.map +1 -0
- package/build/cc/ThermostatModeCC.d.ts +58 -0
- package/build/cc/ThermostatModeCC.d.ts.map +1 -0
- package/build/cc/ThermostatModeCC.js +370 -0
- package/build/cc/ThermostatModeCC.js.map +1 -0
- package/build/cc/ThermostatOperatingStateCC.d.ts +24 -0
- package/build/cc/ThermostatOperatingStateCC.d.ts.map +1 -0
- package/build/cc/ThermostatOperatingStateCC.js +127 -0
- package/build/cc/ThermostatOperatingStateCC.js.map +1 -0
- package/build/cc/ThermostatSetbackCC.d.ts +42 -0
- package/build/cc/ThermostatSetbackCC.d.ts.map +1 -0
- package/build/cc/ThermostatSetbackCC.js +237 -0
- package/build/cc/ThermostatSetbackCC.js.map +1 -0
- package/build/cc/ThermostatSetpointCC.d.ts +98 -0
- package/build/cc/ThermostatSetpointCC.d.ts.map +1 -0
- package/build/cc/ThermostatSetpointCC.js +707 -0
- package/build/cc/ThermostatSetpointCC.js.map +1 -0
- package/build/cc/TimeCC.d.ts +78 -0
- package/build/cc/TimeCC.d.ts.map +1 -0
- package/build/cc/TimeCC.js +373 -0
- package/build/cc/TimeCC.js.map +1 -0
- package/build/cc/TimeParametersCC.d.ts +40 -0
- package/build/cc/TimeParametersCC.d.ts.map +1 -0
- package/build/cc/TimeParametersCC.js +275 -0
- package/build/cc/TimeParametersCC.js.map +1 -0
- package/build/cc/TransportServiceCC.d.ts +101 -0
- package/build/cc/TransportServiceCC.d.ts.map +1 -0
- package/build/cc/TransportServiceCC.js +404 -0
- package/build/cc/TransportServiceCC.js.map +1 -0
- package/build/cc/UserCodeCC.d.ts +219 -0
- package/build/cc/UserCodeCC.d.ts.map +1 -0
- package/build/cc/UserCodeCC.js +1526 -0
- package/build/cc/UserCodeCC.js.map +1 -0
- package/build/cc/VersionCC.d.ts +91 -0
- package/build/cc/VersionCC.d.ts.map +1 -0
- package/build/cc/VersionCC.js +654 -0
- package/build/cc/VersionCC.js.map +1 -0
- package/build/cc/WakeUpCC.d.ts +67 -0
- package/build/cc/WakeUpCC.d.ts.map +1 -0
- package/build/cc/WakeUpCC.js +425 -0
- package/build/cc/WakeUpCC.js.map +1 -0
- package/build/cc/ZWavePlusCC.d.ts +40 -0
- package/build/cc/ZWavePlusCC.d.ts.map +1 -0
- package/build/cc/ZWavePlusCC.js +269 -0
- package/build/cc/ZWavePlusCC.js.map +1 -0
- package/build/cc/index.d.ts +64 -0
- package/build/cc/index.d.ts.map +1 -0
- package/build/cc/index.js +496 -0
- package/build/cc/index.js.map +1 -0
- package/build/cc/manufacturerProprietary/FibaroCC.d.ts +62 -0
- package/build/cc/manufacturerProprietary/FibaroCC.d.ts.map +1 -0
- package/build/cc/manufacturerProprietary/FibaroCC.js +247 -0
- package/build/cc/manufacturerProprietary/FibaroCC.js.map +1 -0
- package/build/index.d.ts +11 -0
- package/build/index.d.ts.map +1 -0
- package/build/index.js +48 -0
- package/build/index.js.map +1 -0
- package/build/index_safe.d.ts +4 -0
- package/build/index_safe.d.ts.map +1 -0
- package/build/index_safe.js +30 -0
- package/build/index_safe.js.map +1 -0
- package/build/lib/API.d.ts +176 -0
- package/build/lib/API.d.ts.map +1 -0
- package/build/lib/API.js +325 -0
- package/build/lib/API.js.map +1 -0
- package/build/lib/CommandClass.d.ts +341 -0
- package/build/lib/CommandClass.d.ts.map +1 -0
- package/build/lib/CommandClass.js +1088 -0
- package/build/lib/CommandClass.js.map +1 -0
- package/build/lib/EncapsulatingCommandClass.d.ts +35 -0
- package/build/lib/EncapsulatingCommandClass.d.ts.map +1 -0
- package/build/lib/EncapsulatingCommandClass.js +53 -0
- package/build/lib/EncapsulatingCommandClass.js.map +1 -0
- package/build/lib/ICommandClassContainer.d.ts +9 -0
- package/build/lib/ICommandClassContainer.d.ts.map +1 -0
- package/build/lib/ICommandClassContainer.js +12 -0
- package/build/lib/ICommandClassContainer.js.map +1 -0
- package/build/lib/NotificationEventPayload.d.ts +11 -0
- package/build/lib/NotificationEventPayload.d.ts.map +1 -0
- package/build/lib/NotificationEventPayload.js +11 -0
- package/build/lib/NotificationEventPayload.js.map +1 -0
- package/build/lib/Security2/Extension.d.ts +87 -0
- package/build/lib/Security2/Extension.d.ts.map +1 -0
- package/build/lib/Security2/Extension.js +235 -0
- package/build/lib/Security2/Extension.js.map +1 -0
- package/build/lib/Security2/shared.d.ts +31 -0
- package/build/lib/Security2/shared.d.ts.map +1 -0
- package/build/lib/Security2/shared.js +37 -0
- package/build/lib/Security2/shared.js.map +1 -0
- package/build/lib/_Types.d.ts +1446 -0
- package/build/lib/_Types.d.ts.map +1 -0
- package/build/lib/_Types.js +1334 -0
- package/build/lib/_Types.js.map +1 -0
- package/build/lib/serializers.d.ts +24 -0
- package/build/lib/serializers.d.ts.map +1 -0
- package/build/lib/serializers.js +66 -0
- package/build/lib/serializers.js.map +1 -0
- package/build/lib/utils.d.ts +13 -0
- package/build/lib/utils.d.ts.map +1 -0
- package/build/lib/utils.js +675 -0
- package/build/lib/utils.js.map +1 -0
- package/package.json +77 -0
|
@@ -0,0 +1,820 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
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
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var _a, _b;
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.MeterCCReset = exports.MeterCCSupportedGet = exports.MeterCCSupportedReport = exports.MeterCCGet = exports.MeterCCReport = exports.MeterCC = exports.MeterCCAPI = exports.getResetValueId = exports.getSupportedRateTypesValueId = exports.getSupportedScalesValueId = exports.getSupportsResetValueId = exports.getTypeValueId = void 0;
|
|
11
|
+
function __assertType(argName, typeName, boundHasError) {
|
|
12
|
+
const { ZWaveError, ZWaveErrorCodes } = require("@zwave-js/core");
|
|
13
|
+
if (boundHasError()) {
|
|
14
|
+
throw new ZWaveError(typeName ? `${argName} is not a ${typeName}` : `${argName} has the wrong type`, ZWaveErrorCodes.Argument_Invalid);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
const __assertType__optional_MeterCCGetOptions = $o => {
|
|
18
|
+
function _number($o) {
|
|
19
|
+
return typeof $o !== "number" ? {} : null;
|
|
20
|
+
}
|
|
21
|
+
function su__2__3__4_eu($o) {
|
|
22
|
+
return ![0, 1, 2].includes($o) ? {} : null;
|
|
23
|
+
}
|
|
24
|
+
function _0($o) {
|
|
25
|
+
if (typeof $o !== "object" || $o === null || Array.isArray($o))
|
|
26
|
+
return {};
|
|
27
|
+
if ("scale" in $o && $o["scale"] !== undefined) {
|
|
28
|
+
const error = _number($o["scale"]);
|
|
29
|
+
if (error)
|
|
30
|
+
return error;
|
|
31
|
+
}
|
|
32
|
+
if ("rateType" in $o && $o["rateType"] !== undefined) {
|
|
33
|
+
const error = su__2__3__4_eu($o["rateType"]);
|
|
34
|
+
if (error)
|
|
35
|
+
return error;
|
|
36
|
+
}
|
|
37
|
+
return null;
|
|
38
|
+
}
|
|
39
|
+
function optional__0($o) {
|
|
40
|
+
if ($o !== undefined) {
|
|
41
|
+
const error = _0($o);
|
|
42
|
+
if (error)
|
|
43
|
+
return error;
|
|
44
|
+
}
|
|
45
|
+
return null;
|
|
46
|
+
}
|
|
47
|
+
return optional__0($o);
|
|
48
|
+
};
|
|
49
|
+
const __assertType__optional_MeterCCResetOptions = $o => {
|
|
50
|
+
function _undefined($o) {
|
|
51
|
+
return $o !== undefined ? {} : null;
|
|
52
|
+
}
|
|
53
|
+
function _1($o) {
|
|
54
|
+
if (typeof $o !== "object" || $o === null || Array.isArray($o))
|
|
55
|
+
return {};
|
|
56
|
+
if ("type" in $o && $o["type"] !== undefined) {
|
|
57
|
+
const error = _undefined($o["type"]);
|
|
58
|
+
if (error)
|
|
59
|
+
return error;
|
|
60
|
+
}
|
|
61
|
+
if ("targetValue" in $o && $o["targetValue"] !== undefined) {
|
|
62
|
+
const error = _undefined($o["targetValue"]);
|
|
63
|
+
if (error)
|
|
64
|
+
return error;
|
|
65
|
+
}
|
|
66
|
+
return null;
|
|
67
|
+
}
|
|
68
|
+
function _number($o) {
|
|
69
|
+
return typeof $o !== "number" ? {} : null;
|
|
70
|
+
}
|
|
71
|
+
function _2($o) {
|
|
72
|
+
if (typeof $o !== "object" || $o === null || Array.isArray($o))
|
|
73
|
+
return {};
|
|
74
|
+
if ("type" in $o && $o["type"] !== undefined) {
|
|
75
|
+
const error = _number($o["type"]);
|
|
76
|
+
if (error)
|
|
77
|
+
return error;
|
|
78
|
+
}
|
|
79
|
+
else
|
|
80
|
+
return {};
|
|
81
|
+
if ("targetValue" in $o && $o["targetValue"] !== undefined) {
|
|
82
|
+
const error = _number($o["targetValue"]);
|
|
83
|
+
if (error)
|
|
84
|
+
return error;
|
|
85
|
+
}
|
|
86
|
+
else
|
|
87
|
+
return {};
|
|
88
|
+
return null;
|
|
89
|
+
}
|
|
90
|
+
function su__1__2_eu($o) {
|
|
91
|
+
const conditions = [_1, _2];
|
|
92
|
+
for (const condition of conditions) {
|
|
93
|
+
const error = condition($o);
|
|
94
|
+
if (!error)
|
|
95
|
+
return null;
|
|
96
|
+
}
|
|
97
|
+
return {};
|
|
98
|
+
}
|
|
99
|
+
function optional_su__1__2_eu($o) {
|
|
100
|
+
if ($o !== undefined) {
|
|
101
|
+
const error = su__1__2_eu($o);
|
|
102
|
+
if (error)
|
|
103
|
+
return error;
|
|
104
|
+
}
|
|
105
|
+
return null;
|
|
106
|
+
}
|
|
107
|
+
return optional_su__1__2_eu($o);
|
|
108
|
+
};
|
|
109
|
+
const config_1 = require("@zwave-js/config");
|
|
110
|
+
const safe_1 = require("@zwave-js/core/safe");
|
|
111
|
+
const safe_2 = require("@zwave-js/shared/safe");
|
|
112
|
+
const API_1 = require("../lib/API");
|
|
113
|
+
const CommandClass_1 = require("../lib/CommandClass");
|
|
114
|
+
const _Types_1 = require("../lib/_Types");
|
|
115
|
+
function toPropertyKey(meterType, rateType, scale) {
|
|
116
|
+
return (meterType << 16) | (scale << 8) | rateType;
|
|
117
|
+
}
|
|
118
|
+
function splitPropertyKey(key) {
|
|
119
|
+
return {
|
|
120
|
+
rateType: key & 0xff,
|
|
121
|
+
scale: (key >>> 8) & 0xff,
|
|
122
|
+
meterType: key >>> 16,
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
function getMeterTypeName(configManager, type) {
|
|
126
|
+
var _c, _d;
|
|
127
|
+
return ((_d = (_c = configManager.lookupMeter(type)) === null || _c === void 0 ? void 0 : _c.name) !== null && _d !== void 0 ? _d : `UNKNOWN (${(0, safe_2.num2hex)(type)})`);
|
|
128
|
+
}
|
|
129
|
+
function getTypeValueId(endpoint) {
|
|
130
|
+
return {
|
|
131
|
+
commandClass: safe_1.CommandClasses.Meter,
|
|
132
|
+
endpoint,
|
|
133
|
+
property: "type",
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
exports.getTypeValueId = getTypeValueId;
|
|
137
|
+
function getSupportsResetValueId(endpoint) {
|
|
138
|
+
return {
|
|
139
|
+
commandClass: safe_1.CommandClasses.Meter,
|
|
140
|
+
endpoint,
|
|
141
|
+
property: "supportsReset",
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
exports.getSupportsResetValueId = getSupportsResetValueId;
|
|
145
|
+
function getSupportedScalesValueId(endpoint) {
|
|
146
|
+
return {
|
|
147
|
+
commandClass: safe_1.CommandClasses.Meter,
|
|
148
|
+
endpoint,
|
|
149
|
+
property: "supportedScales",
|
|
150
|
+
};
|
|
151
|
+
}
|
|
152
|
+
exports.getSupportedScalesValueId = getSupportedScalesValueId;
|
|
153
|
+
function getSupportedRateTypesValueId(endpoint) {
|
|
154
|
+
return {
|
|
155
|
+
commandClass: safe_1.CommandClasses.Meter,
|
|
156
|
+
endpoint,
|
|
157
|
+
property: "supportedRateTypes",
|
|
158
|
+
};
|
|
159
|
+
}
|
|
160
|
+
exports.getSupportedRateTypesValueId = getSupportedRateTypesValueId;
|
|
161
|
+
function getResetValueId(endpoint, type) {
|
|
162
|
+
return {
|
|
163
|
+
commandClass: safe_1.CommandClasses.Meter,
|
|
164
|
+
endpoint,
|
|
165
|
+
property: "reset",
|
|
166
|
+
propertyKey: type,
|
|
167
|
+
};
|
|
168
|
+
}
|
|
169
|
+
exports.getResetValueId = getResetValueId;
|
|
170
|
+
function getValueLabel(configManager, meterType, scale, rateType, suffix) {
|
|
171
|
+
let ret = getMeterTypeName(configManager, meterType);
|
|
172
|
+
switch (rateType) {
|
|
173
|
+
case _Types_1.RateType.Consumed:
|
|
174
|
+
ret += ` Consumption [${scale.label}]`;
|
|
175
|
+
break;
|
|
176
|
+
case _Types_1.RateType.Produced:
|
|
177
|
+
ret += ` Production [${scale.label}]`;
|
|
178
|
+
break;
|
|
179
|
+
default:
|
|
180
|
+
ret += ` [${scale.label}]`;
|
|
181
|
+
}
|
|
182
|
+
if (suffix) {
|
|
183
|
+
ret += ` (${suffix})`;
|
|
184
|
+
}
|
|
185
|
+
return ret;
|
|
186
|
+
}
|
|
187
|
+
let MeterCCAPI = class MeterCCAPI extends API_1.PhysicalCCAPI {
|
|
188
|
+
constructor() {
|
|
189
|
+
super(...arguments);
|
|
190
|
+
this[_a] = async ({ property, propertyKey, }) => {
|
|
191
|
+
var _c;
|
|
192
|
+
switch (property) {
|
|
193
|
+
case "value":
|
|
194
|
+
case "previousValue":
|
|
195
|
+
case "deltaTime": {
|
|
196
|
+
if (propertyKey == undefined) {
|
|
197
|
+
(0, API_1.throwMissingPropertyKey)(this.ccId, property);
|
|
198
|
+
}
|
|
199
|
+
else if (typeof propertyKey !== "number") {
|
|
200
|
+
(0, API_1.throwUnsupportedPropertyKey)(this.ccId, property, propertyKey);
|
|
201
|
+
}
|
|
202
|
+
const { rateType, scale } = splitPropertyKey(propertyKey);
|
|
203
|
+
return (_c = (await this.get({
|
|
204
|
+
rateType,
|
|
205
|
+
scale,
|
|
206
|
+
}))) === null || _c === void 0 ? void 0 : _c[property];
|
|
207
|
+
}
|
|
208
|
+
default:
|
|
209
|
+
(0, API_1.throwUnsupportedProperty)(this.ccId, property);
|
|
210
|
+
}
|
|
211
|
+
};
|
|
212
|
+
this[_b] = async ({ property, propertyKey }, value) => {
|
|
213
|
+
if (property !== "reset") {
|
|
214
|
+
(0, API_1.throwUnsupportedProperty)(this.ccId, property);
|
|
215
|
+
}
|
|
216
|
+
else if (propertyKey != undefined &&
|
|
217
|
+
typeof propertyKey !== "number") {
|
|
218
|
+
(0, API_1.throwUnsupportedPropertyKey)(this.ccId, property, propertyKey);
|
|
219
|
+
}
|
|
220
|
+
else if (value !== true) {
|
|
221
|
+
(0, API_1.throwWrongValueType)(this.ccId, property, "true", value === false ? "false" : typeof value);
|
|
222
|
+
}
|
|
223
|
+
const resetOptions = propertyKey != undefined
|
|
224
|
+
? {
|
|
225
|
+
type: propertyKey,
|
|
226
|
+
targetValue: 0,
|
|
227
|
+
}
|
|
228
|
+
: {};
|
|
229
|
+
await this.reset(resetOptions);
|
|
230
|
+
// Refresh values
|
|
231
|
+
await this.getAll();
|
|
232
|
+
};
|
|
233
|
+
}
|
|
234
|
+
supportsCommand(cmd) {
|
|
235
|
+
var _c;
|
|
236
|
+
switch (cmd) {
|
|
237
|
+
case _Types_1.MeterCommand.Get:
|
|
238
|
+
return true; // This is mandatory
|
|
239
|
+
case _Types_1.MeterCommand.SupportedGet:
|
|
240
|
+
return this.version >= 2;
|
|
241
|
+
case _Types_1.MeterCommand.Reset: {
|
|
242
|
+
const ret = (_c = this.tryGetValueDB()) === null || _c === void 0 ? void 0 : _c.getValue({
|
|
243
|
+
commandClass: (0, CommandClass_1.getCommandClass)(this),
|
|
244
|
+
endpoint: this.endpoint.index,
|
|
245
|
+
property: "supportsReset",
|
|
246
|
+
});
|
|
247
|
+
return ret === true;
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
return super.supportsCommand(cmd);
|
|
251
|
+
}
|
|
252
|
+
async get(options) {
|
|
253
|
+
__assertType("options", "(optional) MeterCCGetOptions", __assertType__optional_MeterCCGetOptions.bind(void 0, options));
|
|
254
|
+
this.assertSupportsCommand(_Types_1.MeterCommand, _Types_1.MeterCommand.Get);
|
|
255
|
+
const cc = new MeterCCGet(this.applHost, {
|
|
256
|
+
nodeId: this.endpoint.nodeId,
|
|
257
|
+
endpoint: this.endpoint.index,
|
|
258
|
+
...options,
|
|
259
|
+
});
|
|
260
|
+
const response = await this.applHost.sendCommand(cc, this.commandOptions);
|
|
261
|
+
if (response) {
|
|
262
|
+
return {
|
|
263
|
+
type: response.type,
|
|
264
|
+
scale: this.applHost.configManager.lookupMeterScale(response.type, response.scale),
|
|
265
|
+
...(0, safe_2.pick)(response, [
|
|
266
|
+
"value",
|
|
267
|
+
"previousValue",
|
|
268
|
+
"rateType",
|
|
269
|
+
"deltaTime",
|
|
270
|
+
]),
|
|
271
|
+
};
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
|
|
275
|
+
async getAll() {
|
|
276
|
+
var _c, _d;
|
|
277
|
+
const valueDB = this.tryGetValueDB();
|
|
278
|
+
if (this.version >= 2) {
|
|
279
|
+
const supportedScales = (_c = valueDB === null || valueDB === void 0 ? void 0 : valueDB.getValue(getSupportedScalesValueId(this.endpoint.index))) !== null && _c !== void 0 ? _c : [];
|
|
280
|
+
const supportedRateTypes = (_d = valueDB === null || valueDB === void 0 ? void 0 : valueDB.getValue(getSupportedRateTypesValueId(this.endpoint.index))) !== null && _d !== void 0 ? _d : [];
|
|
281
|
+
const rateTypes = supportedRateTypes.length
|
|
282
|
+
? supportedRateTypes
|
|
283
|
+
: [undefined];
|
|
284
|
+
const ret = [];
|
|
285
|
+
for (const rateType of rateTypes) {
|
|
286
|
+
for (const scale of supportedScales) {
|
|
287
|
+
const response = await this.get({
|
|
288
|
+
scale,
|
|
289
|
+
rateType,
|
|
290
|
+
});
|
|
291
|
+
if (response)
|
|
292
|
+
ret.push(response);
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
return ret;
|
|
296
|
+
}
|
|
297
|
+
else {
|
|
298
|
+
const response = await this.get();
|
|
299
|
+
return response ? [response] : [];
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
|
|
303
|
+
async getSupported() {
|
|
304
|
+
this.assertSupportsCommand(_Types_1.MeterCommand, _Types_1.MeterCommand.SupportedGet);
|
|
305
|
+
const cc = new MeterCCSupportedGet(this.applHost, {
|
|
306
|
+
nodeId: this.endpoint.nodeId,
|
|
307
|
+
endpoint: this.endpoint.index,
|
|
308
|
+
});
|
|
309
|
+
const response = await this.applHost.sendCommand(cc, this.commandOptions);
|
|
310
|
+
if (response) {
|
|
311
|
+
return (0, safe_2.pick)(response, [
|
|
312
|
+
"type",
|
|
313
|
+
"supportsReset",
|
|
314
|
+
"supportedScales",
|
|
315
|
+
"supportedRateTypes",
|
|
316
|
+
]);
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
async reset(options) {
|
|
320
|
+
__assertType("options", "(optional) MeterCCResetOptions", __assertType__optional_MeterCCResetOptions.bind(void 0, options));
|
|
321
|
+
this.assertSupportsCommand(_Types_1.MeterCommand, _Types_1.MeterCommand.Reset);
|
|
322
|
+
const cc = new MeterCCReset(this.applHost, {
|
|
323
|
+
nodeId: this.endpoint.nodeId,
|
|
324
|
+
endpoint: this.endpoint.index,
|
|
325
|
+
...options,
|
|
326
|
+
});
|
|
327
|
+
await this.applHost.sendCommand(cc, this.commandOptions);
|
|
328
|
+
}
|
|
329
|
+
};
|
|
330
|
+
_a = API_1.POLL_VALUE, _b = API_1.SET_VALUE;
|
|
331
|
+
MeterCCAPI = __decorate([
|
|
332
|
+
(0, CommandClass_1.API)(safe_1.CommandClasses.Meter)
|
|
333
|
+
], MeterCCAPI);
|
|
334
|
+
exports.MeterCCAPI = MeterCCAPI;
|
|
335
|
+
let MeterCC = class MeterCC extends CommandClass_1.CommandClass {
|
|
336
|
+
async interview(applHost) {
|
|
337
|
+
const node = this.getNode(applHost);
|
|
338
|
+
const endpoint = this.getEndpoint(applHost);
|
|
339
|
+
const api = API_1.CCAPI.create(safe_1.CommandClasses.Meter, applHost, endpoint).withOptions({
|
|
340
|
+
priority: safe_1.MessagePriority.NodeQuery,
|
|
341
|
+
});
|
|
342
|
+
applHost.controllerLog.logNode(node.id, {
|
|
343
|
+
endpoint: this.endpointIndex,
|
|
344
|
+
message: `Interviewing ${this.ccName}...`,
|
|
345
|
+
direction: "none",
|
|
346
|
+
});
|
|
347
|
+
if (this.version >= 2) {
|
|
348
|
+
applHost.controllerLog.logNode(node.id, {
|
|
349
|
+
endpoint: this.endpointIndex,
|
|
350
|
+
message: "querying meter support...",
|
|
351
|
+
direction: "outbound",
|
|
352
|
+
});
|
|
353
|
+
const suppResp = await api.getSupported();
|
|
354
|
+
if (suppResp) {
|
|
355
|
+
const logMessage = `received meter support:
|
|
356
|
+
type: ${getMeterTypeName(applHost.configManager, suppResp.type)}
|
|
357
|
+
supported scales: ${suppResp.supportedScales
|
|
358
|
+
.map((s) => applHost.configManager.lookupMeterScale(suppResp.type, s).label)
|
|
359
|
+
.map((label) => `\n· ${label}`)
|
|
360
|
+
.join("")}
|
|
361
|
+
supported rate types: ${suppResp.supportedRateTypes
|
|
362
|
+
.map((rt) => (0, safe_2.getEnumMemberName)(_Types_1.RateType, rt))
|
|
363
|
+
.map((label) => `\n· ${label}`)
|
|
364
|
+
.join("")}
|
|
365
|
+
supports reset: ${suppResp.supportsReset}`;
|
|
366
|
+
applHost.controllerLog.logNode(node.id, {
|
|
367
|
+
endpoint: this.endpointIndex,
|
|
368
|
+
message: logMessage,
|
|
369
|
+
direction: "inbound",
|
|
370
|
+
});
|
|
371
|
+
}
|
|
372
|
+
else {
|
|
373
|
+
applHost.controllerLog.logNode(node.id, {
|
|
374
|
+
endpoint: this.endpointIndex,
|
|
375
|
+
message: "Querying meter support timed out, skipping interview...",
|
|
376
|
+
level: "warn",
|
|
377
|
+
});
|
|
378
|
+
return;
|
|
379
|
+
}
|
|
380
|
+
}
|
|
381
|
+
// Query current meter values
|
|
382
|
+
await this.refreshValues(applHost);
|
|
383
|
+
// Remember that the interview is complete
|
|
384
|
+
this.setInterviewComplete(applHost, true);
|
|
385
|
+
}
|
|
386
|
+
async refreshValues(applHost) {
|
|
387
|
+
var _c, _d, _e;
|
|
388
|
+
const node = this.getNode(applHost);
|
|
389
|
+
const endpoint = this.getEndpoint(applHost);
|
|
390
|
+
const api = API_1.CCAPI.create(safe_1.CommandClasses.Meter, applHost, endpoint).withOptions({
|
|
391
|
+
priority: safe_1.MessagePriority.NodeQuery,
|
|
392
|
+
});
|
|
393
|
+
const valueDB = this.getValueDB(applHost);
|
|
394
|
+
if (this.version === 1) {
|
|
395
|
+
applHost.controllerLog.logNode(node.id, {
|
|
396
|
+
endpoint: this.endpointIndex,
|
|
397
|
+
message: `querying default meter value...`,
|
|
398
|
+
direction: "outbound",
|
|
399
|
+
});
|
|
400
|
+
await api.get();
|
|
401
|
+
}
|
|
402
|
+
else {
|
|
403
|
+
const type = (_c = valueDB.getValue(getTypeValueId(this.endpointIndex))) !== null && _c !== void 0 ? _c : 0;
|
|
404
|
+
const supportedScales = (_d = valueDB.getValue(getSupportedScalesValueId(this.endpointIndex))) !== null && _d !== void 0 ? _d : [];
|
|
405
|
+
const supportedRateTypes = (_e = valueDB.getValue(getSupportedRateTypesValueId(this.endpointIndex))) !== null && _e !== void 0 ? _e : [];
|
|
406
|
+
const rateTypes = supportedRateTypes.length
|
|
407
|
+
? supportedRateTypes
|
|
408
|
+
: [undefined];
|
|
409
|
+
for (const rateType of rateTypes) {
|
|
410
|
+
for (const scale of supportedScales) {
|
|
411
|
+
applHost.controllerLog.logNode(node.id, {
|
|
412
|
+
endpoint: this.endpointIndex,
|
|
413
|
+
message: `querying meter value (type = ${getMeterTypeName(applHost.configManager, type)}, scale = ${applHost.configManager.lookupMeterScale(type, scale)
|
|
414
|
+
.label}${rateType != undefined
|
|
415
|
+
? `, rate type = ${(0, safe_2.getEnumMemberName)(_Types_1.RateType, rateType)}`
|
|
416
|
+
: ""})...`,
|
|
417
|
+
direction: "outbound",
|
|
418
|
+
});
|
|
419
|
+
await api.get({ scale, rateType });
|
|
420
|
+
}
|
|
421
|
+
}
|
|
422
|
+
}
|
|
423
|
+
}
|
|
424
|
+
translatePropertyKey(applHost, property, propertyKey) {
|
|
425
|
+
if (property === "value" && typeof propertyKey === "number") {
|
|
426
|
+
const { meterType, rateType, scale } = splitPropertyKey(propertyKey);
|
|
427
|
+
let ret;
|
|
428
|
+
if (meterType !== 0) {
|
|
429
|
+
ret = `${applHost.configManager.getMeterName(meterType)}_${applHost.configManager.lookupMeterScale(meterType, scale)
|
|
430
|
+
.label}`;
|
|
431
|
+
}
|
|
432
|
+
else {
|
|
433
|
+
ret = "default";
|
|
434
|
+
}
|
|
435
|
+
if (rateType !== _Types_1.RateType.Unspecified) {
|
|
436
|
+
ret += "_" + (0, safe_2.getEnumMemberName)(_Types_1.RateType, rateType);
|
|
437
|
+
}
|
|
438
|
+
return ret;
|
|
439
|
+
}
|
|
440
|
+
else if (property === "reset" && typeof propertyKey === "number") {
|
|
441
|
+
return getMeterTypeName(applHost.configManager, propertyKey);
|
|
442
|
+
}
|
|
443
|
+
return super.translatePropertyKey(applHost, property, propertyKey);
|
|
444
|
+
}
|
|
445
|
+
};
|
|
446
|
+
MeterCC = __decorate([
|
|
447
|
+
(0, CommandClass_1.commandClass)(safe_1.CommandClasses.Meter),
|
|
448
|
+
(0, CommandClass_1.implementedVersion)(6)
|
|
449
|
+
], MeterCC);
|
|
450
|
+
exports.MeterCC = MeterCC;
|
|
451
|
+
let MeterCCReport = class MeterCCReport extends MeterCC {
|
|
452
|
+
constructor(host, options) {
|
|
453
|
+
super(host, options);
|
|
454
|
+
(0, safe_1.validatePayload)(this.payload.length >= 2);
|
|
455
|
+
this._type = this.payload[0] & 31;
|
|
456
|
+
this._rateType = (this.payload[0] & 96) >>> 5;
|
|
457
|
+
const scale1Bit2 = (this.payload[0] & 128) >>> 7;
|
|
458
|
+
const { scale: scale1Bits10, value, bytesRead, } = (0, safe_1.parseFloatWithScale)(this.payload.slice(1));
|
|
459
|
+
let offset = 2 + (bytesRead - 1);
|
|
460
|
+
// The scale is composed of two fields (see SDS13781)
|
|
461
|
+
const scale1 = (scale1Bit2 << 2) | scale1Bits10;
|
|
462
|
+
let scale2 = 0;
|
|
463
|
+
this._value = value;
|
|
464
|
+
if (this.version >= 2 && this.payload.length >= offset + 2) {
|
|
465
|
+
this._deltaTime = this.payload.readUInt16BE(offset);
|
|
466
|
+
offset += 2;
|
|
467
|
+
if (this._deltaTime === 0xffff) {
|
|
468
|
+
this._deltaTime = safe_1.unknownNumber;
|
|
469
|
+
}
|
|
470
|
+
if (
|
|
471
|
+
// 0 means that no previous value is included
|
|
472
|
+
this.deltaTime !== 0 &&
|
|
473
|
+
this.payload.length >= offset + (bytesRead - 1)) {
|
|
474
|
+
const { value: prevValue } = (0, safe_1.parseFloatWithScale)(
|
|
475
|
+
// This float is split in the payload
|
|
476
|
+
Buffer.concat([
|
|
477
|
+
Buffer.from([this.payload[1]]),
|
|
478
|
+
this.payload.slice(offset),
|
|
479
|
+
]));
|
|
480
|
+
offset += bytesRead - 1;
|
|
481
|
+
this._previousValue = prevValue;
|
|
482
|
+
}
|
|
483
|
+
if (this.version >= 4 &&
|
|
484
|
+
scale1 === 7 &&
|
|
485
|
+
this.payload.length >= offset + 1) {
|
|
486
|
+
scale2 = this.payload[offset];
|
|
487
|
+
}
|
|
488
|
+
}
|
|
489
|
+
else {
|
|
490
|
+
// 0 means that no previous value is included
|
|
491
|
+
this._deltaTime = 0;
|
|
492
|
+
}
|
|
493
|
+
this.scale = scale1 === 7 ? scale1 + scale2 : scale1;
|
|
494
|
+
}
|
|
495
|
+
persistValues(applHost) {
|
|
496
|
+
var _c, _d, _e, _f;
|
|
497
|
+
if (!super.persistValues(applHost))
|
|
498
|
+
return false;
|
|
499
|
+
const valueDB = this.getValueDB(applHost);
|
|
500
|
+
const meterType = applHost.configManager.lookupMeter(this._type);
|
|
501
|
+
const scale = applHost.configManager.lookupMeterScale(this._type, this.scale);
|
|
502
|
+
// Filter out unknown meter types and scales, unless the strict validation is disabled
|
|
503
|
+
const measurementValidation = !((_f = (_e = (_d = (_c = this.host).getDeviceConfig) === null || _d === void 0 ? void 0 : _d.call(_c, this.nodeId)) === null || _e === void 0 ? void 0 : _e.compat) === null || _f === void 0 ? void 0 : _f.disableStrictMeasurementValidation);
|
|
504
|
+
if (measurementValidation) {
|
|
505
|
+
safe_1.validatePayload.withReason(`Unknown meter type ${(0, safe_2.num2hex)(this.type)} or corrupted data`)(!!meterType);
|
|
506
|
+
safe_1.validatePayload.withReason(`Unknown meter scale ${(0, safe_2.num2hex)(this.scale)} or corrupted data`)(scale.label !== (0, config_1.getDefaultMeterScale)(this.scale).label);
|
|
507
|
+
// Filter out unsupported meter types, scales and rate types if possible
|
|
508
|
+
if (this.version >= 2) {
|
|
509
|
+
const expectedType = valueDB.getValue(getTypeValueId(this.endpointIndex));
|
|
510
|
+
if (expectedType != undefined) {
|
|
511
|
+
safe_1.validatePayload.withReason("Unexpected meter type or corrupted data")(this._type === expectedType);
|
|
512
|
+
}
|
|
513
|
+
const supportedScales = valueDB.getValue(getSupportedScalesValueId(this.endpointIndex));
|
|
514
|
+
if (supportedScales === null || supportedScales === void 0 ? void 0 : supportedScales.length) {
|
|
515
|
+
safe_1.validatePayload.withReason(`Unsupported meter scale ${scale.label} or corrupted data`)(supportedScales.includes(this.scale));
|
|
516
|
+
}
|
|
517
|
+
const supportedRateTypes = valueDB.getValue(getSupportedRateTypesValueId(this.endpointIndex));
|
|
518
|
+
if (supportedRateTypes === null || supportedRateTypes === void 0 ? void 0 : supportedRateTypes.length) {
|
|
519
|
+
safe_1.validatePayload.withReason(`Unsupported rate type ${(0, safe_2.getEnumMemberName)(_Types_1.RateType, this._rateType)} or corrupted data`)(supportedRateTypes.includes(this._rateType));
|
|
520
|
+
}
|
|
521
|
+
}
|
|
522
|
+
}
|
|
523
|
+
const valueId = {
|
|
524
|
+
commandClass: this.ccId,
|
|
525
|
+
endpoint: this.endpointIndex,
|
|
526
|
+
property: "value",
|
|
527
|
+
propertyKey: toPropertyKey(this._type, this._rateType, this.scale),
|
|
528
|
+
};
|
|
529
|
+
// Always create metadata if it does not exist
|
|
530
|
+
if (!valueDB.hasMetadata(valueId)) {
|
|
531
|
+
valueDB.setMetadata(valueId, {
|
|
532
|
+
...safe_1.ValueMetadata.ReadOnlyNumber,
|
|
533
|
+
label: getValueLabel(applHost.configManager, this._type, scale, this._rateType),
|
|
534
|
+
unit: scale.label,
|
|
535
|
+
ccSpecific: {
|
|
536
|
+
meterType: this._type,
|
|
537
|
+
rateType: this._rateType,
|
|
538
|
+
scale: this.scale,
|
|
539
|
+
},
|
|
540
|
+
});
|
|
541
|
+
}
|
|
542
|
+
valueDB.setValue(valueId, this._value);
|
|
543
|
+
return true;
|
|
544
|
+
}
|
|
545
|
+
get type() {
|
|
546
|
+
return this._type;
|
|
547
|
+
}
|
|
548
|
+
get value() {
|
|
549
|
+
return this._value;
|
|
550
|
+
}
|
|
551
|
+
get previousValue() {
|
|
552
|
+
return this._previousValue;
|
|
553
|
+
}
|
|
554
|
+
get rateType() {
|
|
555
|
+
return this._rateType;
|
|
556
|
+
}
|
|
557
|
+
get deltaTime() {
|
|
558
|
+
return this._deltaTime;
|
|
559
|
+
}
|
|
560
|
+
toLogEntry(applHost) {
|
|
561
|
+
var _c;
|
|
562
|
+
const meterType = applHost.configManager.lookupMeter(this._type);
|
|
563
|
+
const scale = applHost.configManager.lookupMeterScale(this._type, this.scale);
|
|
564
|
+
const message = {
|
|
565
|
+
type: (_c = meterType === null || meterType === void 0 ? void 0 : meterType.name) !== null && _c !== void 0 ? _c : `Unknown (${(0, safe_2.num2hex)(this._type)})`,
|
|
566
|
+
scale: scale.label,
|
|
567
|
+
"rate type": (0, safe_2.getEnumMemberName)(_Types_1.RateType, this._rateType),
|
|
568
|
+
value: this.value,
|
|
569
|
+
};
|
|
570
|
+
if (this._deltaTime !== "unknown") {
|
|
571
|
+
message["time delta"] = `${this.deltaTime} seconds`;
|
|
572
|
+
}
|
|
573
|
+
if (this._previousValue != undefined) {
|
|
574
|
+
message["prev. value"] = this._previousValue;
|
|
575
|
+
}
|
|
576
|
+
return {
|
|
577
|
+
...super.toLogEntry(applHost),
|
|
578
|
+
message,
|
|
579
|
+
};
|
|
580
|
+
}
|
|
581
|
+
};
|
|
582
|
+
MeterCCReport = __decorate([
|
|
583
|
+
(0, CommandClass_1.CCCommand)(_Types_1.MeterCommand.Report)
|
|
584
|
+
], MeterCCReport);
|
|
585
|
+
exports.MeterCCReport = MeterCCReport;
|
|
586
|
+
function testResponseForMeterGet(sent, received) {
|
|
587
|
+
// We expect a Meter Report that matches the requested scale and rate type
|
|
588
|
+
// (if they were requested)
|
|
589
|
+
return ((sent.scale == undefined || sent.scale === received.scale) &&
|
|
590
|
+
(sent.rateType == undefined || sent.rateType == received.rateType));
|
|
591
|
+
}
|
|
592
|
+
let MeterCCGet = class MeterCCGet extends MeterCC {
|
|
593
|
+
constructor(host, options) {
|
|
594
|
+
super(host, options);
|
|
595
|
+
if ((0, CommandClass_1.gotDeserializationOptions)(options)) {
|
|
596
|
+
// TODO: Deserialize payload
|
|
597
|
+
throw new safe_1.ZWaveError(`${this.constructor.name}: deserialization not implemented`, safe_1.ZWaveErrorCodes.Deserialization_NotImplemented);
|
|
598
|
+
}
|
|
599
|
+
else {
|
|
600
|
+
this.rateType = options.rateType;
|
|
601
|
+
this.scale = options.scale;
|
|
602
|
+
}
|
|
603
|
+
}
|
|
604
|
+
serialize() {
|
|
605
|
+
let scale1;
|
|
606
|
+
let scale2;
|
|
607
|
+
let bufferLength = 0;
|
|
608
|
+
if (this.scale == undefined) {
|
|
609
|
+
scale1 = 0;
|
|
610
|
+
}
|
|
611
|
+
else if (this.version >= 4 && this.scale >= 7) {
|
|
612
|
+
scale1 = 7;
|
|
613
|
+
scale2 = this.scale >>> 3;
|
|
614
|
+
bufferLength = 2;
|
|
615
|
+
}
|
|
616
|
+
else if (this.version >= 3) {
|
|
617
|
+
scale1 = this.scale & 0b111;
|
|
618
|
+
bufferLength = 1;
|
|
619
|
+
}
|
|
620
|
+
else if (this.version >= 2) {
|
|
621
|
+
scale1 = this.scale & 0b11;
|
|
622
|
+
bufferLength = 1;
|
|
623
|
+
}
|
|
624
|
+
else {
|
|
625
|
+
scale1 = 0;
|
|
626
|
+
}
|
|
627
|
+
let rateTypeFlags = 0;
|
|
628
|
+
if (this.version >= 4 && this.rateType != undefined) {
|
|
629
|
+
rateTypeFlags = this.rateType & 0b11;
|
|
630
|
+
bufferLength = Math.max(bufferLength, 1);
|
|
631
|
+
}
|
|
632
|
+
this.payload = Buffer.alloc(bufferLength, 0);
|
|
633
|
+
this.payload[0] = (rateTypeFlags << 6) | (scale1 << 3);
|
|
634
|
+
if (scale2)
|
|
635
|
+
this.payload[1] = scale2;
|
|
636
|
+
return super.serialize();
|
|
637
|
+
}
|
|
638
|
+
toLogEntry(applHost) {
|
|
639
|
+
const message = {};
|
|
640
|
+
if (this.rateType != undefined) {
|
|
641
|
+
message["rate type"] = (0, safe_2.getEnumMemberName)(_Types_1.RateType, this.rateType);
|
|
642
|
+
}
|
|
643
|
+
if (this.scale != undefined) {
|
|
644
|
+
// Try to lookup the meter type to translate the scale
|
|
645
|
+
const type = this.getValueDB(applHost).getValue(getTypeValueId(this.endpointIndex));
|
|
646
|
+
if (type != undefined) {
|
|
647
|
+
message.scale = applHost.configManager.lookupMeterScale(type, this.scale).label;
|
|
648
|
+
}
|
|
649
|
+
}
|
|
650
|
+
return {
|
|
651
|
+
...super.toLogEntry(applHost),
|
|
652
|
+
message,
|
|
653
|
+
};
|
|
654
|
+
}
|
|
655
|
+
};
|
|
656
|
+
MeterCCGet = __decorate([
|
|
657
|
+
(0, CommandClass_1.CCCommand)(_Types_1.MeterCommand.Get),
|
|
658
|
+
(0, CommandClass_1.expectedCCResponse)(MeterCCReport, testResponseForMeterGet)
|
|
659
|
+
], MeterCCGet);
|
|
660
|
+
exports.MeterCCGet = MeterCCGet;
|
|
661
|
+
let MeterCCSupportedReport = class MeterCCSupportedReport extends MeterCC {
|
|
662
|
+
constructor(host, options) {
|
|
663
|
+
super(host, options);
|
|
664
|
+
(0, safe_1.validatePayload)(this.payload.length >= 2);
|
|
665
|
+
this._type = this.payload[0] & 31;
|
|
666
|
+
this._supportsReset = !!(this.payload[0] & 128);
|
|
667
|
+
const hasMoreScales = !!(this.payload[1] & 128);
|
|
668
|
+
if (hasMoreScales) {
|
|
669
|
+
// The bitmask is spread out
|
|
670
|
+
(0, safe_1.validatePayload)(this.payload.length >= 3);
|
|
671
|
+
const extraBytes = this.payload[2];
|
|
672
|
+
(0, safe_1.validatePayload)(this.payload.length >= 3 + extraBytes);
|
|
673
|
+
// The bitmask is the original payload byte plus all following bytes
|
|
674
|
+
// Since the first byte only has 7 bits, we need to reduce all following bits by 1
|
|
675
|
+
this._supportedScales = (0, safe_1.parseBitMask)(Buffer.concat([
|
|
676
|
+
Buffer.from([this.payload[1] & 127]),
|
|
677
|
+
this.payload.slice(3, 3 + extraBytes),
|
|
678
|
+
]), 0).map((scale) => (scale >= 8 ? scale - 1 : scale));
|
|
679
|
+
}
|
|
680
|
+
else {
|
|
681
|
+
// only 7 bits in the bitmask. Bit 7 is 0, so no need to mask it out
|
|
682
|
+
this._supportedScales = (0, safe_1.parseBitMask)(Buffer.from([this.payload[1]]), 0);
|
|
683
|
+
}
|
|
684
|
+
// This is only present in V4+
|
|
685
|
+
this._supportedRateTypes = (0, safe_1.parseBitMask)(Buffer.from([(this.payload[0] & 96) >>> 5]), 1);
|
|
686
|
+
}
|
|
687
|
+
get type() {
|
|
688
|
+
return this._type;
|
|
689
|
+
}
|
|
690
|
+
get supportsReset() {
|
|
691
|
+
return this._supportsReset;
|
|
692
|
+
}
|
|
693
|
+
get supportedScales() {
|
|
694
|
+
return this._supportedScales;
|
|
695
|
+
}
|
|
696
|
+
get supportedRateTypes() {
|
|
697
|
+
return this._supportedRateTypes;
|
|
698
|
+
}
|
|
699
|
+
persistValues(applHost) {
|
|
700
|
+
if (!super.persistValues(applHost))
|
|
701
|
+
return false;
|
|
702
|
+
if (!this._supportsReset)
|
|
703
|
+
return true;
|
|
704
|
+
const valueDB = this.getValueDB(applHost);
|
|
705
|
+
// Create reset values
|
|
706
|
+
if (this.version < 6) {
|
|
707
|
+
const resetAllValueId = getResetValueId(this.endpointIndex);
|
|
708
|
+
if (!valueDB.hasMetadata(resetAllValueId)) {
|
|
709
|
+
valueDB.setMetadata(resetAllValueId, {
|
|
710
|
+
...safe_1.ValueMetadata.WriteOnlyBoolean,
|
|
711
|
+
label: `Reset accumulated values`,
|
|
712
|
+
});
|
|
713
|
+
}
|
|
714
|
+
}
|
|
715
|
+
else {
|
|
716
|
+
const resetSingle = getResetValueId(this.endpointIndex, this._type);
|
|
717
|
+
if (!valueDB.hasMetadata(resetSingle)) {
|
|
718
|
+
valueDB.setMetadata(resetSingle, {
|
|
719
|
+
...safe_1.ValueMetadata.WriteOnlyBoolean,
|
|
720
|
+
label: `Reset (${getMeterTypeName(applHost.configManager, this._type)})`,
|
|
721
|
+
ccSpecific: {
|
|
722
|
+
meterType: this._type,
|
|
723
|
+
},
|
|
724
|
+
});
|
|
725
|
+
}
|
|
726
|
+
}
|
|
727
|
+
return true;
|
|
728
|
+
}
|
|
729
|
+
toLogEntry(applHost) {
|
|
730
|
+
var _c, _d;
|
|
731
|
+
const message = {
|
|
732
|
+
type: `${(_d = (_c = applHost.configManager.lookupMeter(this.type)) === null || _c === void 0 ? void 0 : _c.name) !== null && _d !== void 0 ? _d : `Unknown (${(0, safe_2.num2hex)(this.type)})`}`,
|
|
733
|
+
"supports reset": this._supportsReset,
|
|
734
|
+
"supported scales": `${this._supportedScales
|
|
735
|
+
.map((scale) => `
|
|
736
|
+
· ${applHost.configManager.lookupMeterScale(this.type, scale).label}`)
|
|
737
|
+
.join("")}`,
|
|
738
|
+
"supported rate types": this._supportedRateTypes
|
|
739
|
+
.map((rt) => (0, safe_2.getEnumMemberName)(_Types_1.RateType, rt))
|
|
740
|
+
.join(", "),
|
|
741
|
+
};
|
|
742
|
+
return {
|
|
743
|
+
...super.toLogEntry(applHost),
|
|
744
|
+
message,
|
|
745
|
+
};
|
|
746
|
+
}
|
|
747
|
+
};
|
|
748
|
+
__decorate([
|
|
749
|
+
(0, CommandClass_1.ccValue)({ internal: true })
|
|
750
|
+
], MeterCCSupportedReport.prototype, "type", null);
|
|
751
|
+
__decorate([
|
|
752
|
+
(0, CommandClass_1.ccValue)({ internal: true })
|
|
753
|
+
], MeterCCSupportedReport.prototype, "supportsReset", null);
|
|
754
|
+
__decorate([
|
|
755
|
+
(0, CommandClass_1.ccValue)({ internal: true })
|
|
756
|
+
], MeterCCSupportedReport.prototype, "supportedScales", null);
|
|
757
|
+
__decorate([
|
|
758
|
+
(0, CommandClass_1.ccValue)({ internal: true })
|
|
759
|
+
], MeterCCSupportedReport.prototype, "supportedRateTypes", null);
|
|
760
|
+
MeterCCSupportedReport = __decorate([
|
|
761
|
+
(0, CommandClass_1.CCCommand)(_Types_1.MeterCommand.SupportedReport)
|
|
762
|
+
], MeterCCSupportedReport);
|
|
763
|
+
exports.MeterCCSupportedReport = MeterCCSupportedReport;
|
|
764
|
+
let MeterCCSupportedGet = class MeterCCSupportedGet extends MeterCC {
|
|
765
|
+
};
|
|
766
|
+
MeterCCSupportedGet = __decorate([
|
|
767
|
+
(0, CommandClass_1.CCCommand)(_Types_1.MeterCommand.SupportedGet),
|
|
768
|
+
(0, CommandClass_1.expectedCCResponse)(MeterCCSupportedReport)
|
|
769
|
+
], MeterCCSupportedGet);
|
|
770
|
+
exports.MeterCCSupportedGet = MeterCCSupportedGet;
|
|
771
|
+
let MeterCCReset = class MeterCCReset extends MeterCC {
|
|
772
|
+
constructor(host, options) {
|
|
773
|
+
super(host, options);
|
|
774
|
+
if ((0, CommandClass_1.gotDeserializationOptions)(options)) {
|
|
775
|
+
// TODO: Deserialize payload
|
|
776
|
+
throw new safe_1.ZWaveError(`${this.constructor.name}: deserialization not implemented`, safe_1.ZWaveErrorCodes.Deserialization_NotImplemented);
|
|
777
|
+
}
|
|
778
|
+
else {
|
|
779
|
+
this.type = options.type;
|
|
780
|
+
this.targetValue = options.targetValue;
|
|
781
|
+
// Test if this is a valid target value
|
|
782
|
+
if (this.targetValue != undefined &&
|
|
783
|
+
!(0, safe_1.getMinIntegerSize)(this.targetValue, true)) {
|
|
784
|
+
throw new safe_1.ZWaveError(`${this.targetValue} is not a valid target value!`, safe_1.ZWaveErrorCodes.Argument_Invalid);
|
|
785
|
+
}
|
|
786
|
+
}
|
|
787
|
+
}
|
|
788
|
+
serialize() {
|
|
789
|
+
if (this.version >= 6 && this.targetValue != undefined && this.type) {
|
|
790
|
+
const size = (this.targetValue &&
|
|
791
|
+
(0, safe_1.getMinIntegerSize)(this.targetValue, true)) ||
|
|
792
|
+
0;
|
|
793
|
+
if (size > 0) {
|
|
794
|
+
this.payload = Buffer.allocUnsafe(1 + size);
|
|
795
|
+
this.payload[0] = (size << 5) | (this.type & 0b11111);
|
|
796
|
+
this.payload.writeIntBE(this.targetValue, 1, size);
|
|
797
|
+
}
|
|
798
|
+
}
|
|
799
|
+
return super.serialize();
|
|
800
|
+
}
|
|
801
|
+
toLogEntry(applHost) {
|
|
802
|
+
var _c, _d;
|
|
803
|
+
const message = {};
|
|
804
|
+
if (this.type != undefined) {
|
|
805
|
+
message.type = `${(_d = (_c = applHost.configManager.lookupMeter(this.type)) === null || _c === void 0 ? void 0 : _c.name) !== null && _d !== void 0 ? _d : `Unknown (${(0, safe_2.num2hex)(this.type)})`}`;
|
|
806
|
+
}
|
|
807
|
+
if (this.targetValue != undefined) {
|
|
808
|
+
message["target value"] = this.targetValue;
|
|
809
|
+
}
|
|
810
|
+
return {
|
|
811
|
+
...super.toLogEntry(applHost),
|
|
812
|
+
message,
|
|
813
|
+
};
|
|
814
|
+
}
|
|
815
|
+
};
|
|
816
|
+
MeterCCReset = __decorate([
|
|
817
|
+
(0, CommandClass_1.CCCommand)(_Types_1.MeterCommand.Reset)
|
|
818
|
+
], MeterCCReset);
|
|
819
|
+
exports.MeterCCReset = MeterCCReset;
|
|
820
|
+
//# sourceMappingURL=MeterCC.js.map
|