@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,1045 @@
|
|
|
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.ColorSwitchCCStopLevelChange = exports.ColorSwitchCCStartLevelChange = exports.ColorSwitchCCSet = exports.ColorSwitchCCGet = exports.ColorSwitchCCReport = exports.ColorSwitchCCSupportedGet = exports.ColorSwitchCCSupportedReport = exports.ColorSwitchCC = exports.ColorSwitchCCAPI = 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__ColorComponent = $o => {
|
|
18
|
+
function su__1__2__3__4__5__6__7__8__9_eu($o) {
|
|
19
|
+
return ![0, 1, 2, 3, 4, 5, 6, 7, 8].includes($o) ? {} : null;
|
|
20
|
+
}
|
|
21
|
+
return su__1__2__3__4__5__6__7__8__9_eu($o);
|
|
22
|
+
};
|
|
23
|
+
const __assertType__ColorSwitchCCSetOptions = $o => {
|
|
24
|
+
function _undefined($o) {
|
|
25
|
+
return $o !== undefined ? {} : null;
|
|
26
|
+
}
|
|
27
|
+
function _number($o) {
|
|
28
|
+
return typeof $o !== "number" ? {} : null;
|
|
29
|
+
}
|
|
30
|
+
function su__undefined__number_eu($o) {
|
|
31
|
+
const conditions = [_undefined, _number];
|
|
32
|
+
for (const condition of conditions) {
|
|
33
|
+
const error = condition($o);
|
|
34
|
+
if (!error)
|
|
35
|
+
return null;
|
|
36
|
+
}
|
|
37
|
+
return {};
|
|
38
|
+
}
|
|
39
|
+
function _2($o) {
|
|
40
|
+
if (typeof $o !== "object" || $o === null || Array.isArray($o))
|
|
41
|
+
return {};
|
|
42
|
+
if ("warmWhite" in $o && $o["warmWhite"] !== undefined) {
|
|
43
|
+
const error = su__undefined__number_eu($o["warmWhite"]);
|
|
44
|
+
if (error)
|
|
45
|
+
return error;
|
|
46
|
+
}
|
|
47
|
+
if ("coldWhite" in $o && $o["coldWhite"] !== undefined) {
|
|
48
|
+
const error = su__undefined__number_eu($o["coldWhite"]);
|
|
49
|
+
if (error)
|
|
50
|
+
return error;
|
|
51
|
+
}
|
|
52
|
+
if ("red" in $o && $o["red"] !== undefined) {
|
|
53
|
+
const error = su__undefined__number_eu($o["red"]);
|
|
54
|
+
if (error)
|
|
55
|
+
return error;
|
|
56
|
+
}
|
|
57
|
+
if ("green" in $o && $o["green"] !== undefined) {
|
|
58
|
+
const error = su__undefined__number_eu($o["green"]);
|
|
59
|
+
if (error)
|
|
60
|
+
return error;
|
|
61
|
+
}
|
|
62
|
+
if ("blue" in $o && $o["blue"] !== undefined) {
|
|
63
|
+
const error = su__undefined__number_eu($o["blue"]);
|
|
64
|
+
if (error)
|
|
65
|
+
return error;
|
|
66
|
+
}
|
|
67
|
+
if ("amber" in $o && $o["amber"] !== undefined) {
|
|
68
|
+
const error = su__undefined__number_eu($o["amber"]);
|
|
69
|
+
if (error)
|
|
70
|
+
return error;
|
|
71
|
+
}
|
|
72
|
+
if ("cyan" in $o && $o["cyan"] !== undefined) {
|
|
73
|
+
const error = su__undefined__number_eu($o["cyan"]);
|
|
74
|
+
if (error)
|
|
75
|
+
return error;
|
|
76
|
+
}
|
|
77
|
+
if ("purple" in $o && $o["purple"] !== undefined) {
|
|
78
|
+
const error = su__undefined__number_eu($o["purple"]);
|
|
79
|
+
if (error)
|
|
80
|
+
return error;
|
|
81
|
+
}
|
|
82
|
+
if ("index" in $o && $o["index"] !== undefined) {
|
|
83
|
+
const error = su__undefined__number_eu($o["index"]);
|
|
84
|
+
if (error)
|
|
85
|
+
return error;
|
|
86
|
+
}
|
|
87
|
+
return null;
|
|
88
|
+
}
|
|
89
|
+
function _string($o) {
|
|
90
|
+
return typeof $o !== "string" ? {} : null;
|
|
91
|
+
}
|
|
92
|
+
function _13($o) {
|
|
93
|
+
return !($o instanceof require("@zwave-js/core").Duration) ? {} : null;
|
|
94
|
+
}
|
|
95
|
+
function su__string__13_eu($o) {
|
|
96
|
+
const conditions = [_string, _13];
|
|
97
|
+
for (const condition of conditions) {
|
|
98
|
+
const error = condition($o);
|
|
99
|
+
if (!error)
|
|
100
|
+
return null;
|
|
101
|
+
}
|
|
102
|
+
return {};
|
|
103
|
+
}
|
|
104
|
+
function _3($o) {
|
|
105
|
+
if (typeof $o !== "object" || $o === null || Array.isArray($o))
|
|
106
|
+
return {};
|
|
107
|
+
if ("duration" in $o && $o["duration"] !== undefined) {
|
|
108
|
+
const error = su__string__13_eu($o["duration"]);
|
|
109
|
+
if (error)
|
|
110
|
+
return error;
|
|
111
|
+
}
|
|
112
|
+
return null;
|
|
113
|
+
}
|
|
114
|
+
function si__2__3_ei($o) {
|
|
115
|
+
const conditions = [_2, _3];
|
|
116
|
+
for (const condition of conditions) {
|
|
117
|
+
const error = condition($o);
|
|
118
|
+
if (error)
|
|
119
|
+
return error;
|
|
120
|
+
}
|
|
121
|
+
return null;
|
|
122
|
+
}
|
|
123
|
+
function _5($o) {
|
|
124
|
+
if (typeof $o !== "object" || $o === null || Array.isArray($o))
|
|
125
|
+
return {};
|
|
126
|
+
if ("0" in $o && $o["0"] !== undefined) {
|
|
127
|
+
const error = su__undefined__number_eu($o["0"]);
|
|
128
|
+
if (error)
|
|
129
|
+
return error;
|
|
130
|
+
}
|
|
131
|
+
if ("1" in $o && $o["1"] !== undefined) {
|
|
132
|
+
const error = su__undefined__number_eu($o["1"]);
|
|
133
|
+
if (error)
|
|
134
|
+
return error;
|
|
135
|
+
}
|
|
136
|
+
if ("2" in $o && $o["2"] !== undefined) {
|
|
137
|
+
const error = su__undefined__number_eu($o["2"]);
|
|
138
|
+
if (error)
|
|
139
|
+
return error;
|
|
140
|
+
}
|
|
141
|
+
if ("3" in $o && $o["3"] !== undefined) {
|
|
142
|
+
const error = su__undefined__number_eu($o["3"]);
|
|
143
|
+
if (error)
|
|
144
|
+
return error;
|
|
145
|
+
}
|
|
146
|
+
if ("4" in $o && $o["4"] !== undefined) {
|
|
147
|
+
const error = su__undefined__number_eu($o["4"]);
|
|
148
|
+
if (error)
|
|
149
|
+
return error;
|
|
150
|
+
}
|
|
151
|
+
if ("5" in $o && $o["5"] !== undefined) {
|
|
152
|
+
const error = su__undefined__number_eu($o["5"]);
|
|
153
|
+
if (error)
|
|
154
|
+
return error;
|
|
155
|
+
}
|
|
156
|
+
if ("6" in $o && $o["6"] !== undefined) {
|
|
157
|
+
const error = su__undefined__number_eu($o["6"]);
|
|
158
|
+
if (error)
|
|
159
|
+
return error;
|
|
160
|
+
}
|
|
161
|
+
if ("7" in $o && $o["7"] !== undefined) {
|
|
162
|
+
const error = su__undefined__number_eu($o["7"]);
|
|
163
|
+
if (error)
|
|
164
|
+
return error;
|
|
165
|
+
}
|
|
166
|
+
if ("8" in $o && $o["8"] !== undefined) {
|
|
167
|
+
const error = su__undefined__number_eu($o["8"]);
|
|
168
|
+
if (error)
|
|
169
|
+
return error;
|
|
170
|
+
}
|
|
171
|
+
return null;
|
|
172
|
+
}
|
|
173
|
+
function si__5__3_ei($o) {
|
|
174
|
+
const conditions = [_5, _3];
|
|
175
|
+
for (const condition of conditions) {
|
|
176
|
+
const error = condition($o);
|
|
177
|
+
if (error)
|
|
178
|
+
return error;
|
|
179
|
+
}
|
|
180
|
+
return null;
|
|
181
|
+
}
|
|
182
|
+
function _7($o) {
|
|
183
|
+
if (typeof $o !== "object" || $o === null || Array.isArray($o))
|
|
184
|
+
return {};
|
|
185
|
+
if ("hexColor" in $o && $o["hexColor"] !== undefined) {
|
|
186
|
+
const error = _string($o["hexColor"]);
|
|
187
|
+
if (error)
|
|
188
|
+
return error;
|
|
189
|
+
}
|
|
190
|
+
else
|
|
191
|
+
return {};
|
|
192
|
+
return null;
|
|
193
|
+
}
|
|
194
|
+
function si__7__3_ei($o) {
|
|
195
|
+
const conditions = [_7, _3];
|
|
196
|
+
for (const condition of conditions) {
|
|
197
|
+
const error = condition($o);
|
|
198
|
+
if (error)
|
|
199
|
+
return error;
|
|
200
|
+
}
|
|
201
|
+
return null;
|
|
202
|
+
}
|
|
203
|
+
function su_si__2__3_ei_si__5__3_ei_si__7__3_ei_eu($o) {
|
|
204
|
+
const conditions = [si__2__3_ei, si__5__3_ei, si__7__3_ei];
|
|
205
|
+
for (const condition of conditions) {
|
|
206
|
+
const error = condition($o);
|
|
207
|
+
if (!error)
|
|
208
|
+
return null;
|
|
209
|
+
}
|
|
210
|
+
return {};
|
|
211
|
+
}
|
|
212
|
+
return su_si__2__3_ei_si__5__3_ei_si__7__3_ei_eu($o);
|
|
213
|
+
};
|
|
214
|
+
const __assertType__ColorSwitchCCStartLevelChangeOptions = $o => {
|
|
215
|
+
function su__8__9__10__11__12__13__14__15__16_eu($o) {
|
|
216
|
+
return ![0, 1, 2, 3, 4, 5, 6, 7, 8].includes($o) ? {} : null;
|
|
217
|
+
}
|
|
218
|
+
function _18($o) {
|
|
219
|
+
return $o !== "up" ? {} : null;
|
|
220
|
+
}
|
|
221
|
+
function _19($o) {
|
|
222
|
+
return $o !== "down" ? {} : null;
|
|
223
|
+
}
|
|
224
|
+
function su__18__19_eu($o) {
|
|
225
|
+
const conditions = [_18, _19];
|
|
226
|
+
for (const condition of conditions) {
|
|
227
|
+
const error = condition($o);
|
|
228
|
+
if (!error)
|
|
229
|
+
return null;
|
|
230
|
+
}
|
|
231
|
+
return {};
|
|
232
|
+
}
|
|
233
|
+
function _2($o) {
|
|
234
|
+
if (typeof $o !== "object" || $o === null || Array.isArray($o))
|
|
235
|
+
return {};
|
|
236
|
+
if ("colorComponent" in $o && $o["colorComponent"] !== undefined) {
|
|
237
|
+
const error = su__8__9__10__11__12__13__14__15__16_eu($o["colorComponent"]);
|
|
238
|
+
if (error)
|
|
239
|
+
return error;
|
|
240
|
+
}
|
|
241
|
+
else
|
|
242
|
+
return {};
|
|
243
|
+
if ("direction" in $o && $o["direction"] !== undefined) {
|
|
244
|
+
const error = su__18__19_eu($o["direction"]);
|
|
245
|
+
if (error)
|
|
246
|
+
return error;
|
|
247
|
+
}
|
|
248
|
+
else
|
|
249
|
+
return {};
|
|
250
|
+
return null;
|
|
251
|
+
}
|
|
252
|
+
function _true($o) {
|
|
253
|
+
return $o !== true ? {} : null;
|
|
254
|
+
}
|
|
255
|
+
function _number($o) {
|
|
256
|
+
return typeof $o !== "number" ? {} : null;
|
|
257
|
+
}
|
|
258
|
+
function _3($o) {
|
|
259
|
+
if (typeof $o !== "object" || $o === null || Array.isArray($o))
|
|
260
|
+
return {};
|
|
261
|
+
if ("ignoreStartLevel" in $o && $o["ignoreStartLevel"] !== undefined) {
|
|
262
|
+
const error = _true($o["ignoreStartLevel"]);
|
|
263
|
+
if (error)
|
|
264
|
+
return error;
|
|
265
|
+
}
|
|
266
|
+
else
|
|
267
|
+
return {};
|
|
268
|
+
if ("startLevel" in $o && $o["startLevel"] !== undefined) {
|
|
269
|
+
const error = _number($o["startLevel"]);
|
|
270
|
+
if (error)
|
|
271
|
+
return error;
|
|
272
|
+
}
|
|
273
|
+
return null;
|
|
274
|
+
}
|
|
275
|
+
function _string($o) {
|
|
276
|
+
return typeof $o !== "string" ? {} : null;
|
|
277
|
+
}
|
|
278
|
+
function _22($o) {
|
|
279
|
+
return !($o instanceof require("@zwave-js/core").Duration) ? {} : null;
|
|
280
|
+
}
|
|
281
|
+
function su__string__22_eu($o) {
|
|
282
|
+
const conditions = [_string, _22];
|
|
283
|
+
for (const condition of conditions) {
|
|
284
|
+
const error = condition($o);
|
|
285
|
+
if (!error)
|
|
286
|
+
return null;
|
|
287
|
+
}
|
|
288
|
+
return {};
|
|
289
|
+
}
|
|
290
|
+
function _4($o) {
|
|
291
|
+
if (typeof $o !== "object" || $o === null || Array.isArray($o))
|
|
292
|
+
return {};
|
|
293
|
+
if ("duration" in $o && $o["duration"] !== undefined) {
|
|
294
|
+
const error = su__string__22_eu($o["duration"]);
|
|
295
|
+
if (error)
|
|
296
|
+
return error;
|
|
297
|
+
}
|
|
298
|
+
return null;
|
|
299
|
+
}
|
|
300
|
+
function si__2__3__4_ei($o) {
|
|
301
|
+
const conditions = [_2, _3, _4];
|
|
302
|
+
for (const condition of conditions) {
|
|
303
|
+
const error = condition($o);
|
|
304
|
+
if (error)
|
|
305
|
+
return error;
|
|
306
|
+
}
|
|
307
|
+
return null;
|
|
308
|
+
}
|
|
309
|
+
function _false($o) {
|
|
310
|
+
return $o !== false ? {} : null;
|
|
311
|
+
}
|
|
312
|
+
function _6($o) {
|
|
313
|
+
if (typeof $o !== "object" || $o === null || Array.isArray($o))
|
|
314
|
+
return {};
|
|
315
|
+
if ("ignoreStartLevel" in $o && $o["ignoreStartLevel"] !== undefined) {
|
|
316
|
+
const error = _false($o["ignoreStartLevel"]);
|
|
317
|
+
if (error)
|
|
318
|
+
return error;
|
|
319
|
+
}
|
|
320
|
+
else
|
|
321
|
+
return {};
|
|
322
|
+
if ("startLevel" in $o && $o["startLevel"] !== undefined) {
|
|
323
|
+
const error = _number($o["startLevel"]);
|
|
324
|
+
if (error)
|
|
325
|
+
return error;
|
|
326
|
+
}
|
|
327
|
+
else
|
|
328
|
+
return {};
|
|
329
|
+
return null;
|
|
330
|
+
}
|
|
331
|
+
function si__2__6__4_ei($o) {
|
|
332
|
+
const conditions = [_2, _6, _4];
|
|
333
|
+
for (const condition of conditions) {
|
|
334
|
+
const error = condition($o);
|
|
335
|
+
if (error)
|
|
336
|
+
return error;
|
|
337
|
+
}
|
|
338
|
+
return null;
|
|
339
|
+
}
|
|
340
|
+
function su_si__2__3__4_ei_si__2__6__4_ei_eu($o) {
|
|
341
|
+
const conditions = [si__2__3__4_ei, si__2__6__4_ei];
|
|
342
|
+
for (const condition of conditions) {
|
|
343
|
+
const error = condition($o);
|
|
344
|
+
if (!error)
|
|
345
|
+
return null;
|
|
346
|
+
}
|
|
347
|
+
return {};
|
|
348
|
+
}
|
|
349
|
+
return su_si__2__3__4_ei_si__2__6__4_ei_eu($o);
|
|
350
|
+
};
|
|
351
|
+
const core_1 = require("@zwave-js/core");
|
|
352
|
+
const safe_1 = require("@zwave-js/shared/safe");
|
|
353
|
+
const math_1 = require("alcalzone-shared/math");
|
|
354
|
+
const objects_1 = require("alcalzone-shared/objects");
|
|
355
|
+
const typeguards_1 = require("alcalzone-shared/typeguards");
|
|
356
|
+
const API_1 = require("../lib/API");
|
|
357
|
+
const CommandClass_1 = require("../lib/CommandClass");
|
|
358
|
+
const _Types_1 = require("../lib/_Types");
|
|
359
|
+
const hexColorRegex = /^#?(?<red>[0-9a-f]{2})(?<green>[0-9a-f]{2})(?<blue>[0-9a-f]{2})$/i;
|
|
360
|
+
const colorTableKeys = [
|
|
361
|
+
...(0, safe_1.keysOf)(_Types_1.ColorComponent),
|
|
362
|
+
...(0, safe_1.keysOf)(_Types_1.ColorComponentMap),
|
|
363
|
+
];
|
|
364
|
+
function colorTableKeyToComponent(key) {
|
|
365
|
+
if (/^\d+$/.test(key)) {
|
|
366
|
+
return parseInt(key, 10);
|
|
367
|
+
}
|
|
368
|
+
else if (key in _Types_1.ColorComponentMap) {
|
|
369
|
+
return _Types_1.ColorComponentMap[key];
|
|
370
|
+
}
|
|
371
|
+
else if (key in _Types_1.ColorComponent) {
|
|
372
|
+
return _Types_1.ColorComponent[key];
|
|
373
|
+
}
|
|
374
|
+
throw new core_1.ZWaveError(`Invalid color key ${key}!`, core_1.ZWaveErrorCodes.Argument_Invalid);
|
|
375
|
+
}
|
|
376
|
+
function colorComponentToTableKey(component) {
|
|
377
|
+
for (const [key, comp] of Object.entries(_Types_1.ColorComponentMap)) {
|
|
378
|
+
if (comp === component)
|
|
379
|
+
return key;
|
|
380
|
+
}
|
|
381
|
+
}
|
|
382
|
+
function getSupportedColorComponentsValueID(endpointIndex) {
|
|
383
|
+
return {
|
|
384
|
+
commandClass: core_1.CommandClasses["Color Switch"],
|
|
385
|
+
endpoint: endpointIndex,
|
|
386
|
+
property: "supportedColorComponents",
|
|
387
|
+
};
|
|
388
|
+
}
|
|
389
|
+
function getCurrentColorValueID(endpointIndex, component) {
|
|
390
|
+
return {
|
|
391
|
+
commandClass: core_1.CommandClasses["Color Switch"],
|
|
392
|
+
property: "currentColor",
|
|
393
|
+
endpoint: endpointIndex,
|
|
394
|
+
propertyKey: component,
|
|
395
|
+
};
|
|
396
|
+
}
|
|
397
|
+
function getTargetColorValueID(endpointIndex, component) {
|
|
398
|
+
return {
|
|
399
|
+
commandClass: core_1.CommandClasses["Color Switch"],
|
|
400
|
+
property: "targetColor",
|
|
401
|
+
endpoint: endpointIndex,
|
|
402
|
+
propertyKey: component,
|
|
403
|
+
};
|
|
404
|
+
}
|
|
405
|
+
function getSupportsHexColorValueID(endpointIndex) {
|
|
406
|
+
return {
|
|
407
|
+
commandClass: core_1.CommandClasses["Color Switch"],
|
|
408
|
+
property: "supportsHexColor",
|
|
409
|
+
endpoint: endpointIndex,
|
|
410
|
+
};
|
|
411
|
+
}
|
|
412
|
+
function getHexColorValueID(endpointIndex) {
|
|
413
|
+
return {
|
|
414
|
+
commandClass: core_1.CommandClasses["Color Switch"],
|
|
415
|
+
property: "hexColor",
|
|
416
|
+
endpoint: endpointIndex,
|
|
417
|
+
};
|
|
418
|
+
}
|
|
419
|
+
let ColorSwitchCCAPI = class ColorSwitchCCAPI extends API_1.CCAPI {
|
|
420
|
+
constructor() {
|
|
421
|
+
super(...arguments);
|
|
422
|
+
this[_a] = async ({ property, propertyKey }, value, options) => {
|
|
423
|
+
var _c;
|
|
424
|
+
if (property === "targetColor") {
|
|
425
|
+
const duration = core_1.Duration.from(options === null || options === void 0 ? void 0 : options.transitionDuration);
|
|
426
|
+
if (propertyKey != undefined) {
|
|
427
|
+
// Single color component, only accepts numbers
|
|
428
|
+
if (typeof propertyKey !== "number") {
|
|
429
|
+
(0, API_1.throwUnsupportedPropertyKey)(this.ccId, property, propertyKey);
|
|
430
|
+
}
|
|
431
|
+
else if (typeof value !== "number") {
|
|
432
|
+
(0, API_1.throwWrongValueType)(this.ccId, property, "number", typeof value);
|
|
433
|
+
}
|
|
434
|
+
await this.set({ [propertyKey]: value, duration });
|
|
435
|
+
if (this.isSinglecast()) {
|
|
436
|
+
// Verify the current value after a (short) delay
|
|
437
|
+
this.schedulePoll({ property, propertyKey }, value, {
|
|
438
|
+
duration,
|
|
439
|
+
transition: "fast",
|
|
440
|
+
});
|
|
441
|
+
}
|
|
442
|
+
}
|
|
443
|
+
else {
|
|
444
|
+
// Set the compound color object
|
|
445
|
+
if (!(0, typeguards_1.isObject)(value) ||
|
|
446
|
+
!Object.keys(value).every((key) => key in _Types_1.ColorComponentMap)) {
|
|
447
|
+
throw new core_1.ZWaveError(`${core_1.CommandClasses[this.ccId]}: "${property}" must be set to an object which specifies each color channel`, core_1.ZWaveErrorCodes.Argument_Invalid);
|
|
448
|
+
}
|
|
449
|
+
// GH#2527: strip unsupported color components, because some devices don't react otherwise
|
|
450
|
+
if (this.isSinglecast()) {
|
|
451
|
+
const supportedColors = (_c = this.tryGetValueDB()) === null || _c === void 0 ? void 0 : _c.getValue(getSupportedColorComponentsValueID(this.endpoint.index));
|
|
452
|
+
if (supportedColors) {
|
|
453
|
+
value = (0, safe_1.pick)(value, supportedColors
|
|
454
|
+
.map((c) => colorComponentToTableKey(c))
|
|
455
|
+
.filter((c) => !!c));
|
|
456
|
+
}
|
|
457
|
+
}
|
|
458
|
+
// Avoid sending empty commands
|
|
459
|
+
if (Object.keys(value).length === 0)
|
|
460
|
+
return;
|
|
461
|
+
await this.set({ ...value, duration });
|
|
462
|
+
// We're not going to poll each color component separately
|
|
463
|
+
}
|
|
464
|
+
}
|
|
465
|
+
else if (property === "hexColor") {
|
|
466
|
+
// No property key, this is the hex color #rrggbb
|
|
467
|
+
if (typeof value !== "string") {
|
|
468
|
+
(0, API_1.throwWrongValueType)(this.ccId, property, "string", typeof value);
|
|
469
|
+
}
|
|
470
|
+
const duration = core_1.Duration.from(options === null || options === void 0 ? void 0 : options.transitionDuration);
|
|
471
|
+
await this.set({ hexColor: value, duration });
|
|
472
|
+
}
|
|
473
|
+
else {
|
|
474
|
+
(0, API_1.throwUnsupportedProperty)(this.ccId, property);
|
|
475
|
+
}
|
|
476
|
+
};
|
|
477
|
+
this[_b] = async ({ property, propertyKey, }) => {
|
|
478
|
+
var _c, _d, _e;
|
|
479
|
+
if (propertyKey == undefined) {
|
|
480
|
+
(0, API_1.throwMissingPropertyKey)(this.ccId, property);
|
|
481
|
+
}
|
|
482
|
+
else if (typeof propertyKey !== "number") {
|
|
483
|
+
(0, API_1.throwUnsupportedPropertyKey)(this.ccId, property, propertyKey);
|
|
484
|
+
}
|
|
485
|
+
switch (property) {
|
|
486
|
+
case "currentColor":
|
|
487
|
+
return (_c = (await this.get(propertyKey))) === null || _c === void 0 ? void 0 : _c.currentValue;
|
|
488
|
+
case "targetColor":
|
|
489
|
+
return (_d = (await this.get(propertyKey))) === null || _d === void 0 ? void 0 : _d.targetValue;
|
|
490
|
+
case "duration":
|
|
491
|
+
return (_e = (await this.get(propertyKey))) === null || _e === void 0 ? void 0 : _e.duration;
|
|
492
|
+
default:
|
|
493
|
+
(0, API_1.throwUnsupportedProperty)(this.ccId, property);
|
|
494
|
+
}
|
|
495
|
+
};
|
|
496
|
+
}
|
|
497
|
+
supportsCommand(cmd) {
|
|
498
|
+
switch (cmd) {
|
|
499
|
+
case _Types_1.ColorSwitchCommand.SupportedGet:
|
|
500
|
+
case _Types_1.ColorSwitchCommand.Get:
|
|
501
|
+
return this.isSinglecast();
|
|
502
|
+
case _Types_1.ColorSwitchCommand.Set:
|
|
503
|
+
case _Types_1.ColorSwitchCommand.StartLevelChange:
|
|
504
|
+
case _Types_1.ColorSwitchCommand.StopLevelChange:
|
|
505
|
+
return true; // These are mandatory
|
|
506
|
+
}
|
|
507
|
+
return super.supportsCommand(cmd);
|
|
508
|
+
}
|
|
509
|
+
async getSupported() {
|
|
510
|
+
this.assertSupportsCommand(_Types_1.ColorSwitchCommand, _Types_1.ColorSwitchCommand.SupportedGet);
|
|
511
|
+
const cc = new ColorSwitchCCSupportedGet(this.applHost, {
|
|
512
|
+
nodeId: this.endpoint.nodeId,
|
|
513
|
+
endpoint: this.endpoint.index,
|
|
514
|
+
});
|
|
515
|
+
const response = await this.applHost.sendCommand(cc, this.commandOptions);
|
|
516
|
+
return response === null || response === void 0 ? void 0 : response.supportedColorComponents;
|
|
517
|
+
}
|
|
518
|
+
async get(component) {
|
|
519
|
+
__assertType("component", "ColorComponent", __assertType__ColorComponent.bind(void 0, component));
|
|
520
|
+
this.assertSupportsCommand(_Types_1.ColorSwitchCommand, _Types_1.ColorSwitchCommand.Get);
|
|
521
|
+
const cc = new ColorSwitchCCGet(this.applHost, {
|
|
522
|
+
nodeId: this.endpoint.nodeId,
|
|
523
|
+
endpoint: this.endpoint.index,
|
|
524
|
+
colorComponent: component,
|
|
525
|
+
});
|
|
526
|
+
const response = await this.applHost.sendCommand(cc, this.commandOptions);
|
|
527
|
+
if (response) {
|
|
528
|
+
return (0, safe_1.pick)(response, ["currentValue", "targetValue", "duration"]);
|
|
529
|
+
}
|
|
530
|
+
}
|
|
531
|
+
async set(options) {
|
|
532
|
+
__assertType("options", "ColorSwitchCCSetOptions", __assertType__ColorSwitchCCSetOptions.bind(void 0, options));
|
|
533
|
+
this.assertSupportsCommand(_Types_1.ColorSwitchCommand, _Types_1.ColorSwitchCommand.Set);
|
|
534
|
+
const cc = new ColorSwitchCCSet(this.applHost, {
|
|
535
|
+
nodeId: this.endpoint.nodeId,
|
|
536
|
+
endpoint: this.endpoint.index,
|
|
537
|
+
...options,
|
|
538
|
+
});
|
|
539
|
+
await this.applHost.sendCommand(cc, this.commandOptions);
|
|
540
|
+
// If the command did not fail, assume that it succeeded and update the values accordingly
|
|
541
|
+
// TODO: The API methods should not modify the value DB directly, but to do so
|
|
542
|
+
// this requires a nicer way of synchronizing hexColor with the others
|
|
543
|
+
if (this.isSinglecast()) {
|
|
544
|
+
// Update each color component separately and record the changes to the compound value
|
|
545
|
+
this.updateCurrentColor(this.getValueDB(), cc.colorTable);
|
|
546
|
+
}
|
|
547
|
+
else if (this.isMulticast()) {
|
|
548
|
+
// Figure out which nodes were affected by this command
|
|
549
|
+
const affectedNodes = this.endpoint.node.physicalNodes.filter((node) => {
|
|
550
|
+
var _c;
|
|
551
|
+
return (_c = node
|
|
552
|
+
.getEndpoint(this.endpoint.index)) === null || _c === void 0 ? void 0 : _c.supportsCC(this.ccId);
|
|
553
|
+
});
|
|
554
|
+
// and optimistically update the currentColor
|
|
555
|
+
for (const node of affectedNodes) {
|
|
556
|
+
const valueDB = this.applHost.tryGetValueDB(node.id);
|
|
557
|
+
if (valueDB) {
|
|
558
|
+
this.updateCurrentColor(valueDB, cc.colorTable);
|
|
559
|
+
}
|
|
560
|
+
}
|
|
561
|
+
}
|
|
562
|
+
}
|
|
563
|
+
/** Updates the current color for a given node by merging in the given changes */
|
|
564
|
+
updateCurrentColor(valueDB, colorTable) {
|
|
565
|
+
var _c, _d;
|
|
566
|
+
let updatedRGB = false;
|
|
567
|
+
const currentCompoundValue = (_c = valueDB.getValue(getCurrentColorValueID(this.endpoint.index))) !== null && _c !== void 0 ? _c : {};
|
|
568
|
+
const targetCompoundValue = (_d = valueDB.getValue(getCurrentColorValueID(this.endpoint.index))) !== null && _d !== void 0 ? _d : {};
|
|
569
|
+
for (const [key, value] of (0, objects_1.entries)(colorTable)) {
|
|
570
|
+
const component = colorTableKeyToComponent(key);
|
|
571
|
+
if (component === _Types_1.ColorComponent.Red ||
|
|
572
|
+
component === _Types_1.ColorComponent.Green ||
|
|
573
|
+
component === _Types_1.ColorComponent.Blue) {
|
|
574
|
+
updatedRGB = true;
|
|
575
|
+
}
|
|
576
|
+
valueDB.setValue(getCurrentColorValueID(this.endpoint.index, component), value);
|
|
577
|
+
// Update the compound value
|
|
578
|
+
if (key in _Types_1.ColorComponentMap) {
|
|
579
|
+
currentCompoundValue[key] = value;
|
|
580
|
+
targetCompoundValue[key] = value;
|
|
581
|
+
}
|
|
582
|
+
}
|
|
583
|
+
// And store the updated compound values
|
|
584
|
+
valueDB.setValue(getCurrentColorValueID(this.endpoint.index), currentCompoundValue);
|
|
585
|
+
valueDB.setValue(getTargetColorValueID(this.endpoint.index), targetCompoundValue);
|
|
586
|
+
// and hex color if necessary
|
|
587
|
+
const supportsHex = valueDB.getValue(getSupportsHexColorValueID(this.endpoint.index));
|
|
588
|
+
if (supportsHex && updatedRGB) {
|
|
589
|
+
const hexValueId = getHexColorValueID(this.endpoint.index);
|
|
590
|
+
const [r, g, b] = [
|
|
591
|
+
_Types_1.ColorComponent.Red,
|
|
592
|
+
_Types_1.ColorComponent.Green,
|
|
593
|
+
_Types_1.ColorComponent.Blue,
|
|
594
|
+
].map((c) => {
|
|
595
|
+
var _c;
|
|
596
|
+
return (_c = valueDB.getValue(getCurrentColorValueID(this.endpoint.index, c))) !== null && _c !== void 0 ? _c : 0;
|
|
597
|
+
});
|
|
598
|
+
const hexValue = (r << 16) | (g << 8) | b;
|
|
599
|
+
valueDB.setValue(hexValueId, hexValue.toString(16).padStart(6, "0"));
|
|
600
|
+
}
|
|
601
|
+
}
|
|
602
|
+
async startLevelChange(options) {
|
|
603
|
+
__assertType("options", "ColorSwitchCCStartLevelChangeOptions", __assertType__ColorSwitchCCStartLevelChangeOptions.bind(void 0, options));
|
|
604
|
+
this.assertSupportsCommand(_Types_1.ColorSwitchCommand, _Types_1.ColorSwitchCommand.StartLevelChange);
|
|
605
|
+
const cc = new ColorSwitchCCStartLevelChange(this.applHost, {
|
|
606
|
+
nodeId: this.endpoint.nodeId,
|
|
607
|
+
endpoint: this.endpoint.index,
|
|
608
|
+
...options,
|
|
609
|
+
});
|
|
610
|
+
await this.applHost.sendCommand(cc, this.commandOptions);
|
|
611
|
+
}
|
|
612
|
+
async stopLevelChange(colorComponent) {
|
|
613
|
+
__assertType("colorComponent", "ColorComponent", __assertType__ColorComponent.bind(void 0, colorComponent));
|
|
614
|
+
this.assertSupportsCommand(_Types_1.ColorSwitchCommand, _Types_1.ColorSwitchCommand.StopLevelChange);
|
|
615
|
+
const cc = new ColorSwitchCCStopLevelChange(this.applHost, {
|
|
616
|
+
nodeId: this.endpoint.nodeId,
|
|
617
|
+
endpoint: this.endpoint.index,
|
|
618
|
+
colorComponent,
|
|
619
|
+
});
|
|
620
|
+
await this.applHost.sendCommand(cc, this.commandOptions);
|
|
621
|
+
}
|
|
622
|
+
isSetValueOptimistic(_valueId) {
|
|
623
|
+
return false; // Color Switch CC handles updating the value DB itself
|
|
624
|
+
}
|
|
625
|
+
};
|
|
626
|
+
_a = API_1.SET_VALUE, _b = API_1.POLL_VALUE;
|
|
627
|
+
ColorSwitchCCAPI = __decorate([
|
|
628
|
+
(0, CommandClass_1.API)(core_1.CommandClasses["Color Switch"])
|
|
629
|
+
], ColorSwitchCCAPI);
|
|
630
|
+
exports.ColorSwitchCCAPI = ColorSwitchCCAPI;
|
|
631
|
+
let ColorSwitchCC = class ColorSwitchCC extends CommandClass_1.CommandClass {
|
|
632
|
+
constructor(host, options) {
|
|
633
|
+
super(host, options);
|
|
634
|
+
this.registerValue(getSupportsHexColorValueID(0).property, {
|
|
635
|
+
internal: true,
|
|
636
|
+
});
|
|
637
|
+
}
|
|
638
|
+
async interview(applHost) {
|
|
639
|
+
const node = this.getNode(applHost);
|
|
640
|
+
const endpoint = this.getEndpoint(applHost);
|
|
641
|
+
const api = API_1.CCAPI.create(core_1.CommandClasses["Color Switch"], applHost, endpoint).withOptions({
|
|
642
|
+
priority: core_1.MessagePriority.NodeQuery,
|
|
643
|
+
});
|
|
644
|
+
const valueDB = this.getValueDB(applHost);
|
|
645
|
+
applHost.controllerLog.logNode(node.id, {
|
|
646
|
+
endpoint: this.endpointIndex,
|
|
647
|
+
message: `Interviewing ${this.ccName}...`,
|
|
648
|
+
direction: "none",
|
|
649
|
+
});
|
|
650
|
+
applHost.controllerLog.logNode(node.id, {
|
|
651
|
+
endpoint: this.endpointIndex,
|
|
652
|
+
message: "querying supported colors...",
|
|
653
|
+
direction: "outbound",
|
|
654
|
+
});
|
|
655
|
+
const supportedColors = await api.getSupported();
|
|
656
|
+
if (!supportedColors) {
|
|
657
|
+
applHost.controllerLog.logNode(node.id, {
|
|
658
|
+
endpoint: this.endpointIndex,
|
|
659
|
+
message: "Querying supported colors timed out, skipping interview...",
|
|
660
|
+
level: "warn",
|
|
661
|
+
});
|
|
662
|
+
return;
|
|
663
|
+
}
|
|
664
|
+
applHost.controllerLog.logNode(node.id, {
|
|
665
|
+
endpoint: this.endpointIndex,
|
|
666
|
+
message: `received supported colors:${supportedColors
|
|
667
|
+
.map((c) => `\n· ${(0, safe_1.getEnumMemberName)(_Types_1.ColorComponent, c)}`)
|
|
668
|
+
.join("")}`,
|
|
669
|
+
direction: "outbound",
|
|
670
|
+
});
|
|
671
|
+
// Create metadata for the separate color channels
|
|
672
|
+
for (const color of supportedColors) {
|
|
673
|
+
const colorName = (0, safe_1.getEnumMemberName)(_Types_1.ColorComponent, color);
|
|
674
|
+
valueDB.setMetadata(getCurrentColorValueID(this.endpointIndex, color), {
|
|
675
|
+
...core_1.ValueMetadata.ReadOnlyUInt8,
|
|
676
|
+
label: `Current value (${colorName})`,
|
|
677
|
+
description: `The current value of the ${colorName} color.`,
|
|
678
|
+
});
|
|
679
|
+
valueDB.setMetadata(getTargetColorValueID(this.endpointIndex, color), {
|
|
680
|
+
...core_1.ValueMetadata.UInt8,
|
|
681
|
+
label: `Target value (${colorName})`,
|
|
682
|
+
description: `The target value of the ${colorName} color.`,
|
|
683
|
+
});
|
|
684
|
+
}
|
|
685
|
+
// And the compound one
|
|
686
|
+
valueDB.setMetadata(getCurrentColorValueID(this.endpointIndex), {
|
|
687
|
+
...core_1.ValueMetadata.ReadOnly,
|
|
688
|
+
label: `Current Color`,
|
|
689
|
+
});
|
|
690
|
+
valueDB.setMetadata(getTargetColorValueID(this.endpointIndex), {
|
|
691
|
+
...core_1.ValueMetadata.Any,
|
|
692
|
+
label: `Target Color`,
|
|
693
|
+
valueChangeOptions: ["transitionDuration"],
|
|
694
|
+
});
|
|
695
|
+
// Create the collective HEX color values
|
|
696
|
+
const supportsHex = [
|
|
697
|
+
_Types_1.ColorComponent.Red,
|
|
698
|
+
_Types_1.ColorComponent.Green,
|
|
699
|
+
_Types_1.ColorComponent.Blue,
|
|
700
|
+
].every((c) => supportedColors.includes(c));
|
|
701
|
+
valueDB.setValue(getSupportsHexColorValueID(this.endpointIndex), supportsHex);
|
|
702
|
+
if (supportsHex) {
|
|
703
|
+
valueDB.setMetadata(getHexColorValueID(this.endpointIndex), {
|
|
704
|
+
...core_1.ValueMetadata.Color,
|
|
705
|
+
minLength: 6,
|
|
706
|
+
maxLength: 7,
|
|
707
|
+
label: `RGB Color`,
|
|
708
|
+
valueChangeOptions: ["transitionDuration"],
|
|
709
|
+
});
|
|
710
|
+
}
|
|
711
|
+
// Query all color components
|
|
712
|
+
await this.refreshValues(applHost);
|
|
713
|
+
// Remember that the interview is complete
|
|
714
|
+
this.setInterviewComplete(applHost, true);
|
|
715
|
+
}
|
|
716
|
+
async refreshValues(applHost) {
|
|
717
|
+
var _c;
|
|
718
|
+
const node = this.getNode(applHost);
|
|
719
|
+
const endpoint = this.getEndpoint(applHost);
|
|
720
|
+
const api = API_1.CCAPI.create(core_1.CommandClasses["Color Switch"], applHost, endpoint).withOptions({
|
|
721
|
+
priority: core_1.MessagePriority.NodeQuery,
|
|
722
|
+
});
|
|
723
|
+
const valueDB = this.getValueDB(applHost);
|
|
724
|
+
const supportedColors = (_c = valueDB.getValue(getSupportedColorComponentsValueID(this.endpointIndex))) !== null && _c !== void 0 ? _c : [];
|
|
725
|
+
for (const color of supportedColors) {
|
|
726
|
+
const colorName = (0, safe_1.getEnumMemberName)(_Types_1.ColorComponent, color);
|
|
727
|
+
applHost.controllerLog.logNode(node.id, {
|
|
728
|
+
endpoint: this.endpointIndex,
|
|
729
|
+
message: `querying current color state (${colorName})`,
|
|
730
|
+
direction: "outbound",
|
|
731
|
+
});
|
|
732
|
+
await api.get(color);
|
|
733
|
+
}
|
|
734
|
+
}
|
|
735
|
+
translatePropertyKey(applHost, property, propertyKey) {
|
|
736
|
+
if ((property === "currentColor" || property === "targetColor") &&
|
|
737
|
+
typeof propertyKey === "number") {
|
|
738
|
+
const translated = _Types_1.ColorComponent[propertyKey];
|
|
739
|
+
if (translated)
|
|
740
|
+
return translated;
|
|
741
|
+
}
|
|
742
|
+
return super.translatePropertyKey(applHost, property, propertyKey);
|
|
743
|
+
}
|
|
744
|
+
};
|
|
745
|
+
ColorSwitchCC = __decorate([
|
|
746
|
+
(0, CommandClass_1.commandClass)(core_1.CommandClasses["Color Switch"]),
|
|
747
|
+
(0, CommandClass_1.implementedVersion)(3)
|
|
748
|
+
], ColorSwitchCC);
|
|
749
|
+
exports.ColorSwitchCC = ColorSwitchCC;
|
|
750
|
+
let ColorSwitchCCSupportedReport = class ColorSwitchCCSupportedReport extends ColorSwitchCC {
|
|
751
|
+
constructor(host, options) {
|
|
752
|
+
super(host, options);
|
|
753
|
+
// Docs say 'variable length', but the table shows 2 bytes.
|
|
754
|
+
(0, core_1.validatePayload)(this.payload.length >= 2);
|
|
755
|
+
this.supportedColorComponents = (0, core_1.parseBitMask)(this.payload.slice(0, 2), _Types_1.ColorComponent["Warm White"]);
|
|
756
|
+
}
|
|
757
|
+
toLogEntry(applHost) {
|
|
758
|
+
return {
|
|
759
|
+
...super.toLogEntry(applHost),
|
|
760
|
+
message: {
|
|
761
|
+
"supported color components": this.supportedColorComponents
|
|
762
|
+
.map((c) => `\n· ${(0, safe_1.getEnumMemberName)(_Types_1.ColorComponent, c)}`)
|
|
763
|
+
.join(""),
|
|
764
|
+
},
|
|
765
|
+
};
|
|
766
|
+
}
|
|
767
|
+
};
|
|
768
|
+
__decorate([
|
|
769
|
+
(0, CommandClass_1.ccValue)({ internal: true })
|
|
770
|
+
], ColorSwitchCCSupportedReport.prototype, "supportedColorComponents", void 0);
|
|
771
|
+
ColorSwitchCCSupportedReport = __decorate([
|
|
772
|
+
(0, CommandClass_1.CCCommand)(_Types_1.ColorSwitchCommand.SupportedReport)
|
|
773
|
+
], ColorSwitchCCSupportedReport);
|
|
774
|
+
exports.ColorSwitchCCSupportedReport = ColorSwitchCCSupportedReport;
|
|
775
|
+
let ColorSwitchCCSupportedGet = class ColorSwitchCCSupportedGet extends ColorSwitchCC {
|
|
776
|
+
};
|
|
777
|
+
ColorSwitchCCSupportedGet = __decorate([
|
|
778
|
+
(0, CommandClass_1.CCCommand)(_Types_1.ColorSwitchCommand.SupportedGet),
|
|
779
|
+
(0, CommandClass_1.expectedCCResponse)(ColorSwitchCCSupportedReport)
|
|
780
|
+
], ColorSwitchCCSupportedGet);
|
|
781
|
+
exports.ColorSwitchCCSupportedGet = ColorSwitchCCSupportedGet;
|
|
782
|
+
let ColorSwitchCCReport = class ColorSwitchCCReport extends ColorSwitchCC {
|
|
783
|
+
constructor(host, options) {
|
|
784
|
+
super(host, options);
|
|
785
|
+
(0, core_1.validatePayload)(this.payload.length >= 2);
|
|
786
|
+
this.colorComponent = this.payload[0];
|
|
787
|
+
this.currentValue = this.payload[1];
|
|
788
|
+
if (this.version >= 3 && this.payload.length >= 4) {
|
|
789
|
+
this.targetValue = this.payload[2];
|
|
790
|
+
this.duration = core_1.Duration.parseReport(this.payload[3]);
|
|
791
|
+
}
|
|
792
|
+
}
|
|
793
|
+
persistValues(applHost) {
|
|
794
|
+
var _c, _d, _e;
|
|
795
|
+
// Duration is stored globally instead of per component
|
|
796
|
+
if (!super.persistValues(applHost))
|
|
797
|
+
return false;
|
|
798
|
+
const valueDB = this.getValueDB(applHost);
|
|
799
|
+
const valueId = getCurrentColorValueID(this.endpointIndex, this.colorComponent);
|
|
800
|
+
valueDB.setValue(valueId, this.currentValue);
|
|
801
|
+
// Update target value if required
|
|
802
|
+
if (this.targetValue != undefined) {
|
|
803
|
+
const targetValueId = getTargetColorValueID(this.endpointIndex, this.colorComponent);
|
|
804
|
+
valueDB.setValue(targetValueId, this.targetValue);
|
|
805
|
+
}
|
|
806
|
+
// Update compound current value
|
|
807
|
+
const colorTableKey = colorComponentToTableKey(this.colorComponent);
|
|
808
|
+
if (colorTableKey) {
|
|
809
|
+
const compoundValueId = getCurrentColorValueID(this.endpointIndex);
|
|
810
|
+
const compoundValue = (_c = valueDB.getValue(compoundValueId)) !== null && _c !== void 0 ? _c : {};
|
|
811
|
+
compoundValue[colorTableKey] = this.currentValue;
|
|
812
|
+
valueDB.setValue(compoundValueId, compoundValue);
|
|
813
|
+
// and target value
|
|
814
|
+
if (this.targetValue != undefined) {
|
|
815
|
+
const compoundTargetValueId = getTargetColorValueID(this.endpointIndex);
|
|
816
|
+
const compoundTargetValue = (_d = valueDB.getValue(compoundTargetValueId)) !== null && _d !== void 0 ? _d : {};
|
|
817
|
+
compoundTargetValue[colorTableKey] = this.targetValue;
|
|
818
|
+
valueDB.setValue(compoundTargetValueId, compoundTargetValue);
|
|
819
|
+
}
|
|
820
|
+
}
|
|
821
|
+
// Update collective hex value if required
|
|
822
|
+
const supportsHex = valueDB.getValue(getSupportsHexColorValueID(this.endpointIndex));
|
|
823
|
+
if (supportsHex &&
|
|
824
|
+
(this.colorComponent === _Types_1.ColorComponent.Red ||
|
|
825
|
+
this.colorComponent === _Types_1.ColorComponent.Green ||
|
|
826
|
+
this.colorComponent === _Types_1.ColorComponent.Blue)) {
|
|
827
|
+
const hexValueId = getHexColorValueID(this.endpointIndex);
|
|
828
|
+
const hexValue = (_e = valueDB.getValue(hexValueId)) !== null && _e !== void 0 ? _e : "000000";
|
|
829
|
+
const byteOffset = _Types_1.ColorComponent.Blue - this.colorComponent;
|
|
830
|
+
const byteMask = 0xff << (byteOffset * 8);
|
|
831
|
+
let hexValueNumeric = parseInt(hexValue, 16);
|
|
832
|
+
hexValueNumeric =
|
|
833
|
+
(hexValueNumeric & ~byteMask) |
|
|
834
|
+
(this.currentValue << (byteOffset * 8));
|
|
835
|
+
valueDB.setValue(hexValueId, hexValueNumeric.toString(16).padStart(6, "0"));
|
|
836
|
+
}
|
|
837
|
+
return true;
|
|
838
|
+
}
|
|
839
|
+
toLogEntry(applHost) {
|
|
840
|
+
const message = {
|
|
841
|
+
"color component": (0, safe_1.getEnumMemberName)(_Types_1.ColorComponent, this.colorComponent),
|
|
842
|
+
"current value": this.currentValue,
|
|
843
|
+
};
|
|
844
|
+
if (this.targetValue != undefined) {
|
|
845
|
+
message["target value"] = this.targetValue;
|
|
846
|
+
}
|
|
847
|
+
if (this.duration != undefined) {
|
|
848
|
+
message.duration = this.duration.toString();
|
|
849
|
+
}
|
|
850
|
+
return {
|
|
851
|
+
...super.toLogEntry(applHost),
|
|
852
|
+
message,
|
|
853
|
+
};
|
|
854
|
+
}
|
|
855
|
+
};
|
|
856
|
+
__decorate([
|
|
857
|
+
(0, CommandClass_1.ccValue)(),
|
|
858
|
+
(0, CommandClass_1.ccValueMetadata)({
|
|
859
|
+
...core_1.ValueMetadata.ReadOnlyDuration,
|
|
860
|
+
label: "Remaining duration",
|
|
861
|
+
})
|
|
862
|
+
], ColorSwitchCCReport.prototype, "duration", void 0);
|
|
863
|
+
ColorSwitchCCReport = __decorate([
|
|
864
|
+
(0, CommandClass_1.CCCommand)(_Types_1.ColorSwitchCommand.Report)
|
|
865
|
+
], ColorSwitchCCReport);
|
|
866
|
+
exports.ColorSwitchCCReport = ColorSwitchCCReport;
|
|
867
|
+
function testResponseForColorSwitchGet(sent, received) {
|
|
868
|
+
return sent.colorComponent === received.colorComponent;
|
|
869
|
+
}
|
|
870
|
+
let ColorSwitchCCGet = class ColorSwitchCCGet extends ColorSwitchCC {
|
|
871
|
+
constructor(host, options) {
|
|
872
|
+
super(host, options);
|
|
873
|
+
if ((0, CommandClass_1.gotDeserializationOptions)(options)) {
|
|
874
|
+
// TODO: Deserialize payload
|
|
875
|
+
throw new core_1.ZWaveError(`${this.constructor.name}: deserialization not implemented`, core_1.ZWaveErrorCodes.Deserialization_NotImplemented);
|
|
876
|
+
}
|
|
877
|
+
else {
|
|
878
|
+
this._colorComponent = options.colorComponent;
|
|
879
|
+
}
|
|
880
|
+
}
|
|
881
|
+
get colorComponent() {
|
|
882
|
+
return this._colorComponent;
|
|
883
|
+
}
|
|
884
|
+
set colorComponent(value) {
|
|
885
|
+
if (!_Types_1.ColorComponent[value]) {
|
|
886
|
+
throw new core_1.ZWaveError("colorComponent must be a valid color component index.", core_1.ZWaveErrorCodes.Argument_Invalid);
|
|
887
|
+
}
|
|
888
|
+
this._colorComponent = value;
|
|
889
|
+
}
|
|
890
|
+
serialize() {
|
|
891
|
+
this.payload = Buffer.from([this._colorComponent]);
|
|
892
|
+
return super.serialize();
|
|
893
|
+
}
|
|
894
|
+
toLogEntry(applHost) {
|
|
895
|
+
return {
|
|
896
|
+
...super.toLogEntry(applHost),
|
|
897
|
+
message: {
|
|
898
|
+
"color component": (0, safe_1.getEnumMemberName)(_Types_1.ColorComponent, this.colorComponent),
|
|
899
|
+
},
|
|
900
|
+
};
|
|
901
|
+
}
|
|
902
|
+
};
|
|
903
|
+
ColorSwitchCCGet = __decorate([
|
|
904
|
+
(0, CommandClass_1.CCCommand)(_Types_1.ColorSwitchCommand.Get),
|
|
905
|
+
(0, CommandClass_1.expectedCCResponse)(ColorSwitchCCReport, testResponseForColorSwitchGet)
|
|
906
|
+
], ColorSwitchCCGet);
|
|
907
|
+
exports.ColorSwitchCCGet = ColorSwitchCCGet;
|
|
908
|
+
let ColorSwitchCCSet = class ColorSwitchCCSet extends ColorSwitchCC {
|
|
909
|
+
constructor(host, options) {
|
|
910
|
+
super(host, options);
|
|
911
|
+
if ((0, CommandClass_1.gotDeserializationOptions)(options)) {
|
|
912
|
+
// TODO: Deserialize payload
|
|
913
|
+
throw new core_1.ZWaveError(`${this.constructor.name}: deserialization not implemented`, core_1.ZWaveErrorCodes.Deserialization_NotImplemented);
|
|
914
|
+
}
|
|
915
|
+
else {
|
|
916
|
+
// Populate properties from options object
|
|
917
|
+
if ("hexColor" in options) {
|
|
918
|
+
const match = hexColorRegex.exec(options.hexColor);
|
|
919
|
+
if (!match) {
|
|
920
|
+
throw new core_1.ZWaveError(`${options.hexColor} is not a valid HEX color string`, core_1.ZWaveErrorCodes.Argument_Invalid);
|
|
921
|
+
}
|
|
922
|
+
this.colorTable = {
|
|
923
|
+
red: parseInt(match.groups.red, 16),
|
|
924
|
+
green: parseInt(match.groups.green, 16),
|
|
925
|
+
blue: parseInt(match.groups.blue, 16),
|
|
926
|
+
};
|
|
927
|
+
}
|
|
928
|
+
else {
|
|
929
|
+
this.colorTable = (0, safe_1.pick)(options, colorTableKeys);
|
|
930
|
+
}
|
|
931
|
+
this.duration = core_1.Duration.from(options.duration);
|
|
932
|
+
}
|
|
933
|
+
}
|
|
934
|
+
serialize() {
|
|
935
|
+
var _c;
|
|
936
|
+
const populatedColorCount = Object.keys(this.colorTable).length;
|
|
937
|
+
this.payload = Buffer.allocUnsafe(1 + populatedColorCount * 2 + (this.version >= 2 ? 1 : 0));
|
|
938
|
+
this.payload[0] = populatedColorCount & 0b11111;
|
|
939
|
+
let i = 1;
|
|
940
|
+
for (const [key, value] of (0, objects_1.entries)(this.colorTable)) {
|
|
941
|
+
const component = colorTableKeyToComponent(key);
|
|
942
|
+
this.payload[i] = component;
|
|
943
|
+
this.payload[i + 1] = (0, math_1.clamp)(value, 0, 0xff);
|
|
944
|
+
i += 2;
|
|
945
|
+
}
|
|
946
|
+
if (this.version >= 2) {
|
|
947
|
+
this.payload[i] = ((_c = this.duration) !== null && _c !== void 0 ? _c : core_1.Duration.from("default")).serializeSet();
|
|
948
|
+
}
|
|
949
|
+
return super.serialize();
|
|
950
|
+
}
|
|
951
|
+
toLogEntry(applHost) {
|
|
952
|
+
const message = {};
|
|
953
|
+
for (const [key, value] of Object.entries(this.colorTable)) {
|
|
954
|
+
const realKey = key in _Types_1.ColorComponentMap
|
|
955
|
+
? _Types_1.ColorComponent[_Types_1.ColorComponentMap[key]]
|
|
956
|
+
: _Types_1.ColorComponent[key];
|
|
957
|
+
message[realKey] = value;
|
|
958
|
+
}
|
|
959
|
+
if (this.duration != undefined) {
|
|
960
|
+
message.duration = this.duration.toString();
|
|
961
|
+
}
|
|
962
|
+
return {
|
|
963
|
+
...super.toLogEntry(applHost),
|
|
964
|
+
message,
|
|
965
|
+
};
|
|
966
|
+
}
|
|
967
|
+
};
|
|
968
|
+
ColorSwitchCCSet = __decorate([
|
|
969
|
+
(0, CommandClass_1.CCCommand)(_Types_1.ColorSwitchCommand.Set)
|
|
970
|
+
], ColorSwitchCCSet);
|
|
971
|
+
exports.ColorSwitchCCSet = ColorSwitchCCSet;
|
|
972
|
+
let ColorSwitchCCStartLevelChange = class ColorSwitchCCStartLevelChange extends ColorSwitchCC {
|
|
973
|
+
constructor(host, options) {
|
|
974
|
+
var _c;
|
|
975
|
+
super(host, options);
|
|
976
|
+
if ((0, CommandClass_1.gotDeserializationOptions)(options)) {
|
|
977
|
+
// TODO: Deserialize payload
|
|
978
|
+
throw new core_1.ZWaveError(`${this.constructor.name}: deserialization not implemented`, core_1.ZWaveErrorCodes.Deserialization_NotImplemented);
|
|
979
|
+
}
|
|
980
|
+
else {
|
|
981
|
+
this.duration = core_1.Duration.from(options.duration);
|
|
982
|
+
this.ignoreStartLevel = options.ignoreStartLevel;
|
|
983
|
+
this.startLevel = (_c = options.startLevel) !== null && _c !== void 0 ? _c : 0;
|
|
984
|
+
this.direction = options.direction;
|
|
985
|
+
this.colorComponent = options.colorComponent;
|
|
986
|
+
}
|
|
987
|
+
}
|
|
988
|
+
serialize() {
|
|
989
|
+
const controlByte = (_Types_1.LevelChangeDirection[this.direction] << 6) |
|
|
990
|
+
(this.ignoreStartLevel ? 32 : 0);
|
|
991
|
+
const payload = [controlByte, this.colorComponent, this.startLevel];
|
|
992
|
+
if (this.version >= 3 && this.duration) {
|
|
993
|
+
payload.push(this.duration.serializeSet());
|
|
994
|
+
}
|
|
995
|
+
this.payload = Buffer.from(payload);
|
|
996
|
+
return super.serialize();
|
|
997
|
+
}
|
|
998
|
+
toLogEntry(applHost) {
|
|
999
|
+
const message = {
|
|
1000
|
+
"color component": (0, safe_1.getEnumMemberName)(_Types_1.ColorComponent, this.colorComponent),
|
|
1001
|
+
"start level": `${this.startLevel}${this.ignoreStartLevel ? " (ignored)" : ""}`,
|
|
1002
|
+
direction: this.direction,
|
|
1003
|
+
};
|
|
1004
|
+
if (this.duration != undefined) {
|
|
1005
|
+
message.duration = this.duration.toString();
|
|
1006
|
+
}
|
|
1007
|
+
return {
|
|
1008
|
+
...super.toLogEntry(applHost),
|
|
1009
|
+
message,
|
|
1010
|
+
};
|
|
1011
|
+
}
|
|
1012
|
+
};
|
|
1013
|
+
ColorSwitchCCStartLevelChange = __decorate([
|
|
1014
|
+
(0, CommandClass_1.CCCommand)(_Types_1.ColorSwitchCommand.StartLevelChange)
|
|
1015
|
+
], ColorSwitchCCStartLevelChange);
|
|
1016
|
+
exports.ColorSwitchCCStartLevelChange = ColorSwitchCCStartLevelChange;
|
|
1017
|
+
let ColorSwitchCCStopLevelChange = class ColorSwitchCCStopLevelChange extends ColorSwitchCC {
|
|
1018
|
+
constructor(host, options) {
|
|
1019
|
+
super(host, options);
|
|
1020
|
+
if ((0, CommandClass_1.gotDeserializationOptions)(options)) {
|
|
1021
|
+
// TODO: Deserialize payload
|
|
1022
|
+
throw new core_1.ZWaveError(`${this.constructor.name}: deserialization not implemented`, core_1.ZWaveErrorCodes.Deserialization_NotImplemented);
|
|
1023
|
+
}
|
|
1024
|
+
else {
|
|
1025
|
+
this.colorComponent = options.colorComponent;
|
|
1026
|
+
}
|
|
1027
|
+
}
|
|
1028
|
+
serialize() {
|
|
1029
|
+
this.payload = Buffer.from([this.colorComponent]);
|
|
1030
|
+
return super.serialize();
|
|
1031
|
+
}
|
|
1032
|
+
toLogEntry(applHost) {
|
|
1033
|
+
return {
|
|
1034
|
+
...super.toLogEntry(applHost),
|
|
1035
|
+
message: {
|
|
1036
|
+
"color component": (0, safe_1.getEnumMemberName)(_Types_1.ColorComponent, this.colorComponent),
|
|
1037
|
+
},
|
|
1038
|
+
};
|
|
1039
|
+
}
|
|
1040
|
+
};
|
|
1041
|
+
ColorSwitchCCStopLevelChange = __decorate([
|
|
1042
|
+
(0, CommandClass_1.CCCommand)(_Types_1.ColorSwitchCommand.StopLevelChange)
|
|
1043
|
+
], ColorSwitchCCStopLevelChange);
|
|
1044
|
+
exports.ColorSwitchCCStopLevelChange = ColorSwitchCCStopLevelChange;
|
|
1045
|
+
//# sourceMappingURL=ColorSwitchCC.js.map
|