@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,1526 @@
|
|
|
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.UserCodeCCExtendedUserCodeGet = exports.UserCodeCCExtendedUserCodeReport = exports.UserCodeCCExtendedUserCodeSet = exports.UserCodeCCUserCodeChecksumGet = exports.UserCodeCCUserCodeChecksumReport = exports.UserCodeCCMasterCodeGet = exports.UserCodeCCMasterCodeReport = exports.UserCodeCCMasterCodeSet = exports.UserCodeCCKeypadModeGet = exports.UserCodeCCKeypadModeReport = exports.UserCodeCCKeypadModeSet = exports.UserCodeCCCapabilitiesGet = exports.UserCodeCCCapabilitiesReport = exports.UserCodeCCUsersNumberGet = exports.UserCodeCCUsersNumberReport = exports.UserCodeCCGet = exports.UserCodeCCReport = exports.UserCodeCCSet = exports.UserCodeCC = exports.UserCodeCCAPI = exports.userCodeToLogString = exports.getSupportsMultipleUserCodeSetValueID = exports.getSupportedASCIICharsValueID = exports.getKeypadModeValueID = exports.getSupportedKeypadModesValueID = exports.getSupportedUserIDStatusesValueID = exports.getSupportsUserCodeChecksumValueID = exports.getSupportsMasterCodeDeactivationValueID = exports.getSupportsMasterCodeValueID = exports.getUserCodeChecksumValueID = exports.getUserCodeValueID = exports.getUserIdStatusValueID = exports.getSupportedUsersValueID = 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__number = $o => {
|
|
18
|
+
function _number($o) {
|
|
19
|
+
return typeof $o !== "number" ? {} : null;
|
|
20
|
+
}
|
|
21
|
+
return _number($o);
|
|
22
|
+
};
|
|
23
|
+
const __assertType__optional_boolean = $o => {
|
|
24
|
+
function _boolean($o) {
|
|
25
|
+
return typeof $o !== "boolean" ? {} : null;
|
|
26
|
+
}
|
|
27
|
+
function optional__boolean($o) {
|
|
28
|
+
if ($o !== undefined) {
|
|
29
|
+
const error = _boolean($o);
|
|
30
|
+
if (error)
|
|
31
|
+
return error;
|
|
32
|
+
}
|
|
33
|
+
return null;
|
|
34
|
+
}
|
|
35
|
+
return optional__boolean($o);
|
|
36
|
+
};
|
|
37
|
+
const __assertType__su__1__2__3__4_eu = $o => {
|
|
38
|
+
function _1($o) {
|
|
39
|
+
return $o !== 1 ? {} : null;
|
|
40
|
+
}
|
|
41
|
+
function _2($o) {
|
|
42
|
+
return $o !== 2 ? {} : null;
|
|
43
|
+
}
|
|
44
|
+
function _3($o) {
|
|
45
|
+
return $o !== 3 ? {} : null;
|
|
46
|
+
}
|
|
47
|
+
function _4($o) {
|
|
48
|
+
return $o !== 4 ? {} : null;
|
|
49
|
+
}
|
|
50
|
+
function su__1__2__3__4_eu($o) {
|
|
51
|
+
const conditions = [_1, _2, _3, _4];
|
|
52
|
+
for (const condition of conditions) {
|
|
53
|
+
const error = condition($o);
|
|
54
|
+
if (!error)
|
|
55
|
+
return null;
|
|
56
|
+
}
|
|
57
|
+
return {};
|
|
58
|
+
}
|
|
59
|
+
return su__1__2__3__4_eu($o);
|
|
60
|
+
};
|
|
61
|
+
const __assertType__su__string__buffer_eu = $o => {
|
|
62
|
+
function _string($o) {
|
|
63
|
+
return typeof $o !== "string" ? {} : null;
|
|
64
|
+
}
|
|
65
|
+
function _buffer($o) {
|
|
66
|
+
return !Buffer.isBuffer($o) ? {} : null;
|
|
67
|
+
}
|
|
68
|
+
function su__string__buffer_eu($o) {
|
|
69
|
+
const conditions = [_string, _buffer];
|
|
70
|
+
for (const condition of conditions) {
|
|
71
|
+
const error = condition($o);
|
|
72
|
+
if (!error)
|
|
73
|
+
return null;
|
|
74
|
+
}
|
|
75
|
+
return {};
|
|
76
|
+
}
|
|
77
|
+
return su__string__buffer_eu($o);
|
|
78
|
+
};
|
|
79
|
+
const __assertType__sa_su__3__4__5_eu_ea_2 = $o => {
|
|
80
|
+
function _6($o) {
|
|
81
|
+
return $o !== 0 ? {} : null;
|
|
82
|
+
}
|
|
83
|
+
function _7($o) {
|
|
84
|
+
return $o !== 0 ? {} : null;
|
|
85
|
+
}
|
|
86
|
+
function _undefined($o) {
|
|
87
|
+
return $o !== undefined ? {} : null;
|
|
88
|
+
}
|
|
89
|
+
function _3($o) {
|
|
90
|
+
if (typeof $o !== "object" || $o === null || Array.isArray($o))
|
|
91
|
+
return {};
|
|
92
|
+
if ("userId" in $o && $o["userId"] !== undefined) {
|
|
93
|
+
const error = _6($o["userId"]);
|
|
94
|
+
if (error)
|
|
95
|
+
return error;
|
|
96
|
+
}
|
|
97
|
+
else
|
|
98
|
+
return {};
|
|
99
|
+
if ("userIdStatus" in $o && $o["userIdStatus"] !== undefined) {
|
|
100
|
+
const error = _7($o["userIdStatus"]);
|
|
101
|
+
if (error)
|
|
102
|
+
return error;
|
|
103
|
+
}
|
|
104
|
+
else
|
|
105
|
+
return {};
|
|
106
|
+
if ("userCode" in $o && $o["userCode"] !== undefined) {
|
|
107
|
+
const error = _undefined($o["userCode"]);
|
|
108
|
+
if (error)
|
|
109
|
+
return error;
|
|
110
|
+
}
|
|
111
|
+
return null;
|
|
112
|
+
}
|
|
113
|
+
function _number($o) {
|
|
114
|
+
return typeof $o !== "number" ? {} : null;
|
|
115
|
+
}
|
|
116
|
+
function _4($o) {
|
|
117
|
+
if (typeof $o !== "object" || $o === null || Array.isArray($o))
|
|
118
|
+
return {};
|
|
119
|
+
if ("userId" in $o && $o["userId"] !== undefined) {
|
|
120
|
+
const error = _number($o["userId"]);
|
|
121
|
+
if (error)
|
|
122
|
+
return error;
|
|
123
|
+
}
|
|
124
|
+
else
|
|
125
|
+
return {};
|
|
126
|
+
if ("userIdStatus" in $o && $o["userIdStatus"] !== undefined) {
|
|
127
|
+
const error = _7($o["userIdStatus"]);
|
|
128
|
+
if (error)
|
|
129
|
+
return error;
|
|
130
|
+
}
|
|
131
|
+
else
|
|
132
|
+
return {};
|
|
133
|
+
if ("userCode" in $o && $o["userCode"] !== undefined) {
|
|
134
|
+
const error = _undefined($o["userCode"]);
|
|
135
|
+
if (error)
|
|
136
|
+
return error;
|
|
137
|
+
}
|
|
138
|
+
return null;
|
|
139
|
+
}
|
|
140
|
+
function _9($o) {
|
|
141
|
+
return $o !== 1 ? {} : null;
|
|
142
|
+
}
|
|
143
|
+
function _10($o) {
|
|
144
|
+
return $o !== 2 ? {} : null;
|
|
145
|
+
}
|
|
146
|
+
function _11($o) {
|
|
147
|
+
return $o !== 3 ? {} : null;
|
|
148
|
+
}
|
|
149
|
+
function _12($o) {
|
|
150
|
+
return $o !== 4 ? {} : null;
|
|
151
|
+
}
|
|
152
|
+
function su__9__10__11__12_eu($o) {
|
|
153
|
+
const conditions = [_9, _10, _11, _12];
|
|
154
|
+
for (const condition of conditions) {
|
|
155
|
+
const error = condition($o);
|
|
156
|
+
if (!error)
|
|
157
|
+
return null;
|
|
158
|
+
}
|
|
159
|
+
return {};
|
|
160
|
+
}
|
|
161
|
+
function _string($o) {
|
|
162
|
+
return typeof $o !== "string" ? {} : null;
|
|
163
|
+
}
|
|
164
|
+
function _buffer($o) {
|
|
165
|
+
return !Buffer.isBuffer($o) ? {} : null;
|
|
166
|
+
}
|
|
167
|
+
function su__string__buffer_eu($o) {
|
|
168
|
+
const conditions = [_string, _buffer];
|
|
169
|
+
for (const condition of conditions) {
|
|
170
|
+
const error = condition($o);
|
|
171
|
+
if (!error)
|
|
172
|
+
return null;
|
|
173
|
+
}
|
|
174
|
+
return {};
|
|
175
|
+
}
|
|
176
|
+
function _5($o) {
|
|
177
|
+
if (typeof $o !== "object" || $o === null || Array.isArray($o))
|
|
178
|
+
return {};
|
|
179
|
+
if ("userId" in $o && $o["userId"] !== undefined) {
|
|
180
|
+
const error = _number($o["userId"]);
|
|
181
|
+
if (error)
|
|
182
|
+
return error;
|
|
183
|
+
}
|
|
184
|
+
else
|
|
185
|
+
return {};
|
|
186
|
+
if ("userIdStatus" in $o && $o["userIdStatus"] !== undefined) {
|
|
187
|
+
const error = su__9__10__11__12_eu($o["userIdStatus"]);
|
|
188
|
+
if (error)
|
|
189
|
+
return error;
|
|
190
|
+
}
|
|
191
|
+
else
|
|
192
|
+
return {};
|
|
193
|
+
if ("userCode" in $o && $o["userCode"] !== undefined) {
|
|
194
|
+
const error = su__string__buffer_eu($o["userCode"]);
|
|
195
|
+
if (error)
|
|
196
|
+
return error;
|
|
197
|
+
}
|
|
198
|
+
else
|
|
199
|
+
return {};
|
|
200
|
+
return null;
|
|
201
|
+
}
|
|
202
|
+
function su__3__4__5_eu($o) {
|
|
203
|
+
const conditions = [_3, _4, _5];
|
|
204
|
+
for (const condition of conditions) {
|
|
205
|
+
const error = condition($o);
|
|
206
|
+
if (!error)
|
|
207
|
+
return null;
|
|
208
|
+
}
|
|
209
|
+
return {};
|
|
210
|
+
}
|
|
211
|
+
function sa_su__3__4__5_eu_ea_2($o) {
|
|
212
|
+
if (!Array.isArray($o))
|
|
213
|
+
return {};
|
|
214
|
+
for (let i = 0; i < $o.length; i++) {
|
|
215
|
+
const error = su__3__4__5_eu($o[i]);
|
|
216
|
+
if (error)
|
|
217
|
+
return error;
|
|
218
|
+
}
|
|
219
|
+
return null;
|
|
220
|
+
}
|
|
221
|
+
return sa_su__3__4__5_eu_ea_2($o);
|
|
222
|
+
};
|
|
223
|
+
const __assertType__optional_number = $o => {
|
|
224
|
+
function _number($o) {
|
|
225
|
+
return typeof $o !== "number" ? {} : null;
|
|
226
|
+
}
|
|
227
|
+
function optional__number($o) {
|
|
228
|
+
if ($o !== undefined) {
|
|
229
|
+
const error = _number($o);
|
|
230
|
+
if (error)
|
|
231
|
+
return error;
|
|
232
|
+
}
|
|
233
|
+
return null;
|
|
234
|
+
}
|
|
235
|
+
return optional__number($o);
|
|
236
|
+
};
|
|
237
|
+
const __assertType__KeypadMode = $o => {
|
|
238
|
+
function su__1__2__3__4_eu($o) {
|
|
239
|
+
return ![0, 1, 2, 3].includes($o) ? {} : null;
|
|
240
|
+
}
|
|
241
|
+
return su__1__2__3__4_eu($o);
|
|
242
|
+
};
|
|
243
|
+
const __assertType__string = $o => {
|
|
244
|
+
function _string($o) {
|
|
245
|
+
return typeof $o !== "string" ? {} : null;
|
|
246
|
+
}
|
|
247
|
+
return _string($o);
|
|
248
|
+
};
|
|
249
|
+
const safe_1 = require("@zwave-js/core/safe");
|
|
250
|
+
const safe_2 = require("@zwave-js/shared/safe");
|
|
251
|
+
const API_1 = require("../lib/API");
|
|
252
|
+
const CommandClass_1 = require("../lib/CommandClass");
|
|
253
|
+
const _Types_1 = require("../lib/_Types");
|
|
254
|
+
function getSupportedUsersValueID(endpoint) {
|
|
255
|
+
return {
|
|
256
|
+
commandClass: safe_1.CommandClasses["User Code"],
|
|
257
|
+
endpoint,
|
|
258
|
+
property: "supportedUsers",
|
|
259
|
+
};
|
|
260
|
+
}
|
|
261
|
+
exports.getSupportedUsersValueID = getSupportedUsersValueID;
|
|
262
|
+
function getUserIdStatusValueID(endpoint, userId) {
|
|
263
|
+
return {
|
|
264
|
+
commandClass: safe_1.CommandClasses["User Code"],
|
|
265
|
+
endpoint,
|
|
266
|
+
property: "userIdStatus",
|
|
267
|
+
propertyKey: userId,
|
|
268
|
+
};
|
|
269
|
+
}
|
|
270
|
+
exports.getUserIdStatusValueID = getUserIdStatusValueID;
|
|
271
|
+
function getUserCodeValueID(endpoint, userId) {
|
|
272
|
+
return {
|
|
273
|
+
commandClass: safe_1.CommandClasses["User Code"],
|
|
274
|
+
endpoint,
|
|
275
|
+
property: "userCode",
|
|
276
|
+
propertyKey: userId,
|
|
277
|
+
};
|
|
278
|
+
}
|
|
279
|
+
exports.getUserCodeValueID = getUserCodeValueID;
|
|
280
|
+
function getUserCodeChecksumValueID(endpoint) {
|
|
281
|
+
return {
|
|
282
|
+
commandClass: safe_1.CommandClasses["User Code"],
|
|
283
|
+
endpoint,
|
|
284
|
+
property: "userCodeChecksum",
|
|
285
|
+
};
|
|
286
|
+
}
|
|
287
|
+
exports.getUserCodeChecksumValueID = getUserCodeChecksumValueID;
|
|
288
|
+
function getSupportsMasterCodeValueID(endpoint) {
|
|
289
|
+
return {
|
|
290
|
+
commandClass: safe_1.CommandClasses["User Code"],
|
|
291
|
+
endpoint,
|
|
292
|
+
property: "supportsMasterCode",
|
|
293
|
+
};
|
|
294
|
+
}
|
|
295
|
+
exports.getSupportsMasterCodeValueID = getSupportsMasterCodeValueID;
|
|
296
|
+
function getSupportsMasterCodeDeactivationValueID(endpoint) {
|
|
297
|
+
return {
|
|
298
|
+
commandClass: safe_1.CommandClasses["User Code"],
|
|
299
|
+
endpoint,
|
|
300
|
+
property: "supportsMasterCodeDeactivation",
|
|
301
|
+
};
|
|
302
|
+
}
|
|
303
|
+
exports.getSupportsMasterCodeDeactivationValueID = getSupportsMasterCodeDeactivationValueID;
|
|
304
|
+
function getSupportsUserCodeChecksumValueID(endpoint) {
|
|
305
|
+
return {
|
|
306
|
+
commandClass: safe_1.CommandClasses["User Code"],
|
|
307
|
+
endpoint,
|
|
308
|
+
property: "supportsUserCodeChecksum",
|
|
309
|
+
};
|
|
310
|
+
}
|
|
311
|
+
exports.getSupportsUserCodeChecksumValueID = getSupportsUserCodeChecksumValueID;
|
|
312
|
+
function getSupportedUserIDStatusesValueID(endpoint) {
|
|
313
|
+
return {
|
|
314
|
+
commandClass: safe_1.CommandClasses["User Code"],
|
|
315
|
+
endpoint,
|
|
316
|
+
property: "supportedUserIDStatuses",
|
|
317
|
+
};
|
|
318
|
+
}
|
|
319
|
+
exports.getSupportedUserIDStatusesValueID = getSupportedUserIDStatusesValueID;
|
|
320
|
+
function getSupportedKeypadModesValueID(endpoint) {
|
|
321
|
+
return {
|
|
322
|
+
commandClass: safe_1.CommandClasses["User Code"],
|
|
323
|
+
endpoint,
|
|
324
|
+
property: "supportedKeypadModes",
|
|
325
|
+
};
|
|
326
|
+
}
|
|
327
|
+
exports.getSupportedKeypadModesValueID = getSupportedKeypadModesValueID;
|
|
328
|
+
function getKeypadModeValueID(endpoint) {
|
|
329
|
+
return {
|
|
330
|
+
commandClass: safe_1.CommandClasses["User Code"],
|
|
331
|
+
endpoint,
|
|
332
|
+
property: "keypadMode",
|
|
333
|
+
};
|
|
334
|
+
}
|
|
335
|
+
exports.getKeypadModeValueID = getKeypadModeValueID;
|
|
336
|
+
function getSupportedASCIICharsValueID(endpoint) {
|
|
337
|
+
return {
|
|
338
|
+
commandClass: safe_1.CommandClasses["User Code"],
|
|
339
|
+
endpoint,
|
|
340
|
+
property: "supportedASCIIChars",
|
|
341
|
+
};
|
|
342
|
+
}
|
|
343
|
+
exports.getSupportedASCIICharsValueID = getSupportedASCIICharsValueID;
|
|
344
|
+
function getSupportsMultipleUserCodeSetValueID(endpoint) {
|
|
345
|
+
return {
|
|
346
|
+
commandClass: safe_1.CommandClasses["User Code"],
|
|
347
|
+
endpoint,
|
|
348
|
+
property: "supportsMultipleUserCodeSet",
|
|
349
|
+
};
|
|
350
|
+
}
|
|
351
|
+
exports.getSupportsMultipleUserCodeSetValueID = getSupportsMultipleUserCodeSetValueID;
|
|
352
|
+
function parseExtendedUserCode(payload) {
|
|
353
|
+
(0, safe_1.validatePayload)(payload.length >= 4);
|
|
354
|
+
const userId = payload.readUInt16BE(0);
|
|
355
|
+
const status = payload[2];
|
|
356
|
+
const codeLength = payload[3] & 0b1111;
|
|
357
|
+
(0, safe_1.validatePayload)(payload.length >= 4 + codeLength);
|
|
358
|
+
const code = payload.slice(4, 4 + codeLength).toString("ascii");
|
|
359
|
+
return {
|
|
360
|
+
code: {
|
|
361
|
+
userId,
|
|
362
|
+
userIdStatus: status,
|
|
363
|
+
userCode: code,
|
|
364
|
+
},
|
|
365
|
+
bytesRead: 4 + codeLength,
|
|
366
|
+
};
|
|
367
|
+
}
|
|
368
|
+
function validateCode(code, supportedChars) {
|
|
369
|
+
if (code.length < 4 || code.length > 10)
|
|
370
|
+
return false;
|
|
371
|
+
return [...code].every((char) => supportedChars.includes(char));
|
|
372
|
+
}
|
|
373
|
+
function setUserCodeMetadata(applHost, userId, userCode) {
|
|
374
|
+
var _c, _d;
|
|
375
|
+
const valueDB = this.getValueDB(applHost);
|
|
376
|
+
const statusValueId = getUserIdStatusValueID(this.endpointIndex, userId);
|
|
377
|
+
const codeValueId = getUserCodeValueID(this.endpointIndex, userId);
|
|
378
|
+
const supportedUserIDStatuses = (_c = valueDB.getValue(getSupportedUserIDStatusesValueID(this.endpointIndex))) !== null && _c !== void 0 ? _c : (this.version === 1
|
|
379
|
+
? [
|
|
380
|
+
_Types_1.UserIDStatus.Available,
|
|
381
|
+
_Types_1.UserIDStatus.Enabled,
|
|
382
|
+
_Types_1.UserIDStatus.Disabled,
|
|
383
|
+
]
|
|
384
|
+
: [
|
|
385
|
+
_Types_1.UserIDStatus.Available,
|
|
386
|
+
_Types_1.UserIDStatus.Enabled,
|
|
387
|
+
_Types_1.UserIDStatus.Disabled,
|
|
388
|
+
_Types_1.UserIDStatus.Messaging,
|
|
389
|
+
_Types_1.UserIDStatus.PassageMode,
|
|
390
|
+
]);
|
|
391
|
+
if (!valueDB.hasMetadata(statusValueId)) {
|
|
392
|
+
valueDB.setMetadata(statusValueId, {
|
|
393
|
+
...safe_1.ValueMetadata.Number,
|
|
394
|
+
label: `User ID status (${userId})`,
|
|
395
|
+
states: (0, safe_1.enumValuesToMetadataStates)(_Types_1.UserIDStatus, supportedUserIDStatuses),
|
|
396
|
+
});
|
|
397
|
+
}
|
|
398
|
+
const codeMetadata = {
|
|
399
|
+
...(Buffer.isBuffer(userCode)
|
|
400
|
+
? safe_1.ValueMetadata.Buffer
|
|
401
|
+
: safe_1.ValueMetadata.String),
|
|
402
|
+
minLength: 4,
|
|
403
|
+
maxLength: 10,
|
|
404
|
+
label: `User Code (${userId})`,
|
|
405
|
+
};
|
|
406
|
+
if (((_d = valueDB.getMetadata(codeValueId)) === null || _d === void 0 ? void 0 : _d.type) !== codeMetadata.type) {
|
|
407
|
+
valueDB.setMetadata(codeValueId, codeMetadata);
|
|
408
|
+
}
|
|
409
|
+
}
|
|
410
|
+
function persistUserCode(applHost, userId, userIdStatus, userCode) {
|
|
411
|
+
const statusValueId = getUserIdStatusValueID(this.endpointIndex, userId);
|
|
412
|
+
const codeValueId = getUserCodeValueID(this.endpointIndex, userId);
|
|
413
|
+
const valueDB = this.getValueDB(applHost);
|
|
414
|
+
// Check if this code is supported
|
|
415
|
+
if (userIdStatus === _Types_1.UserIDStatus.StatusNotAvailable) {
|
|
416
|
+
// It is not, remove all values if any exist
|
|
417
|
+
valueDB.removeValue(statusValueId);
|
|
418
|
+
valueDB.removeValue(codeValueId);
|
|
419
|
+
valueDB.setMetadata(statusValueId, undefined);
|
|
420
|
+
valueDB.setMetadata(codeValueId, undefined);
|
|
421
|
+
}
|
|
422
|
+
else {
|
|
423
|
+
// Always create metadata in case it does not exist
|
|
424
|
+
setUserCodeMetadata.call(this, applHost, userId, userCode);
|
|
425
|
+
valueDB.setValue(statusValueId, userIdStatus);
|
|
426
|
+
valueDB.setValue(codeValueId, userCode);
|
|
427
|
+
}
|
|
428
|
+
return true;
|
|
429
|
+
}
|
|
430
|
+
/** Formats a user code in a way that's safe to print in public logs */
|
|
431
|
+
function userCodeToLogString(userCode) {
|
|
432
|
+
if (userCode === "")
|
|
433
|
+
return "(empty)";
|
|
434
|
+
return "*".repeat(userCode.length);
|
|
435
|
+
}
|
|
436
|
+
exports.userCodeToLogString = userCodeToLogString;
|
|
437
|
+
let UserCodeCCAPI = class UserCodeCCAPI extends API_1.PhysicalCCAPI {
|
|
438
|
+
constructor() {
|
|
439
|
+
super(...arguments);
|
|
440
|
+
this[_a] = async ({ property, propertyKey }, value) => {
|
|
441
|
+
if (property === "keypadMode") {
|
|
442
|
+
if (typeof value !== "number") {
|
|
443
|
+
(0, API_1.throwWrongValueType)(this.ccId, property, "number", typeof value);
|
|
444
|
+
}
|
|
445
|
+
await this.setKeypadMode(value);
|
|
446
|
+
}
|
|
447
|
+
else if (property === "masterCode") {
|
|
448
|
+
if (typeof value !== "string") {
|
|
449
|
+
(0, API_1.throwWrongValueType)(this.ccId, property, "string", typeof value);
|
|
450
|
+
}
|
|
451
|
+
await this.setMasterCode(value);
|
|
452
|
+
}
|
|
453
|
+
else if (property === "userIdStatus") {
|
|
454
|
+
if (propertyKey == undefined) {
|
|
455
|
+
(0, API_1.throwMissingPropertyKey)(this.ccId, property);
|
|
456
|
+
}
|
|
457
|
+
else if (typeof propertyKey !== "number") {
|
|
458
|
+
(0, API_1.throwUnsupportedPropertyKey)(this.ccId, property, propertyKey);
|
|
459
|
+
}
|
|
460
|
+
if (typeof value !== "number") {
|
|
461
|
+
(0, API_1.throwWrongValueType)(this.ccId, property, "number", typeof value);
|
|
462
|
+
}
|
|
463
|
+
if (value === _Types_1.UserIDStatus.Available) {
|
|
464
|
+
// Clear Code
|
|
465
|
+
await this.clear(propertyKey);
|
|
466
|
+
}
|
|
467
|
+
else {
|
|
468
|
+
// We need to set the user code along with the status
|
|
469
|
+
const userCode = this.getValueDB().getValue(getUserCodeValueID(this.endpoint.index, propertyKey));
|
|
470
|
+
await this.set(propertyKey, value, userCode);
|
|
471
|
+
}
|
|
472
|
+
}
|
|
473
|
+
else if (property === "userCode") {
|
|
474
|
+
if (propertyKey == undefined) {
|
|
475
|
+
(0, API_1.throwMissingPropertyKey)(this.ccId, property);
|
|
476
|
+
}
|
|
477
|
+
else if (typeof propertyKey !== "number") {
|
|
478
|
+
(0, API_1.throwUnsupportedPropertyKey)(this.ccId, property, propertyKey);
|
|
479
|
+
}
|
|
480
|
+
if (typeof value !== "string" && !Buffer.isBuffer(value)) {
|
|
481
|
+
(0, API_1.throwWrongValueType)(this.ccId, property, "string or Buffer", typeof value);
|
|
482
|
+
}
|
|
483
|
+
// We need to set the user id status along with the code
|
|
484
|
+
let userIdStatus = this.getValueDB().getValue(getUserIdStatusValueID(this.endpoint.index, propertyKey));
|
|
485
|
+
if (userIdStatus === _Types_1.UserIDStatus.Available ||
|
|
486
|
+
userIdStatus == undefined) {
|
|
487
|
+
userIdStatus = _Types_1.UserIDStatus.Enabled;
|
|
488
|
+
}
|
|
489
|
+
await this.set(propertyKey, userIdStatus, value);
|
|
490
|
+
}
|
|
491
|
+
else {
|
|
492
|
+
(0, API_1.throwUnsupportedProperty)(this.ccId, property);
|
|
493
|
+
}
|
|
494
|
+
// Verify the current value after a (short) delay
|
|
495
|
+
this.schedulePoll({ property, propertyKey }, value, {
|
|
496
|
+
transition: "fast",
|
|
497
|
+
});
|
|
498
|
+
};
|
|
499
|
+
this[_b] = async ({ property, propertyKey, }) => {
|
|
500
|
+
var _c;
|
|
501
|
+
switch (property) {
|
|
502
|
+
case "keypadMode":
|
|
503
|
+
return this.getKeypadMode();
|
|
504
|
+
case "masterCode":
|
|
505
|
+
return this.getMasterCode();
|
|
506
|
+
case "userIdStatus":
|
|
507
|
+
case "userCode": {
|
|
508
|
+
if (propertyKey == undefined) {
|
|
509
|
+
(0, API_1.throwMissingPropertyKey)(this.ccId, property);
|
|
510
|
+
}
|
|
511
|
+
else if (typeof propertyKey !== "number") {
|
|
512
|
+
(0, API_1.throwUnsupportedPropertyKey)(this.ccId, property, propertyKey);
|
|
513
|
+
}
|
|
514
|
+
return (_c = (await this.get(propertyKey))) === null || _c === void 0 ? void 0 : _c[property];
|
|
515
|
+
}
|
|
516
|
+
default:
|
|
517
|
+
(0, API_1.throwUnsupportedProperty)(this.ccId, property);
|
|
518
|
+
}
|
|
519
|
+
};
|
|
520
|
+
}
|
|
521
|
+
supportsCommand(cmd) {
|
|
522
|
+
var _c, _d, _e, _f;
|
|
523
|
+
switch (cmd) {
|
|
524
|
+
case _Types_1.UserCodeCommand.Get:
|
|
525
|
+
case _Types_1.UserCodeCommand.Set:
|
|
526
|
+
case _Types_1.UserCodeCommand.UsersNumberGet:
|
|
527
|
+
return true; // This is mandatory
|
|
528
|
+
case _Types_1.UserCodeCommand.CapabilitiesGet:
|
|
529
|
+
case _Types_1.UserCodeCommand.KeypadModeSet:
|
|
530
|
+
case _Types_1.UserCodeCommand.KeypadModeGet:
|
|
531
|
+
case _Types_1.UserCodeCommand.ExtendedUserCodeSet:
|
|
532
|
+
case _Types_1.UserCodeCommand.ExtendedUserCodeGet:
|
|
533
|
+
return this.version >= 2;
|
|
534
|
+
case _Types_1.UserCodeCommand.MasterCodeSet:
|
|
535
|
+
case _Types_1.UserCodeCommand.MasterCodeGet: {
|
|
536
|
+
if (this.version < 2)
|
|
537
|
+
return false;
|
|
538
|
+
return ((_d = (_c = this.tryGetValueDB()) === null || _c === void 0 ? void 0 : _c.getValue(getSupportsMasterCodeValueID(this.endpoint.index))) !== null && _d !== void 0 ? _d : safe_1.unknownBoolean);
|
|
539
|
+
}
|
|
540
|
+
case _Types_1.UserCodeCommand.UserCodeChecksumGet: {
|
|
541
|
+
if (this.version < 2)
|
|
542
|
+
return false;
|
|
543
|
+
return ((_f = (_e = this.tryGetValueDB()) === null || _e === void 0 ? void 0 : _e.getValue(getSupportsUserCodeChecksumValueID(this.endpoint.index))) !== null && _f !== void 0 ? _f : safe_1.unknownBoolean);
|
|
544
|
+
}
|
|
545
|
+
}
|
|
546
|
+
return super.supportsCommand(cmd);
|
|
547
|
+
}
|
|
548
|
+
async getUsersCount() {
|
|
549
|
+
this.assertSupportsCommand(_Types_1.UserCodeCommand, _Types_1.UserCodeCommand.UsersNumberGet);
|
|
550
|
+
const cc = new UserCodeCCUsersNumberGet(this.applHost, {
|
|
551
|
+
nodeId: this.endpoint.nodeId,
|
|
552
|
+
endpoint: this.endpoint.index,
|
|
553
|
+
});
|
|
554
|
+
const response = await this.applHost.sendCommand(cc, this.commandOptions);
|
|
555
|
+
return response === null || response === void 0 ? void 0 : response.supportedUsers;
|
|
556
|
+
}
|
|
557
|
+
async get(userId, multiple = false) {
|
|
558
|
+
__assertType("userId", "number", __assertType__number.bind(void 0, userId));
|
|
559
|
+
__assertType("multiple", "(optional) boolean", __assertType__optional_boolean.bind(void 0, multiple));
|
|
560
|
+
if (userId > 255 || multiple) {
|
|
561
|
+
this.assertSupportsCommand(_Types_1.UserCodeCommand, _Types_1.UserCodeCommand.ExtendedUserCodeGet);
|
|
562
|
+
const cc = new UserCodeCCExtendedUserCodeGet(this.applHost, {
|
|
563
|
+
nodeId: this.endpoint.nodeId,
|
|
564
|
+
endpoint: this.endpoint.index,
|
|
565
|
+
userId,
|
|
566
|
+
reportMore: multiple,
|
|
567
|
+
});
|
|
568
|
+
const response = await this.applHost.sendCommand(cc, this.commandOptions);
|
|
569
|
+
if (!response) {
|
|
570
|
+
return;
|
|
571
|
+
}
|
|
572
|
+
else if (multiple) {
|
|
573
|
+
return (0, safe_2.pick)(response, ["userCodes", "nextUserId"]);
|
|
574
|
+
}
|
|
575
|
+
else {
|
|
576
|
+
return (0, safe_2.pick)(response.userCodes[0], [
|
|
577
|
+
"userIdStatus",
|
|
578
|
+
"userCode",
|
|
579
|
+
]);
|
|
580
|
+
}
|
|
581
|
+
}
|
|
582
|
+
else {
|
|
583
|
+
this.assertSupportsCommand(_Types_1.UserCodeCommand, _Types_1.UserCodeCommand.Get);
|
|
584
|
+
const cc = new UserCodeCCGet(this.applHost, {
|
|
585
|
+
nodeId: this.endpoint.nodeId,
|
|
586
|
+
endpoint: this.endpoint.index,
|
|
587
|
+
userId,
|
|
588
|
+
});
|
|
589
|
+
const response = await this.applHost.sendCommand(cc, this.commandOptions);
|
|
590
|
+
if (response)
|
|
591
|
+
return (0, safe_2.pick)(response, ["userIdStatus", "userCode"]);
|
|
592
|
+
}
|
|
593
|
+
}
|
|
594
|
+
/** Configures a single user code */
|
|
595
|
+
async set(userId, userIdStatus, userCode) {
|
|
596
|
+
__assertType("userId", "number", __assertType__number.bind(void 0, userId));
|
|
597
|
+
__assertType("userIdStatus", undefined, __assertType__su__1__2__3__4_eu.bind(void 0, userIdStatus));
|
|
598
|
+
__assertType("userCode", undefined, __assertType__su__string__buffer_eu.bind(void 0, userCode));
|
|
599
|
+
if (this.version > 1 || userId > 255) {
|
|
600
|
+
return this.setMany([{ userId, userIdStatus, userCode }]);
|
|
601
|
+
}
|
|
602
|
+
this.assertSupportsCommand(_Types_1.UserCodeCommand, _Types_1.UserCodeCommand.Set);
|
|
603
|
+
const numUsers = UserCodeCC.getSupportedUsersCached(this.applHost, this.endpoint);
|
|
604
|
+
if (numUsers != undefined && userId > numUsers) {
|
|
605
|
+
throw new safe_1.ZWaveError(`The user ID must be between 0 and the number of supported users ${numUsers}.`, safe_1.ZWaveErrorCodes.Argument_Invalid);
|
|
606
|
+
}
|
|
607
|
+
const cc = new UserCodeCCSet(this.applHost, {
|
|
608
|
+
nodeId: this.endpoint.nodeId,
|
|
609
|
+
endpoint: this.endpoint.index,
|
|
610
|
+
userId,
|
|
611
|
+
userIdStatus,
|
|
612
|
+
userCode,
|
|
613
|
+
});
|
|
614
|
+
await this.applHost.sendCommand(cc, this.commandOptions);
|
|
615
|
+
}
|
|
616
|
+
/** Configures multiple user codes */
|
|
617
|
+
async setMany(codes) {
|
|
618
|
+
var _c;
|
|
619
|
+
__assertType("codes", undefined, __assertType__sa_su__3__4__5_eu_ea_2.bind(void 0, codes));
|
|
620
|
+
this.assertSupportsCommand(_Types_1.UserCodeCommand, _Types_1.UserCodeCommand.ExtendedUserCodeSet);
|
|
621
|
+
const numUsers = UserCodeCC.getSupportedUsersCached(this.applHost, this.endpoint);
|
|
622
|
+
const supportedStatuses = UserCodeCC.getSupportedUserIDStatusesCached(this.applHost, this.endpoint);
|
|
623
|
+
const supportedASCIIChars = UserCodeCC.getSupportedASCIICharsCached(this.applHost, this.endpoint);
|
|
624
|
+
const supportsMultipleUserCodeSet = (_c = UserCodeCC.supportsMultipleUserCodeSetCached(this.applHost, this.endpoint)) !== null && _c !== void 0 ? _c : false;
|
|
625
|
+
// Validate options
|
|
626
|
+
if (numUsers != undefined) {
|
|
627
|
+
if (codes.some((code) => code.userId < 0 || code.userId > numUsers)) {
|
|
628
|
+
throw new safe_1.ZWaveError(`All User IDs must be between 0 and the number of supported users ${numUsers}.`, safe_1.ZWaveErrorCodes.Argument_Invalid);
|
|
629
|
+
}
|
|
630
|
+
}
|
|
631
|
+
else {
|
|
632
|
+
if (codes.some((code) => code.userId < 0)) {
|
|
633
|
+
throw new safe_1.ZWaveError(`All User IDs must be greater than 0.`, safe_1.ZWaveErrorCodes.Argument_Invalid);
|
|
634
|
+
}
|
|
635
|
+
}
|
|
636
|
+
if (codes.some((code) => code.userId === 0) && codes.length > 1) {
|
|
637
|
+
throw new safe_1.ZWaveError(`If user ID 0 is used, only one code may be set`, safe_1.ZWaveErrorCodes.Argument_Invalid);
|
|
638
|
+
}
|
|
639
|
+
else if (codes.some((code) => code.userId === 0 &&
|
|
640
|
+
code.userIdStatus !== _Types_1.UserIDStatus.Available)) {
|
|
641
|
+
throw new safe_1.ZWaveError(`User ID 0 may only be used to clear all user codes`, safe_1.ZWaveErrorCodes.Argument_Invalid);
|
|
642
|
+
}
|
|
643
|
+
else if (codes.length > 1 && !supportsMultipleUserCodeSet) {
|
|
644
|
+
throw new safe_1.ZWaveError(`The node does not support setting multiple user codes at once`, safe_1.ZWaveErrorCodes.Argument_Invalid);
|
|
645
|
+
}
|
|
646
|
+
for (const code of codes) {
|
|
647
|
+
if (supportedStatuses != undefined &&
|
|
648
|
+
!supportedStatuses.includes(code.userIdStatus)) {
|
|
649
|
+
throw new safe_1.ZWaveError(`The user ID status ${(0, safe_2.getEnumMemberName)(_Types_1.UserIDStatus, code.userIdStatus)} is not supported by the node`, safe_1.ZWaveErrorCodes.Argument_Invalid);
|
|
650
|
+
}
|
|
651
|
+
else if (code.userIdStatus === _Types_1.UserIDStatus.Available) {
|
|
652
|
+
code.userCode = undefined;
|
|
653
|
+
}
|
|
654
|
+
else if (supportedASCIIChars) {
|
|
655
|
+
if (!validateCode(code.userCode.toString("ascii"), supportedASCIIChars)) {
|
|
656
|
+
throw new safe_1.ZWaveError(`The user code must consist of 4 to 10 of the following characters: ${supportedASCIIChars}`, safe_1.ZWaveErrorCodes.Argument_Invalid);
|
|
657
|
+
}
|
|
658
|
+
}
|
|
659
|
+
}
|
|
660
|
+
const cc = new UserCodeCCExtendedUserCodeSet(this.applHost, {
|
|
661
|
+
nodeId: this.endpoint.nodeId,
|
|
662
|
+
endpoint: this.endpoint.index,
|
|
663
|
+
userCodes: codes,
|
|
664
|
+
});
|
|
665
|
+
await this.applHost.sendCommand(cc, this.commandOptions);
|
|
666
|
+
}
|
|
667
|
+
/**
|
|
668
|
+
* Clears one or all user code
|
|
669
|
+
* @param userId The user code to clear. If none or 0 is given, all codes are cleared
|
|
670
|
+
*/
|
|
671
|
+
async clear(userId = 0) {
|
|
672
|
+
__assertType("userId", "(optional) number", __assertType__optional_number.bind(void 0, userId));
|
|
673
|
+
if (this.version > 1 || userId > 255) {
|
|
674
|
+
await this.setMany([
|
|
675
|
+
{ userId, userIdStatus: _Types_1.UserIDStatus.Available },
|
|
676
|
+
]);
|
|
677
|
+
}
|
|
678
|
+
else {
|
|
679
|
+
this.assertSupportsCommand(_Types_1.UserCodeCommand, _Types_1.UserCodeCommand.Set);
|
|
680
|
+
const numUsers = UserCodeCC.getSupportedUsersCached(this.applHost, this.endpoint);
|
|
681
|
+
if (numUsers != undefined && userId > numUsers) {
|
|
682
|
+
throw new safe_1.ZWaveError(`The user ID must be between 0 and the number of supported users ${numUsers}.`, safe_1.ZWaveErrorCodes.Argument_Invalid);
|
|
683
|
+
}
|
|
684
|
+
const cc = new UserCodeCCSet(this.applHost, {
|
|
685
|
+
nodeId: this.endpoint.nodeId,
|
|
686
|
+
endpoint: this.endpoint.index,
|
|
687
|
+
userId,
|
|
688
|
+
userIdStatus: _Types_1.UserIDStatus.Available,
|
|
689
|
+
});
|
|
690
|
+
await this.applHost.sendCommand(cc, this.commandOptions);
|
|
691
|
+
}
|
|
692
|
+
}
|
|
693
|
+
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
|
|
694
|
+
async getCapabilities() {
|
|
695
|
+
this.assertSupportsCommand(_Types_1.UserCodeCommand, _Types_1.UserCodeCommand.CapabilitiesGet);
|
|
696
|
+
const cc = new UserCodeCCCapabilitiesGet(this.applHost, {
|
|
697
|
+
nodeId: this.endpoint.nodeId,
|
|
698
|
+
endpoint: this.endpoint.index,
|
|
699
|
+
});
|
|
700
|
+
const response = await this.applHost.sendCommand(cc, this.commandOptions);
|
|
701
|
+
if (response) {
|
|
702
|
+
return (0, safe_2.pick)(response, [
|
|
703
|
+
"supportsMasterCode",
|
|
704
|
+
"supportsMasterCodeDeactivation",
|
|
705
|
+
"supportsUserCodeChecksum",
|
|
706
|
+
"supportsMultipleUserCodeReport",
|
|
707
|
+
"supportsMultipleUserCodeSet",
|
|
708
|
+
"supportedUserIDStatuses",
|
|
709
|
+
"supportedKeypadModes",
|
|
710
|
+
"supportedASCIIChars",
|
|
711
|
+
]);
|
|
712
|
+
}
|
|
713
|
+
}
|
|
714
|
+
async getKeypadMode() {
|
|
715
|
+
this.assertSupportsCommand(_Types_1.UserCodeCommand, _Types_1.UserCodeCommand.KeypadModeGet);
|
|
716
|
+
const cc = new UserCodeCCKeypadModeGet(this.applHost, {
|
|
717
|
+
nodeId: this.endpoint.nodeId,
|
|
718
|
+
endpoint: this.endpoint.index,
|
|
719
|
+
});
|
|
720
|
+
const response = await this.applHost.sendCommand(cc, this.commandOptions);
|
|
721
|
+
return response === null || response === void 0 ? void 0 : response.keypadMode;
|
|
722
|
+
}
|
|
723
|
+
async setKeypadMode(keypadMode) {
|
|
724
|
+
__assertType("keypadMode", "KeypadMode", __assertType__KeypadMode.bind(void 0, keypadMode));
|
|
725
|
+
this.assertSupportsCommand(_Types_1.UserCodeCommand, _Types_1.UserCodeCommand.KeypadModeSet);
|
|
726
|
+
const supportedModes = UserCodeCC.getSupportedKeypadModesCached(this.applHost, this.endpoint);
|
|
727
|
+
if (!supportedModes) {
|
|
728
|
+
throw new safe_1.ZWaveError(`The keypad mode can only be set after the interview is complete!`, safe_1.ZWaveErrorCodes.Argument_Invalid);
|
|
729
|
+
}
|
|
730
|
+
else if (!supportedModes.includes(keypadMode)) {
|
|
731
|
+
throw new safe_1.ZWaveError(`The keypad mode ${(0, safe_2.getEnumMemberName)(_Types_1.KeypadMode, keypadMode)} is not supported by the node!`, safe_1.ZWaveErrorCodes.Argument_Invalid);
|
|
732
|
+
}
|
|
733
|
+
const cc = new UserCodeCCKeypadModeSet(this.applHost, {
|
|
734
|
+
nodeId: this.endpoint.nodeId,
|
|
735
|
+
endpoint: this.endpoint.index,
|
|
736
|
+
keypadMode,
|
|
737
|
+
});
|
|
738
|
+
await this.applHost.sendCommand(cc, this.commandOptions);
|
|
739
|
+
}
|
|
740
|
+
async getMasterCode() {
|
|
741
|
+
this.assertSupportsCommand(_Types_1.UserCodeCommand, _Types_1.UserCodeCommand.MasterCodeGet);
|
|
742
|
+
const cc = new UserCodeCCMasterCodeGet(this.applHost, {
|
|
743
|
+
nodeId: this.endpoint.nodeId,
|
|
744
|
+
endpoint: this.endpoint.index,
|
|
745
|
+
});
|
|
746
|
+
const response = await this.applHost.sendCommand(cc, this.commandOptions);
|
|
747
|
+
return response === null || response === void 0 ? void 0 : response.masterCode;
|
|
748
|
+
}
|
|
749
|
+
async setMasterCode(masterCode) {
|
|
750
|
+
__assertType("masterCode", "string", __assertType__string.bind(void 0, masterCode));
|
|
751
|
+
this.assertSupportsCommand(_Types_1.UserCodeCommand, _Types_1.UserCodeCommand.MasterCodeSet);
|
|
752
|
+
const supportedASCIIChars = UserCodeCC.getSupportedASCIICharsCached(this.applHost, this.endpoint);
|
|
753
|
+
if (!supportedASCIIChars) {
|
|
754
|
+
throw new safe_1.ZWaveError(`The master code can only be set after the interview is complete!`, safe_1.ZWaveErrorCodes.Argument_Invalid);
|
|
755
|
+
}
|
|
756
|
+
// Validate the code
|
|
757
|
+
if (!masterCode) {
|
|
758
|
+
const supportsDeactivation = UserCodeCC.supportsMasterCodeDeactivationCached(this.applHost, this.endpoint);
|
|
759
|
+
if (!supportsDeactivation) {
|
|
760
|
+
throw new safe_1.ZWaveError(`The node does not support deactivating the master code!`, safe_1.ZWaveErrorCodes.Argument_Invalid);
|
|
761
|
+
}
|
|
762
|
+
}
|
|
763
|
+
else if (!validateCode(masterCode, supportedASCIIChars)) {
|
|
764
|
+
throw new safe_1.ZWaveError(`The master code must consist of 4 to 10 of the following characters: ${supportedASCIIChars}`, safe_1.ZWaveErrorCodes.Argument_Invalid);
|
|
765
|
+
}
|
|
766
|
+
const cc = new UserCodeCCMasterCodeSet(this.applHost, {
|
|
767
|
+
nodeId: this.endpoint.nodeId,
|
|
768
|
+
endpoint: this.endpoint.index,
|
|
769
|
+
masterCode,
|
|
770
|
+
});
|
|
771
|
+
await this.applHost.sendCommand(cc, this.commandOptions);
|
|
772
|
+
}
|
|
773
|
+
async getUserCodeChecksum() {
|
|
774
|
+
this.assertSupportsCommand(_Types_1.UserCodeCommand, _Types_1.UserCodeCommand.UserCodeChecksumGet);
|
|
775
|
+
const cc = new UserCodeCCUserCodeChecksumGet(this.applHost, {
|
|
776
|
+
nodeId: this.endpoint.nodeId,
|
|
777
|
+
endpoint: this.endpoint.index,
|
|
778
|
+
});
|
|
779
|
+
const response = await this.applHost.sendCommand(cc, this.commandOptions);
|
|
780
|
+
return response === null || response === void 0 ? void 0 : response.userCodeChecksum;
|
|
781
|
+
}
|
|
782
|
+
};
|
|
783
|
+
_a = API_1.SET_VALUE, _b = API_1.POLL_VALUE;
|
|
784
|
+
UserCodeCCAPI = __decorate([
|
|
785
|
+
(0, CommandClass_1.API)(safe_1.CommandClasses["User Code"])
|
|
786
|
+
], UserCodeCCAPI);
|
|
787
|
+
exports.UserCodeCCAPI = UserCodeCCAPI;
|
|
788
|
+
let UserCodeCC = class UserCodeCC extends CommandClass_1.CommandClass {
|
|
789
|
+
constructor(host, options) {
|
|
790
|
+
super(host, options);
|
|
791
|
+
// Hide user codes from value logs
|
|
792
|
+
this.registerValue(getUserCodeValueID(undefined, 0).property, {
|
|
793
|
+
secret: true,
|
|
794
|
+
});
|
|
795
|
+
}
|
|
796
|
+
async interview(applHost) {
|
|
797
|
+
var _c;
|
|
798
|
+
const node = this.getNode(applHost);
|
|
799
|
+
const endpoint = this.getEndpoint(applHost);
|
|
800
|
+
const api = API_1.CCAPI.create(safe_1.CommandClasses["User Code"], applHost, endpoint).withOptions({
|
|
801
|
+
priority: safe_1.MessagePriority.NodeQuery,
|
|
802
|
+
});
|
|
803
|
+
applHost.controllerLog.logNode(node.id, {
|
|
804
|
+
endpoint: this.endpointIndex,
|
|
805
|
+
message: `Interviewing ${this.ccName}...`,
|
|
806
|
+
direction: "none",
|
|
807
|
+
});
|
|
808
|
+
// Query capabilities first to determine what needs to be done when refreshing
|
|
809
|
+
if (this.version >= 2) {
|
|
810
|
+
applHost.controllerLog.logNode(node.id, {
|
|
811
|
+
message: "querying capabilities...",
|
|
812
|
+
direction: "outbound",
|
|
813
|
+
});
|
|
814
|
+
const caps = await api.getCapabilities();
|
|
815
|
+
if (!caps) {
|
|
816
|
+
applHost.controllerLog.logNode(node.id, {
|
|
817
|
+
endpoint: this.endpointIndex,
|
|
818
|
+
message: "User Code capabilities query timed out, skipping interview...",
|
|
819
|
+
level: "warn",
|
|
820
|
+
});
|
|
821
|
+
return;
|
|
822
|
+
}
|
|
823
|
+
}
|
|
824
|
+
applHost.controllerLog.logNode(node.id, {
|
|
825
|
+
message: "querying number of user codes...",
|
|
826
|
+
direction: "outbound",
|
|
827
|
+
});
|
|
828
|
+
const supportedUsers = await api.getUsersCount();
|
|
829
|
+
if (supportedUsers == undefined) {
|
|
830
|
+
applHost.controllerLog.logNode(node.id, {
|
|
831
|
+
endpoint: this.endpointIndex,
|
|
832
|
+
message: "Querying number of user codes timed out, skipping interview...",
|
|
833
|
+
level: "warn",
|
|
834
|
+
});
|
|
835
|
+
return;
|
|
836
|
+
}
|
|
837
|
+
for (let userId = 1; userId <= supportedUsers; userId++) {
|
|
838
|
+
setUserCodeMetadata.call(this, applHost, userId);
|
|
839
|
+
}
|
|
840
|
+
// Synchronize user codes and settings
|
|
841
|
+
if ((_c = applHost.options.interview) === null || _c === void 0 ? void 0 : _c.queryAllUserCodes) {
|
|
842
|
+
await this.refreshValues(applHost);
|
|
843
|
+
}
|
|
844
|
+
// Remember that the interview is complete
|
|
845
|
+
this.setInterviewComplete(applHost, true);
|
|
846
|
+
}
|
|
847
|
+
async refreshValues(applHost) {
|
|
848
|
+
var _c, _d, _e, _f, _g;
|
|
849
|
+
const node = this.getNode(applHost);
|
|
850
|
+
const endpoint = this.getEndpoint(applHost);
|
|
851
|
+
const api = API_1.CCAPI.create(safe_1.CommandClasses["User Code"], applHost, endpoint).withOptions({
|
|
852
|
+
priority: safe_1.MessagePriority.NodeQuery,
|
|
853
|
+
});
|
|
854
|
+
const valueDB = this.getValueDB(applHost);
|
|
855
|
+
const supportsMasterCode = (_c = valueDB.getValue(getSupportsMasterCodeValueID(this.endpointIndex))) !== null && _c !== void 0 ? _c : false;
|
|
856
|
+
const supportsUserCodeChecksum = (_d = valueDB.getValue(getSupportsUserCodeChecksumValueID(this.endpointIndex))) !== null && _d !== void 0 ? _d : false;
|
|
857
|
+
const supportedKeypadModes = (_e = valueDB.getValue(getSupportedKeypadModesValueID(this.endpointIndex))) !== null && _e !== void 0 ? _e : [];
|
|
858
|
+
const supportedUsers = (_f = valueDB.getValue(getSupportedUsersValueID(this.endpointIndex))) !== null && _f !== void 0 ? _f : 0;
|
|
859
|
+
// Check for changed values and codes
|
|
860
|
+
if (this.version >= 2) {
|
|
861
|
+
if (supportsMasterCode) {
|
|
862
|
+
applHost.controllerLog.logNode(node.id, {
|
|
863
|
+
message: "querying master code...",
|
|
864
|
+
direction: "outbound",
|
|
865
|
+
});
|
|
866
|
+
await api.getMasterCode();
|
|
867
|
+
}
|
|
868
|
+
if (supportedKeypadModes.length > 1) {
|
|
869
|
+
applHost.controllerLog.logNode(node.id, {
|
|
870
|
+
message: "querying active keypad mode...",
|
|
871
|
+
direction: "outbound",
|
|
872
|
+
});
|
|
873
|
+
await api.getKeypadMode();
|
|
874
|
+
}
|
|
875
|
+
const storedUserCodeChecksum = (_g = valueDB.getValue(getUserCodeChecksumValueID(this.endpointIndex))) !== null && _g !== void 0 ? _g : 0;
|
|
876
|
+
let currentUserCodeChecksum = 0;
|
|
877
|
+
if (supportsUserCodeChecksum) {
|
|
878
|
+
applHost.controllerLog.logNode(node.id, {
|
|
879
|
+
message: "retrieving current user code checksum...",
|
|
880
|
+
direction: "outbound",
|
|
881
|
+
});
|
|
882
|
+
currentUserCodeChecksum = await api.getUserCodeChecksum();
|
|
883
|
+
}
|
|
884
|
+
if (!supportsUserCodeChecksum ||
|
|
885
|
+
currentUserCodeChecksum !== storedUserCodeChecksum) {
|
|
886
|
+
applHost.controllerLog.logNode(node.id, {
|
|
887
|
+
message: "checksum changed or is not supported, querying all user codes...",
|
|
888
|
+
direction: "outbound",
|
|
889
|
+
});
|
|
890
|
+
let nextUserId = 1;
|
|
891
|
+
while (nextUserId > 0 && nextUserId <= supportedUsers) {
|
|
892
|
+
const response = await api.get(nextUserId, true);
|
|
893
|
+
if (response) {
|
|
894
|
+
nextUserId = response.nextUserId;
|
|
895
|
+
}
|
|
896
|
+
else {
|
|
897
|
+
applHost.controllerLog.logNode(node.id, {
|
|
898
|
+
endpoint: this.endpointIndex,
|
|
899
|
+
message: `Querying user code #${nextUserId} timed out, skipping the remaining interview...`,
|
|
900
|
+
level: "warn",
|
|
901
|
+
});
|
|
902
|
+
break;
|
|
903
|
+
}
|
|
904
|
+
}
|
|
905
|
+
}
|
|
906
|
+
}
|
|
907
|
+
else {
|
|
908
|
+
// V1
|
|
909
|
+
applHost.controllerLog.logNode(node.id, {
|
|
910
|
+
message: "querying all user codes...",
|
|
911
|
+
direction: "outbound",
|
|
912
|
+
});
|
|
913
|
+
for (let userId = 1; userId <= supportedUsers; userId++) {
|
|
914
|
+
await api.get(userId);
|
|
915
|
+
}
|
|
916
|
+
}
|
|
917
|
+
}
|
|
918
|
+
/**
|
|
919
|
+
* Returns the number of supported users.
|
|
920
|
+
* This only works AFTER the interview process
|
|
921
|
+
*/
|
|
922
|
+
static getSupportedUsersCached(applHost, endpoint) {
|
|
923
|
+
return applHost
|
|
924
|
+
.getValueDB(endpoint.nodeId)
|
|
925
|
+
.getValue(getSupportedUsersValueID(endpoint.index));
|
|
926
|
+
}
|
|
927
|
+
/**
|
|
928
|
+
* Returns the supported keypad modes.
|
|
929
|
+
* This only works AFTER the interview process
|
|
930
|
+
*/
|
|
931
|
+
static getSupportedKeypadModesCached(applHost, endpoint) {
|
|
932
|
+
return applHost
|
|
933
|
+
.getValueDB(endpoint.nodeId)
|
|
934
|
+
.getValue(getSupportedKeypadModesValueID(endpoint.index));
|
|
935
|
+
}
|
|
936
|
+
/**
|
|
937
|
+
* Returns the supported user ID statuses.
|
|
938
|
+
* This only works AFTER the interview process
|
|
939
|
+
*/
|
|
940
|
+
static getSupportedUserIDStatusesCached(applHost, endpoint) {
|
|
941
|
+
return applHost
|
|
942
|
+
.getValueDB(endpoint.nodeId)
|
|
943
|
+
.getValue(getSupportedUserIDStatusesValueID(endpoint.index));
|
|
944
|
+
}
|
|
945
|
+
/**
|
|
946
|
+
* Returns the supported ASCII characters.
|
|
947
|
+
* This only works AFTER the interview process
|
|
948
|
+
*/
|
|
949
|
+
static getSupportedASCIICharsCached(applHost, endpoint) {
|
|
950
|
+
return applHost
|
|
951
|
+
.getValueDB(endpoint.nodeId)
|
|
952
|
+
.getValue(getSupportedASCIICharsValueID(endpoint.index));
|
|
953
|
+
}
|
|
954
|
+
/**
|
|
955
|
+
* Returns whether deactivating the master code is supported.
|
|
956
|
+
* This only works AFTER the interview process
|
|
957
|
+
*/
|
|
958
|
+
static supportsMasterCodeDeactivationCached(applHost, endpoint) {
|
|
959
|
+
return !!applHost
|
|
960
|
+
.getValueDB(endpoint.nodeId)
|
|
961
|
+
.getValue(getSupportsMasterCodeDeactivationValueID(endpoint.index));
|
|
962
|
+
}
|
|
963
|
+
/**
|
|
964
|
+
* Returns whether setting multiple user codes at once is supported.
|
|
965
|
+
* This only works AFTER the interview process
|
|
966
|
+
*/
|
|
967
|
+
static supportsMultipleUserCodeSetCached(applHost, endpoint) {
|
|
968
|
+
return !!applHost
|
|
969
|
+
.getValueDB(endpoint.nodeId)
|
|
970
|
+
.getValue(getSupportsMultipleUserCodeSetValueID(endpoint.index));
|
|
971
|
+
}
|
|
972
|
+
};
|
|
973
|
+
UserCodeCC = __decorate([
|
|
974
|
+
(0, CommandClass_1.commandClass)(safe_1.CommandClasses["User Code"]),
|
|
975
|
+
(0, CommandClass_1.implementedVersion)(2)
|
|
976
|
+
], UserCodeCC);
|
|
977
|
+
exports.UserCodeCC = UserCodeCC;
|
|
978
|
+
let UserCodeCCSet = class UserCodeCCSet extends UserCodeCC {
|
|
979
|
+
constructor(host, options) {
|
|
980
|
+
super(host, options);
|
|
981
|
+
if ((0, CommandClass_1.gotDeserializationOptions)(options)) {
|
|
982
|
+
// TODO: Deserialize payload
|
|
983
|
+
throw new safe_1.ZWaveError(`${this.constructor.name}: deserialization not implemented`, safe_1.ZWaveErrorCodes.Deserialization_NotImplemented);
|
|
984
|
+
}
|
|
985
|
+
else {
|
|
986
|
+
this.userId = options.userId;
|
|
987
|
+
this.userIdStatus = options.userIdStatus;
|
|
988
|
+
// Validate options
|
|
989
|
+
if (this.userId < 0) {
|
|
990
|
+
throw new safe_1.ZWaveError(`${this.constructor.name}: The user ID must be between greater than 0.`, safe_1.ZWaveErrorCodes.Argument_Invalid);
|
|
991
|
+
}
|
|
992
|
+
else if (this.userId === 0 &&
|
|
993
|
+
this.userIdStatus !== _Types_1.UserIDStatus.Available) {
|
|
994
|
+
throw new safe_1.ZWaveError(`${this.constructor.name}: User ID 0 may only be used to clear all user codes`, safe_1.ZWaveErrorCodes.Argument_Invalid);
|
|
995
|
+
}
|
|
996
|
+
else if (this.userIdStatus === _Types_1.UserIDStatus.Available) {
|
|
997
|
+
this.userCode = "\0".repeat(4);
|
|
998
|
+
}
|
|
999
|
+
else {
|
|
1000
|
+
this.userCode = options.userCode;
|
|
1001
|
+
// Specs say ASCII 0-9, manufacturers don't care :)
|
|
1002
|
+
if (this.userCode.length < 4 || this.userCode.length > 10) {
|
|
1003
|
+
throw new safe_1.ZWaveError(`${this.constructor.name}: The user code must have a length of 4 to 10 ${typeof this.userCode === "string"
|
|
1004
|
+
? "characters"
|
|
1005
|
+
: "bytes"}`, safe_1.ZWaveErrorCodes.Argument_Invalid);
|
|
1006
|
+
}
|
|
1007
|
+
}
|
|
1008
|
+
}
|
|
1009
|
+
}
|
|
1010
|
+
serialize() {
|
|
1011
|
+
this.payload = Buffer.concat([
|
|
1012
|
+
Buffer.from([this.userId, this.userIdStatus]),
|
|
1013
|
+
typeof this.userCode === "string"
|
|
1014
|
+
? Buffer.from(this.userCode, "ascii")
|
|
1015
|
+
: this.userCode,
|
|
1016
|
+
]);
|
|
1017
|
+
return super.serialize();
|
|
1018
|
+
}
|
|
1019
|
+
toLogEntry(applHost) {
|
|
1020
|
+
return {
|
|
1021
|
+
...super.toLogEntry(applHost),
|
|
1022
|
+
message: {
|
|
1023
|
+
"user id": this.userId,
|
|
1024
|
+
"id status": (0, safe_2.getEnumMemberName)(_Types_1.UserIDStatus, this.userIdStatus),
|
|
1025
|
+
"user code": userCodeToLogString(this.userCode),
|
|
1026
|
+
},
|
|
1027
|
+
};
|
|
1028
|
+
}
|
|
1029
|
+
};
|
|
1030
|
+
UserCodeCCSet = __decorate([
|
|
1031
|
+
(0, CommandClass_1.CCCommand)(_Types_1.UserCodeCommand.Set)
|
|
1032
|
+
], UserCodeCCSet);
|
|
1033
|
+
exports.UserCodeCCSet = UserCodeCCSet;
|
|
1034
|
+
let UserCodeCCReport = class UserCodeCCReport extends UserCodeCC {
|
|
1035
|
+
constructor(host, options) {
|
|
1036
|
+
super(host, options);
|
|
1037
|
+
(0, safe_1.validatePayload)(this.payload.length >= 2);
|
|
1038
|
+
this.userId = this.payload[0];
|
|
1039
|
+
this.userIdStatus = this.payload[1];
|
|
1040
|
+
if (this.payload.length === 2 &&
|
|
1041
|
+
(this.userIdStatus === _Types_1.UserIDStatus.Available ||
|
|
1042
|
+
this.userIdStatus === _Types_1.UserIDStatus.StatusNotAvailable)) {
|
|
1043
|
+
// The user code is not set or not available and this report contains no user code
|
|
1044
|
+
this.userCode = "";
|
|
1045
|
+
}
|
|
1046
|
+
else {
|
|
1047
|
+
// The specs require the user code to be at least 4 digits
|
|
1048
|
+
(0, safe_1.validatePayload)(this.payload.length >= 6);
|
|
1049
|
+
let userCodeBuffer = this.payload.slice(2);
|
|
1050
|
+
// Specs say infer user code from payload length, manufacturers send zero-padded strings
|
|
1051
|
+
while (userCodeBuffer[userCodeBuffer.length - 1] === 0) {
|
|
1052
|
+
userCodeBuffer = userCodeBuffer.slice(0, -1);
|
|
1053
|
+
}
|
|
1054
|
+
// Specs say ASCII 0-9, manufacturers don't care :)
|
|
1055
|
+
// Thus we check if the code is printable using ASCII, if not keep it as a Buffer
|
|
1056
|
+
const userCodeString = userCodeBuffer.toString("utf8");
|
|
1057
|
+
if ((0, safe_2.isPrintableASCII)(userCodeString)) {
|
|
1058
|
+
this.userCode = userCodeString;
|
|
1059
|
+
}
|
|
1060
|
+
else if (this.version === 1 &&
|
|
1061
|
+
(0, safe_2.isPrintableASCIIWithNewlines)(userCodeString)) {
|
|
1062
|
+
// Ignore leading and trailing newlines in V1 reports if the rest is ASCII
|
|
1063
|
+
this.userCode = userCodeString
|
|
1064
|
+
.replace(/^[\r\n]*/, "")
|
|
1065
|
+
.replace(/[\r\n]*$/, "");
|
|
1066
|
+
}
|
|
1067
|
+
else {
|
|
1068
|
+
this.userCode = userCodeBuffer;
|
|
1069
|
+
}
|
|
1070
|
+
}
|
|
1071
|
+
}
|
|
1072
|
+
persistValues(applHost) {
|
|
1073
|
+
if (!super.persistValues(applHost))
|
|
1074
|
+
return false;
|
|
1075
|
+
persistUserCode.call(this, applHost, this.userId, this.userIdStatus, this.userCode);
|
|
1076
|
+
return true;
|
|
1077
|
+
}
|
|
1078
|
+
toLogEntry(applHost) {
|
|
1079
|
+
return {
|
|
1080
|
+
...super.toLogEntry(applHost),
|
|
1081
|
+
message: {
|
|
1082
|
+
"user id": this.userId,
|
|
1083
|
+
"id status": (0, safe_2.getEnumMemberName)(_Types_1.UserIDStatus, this.userIdStatus),
|
|
1084
|
+
"user code": userCodeToLogString(this.userCode),
|
|
1085
|
+
},
|
|
1086
|
+
};
|
|
1087
|
+
}
|
|
1088
|
+
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
|
|
1089
|
+
toNotificationEventParameters() {
|
|
1090
|
+
return { userId: this.userId };
|
|
1091
|
+
}
|
|
1092
|
+
};
|
|
1093
|
+
UserCodeCCReport = __decorate([
|
|
1094
|
+
(0, CommandClass_1.CCCommand)(_Types_1.UserCodeCommand.Report)
|
|
1095
|
+
], UserCodeCCReport);
|
|
1096
|
+
exports.UserCodeCCReport = UserCodeCCReport;
|
|
1097
|
+
let UserCodeCCGet = class UserCodeCCGet extends UserCodeCC {
|
|
1098
|
+
constructor(host, options) {
|
|
1099
|
+
super(host, options);
|
|
1100
|
+
if ((0, CommandClass_1.gotDeserializationOptions)(options)) {
|
|
1101
|
+
// TODO: Deserialize payload
|
|
1102
|
+
throw new safe_1.ZWaveError(`${this.constructor.name}: deserialization not implemented`, safe_1.ZWaveErrorCodes.Deserialization_NotImplemented);
|
|
1103
|
+
}
|
|
1104
|
+
else {
|
|
1105
|
+
this.userId = options.userId;
|
|
1106
|
+
}
|
|
1107
|
+
}
|
|
1108
|
+
serialize() {
|
|
1109
|
+
this.payload = Buffer.from([this.userId]);
|
|
1110
|
+
return super.serialize();
|
|
1111
|
+
}
|
|
1112
|
+
toLogEntry(applHost) {
|
|
1113
|
+
return {
|
|
1114
|
+
...super.toLogEntry(applHost),
|
|
1115
|
+
message: { "user id": this.userId },
|
|
1116
|
+
};
|
|
1117
|
+
}
|
|
1118
|
+
};
|
|
1119
|
+
UserCodeCCGet = __decorate([
|
|
1120
|
+
(0, CommandClass_1.CCCommand)(_Types_1.UserCodeCommand.Get),
|
|
1121
|
+
(0, CommandClass_1.expectedCCResponse)(UserCodeCCReport)
|
|
1122
|
+
], UserCodeCCGet);
|
|
1123
|
+
exports.UserCodeCCGet = UserCodeCCGet;
|
|
1124
|
+
let UserCodeCCUsersNumberReport = class UserCodeCCUsersNumberReport extends UserCodeCC {
|
|
1125
|
+
constructor(host, options) {
|
|
1126
|
+
super(host, options);
|
|
1127
|
+
(0, safe_1.validatePayload)(this.payload.length >= 1);
|
|
1128
|
+
if (this.payload.length >= 3) {
|
|
1129
|
+
// V2+
|
|
1130
|
+
this.supportedUsers = this.payload.readUInt16BE(1);
|
|
1131
|
+
}
|
|
1132
|
+
else {
|
|
1133
|
+
// V1
|
|
1134
|
+
this.supportedUsers = this.payload[0];
|
|
1135
|
+
}
|
|
1136
|
+
}
|
|
1137
|
+
toLogEntry(applHost) {
|
|
1138
|
+
return {
|
|
1139
|
+
...super.toLogEntry(applHost),
|
|
1140
|
+
message: { "supported users": this.supportedUsers },
|
|
1141
|
+
};
|
|
1142
|
+
}
|
|
1143
|
+
};
|
|
1144
|
+
__decorate([
|
|
1145
|
+
(0, CommandClass_1.ccValue)({ internal: true })
|
|
1146
|
+
], UserCodeCCUsersNumberReport.prototype, "supportedUsers", void 0);
|
|
1147
|
+
UserCodeCCUsersNumberReport = __decorate([
|
|
1148
|
+
(0, CommandClass_1.CCCommand)(_Types_1.UserCodeCommand.UsersNumberReport)
|
|
1149
|
+
], UserCodeCCUsersNumberReport);
|
|
1150
|
+
exports.UserCodeCCUsersNumberReport = UserCodeCCUsersNumberReport;
|
|
1151
|
+
let UserCodeCCUsersNumberGet = class UserCodeCCUsersNumberGet extends UserCodeCC {
|
|
1152
|
+
};
|
|
1153
|
+
UserCodeCCUsersNumberGet = __decorate([
|
|
1154
|
+
(0, CommandClass_1.CCCommand)(_Types_1.UserCodeCommand.UsersNumberGet),
|
|
1155
|
+
(0, CommandClass_1.expectedCCResponse)(UserCodeCCUsersNumberReport)
|
|
1156
|
+
], UserCodeCCUsersNumberGet);
|
|
1157
|
+
exports.UserCodeCCUsersNumberGet = UserCodeCCUsersNumberGet;
|
|
1158
|
+
let UserCodeCCCapabilitiesReport = class UserCodeCCCapabilitiesReport extends UserCodeCC {
|
|
1159
|
+
constructor(host, options) {
|
|
1160
|
+
super(host, options);
|
|
1161
|
+
let offset = 0;
|
|
1162
|
+
(0, safe_1.validatePayload)(this.payload.length >= offset + 1);
|
|
1163
|
+
this.supportsMasterCode = !!(this.payload[offset] & 128);
|
|
1164
|
+
this.supportsMasterCodeDeactivation = !!(this.payload[offset] & 64);
|
|
1165
|
+
const statusBitMaskLength = this.payload[offset] & 31;
|
|
1166
|
+
offset += 1;
|
|
1167
|
+
(0, safe_1.validatePayload)(this.payload.length >= offset + statusBitMaskLength + 1);
|
|
1168
|
+
this.supportedUserIDStatuses = (0, safe_1.parseBitMask)(this.payload.slice(offset, offset + statusBitMaskLength), _Types_1.UserIDStatus.Available);
|
|
1169
|
+
offset += statusBitMaskLength;
|
|
1170
|
+
this.supportsUserCodeChecksum = !!(this.payload[offset] & 128);
|
|
1171
|
+
this.supportsMultipleUserCodeReport = !!(this.payload[offset] & 64);
|
|
1172
|
+
this.supportsMultipleUserCodeSet = !!(this.payload[offset] & 32);
|
|
1173
|
+
const keypadModesBitMaskLength = this.payload[offset] & 31;
|
|
1174
|
+
offset += 1;
|
|
1175
|
+
(0, safe_1.validatePayload)(this.payload.length >= offset + keypadModesBitMaskLength + 1);
|
|
1176
|
+
this.supportedKeypadModes = (0, safe_1.parseBitMask)(this.payload.slice(offset, offset + keypadModesBitMaskLength), _Types_1.KeypadMode.Normal);
|
|
1177
|
+
offset += keypadModesBitMaskLength;
|
|
1178
|
+
const keysBitMaskLength = this.payload[offset] & 31;
|
|
1179
|
+
offset += 1;
|
|
1180
|
+
(0, safe_1.validatePayload)(this.payload.length >= offset + keysBitMaskLength);
|
|
1181
|
+
this.supportedASCIIChars = Buffer.from((0, safe_1.parseBitMask)(this.payload.slice(offset, offset + keysBitMaskLength), 0)).toString("ascii");
|
|
1182
|
+
}
|
|
1183
|
+
toLogEntry(applHost) {
|
|
1184
|
+
return {
|
|
1185
|
+
...super.toLogEntry(applHost),
|
|
1186
|
+
message: {
|
|
1187
|
+
"supports master code": this.supportsMasterCode,
|
|
1188
|
+
"supports master code deactivation": this.supportsMasterCodeDeactivation,
|
|
1189
|
+
"supports user code checksum": this.supportsUserCodeChecksum,
|
|
1190
|
+
"supports multiple codes in report": this.supportsMultipleUserCodeReport,
|
|
1191
|
+
"supports multiple codes in set": this.supportsMultipleUserCodeSet,
|
|
1192
|
+
"supported user id statuses": this.supportedUserIDStatuses
|
|
1193
|
+
.map((status) => `\n· ${(0, safe_2.getEnumMemberName)(_Types_1.UserIDStatus, status)}`)
|
|
1194
|
+
.join(""),
|
|
1195
|
+
"supported keypad modes": this.supportedKeypadModes
|
|
1196
|
+
.map((mode) => `\n· ${(0, safe_2.getEnumMemberName)(_Types_1.KeypadMode, mode)}`)
|
|
1197
|
+
.join(""),
|
|
1198
|
+
"supported ASCII chars": this.supportedASCIIChars,
|
|
1199
|
+
},
|
|
1200
|
+
};
|
|
1201
|
+
}
|
|
1202
|
+
};
|
|
1203
|
+
__decorate([
|
|
1204
|
+
(0, CommandClass_1.ccValue)({ internal: true })
|
|
1205
|
+
], UserCodeCCCapabilitiesReport.prototype, "supportsMasterCode", void 0);
|
|
1206
|
+
__decorate([
|
|
1207
|
+
(0, CommandClass_1.ccValue)({ internal: true })
|
|
1208
|
+
], UserCodeCCCapabilitiesReport.prototype, "supportsMasterCodeDeactivation", void 0);
|
|
1209
|
+
__decorate([
|
|
1210
|
+
(0, CommandClass_1.ccValue)({ internal: true })
|
|
1211
|
+
], UserCodeCCCapabilitiesReport.prototype, "supportsUserCodeChecksum", void 0);
|
|
1212
|
+
__decorate([
|
|
1213
|
+
(0, CommandClass_1.ccValue)({ internal: true })
|
|
1214
|
+
], UserCodeCCCapabilitiesReport.prototype, "supportsMultipleUserCodeReport", void 0);
|
|
1215
|
+
__decorate([
|
|
1216
|
+
(0, CommandClass_1.ccValue)({ internal: true })
|
|
1217
|
+
], UserCodeCCCapabilitiesReport.prototype, "supportsMultipleUserCodeSet", void 0);
|
|
1218
|
+
__decorate([
|
|
1219
|
+
(0, CommandClass_1.ccValue)({ internal: true })
|
|
1220
|
+
], UserCodeCCCapabilitiesReport.prototype, "supportedUserIDStatuses", void 0);
|
|
1221
|
+
__decorate([
|
|
1222
|
+
(0, CommandClass_1.ccValue)({ internal: true })
|
|
1223
|
+
], UserCodeCCCapabilitiesReport.prototype, "supportedKeypadModes", void 0);
|
|
1224
|
+
__decorate([
|
|
1225
|
+
(0, CommandClass_1.ccValue)({ internal: true })
|
|
1226
|
+
], UserCodeCCCapabilitiesReport.prototype, "supportedASCIIChars", void 0);
|
|
1227
|
+
UserCodeCCCapabilitiesReport = __decorate([
|
|
1228
|
+
(0, CommandClass_1.CCCommand)(_Types_1.UserCodeCommand.CapabilitiesReport)
|
|
1229
|
+
], UserCodeCCCapabilitiesReport);
|
|
1230
|
+
exports.UserCodeCCCapabilitiesReport = UserCodeCCCapabilitiesReport;
|
|
1231
|
+
let UserCodeCCCapabilitiesGet = class UserCodeCCCapabilitiesGet extends UserCodeCC {
|
|
1232
|
+
};
|
|
1233
|
+
UserCodeCCCapabilitiesGet = __decorate([
|
|
1234
|
+
(0, CommandClass_1.CCCommand)(_Types_1.UserCodeCommand.CapabilitiesGet),
|
|
1235
|
+
(0, CommandClass_1.expectedCCResponse)(UserCodeCCCapabilitiesReport)
|
|
1236
|
+
], UserCodeCCCapabilitiesGet);
|
|
1237
|
+
exports.UserCodeCCCapabilitiesGet = UserCodeCCCapabilitiesGet;
|
|
1238
|
+
let UserCodeCCKeypadModeSet = class UserCodeCCKeypadModeSet extends UserCodeCC {
|
|
1239
|
+
constructor(host, options) {
|
|
1240
|
+
super(host, options);
|
|
1241
|
+
if ((0, CommandClass_1.gotDeserializationOptions)(options)) {
|
|
1242
|
+
// TODO: Deserialize payload
|
|
1243
|
+
throw new safe_1.ZWaveError(`${this.constructor.name}: deserialization not implemented`, safe_1.ZWaveErrorCodes.Deserialization_NotImplemented);
|
|
1244
|
+
}
|
|
1245
|
+
else {
|
|
1246
|
+
this.keypadMode = options.keypadMode;
|
|
1247
|
+
}
|
|
1248
|
+
}
|
|
1249
|
+
serialize() {
|
|
1250
|
+
this.payload = Buffer.from([this.keypadMode]);
|
|
1251
|
+
return super.serialize();
|
|
1252
|
+
}
|
|
1253
|
+
toLogEntry(applHost) {
|
|
1254
|
+
return {
|
|
1255
|
+
...super.toLogEntry(applHost),
|
|
1256
|
+
message: { mode: (0, safe_2.getEnumMemberName)(_Types_1.KeypadMode, this.keypadMode) },
|
|
1257
|
+
};
|
|
1258
|
+
}
|
|
1259
|
+
};
|
|
1260
|
+
UserCodeCCKeypadModeSet = __decorate([
|
|
1261
|
+
(0, CommandClass_1.CCCommand)(_Types_1.UserCodeCommand.KeypadModeSet)
|
|
1262
|
+
], UserCodeCCKeypadModeSet);
|
|
1263
|
+
exports.UserCodeCCKeypadModeSet = UserCodeCCKeypadModeSet;
|
|
1264
|
+
let UserCodeCCKeypadModeReport = class UserCodeCCKeypadModeReport extends UserCodeCC {
|
|
1265
|
+
constructor(host, options) {
|
|
1266
|
+
super(host, options);
|
|
1267
|
+
(0, safe_1.validatePayload)(this.payload.length >= 1);
|
|
1268
|
+
this.keypadMode = this.payload[0];
|
|
1269
|
+
}
|
|
1270
|
+
persistValues(applHost) {
|
|
1271
|
+
var _c;
|
|
1272
|
+
if (!super.persistValues(applHost))
|
|
1273
|
+
return false;
|
|
1274
|
+
const valueDB = this.getValueDB(applHost);
|
|
1275
|
+
// Update the keypad modes metadata
|
|
1276
|
+
const supportedKeypadModes = (_c = valueDB.getValue(getSupportedKeypadModesValueID(this.endpointIndex))) !== null && _c !== void 0 ? _c : [this.keypadMode];
|
|
1277
|
+
const valueId = getKeypadModeValueID(this.endpointIndex);
|
|
1278
|
+
valueDB.setMetadata(valueId, {
|
|
1279
|
+
...safe_1.ValueMetadata.ReadOnlyNumber,
|
|
1280
|
+
label: "Keypad Mode",
|
|
1281
|
+
states: (0, safe_1.enumValuesToMetadataStates)(_Types_1.KeypadMode, supportedKeypadModes),
|
|
1282
|
+
});
|
|
1283
|
+
return true;
|
|
1284
|
+
}
|
|
1285
|
+
toLogEntry(applHost) {
|
|
1286
|
+
return {
|
|
1287
|
+
...super.toLogEntry(applHost),
|
|
1288
|
+
message: {
|
|
1289
|
+
keypadMode: (0, safe_2.getEnumMemberName)(_Types_1.KeypadMode, this.keypadMode),
|
|
1290
|
+
},
|
|
1291
|
+
};
|
|
1292
|
+
}
|
|
1293
|
+
};
|
|
1294
|
+
__decorate([
|
|
1295
|
+
(0, CommandClass_1.ccValue)({ minVersion: 2 })
|
|
1296
|
+
], UserCodeCCKeypadModeReport.prototype, "keypadMode", void 0);
|
|
1297
|
+
UserCodeCCKeypadModeReport = __decorate([
|
|
1298
|
+
(0, CommandClass_1.CCCommand)(_Types_1.UserCodeCommand.KeypadModeReport)
|
|
1299
|
+
], UserCodeCCKeypadModeReport);
|
|
1300
|
+
exports.UserCodeCCKeypadModeReport = UserCodeCCKeypadModeReport;
|
|
1301
|
+
let UserCodeCCKeypadModeGet = class UserCodeCCKeypadModeGet extends UserCodeCC {
|
|
1302
|
+
};
|
|
1303
|
+
UserCodeCCKeypadModeGet = __decorate([
|
|
1304
|
+
(0, CommandClass_1.CCCommand)(_Types_1.UserCodeCommand.KeypadModeGet),
|
|
1305
|
+
(0, CommandClass_1.expectedCCResponse)(UserCodeCCKeypadModeReport)
|
|
1306
|
+
], UserCodeCCKeypadModeGet);
|
|
1307
|
+
exports.UserCodeCCKeypadModeGet = UserCodeCCKeypadModeGet;
|
|
1308
|
+
let UserCodeCCMasterCodeSet = class UserCodeCCMasterCodeSet extends UserCodeCC {
|
|
1309
|
+
constructor(host, options) {
|
|
1310
|
+
super(host, options);
|
|
1311
|
+
if ((0, CommandClass_1.gotDeserializationOptions)(options)) {
|
|
1312
|
+
// TODO: Deserialize payload
|
|
1313
|
+
throw new safe_1.ZWaveError(`${this.constructor.name}: deserialization not implemented`, safe_1.ZWaveErrorCodes.Deserialization_NotImplemented);
|
|
1314
|
+
}
|
|
1315
|
+
else {
|
|
1316
|
+
this.masterCode = options.masterCode;
|
|
1317
|
+
}
|
|
1318
|
+
}
|
|
1319
|
+
serialize() {
|
|
1320
|
+
this.payload = Buffer.concat([
|
|
1321
|
+
Buffer.from([this.masterCode.length & 0b11111]),
|
|
1322
|
+
Buffer.from(this.masterCode, "ascii"),
|
|
1323
|
+
]);
|
|
1324
|
+
return super.serialize();
|
|
1325
|
+
}
|
|
1326
|
+
toLogEntry(applHost) {
|
|
1327
|
+
return {
|
|
1328
|
+
...super.toLogEntry(applHost),
|
|
1329
|
+
message: { "master code": userCodeToLogString(this.masterCode) },
|
|
1330
|
+
};
|
|
1331
|
+
}
|
|
1332
|
+
};
|
|
1333
|
+
UserCodeCCMasterCodeSet = __decorate([
|
|
1334
|
+
(0, CommandClass_1.CCCommand)(_Types_1.UserCodeCommand.MasterCodeSet)
|
|
1335
|
+
], UserCodeCCMasterCodeSet);
|
|
1336
|
+
exports.UserCodeCCMasterCodeSet = UserCodeCCMasterCodeSet;
|
|
1337
|
+
let UserCodeCCMasterCodeReport = class UserCodeCCMasterCodeReport extends UserCodeCC {
|
|
1338
|
+
constructor(host, options) {
|
|
1339
|
+
super(host, options);
|
|
1340
|
+
(0, safe_1.validatePayload)(this.payload.length >= 1);
|
|
1341
|
+
const codeLength = this.payload[0] & 0b1111;
|
|
1342
|
+
(0, safe_1.validatePayload)(this.payload.length >= 1 + codeLength);
|
|
1343
|
+
this.masterCode = this.payload
|
|
1344
|
+
.slice(1, 1 + codeLength)
|
|
1345
|
+
.toString("ascii");
|
|
1346
|
+
}
|
|
1347
|
+
toLogEntry(applHost) {
|
|
1348
|
+
return {
|
|
1349
|
+
...super.toLogEntry(applHost),
|
|
1350
|
+
message: { "master code": userCodeToLogString(this.masterCode) },
|
|
1351
|
+
};
|
|
1352
|
+
}
|
|
1353
|
+
};
|
|
1354
|
+
__decorate([
|
|
1355
|
+
(0, CommandClass_1.ccValue)({
|
|
1356
|
+
minVersion: 2,
|
|
1357
|
+
secret: true,
|
|
1358
|
+
}),
|
|
1359
|
+
(0, CommandClass_1.ccValueMetadata)({
|
|
1360
|
+
...safe_1.ValueMetadata.String,
|
|
1361
|
+
label: "Master Code",
|
|
1362
|
+
minLength: 4,
|
|
1363
|
+
maxLength: 10,
|
|
1364
|
+
})
|
|
1365
|
+
], UserCodeCCMasterCodeReport.prototype, "masterCode", void 0);
|
|
1366
|
+
UserCodeCCMasterCodeReport = __decorate([
|
|
1367
|
+
(0, CommandClass_1.CCCommand)(_Types_1.UserCodeCommand.MasterCodeReport)
|
|
1368
|
+
], UserCodeCCMasterCodeReport);
|
|
1369
|
+
exports.UserCodeCCMasterCodeReport = UserCodeCCMasterCodeReport;
|
|
1370
|
+
let UserCodeCCMasterCodeGet = class UserCodeCCMasterCodeGet extends UserCodeCC {
|
|
1371
|
+
};
|
|
1372
|
+
UserCodeCCMasterCodeGet = __decorate([
|
|
1373
|
+
(0, CommandClass_1.CCCommand)(_Types_1.UserCodeCommand.MasterCodeGet),
|
|
1374
|
+
(0, CommandClass_1.expectedCCResponse)(UserCodeCCMasterCodeReport)
|
|
1375
|
+
], UserCodeCCMasterCodeGet);
|
|
1376
|
+
exports.UserCodeCCMasterCodeGet = UserCodeCCMasterCodeGet;
|
|
1377
|
+
let UserCodeCCUserCodeChecksumReport = class UserCodeCCUserCodeChecksumReport extends UserCodeCC {
|
|
1378
|
+
constructor(host, options) {
|
|
1379
|
+
super(host, options);
|
|
1380
|
+
(0, safe_1.validatePayload)(this.payload.length >= 2);
|
|
1381
|
+
this.userCodeChecksum = this.payload.readUInt16BE(0);
|
|
1382
|
+
}
|
|
1383
|
+
toLogEntry(applHost) {
|
|
1384
|
+
return {
|
|
1385
|
+
...super.toLogEntry(applHost),
|
|
1386
|
+
message: { "user code checksum": (0, safe_2.num2hex)(this.userCodeChecksum) },
|
|
1387
|
+
};
|
|
1388
|
+
}
|
|
1389
|
+
};
|
|
1390
|
+
__decorate([
|
|
1391
|
+
(0, CommandClass_1.ccValue)({ internal: true })
|
|
1392
|
+
], UserCodeCCUserCodeChecksumReport.prototype, "userCodeChecksum", void 0);
|
|
1393
|
+
UserCodeCCUserCodeChecksumReport = __decorate([
|
|
1394
|
+
(0, CommandClass_1.CCCommand)(_Types_1.UserCodeCommand.UserCodeChecksumReport)
|
|
1395
|
+
], UserCodeCCUserCodeChecksumReport);
|
|
1396
|
+
exports.UserCodeCCUserCodeChecksumReport = UserCodeCCUserCodeChecksumReport;
|
|
1397
|
+
let UserCodeCCUserCodeChecksumGet = class UserCodeCCUserCodeChecksumGet extends UserCodeCC {
|
|
1398
|
+
};
|
|
1399
|
+
UserCodeCCUserCodeChecksumGet = __decorate([
|
|
1400
|
+
(0, CommandClass_1.CCCommand)(_Types_1.UserCodeCommand.UserCodeChecksumGet),
|
|
1401
|
+
(0, CommandClass_1.expectedCCResponse)(UserCodeCCUserCodeChecksumReport)
|
|
1402
|
+
], UserCodeCCUserCodeChecksumGet);
|
|
1403
|
+
exports.UserCodeCCUserCodeChecksumGet = UserCodeCCUserCodeChecksumGet;
|
|
1404
|
+
let UserCodeCCExtendedUserCodeSet = class UserCodeCCExtendedUserCodeSet extends UserCodeCC {
|
|
1405
|
+
constructor(host, options) {
|
|
1406
|
+
super(host, options);
|
|
1407
|
+
if ((0, CommandClass_1.gotDeserializationOptions)(options)) {
|
|
1408
|
+
// TODO: Deserialize payload
|
|
1409
|
+
throw new safe_1.ZWaveError(`${this.constructor.name}: deserialization not implemented`, safe_1.ZWaveErrorCodes.Deserialization_NotImplemented);
|
|
1410
|
+
}
|
|
1411
|
+
else {
|
|
1412
|
+
this.userCodes = options.userCodes;
|
|
1413
|
+
}
|
|
1414
|
+
}
|
|
1415
|
+
serialize() {
|
|
1416
|
+
const userCodeBuffers = this.userCodes.map((code) => {
|
|
1417
|
+
var _c, _d, _e;
|
|
1418
|
+
const ret = Buffer.concat([
|
|
1419
|
+
Buffer.from([
|
|
1420
|
+
0,
|
|
1421
|
+
0,
|
|
1422
|
+
code.userIdStatus,
|
|
1423
|
+
(_d = (_c = code.userCode) === null || _c === void 0 ? void 0 : _c.length) !== null && _d !== void 0 ? _d : 0,
|
|
1424
|
+
]),
|
|
1425
|
+
Buffer.isBuffer(code.userCode)
|
|
1426
|
+
? code.userCode
|
|
1427
|
+
: Buffer.from((_e = code.userCode) !== null && _e !== void 0 ? _e : "", "ascii"),
|
|
1428
|
+
]);
|
|
1429
|
+
ret.writeUInt16BE(code.userId, 0);
|
|
1430
|
+
return ret;
|
|
1431
|
+
});
|
|
1432
|
+
this.payload = Buffer.concat([
|
|
1433
|
+
Buffer.from([this.userCodes.length]),
|
|
1434
|
+
...userCodeBuffers,
|
|
1435
|
+
]);
|
|
1436
|
+
return super.serialize();
|
|
1437
|
+
}
|
|
1438
|
+
toLogEntry(applHost) {
|
|
1439
|
+
const message = {};
|
|
1440
|
+
for (const { userId, userIdStatus, userCode } of this.userCodes) {
|
|
1441
|
+
message[`code #${userId}`] = `${userCodeToLogString(userCode !== null && userCode !== void 0 ? userCode : "")} (status: ${(0, safe_2.getEnumMemberName)(_Types_1.UserIDStatus, userIdStatus)})`;
|
|
1442
|
+
}
|
|
1443
|
+
return {
|
|
1444
|
+
...super.toLogEntry(applHost),
|
|
1445
|
+
message,
|
|
1446
|
+
};
|
|
1447
|
+
}
|
|
1448
|
+
};
|
|
1449
|
+
UserCodeCCExtendedUserCodeSet = __decorate([
|
|
1450
|
+
(0, CommandClass_1.CCCommand)(_Types_1.UserCodeCommand.ExtendedUserCodeSet)
|
|
1451
|
+
], UserCodeCCExtendedUserCodeSet);
|
|
1452
|
+
exports.UserCodeCCExtendedUserCodeSet = UserCodeCCExtendedUserCodeSet;
|
|
1453
|
+
let UserCodeCCExtendedUserCodeReport = class UserCodeCCExtendedUserCodeReport extends UserCodeCC {
|
|
1454
|
+
constructor(host, options) {
|
|
1455
|
+
super(host, options);
|
|
1456
|
+
(0, safe_1.validatePayload)(this.payload.length >= 1);
|
|
1457
|
+
const numCodes = this.payload[0];
|
|
1458
|
+
let offset = 1;
|
|
1459
|
+
const userCodes = [];
|
|
1460
|
+
// parse each user code
|
|
1461
|
+
for (let i = 0; i < numCodes; i++) {
|
|
1462
|
+
const { code, bytesRead } = parseExtendedUserCode(this.payload.slice(offset));
|
|
1463
|
+
userCodes.push(code);
|
|
1464
|
+
offset += bytesRead;
|
|
1465
|
+
}
|
|
1466
|
+
this.userCodes = userCodes;
|
|
1467
|
+
(0, safe_1.validatePayload)(this.payload.length >= offset + 2);
|
|
1468
|
+
this.nextUserId = this.payload.readUInt16BE(offset);
|
|
1469
|
+
}
|
|
1470
|
+
persistValues(applHost) {
|
|
1471
|
+
if (!super.persistValues(applHost))
|
|
1472
|
+
return false;
|
|
1473
|
+
for (const { userId, userIdStatus, userCode } of this.userCodes) {
|
|
1474
|
+
persistUserCode.call(this, applHost, userId, userIdStatus, userCode);
|
|
1475
|
+
}
|
|
1476
|
+
return true;
|
|
1477
|
+
}
|
|
1478
|
+
toLogEntry(applHost) {
|
|
1479
|
+
const message = {};
|
|
1480
|
+
for (const { userId, userIdStatus, userCode } of this.userCodes) {
|
|
1481
|
+
message[`code #${userId}`] = `${userCodeToLogString(userCode)} (status: ${(0, safe_2.getEnumMemberName)(_Types_1.UserIDStatus, userIdStatus)})`;
|
|
1482
|
+
}
|
|
1483
|
+
message["next user id"] = this.nextUserId;
|
|
1484
|
+
return {
|
|
1485
|
+
...super.toLogEntry(applHost),
|
|
1486
|
+
message,
|
|
1487
|
+
};
|
|
1488
|
+
}
|
|
1489
|
+
};
|
|
1490
|
+
UserCodeCCExtendedUserCodeReport = __decorate([
|
|
1491
|
+
(0, CommandClass_1.CCCommand)(_Types_1.UserCodeCommand.ExtendedUserCodeReport)
|
|
1492
|
+
], UserCodeCCExtendedUserCodeReport);
|
|
1493
|
+
exports.UserCodeCCExtendedUserCodeReport = UserCodeCCExtendedUserCodeReport;
|
|
1494
|
+
let UserCodeCCExtendedUserCodeGet = class UserCodeCCExtendedUserCodeGet extends UserCodeCC {
|
|
1495
|
+
constructor(host, options) {
|
|
1496
|
+
super(host, options);
|
|
1497
|
+
if ((0, CommandClass_1.gotDeserializationOptions)(options)) {
|
|
1498
|
+
// TODO: Deserialize payload
|
|
1499
|
+
throw new safe_1.ZWaveError(`${this.constructor.name}: deserialization not implemented`, safe_1.ZWaveErrorCodes.Deserialization_NotImplemented);
|
|
1500
|
+
}
|
|
1501
|
+
else {
|
|
1502
|
+
this.userId = options.userId;
|
|
1503
|
+
this.reportMore = !!options.reportMore;
|
|
1504
|
+
}
|
|
1505
|
+
}
|
|
1506
|
+
serialize() {
|
|
1507
|
+
this.payload = Buffer.from([0, 0, this.reportMore ? 1 : 0]);
|
|
1508
|
+
this.payload.writeUInt16BE(this.userId, 0);
|
|
1509
|
+
return super.serialize();
|
|
1510
|
+
}
|
|
1511
|
+
toLogEntry(applHost) {
|
|
1512
|
+
return {
|
|
1513
|
+
...super.toLogEntry(applHost),
|
|
1514
|
+
message: {
|
|
1515
|
+
"user id": this.userId,
|
|
1516
|
+
"report more": this.reportMore,
|
|
1517
|
+
},
|
|
1518
|
+
};
|
|
1519
|
+
}
|
|
1520
|
+
};
|
|
1521
|
+
UserCodeCCExtendedUserCodeGet = __decorate([
|
|
1522
|
+
(0, CommandClass_1.CCCommand)(_Types_1.UserCodeCommand.ExtendedUserCodeGet),
|
|
1523
|
+
(0, CommandClass_1.expectedCCResponse)(UserCodeCCExtendedUserCodeReport)
|
|
1524
|
+
], UserCodeCCExtendedUserCodeGet);
|
|
1525
|
+
exports.UserCodeCCExtendedUserCodeGet = UserCodeCCExtendedUserCodeGet;
|
|
1526
|
+
//# sourceMappingURL=UserCodeCC.js.map
|