@zwave-js/cc 14.1.0 → 14.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/cjs/cc/AlarmSensorCC.js.map +2 -2
- package/build/cjs/cc/AssociationCC.d.ts +2 -0
- package/build/cjs/cc/AssociationCC.js +5 -0
- package/build/cjs/cc/AssociationCC.js.map +2 -2
- package/build/cjs/cc/AssociationGroupInfoCC.js.map +2 -2
- package/build/cjs/cc/BarrierOperatorCC.js.map +2 -2
- package/build/cjs/cc/BasicCC.js.map +2 -2
- package/build/cjs/cc/BatteryCC.js.map +2 -2
- package/build/cjs/cc/BinarySensorCC.js.map +2 -2
- package/build/cjs/cc/BinarySwitchCC.js.map +2 -2
- package/build/cjs/cc/CRC16CC.d.ts +4 -0
- package/build/cjs/cc/CRC16CC.js +23 -0
- package/build/cjs/cc/CRC16CC.js.map +2 -2
- package/build/cjs/cc/CentralSceneCC.js.map +2 -2
- package/build/cjs/cc/ClimateControlScheduleCC.js.map +2 -2
- package/build/cjs/cc/ClockCC.js.map +2 -2
- package/build/cjs/cc/ColorSwitchCC.js.map +2 -2
- package/build/cjs/cc/ConfigurationCC.d.ts +4 -0
- package/build/cjs/cc/ConfigurationCC.js +10 -0
- package/build/cjs/cc/ConfigurationCC.js.map +2 -2
- package/build/cjs/cc/DoorLockCC.js.map +2 -2
- package/build/cjs/cc/DoorLockLoggingCC.js.map +2 -2
- package/build/cjs/cc/EnergyProductionCC.js.map +2 -2
- package/build/cjs/cc/EntryControlCC.js.map +2 -2
- package/build/cjs/cc/FirmwareUpdateMetaDataCC.js.map +2 -2
- package/build/cjs/cc/HumidityControlModeCC.js.map +2 -2
- package/build/cjs/cc/HumidityControlSetpointCC.js.map +2 -2
- package/build/cjs/cc/InclusionControllerCC.js.map +2 -2
- package/build/cjs/cc/IndicatorCC.js.map +2 -2
- package/build/cjs/cc/IrrigationCC.js.map +2 -2
- package/build/cjs/cc/LanguageCC.js.map +2 -2
- package/build/cjs/cc/LockCC.js.map +2 -2
- package/build/cjs/cc/ManufacturerProprietaryCC.js.map +2 -2
- package/build/cjs/cc/ManufacturerSpecificCC.js.map +2 -2
- package/build/cjs/cc/MeterCC.js.map +2 -2
- package/build/cjs/cc/MultiChannelAssociationCC.d.ts +2 -0
- package/build/cjs/cc/MultiChannelAssociationCC.js +6 -0
- package/build/cjs/cc/MultiChannelAssociationCC.js.map +2 -2
- package/build/cjs/cc/MultiChannelCC.d.ts +10 -0
- package/build/cjs/cc/MultiChannelCC.js +65 -0
- package/build/cjs/cc/MultiChannelCC.js.map +2 -2
- package/build/cjs/cc/MultiCommandCC.d.ts +4 -0
- package/build/cjs/cc/MultiCommandCC.js +34 -1
- package/build/cjs/cc/MultiCommandCC.js.map +2 -2
- package/build/cjs/cc/MultilevelSensorCC.js.map +2 -2
- package/build/cjs/cc/MultilevelSwitchCC.js.map +2 -2
- package/build/cjs/cc/NodeNamingCC.js.map +2 -2
- package/build/cjs/cc/NotificationCC.js.map +2 -2
- package/build/cjs/cc/PowerlevelCC.js.map +2 -2
- package/build/cjs/cc/ProtectionCC.js.map +2 -2
- package/build/cjs/cc/SceneActivationCC.js.map +2 -2
- package/build/cjs/cc/SceneActuatorConfigurationCC.js.map +2 -2
- package/build/cjs/cc/SceneControllerConfigurationCC.js.map +2 -2
- package/build/cjs/cc/ScheduleEntryLockCC.js.map +2 -2
- package/build/cjs/cc/Security2CC.d.ts +7 -1
- package/build/cjs/cc/Security2CC.js +383 -52
- package/build/cjs/cc/Security2CC.js.map +2 -2
- package/build/cjs/cc/SecurityCC.d.ts +7 -0
- package/build/cjs/cc/SecurityCC.js +101 -6
- package/build/cjs/cc/SecurityCC.js.map +2 -2
- package/build/cjs/cc/SoundSwitchCC.js.map +2 -2
- package/build/cjs/cc/SupervisionCC.d.ts +4 -0
- package/build/cjs/cc/SupervisionCC.js +25 -0
- package/build/cjs/cc/SupervisionCC.js.map +2 -2
- package/build/cjs/cc/ThermostatFanModeCC.js.map +2 -2
- package/build/cjs/cc/ThermostatModeCC.js.map +2 -2
- package/build/cjs/cc/ThermostatSetbackCC.js.map +2 -2
- package/build/cjs/cc/ThermostatSetpointCC.js.map +2 -2
- package/build/cjs/cc/TimeCC.js.map +2 -2
- package/build/cjs/cc/TimeParametersCC.js.map +2 -2
- package/build/cjs/cc/TransportServiceCC.d.ts +5 -0
- package/build/cjs/cc/TransportServiceCC.js +13 -0
- package/build/cjs/cc/TransportServiceCC.js.map +2 -2
- package/build/cjs/cc/UserCodeCC.js.map +2 -2
- package/build/cjs/cc/VersionCC.js.map +2 -2
- package/build/cjs/cc/WakeUpCC.js.map +2 -2
- package/build/cjs/cc/WindowCoveringCC.js.map +2 -2
- package/build/cjs/cc/ZWavePlusCC.js.map +2 -2
- package/build/cjs/cc/ZWaveProtocolCC.js.map +2 -2
- package/build/cjs/cc/manufacturerProprietary/Decorators.js +6 -5
- package/build/cjs/cc/manufacturerProprietary/Decorators.js.map +2 -2
- package/build/cjs/cc/manufacturerProprietary/FibaroCC.js.map +2 -2
- package/build/cjs/lib/CommandClass.d.ts +15 -1
- package/build/cjs/lib/CommandClass.js +56 -1
- package/build/cjs/lib/CommandClass.js.map +2 -2
- package/build/cjs/lib/CommandClassDecorators.js +7 -6
- package/build/cjs/lib/CommandClassDecorators.js.map +2 -2
- package/build/cjs/lib/Security2/Extension.js +2 -2
- package/build/cjs/lib/Security2/Extension.js.map +2 -2
- package/build/esm/cc/AlarmSensorCC.d.ts.map +1 -1
- package/build/esm/cc/AlarmSensorCC.js +1 -0
- package/build/esm/cc/AlarmSensorCC.js.map +1 -1
- package/build/esm/cc/AssociationCC.d.ts +2 -0
- package/build/esm/cc/AssociationCC.d.ts.map +1 -1
- package/build/esm/cc/AssociationCC.js +14 -0
- package/build/esm/cc/AssociationCC.js.map +1 -1
- package/build/esm/cc/AssociationGroupInfoCC.d.ts.map +1 -1
- package/build/esm/cc/AssociationGroupInfoCC.js +6 -0
- package/build/esm/cc/AssociationGroupInfoCC.js.map +1 -1
- package/build/esm/cc/BarrierOperatorCC.d.ts.map +1 -1
- package/build/esm/cc/BarrierOperatorCC.js +3 -0
- package/build/esm/cc/BarrierOperatorCC.js.map +1 -1
- package/build/esm/cc/BasicCC.d.ts.map +1 -1
- package/build/esm/cc/BasicCC.js +2 -0
- package/build/esm/cc/BasicCC.js.map +1 -1
- package/build/esm/cc/BatteryCC.d.ts.map +1 -1
- package/build/esm/cc/BatteryCC.js +1 -0
- package/build/esm/cc/BatteryCC.js.map +1 -1
- package/build/esm/cc/BinarySensorCC.d.ts.map +1 -1
- package/build/esm/cc/BinarySensorCC.js +3 -0
- package/build/esm/cc/BinarySensorCC.js.map +1 -1
- package/build/esm/cc/BinarySwitchCC.d.ts.map +1 -1
- package/build/esm/cc/BinarySwitchCC.js +2 -0
- package/build/esm/cc/BinarySwitchCC.js.map +1 -1
- package/build/esm/cc/CRC16CC.d.ts +4 -0
- package/build/esm/cc/CRC16CC.d.ts.map +1 -1
- package/build/esm/cc/CRC16CC.js +30 -0
- package/build/esm/cc/CRC16CC.js.map +1 -1
- package/build/esm/cc/CentralSceneCC.d.ts.map +1 -1
- package/build/esm/cc/CentralSceneCC.js +1 -0
- package/build/esm/cc/CentralSceneCC.js.map +1 -1
- package/build/esm/cc/ClimateControlScheduleCC.d.ts.map +1 -1
- package/build/esm/cc/ClimateControlScheduleCC.js +3 -0
- package/build/esm/cc/ClimateControlScheduleCC.js.map +1 -1
- package/build/esm/cc/ClockCC.d.ts.map +1 -1
- package/build/esm/cc/ClockCC.js +1 -0
- package/build/esm/cc/ClockCC.js.map +1 -1
- package/build/esm/cc/ColorSwitchCC.d.ts.map +1 -1
- package/build/esm/cc/ColorSwitchCC.js +6 -0
- package/build/esm/cc/ColorSwitchCC.js.map +1 -1
- package/build/esm/cc/ConfigurationCC.d.ts +4 -0
- package/build/esm/cc/ConfigurationCC.d.ts.map +1 -1
- package/build/esm/cc/ConfigurationCC.js +27 -0
- package/build/esm/cc/ConfigurationCC.js.map +1 -1
- package/build/esm/cc/DoorLockCC.d.ts.map +1 -1
- package/build/esm/cc/DoorLockCC.js +2 -0
- package/build/esm/cc/DoorLockCC.js.map +1 -1
- package/build/esm/cc/DoorLockLoggingCC.d.ts.map +1 -1
- package/build/esm/cc/DoorLockLoggingCC.js +1 -0
- package/build/esm/cc/DoorLockLoggingCC.js.map +1 -1
- package/build/esm/cc/EnergyProductionCC.d.ts.map +1 -1
- package/build/esm/cc/EnergyProductionCC.js +2 -0
- package/build/esm/cc/EnergyProductionCC.js.map +1 -1
- package/build/esm/cc/EntryControlCC.d.ts.map +1 -1
- package/build/esm/cc/EntryControlCC.js +1 -0
- package/build/esm/cc/EntryControlCC.js.map +1 -1
- package/build/esm/cc/FirmwareUpdateMetaDataCC.d.ts.map +1 -1
- package/build/esm/cc/FirmwareUpdateMetaDataCC.js +5 -0
- package/build/esm/cc/FirmwareUpdateMetaDataCC.js.map +1 -1
- package/build/esm/cc/HumidityControlModeCC.d.ts.map +1 -1
- package/build/esm/cc/HumidityControlModeCC.js +1 -0
- package/build/esm/cc/HumidityControlModeCC.js.map +1 -1
- package/build/esm/cc/HumidityControlSetpointCC.d.ts.map +1 -1
- package/build/esm/cc/HumidityControlSetpointCC.js +4 -0
- package/build/esm/cc/HumidityControlSetpointCC.js.map +1 -1
- package/build/esm/cc/InclusionControllerCC.d.ts.map +1 -1
- package/build/esm/cc/InclusionControllerCC.js +2 -0
- package/build/esm/cc/InclusionControllerCC.js.map +1 -1
- package/build/esm/cc/IndicatorCC.d.ts.map +1 -1
- package/build/esm/cc/IndicatorCC.js +7 -0
- package/build/esm/cc/IndicatorCC.js.map +1 -1
- package/build/esm/cc/IrrigationCC.d.ts.map +1 -1
- package/build/esm/cc/IrrigationCC.js +9 -0
- package/build/esm/cc/IrrigationCC.js.map +1 -1
- package/build/esm/cc/LanguageCC.d.ts.map +1 -1
- package/build/esm/cc/LanguageCC.js +1 -0
- package/build/esm/cc/LanguageCC.js.map +1 -1
- package/build/esm/cc/LockCC.d.ts.map +1 -1
- package/build/esm/cc/LockCC.js +1 -0
- package/build/esm/cc/LockCC.js.map +1 -1
- package/build/esm/cc/ManufacturerProprietaryCC.d.ts.map +1 -1
- package/build/esm/cc/ManufacturerProprietaryCC.js +2 -0
- package/build/esm/cc/ManufacturerProprietaryCC.js.map +1 -1
- package/build/esm/cc/ManufacturerSpecificCC.d.ts.map +1 -1
- package/build/esm/cc/ManufacturerSpecificCC.js +2 -0
- package/build/esm/cc/ManufacturerSpecificCC.js.map +1 -1
- package/build/esm/cc/MeterCC.d.ts.map +1 -1
- package/build/esm/cc/MeterCC.js +4 -0
- package/build/esm/cc/MeterCC.js.map +1 -1
- package/build/esm/cc/MultiChannelAssociationCC.d.ts +2 -0
- package/build/esm/cc/MultiChannelAssociationCC.d.ts.map +1 -1
- package/build/esm/cc/MultiChannelAssociationCC.js +17 -0
- package/build/esm/cc/MultiChannelAssociationCC.js.map +1 -1
- package/build/esm/cc/MultiChannelCC.d.ts +10 -0
- package/build/esm/cc/MultiChannelCC.d.ts.map +1 -1
- package/build/esm/cc/MultiChannelCC.js +94 -0
- package/build/esm/cc/MultiChannelCC.js.map +1 -1
- package/build/esm/cc/MultiCommandCC.d.ts +4 -0
- package/build/esm/cc/MultiCommandCC.d.ts.map +1 -1
- package/build/esm/cc/MultiCommandCC.js +35 -1
- package/build/esm/cc/MultiCommandCC.js.map +1 -1
- package/build/esm/cc/MultilevelSensorCC.d.ts.map +1 -1
- package/build/esm/cc/MultilevelSensorCC.js +5 -0
- package/build/esm/cc/MultilevelSensorCC.js.map +1 -1
- package/build/esm/cc/MultilevelSwitchCC.d.ts.map +1 -1
- package/build/esm/cc/MultilevelSwitchCC.js +4 -0
- package/build/esm/cc/MultilevelSwitchCC.js.map +1 -1
- package/build/esm/cc/NodeNamingCC.d.ts.map +1 -1
- package/build/esm/cc/NodeNamingCC.js +2 -0
- package/build/esm/cc/NodeNamingCC.js.map +1 -1
- package/build/esm/cc/NotificationCC.d.ts.map +1 -1
- package/build/esm/cc/NotificationCC.js +9 -0
- package/build/esm/cc/NotificationCC.js.map +1 -1
- package/build/esm/cc/PowerlevelCC.d.ts.map +1 -1
- package/build/esm/cc/PowerlevelCC.js +4 -0
- package/build/esm/cc/PowerlevelCC.js.map +1 -1
- package/build/esm/cc/ProtectionCC.d.ts.map +1 -1
- package/build/esm/cc/ProtectionCC.js +3 -0
- package/build/esm/cc/ProtectionCC.js.map +1 -1
- package/build/esm/cc/SceneActivationCC.d.ts.map +1 -1
- package/build/esm/cc/SceneActivationCC.js +1 -0
- package/build/esm/cc/SceneActivationCC.js.map +1 -1
- package/build/esm/cc/SceneActuatorConfigurationCC.d.ts.map +1 -1
- package/build/esm/cc/SceneActuatorConfigurationCC.js +2 -0
- package/build/esm/cc/SceneActuatorConfigurationCC.js.map +1 -1
- package/build/esm/cc/SceneControllerConfigurationCC.d.ts.map +1 -1
- package/build/esm/cc/SceneControllerConfigurationCC.js +2 -0
- package/build/esm/cc/SceneControllerConfigurationCC.js.map +1 -1
- package/build/esm/cc/ScheduleEntryLockCC.d.ts.map +1 -1
- package/build/esm/cc/ScheduleEntryLockCC.js +14 -0
- package/build/esm/cc/ScheduleEntryLockCC.js.map +1 -1
- package/build/esm/cc/Security2CC.d.ts +7 -1
- package/build/esm/cc/Security2CC.d.ts.map +1 -1
- package/build/esm/cc/Security2CC.js +534 -68
- package/build/esm/cc/Security2CC.js.map +1 -1
- package/build/esm/cc/SecurityCC.d.ts +7 -0
- package/build/esm/cc/SecurityCC.d.ts.map +1 -1
- package/build/esm/cc/SecurityCC.js +133 -7
- package/build/esm/cc/SecurityCC.js.map +1 -1
- package/build/esm/cc/SoundSwitchCC.d.ts.map +1 -1
- package/build/esm/cc/SoundSwitchCC.js +7 -0
- package/build/esm/cc/SoundSwitchCC.js.map +1 -1
- package/build/esm/cc/SupervisionCC.d.ts +4 -0
- package/build/esm/cc/SupervisionCC.d.ts.map +1 -1
- package/build/esm/cc/SupervisionCC.js +30 -0
- package/build/esm/cc/SupervisionCC.js.map +1 -1
- package/build/esm/cc/ThermostatFanModeCC.d.ts.map +1 -1
- package/build/esm/cc/ThermostatFanModeCC.js +1 -0
- package/build/esm/cc/ThermostatFanModeCC.js.map +1 -1
- package/build/esm/cc/ThermostatModeCC.d.ts.map +1 -1
- package/build/esm/cc/ThermostatModeCC.js +3 -0
- package/build/esm/cc/ThermostatModeCC.js.map +1 -1
- package/build/esm/cc/ThermostatSetbackCC.d.ts.map +1 -1
- package/build/esm/cc/ThermostatSetbackCC.js +2 -0
- package/build/esm/cc/ThermostatSetbackCC.js.map +1 -1
- package/build/esm/cc/ThermostatSetpointCC.d.ts.map +1 -1
- package/build/esm/cc/ThermostatSetpointCC.js +6 -0
- package/build/esm/cc/ThermostatSetpointCC.js.map +1 -1
- package/build/esm/cc/TimeCC.d.ts.map +1 -1
- package/build/esm/cc/TimeCC.js +4 -0
- package/build/esm/cc/TimeCC.js.map +1 -1
- package/build/esm/cc/TimeParametersCC.d.ts.map +1 -1
- package/build/esm/cc/TimeParametersCC.js +1 -0
- package/build/esm/cc/TimeParametersCC.js.map +1 -1
- package/build/esm/cc/TransportServiceCC.d.ts +5 -0
- package/build/esm/cc/TransportServiceCC.d.ts.map +1 -1
- package/build/esm/cc/TransportServiceCC.js +24 -0
- package/build/esm/cc/TransportServiceCC.js.map +1 -1
- package/build/esm/cc/UserCodeCC.d.ts.map +1 -1
- package/build/esm/cc/UserCodeCC.js +12 -0
- package/build/esm/cc/UserCodeCC.js.map +1 -1
- package/build/esm/cc/VersionCC.d.ts.map +1 -1
- package/build/esm/cc/VersionCC.js +4 -0
- package/build/esm/cc/VersionCC.js.map +1 -1
- package/build/esm/cc/WakeUpCC.d.ts.map +1 -1
- package/build/esm/cc/WakeUpCC.js +1 -0
- package/build/esm/cc/WakeUpCC.js.map +1 -1
- package/build/esm/cc/WindowCoveringCC.d.ts.map +1 -1
- package/build/esm/cc/WindowCoveringCC.js +5 -0
- package/build/esm/cc/WindowCoveringCC.js.map +1 -1
- package/build/esm/cc/ZWavePlusCC.d.ts.map +1 -1
- package/build/esm/cc/ZWavePlusCC.js +1 -0
- package/build/esm/cc/ZWavePlusCC.js.map +1 -1
- package/build/esm/cc/ZWaveProtocolCC.d.ts.map +1 -1
- package/build/esm/cc/ZWaveProtocolCC.js +27 -0
- package/build/esm/cc/ZWaveProtocolCC.js.map +1 -1
- package/build/esm/cc/manufacturerProprietary/Decorators.d.ts.map +1 -1
- package/build/esm/cc/manufacturerProprietary/Decorators.js +2 -1
- package/build/esm/cc/manufacturerProprietary/Decorators.js.map +1 -1
- package/build/esm/cc/manufacturerProprietary/FibaroCC.d.ts.map +1 -1
- package/build/esm/cc/manufacturerProprietary/FibaroCC.js +3 -0
- package/build/esm/cc/manufacturerProprietary/FibaroCC.js.map +1 -1
- package/build/esm/lib/CommandClass.d.ts +15 -1
- package/build/esm/lib/CommandClass.d.ts.map +1 -1
- package/build/esm/lib/CommandClass.js +94 -1
- package/build/esm/lib/CommandClass.js.map +1 -1
- package/build/esm/lib/CommandClassDecorators.d.ts.map +1 -1
- package/build/esm/lib/CommandClassDecorators.js +2 -1
- package/build/esm/lib/CommandClassDecorators.js.map +1 -1
- package/build/esm/lib/Security2/Extension.js +1 -1
- package/build/esm/lib/Security2/Extension.js.map +1 -1
- package/package.json +6 -6
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/cc/BinarySwitchCC.ts"],
|
|
4
|
-
"sourcesContent": ["import {\n\tCommandClasses,\n\tDuration,\n\ttype MaybeNotKnown,\n\ttype MaybeUnknown,\n\ttype MessageOrCCLogEntry,\n\tMessagePriority,\n\ttype MessageRecord,\n\ttype SupervisionResult,\n\tUNKNOWN_STATE,\n\tValueMetadata,\n\ttype WithAddress,\n\tencodeMaybeBoolean,\n\tmaybeUnknownToString,\n\tparseMaybeBoolean,\n\tvalidatePayload,\n} from \"@zwave-js/core/safe\";\nimport type {\n\tCCEncodingContext,\n\tCCParsingContext,\n\tGetValueDB,\n} from \"@zwave-js/host/safe\";\nimport { Bytes } from \"@zwave-js/shared/safe\";\nimport { validateArgs } from \"@zwave-js/transformers\";\nimport {\n\tCCAPI,\n\tPOLL_VALUE,\n\ttype PollValueImplementation,\n\tSET_VALUE,\n\tSET_VALUE_HOOKS,\n\ttype SetValueImplementation,\n\ttype SetValueImplementationHooksFactory,\n\tthrowUnsupportedProperty,\n\tthrowWrongValueType,\n} from \"../lib/API.js\";\nimport {\n\ttype CCRaw,\n\tCommandClass,\n\ttype InterviewContext,\n\ttype RefreshValuesContext,\n\tgetEffectiveCCVersion,\n} from \"../lib/CommandClass.js\";\nimport {\n\tAPI,\n\tCCCommand,\n\tccValueProperty,\n\tccValues,\n\tcommandClass,\n\texpectedCCResponse,\n\timplementedVersion,\n\tuseSupervision,\n} from \"../lib/CommandClassDecorators.js\";\nimport { V } from \"../lib/Values.js\";\nimport { BinarySwitchCommand } from \"../lib/_Types.js\";\n\nexport const BinarySwitchCCValues = Object.freeze({\n\t...V.defineStaticCCValues(CommandClasses[\"Binary Switch\"], {\n\t\t...V.staticProperty(\n\t\t\t\"currentValue\",\n\t\t\t{\n\t\t\t\t...ValueMetadata.ReadOnlyBoolean,\n\t\t\t\tlabel: \"Current value\",\n\t\t\t} as const,\n\t\t),\n\n\t\t...V.staticProperty(\n\t\t\t\"targetValue\",\n\t\t\t{\n\t\t\t\t...ValueMetadata.Boolean,\n\t\t\t\tlabel: \"Target value\",\n\t\t\t\tvalueChangeOptions: [\"transitionDuration\"],\n\t\t\t} as const,\n\t\t),\n\n\t\t...V.staticProperty(\n\t\t\t\"duration\",\n\t\t\t{\n\t\t\t\t...ValueMetadata.ReadOnlyDuration,\n\t\t\t\tlabel: \"Remaining duration\",\n\t\t\t} as const,\n\t\t\t{ minVersion: 2 } as const,\n\t\t),\n\t}),\n});\n\n@API(CommandClasses[\"Binary Switch\"])\nexport class BinarySwitchCCAPI extends CCAPI {\n\tpublic supportsCommand(cmd: BinarySwitchCommand): MaybeNotKnown<boolean> {\n\t\tswitch (cmd) {\n\t\t\tcase BinarySwitchCommand.Get:\n\t\t\t\treturn this.isSinglecast();\n\t\t\tcase BinarySwitchCommand.Set:\n\t\t\t\treturn true;\n\t\t}\n\t\treturn super.supportsCommand(cmd);\n\t}\n\n\t// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types\n\tpublic async get() {\n\t\tthis.assertSupportsCommand(\n\t\t\tBinarySwitchCommand,\n\t\t\tBinarySwitchCommand.Get,\n\t\t);\n\n\t\tconst cc = new BinarySwitchCCGet({\n\t\t\tnodeId: this.endpoint.nodeId,\n\t\t\tendpointIndex: this.endpoint.index,\n\t\t});\n\t\tconst response = await this.host.sendCommand<BinarySwitchCCReport>(\n\t\t\tcc,\n\t\t\tthis.commandOptions,\n\t\t);\n\t\tif (response) {\n\t\t\treturn {\n\t\t\t\t// interpret unknown values as false\n\t\t\t\tcurrentValue: response.currentValue || false,\n\t\t\t\ttargetValue: response.targetValue,\n\t\t\t\tduration: response.duration,\n\t\t\t};\n\t\t}\n\t}\n\n\t/**\n\t * Sets the switch to the given value\n\t * @param targetValue The target value to set\n\t * @param duration The duration after which the target value should be reached. Can be a Duration instance or a user-friendly duration string like `\"1m17s\"`. Only supported in V2 and above.\n\t */\n\t@validateArgs()\n\tpublic async set(\n\t\ttargetValue: boolean,\n\t\tduration?: Duration | string,\n\t): Promise<SupervisionResult | undefined> {\n\t\tthis.assertSupportsCommand(\n\t\t\tBinarySwitchCommand,\n\t\t\tBinarySwitchCommand.Set,\n\t\t);\n\n\t\tconst cc = new BinarySwitchCCSet({\n\t\t\tnodeId: this.endpoint.nodeId,\n\t\t\tendpointIndex: this.endpoint.index,\n\t\t\ttargetValue,\n\t\t\tduration,\n\t\t});\n\t\treturn this.host.sendCommand(cc, this.commandOptions);\n\t}\n\n\tprotected override get [SET_VALUE](): SetValueImplementation {\n\t\treturn async function(\n\t\t\tthis: BinarySwitchCCAPI,\n\t\t\t{ property },\n\t\t\tvalue,\n\t\t\toptions,\n\t\t) {\n\t\t\tif (property !== \"targetValue\") {\n\t\t\t\tthrowUnsupportedProperty(this.ccId, property);\n\t\t\t}\n\t\t\tif (typeof value !== \"boolean\") {\n\t\t\t\tthrowWrongValueType(\n\t\t\t\t\tthis.ccId,\n\t\t\t\t\tproperty,\n\t\t\t\t\t\"boolean\",\n\t\t\t\t\ttypeof value,\n\t\t\t\t);\n\t\t\t}\n\t\t\tconst duration = Duration.from(options?.transitionDuration);\n\t\t\treturn this.set(value, duration);\n\t\t};\n\t}\n\n\tprotected [SET_VALUE_HOOKS]: SetValueImplementationHooksFactory = (\n\t\t{ property },\n\t\tvalue,\n\t\toptions,\n\t) => {\n\t\tif (property === \"targetValue\") {\n\t\t\tconst currentValueValueId = BinarySwitchCCValues.currentValue\n\t\t\t\t.endpoint(this.endpoint.index);\n\n\t\t\treturn {\n\t\t\t\toptimisticallyUpdateRelatedValues: (\n\t\t\t\t\t_supervisedAndSuccessful,\n\t\t\t\t) => {\n\t\t\t\t\t// After setting targetValue, optimistically update currentValue\n\t\t\t\t\tif (this.isSinglecast()) {\n\t\t\t\t\t\tthis.tryGetValueDB()?.setValue(\n\t\t\t\t\t\t\tcurrentValueValueId,\n\t\t\t\t\t\t\tvalue,\n\t\t\t\t\t\t);\n\t\t\t\t\t} else if (this.isMulticast()) {\n\t\t\t\t\t\t// Figure out which nodes were affected by this command\n\t\t\t\t\t\tconst affectedNodes = this.endpoint.node.physicalNodes\n\t\t\t\t\t\t\t.filter((node) =>\n\t\t\t\t\t\t\t\tnode\n\t\t\t\t\t\t\t\t\t.getEndpoint(this.endpoint.index)\n\t\t\t\t\t\t\t\t\t?.supportsCC(this.ccId)\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t// and optimistically update the currentValue\n\t\t\t\t\t\tfor (const node of affectedNodes) {\n\t\t\t\t\t\t\tthis.host\n\t\t\t\t\t\t\t\t.tryGetValueDB(node.id)\n\t\t\t\t\t\t\t\t?.setValue(currentValueValueId, value);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t},\n\n\t\t\t\tverifyChanges: () => {\n\t\t\t\t\tif (this.isSinglecast()) {\n\t\t\t\t\t\t// We query currentValue instead of targetValue to make sure that unsolicited updates cancel the scheduled poll\n\t\t\t\t\t\tthis.schedulePoll(currentValueValueId, value, {\n\t\t\t\t\t\t\tduration: Duration.from(\n\t\t\t\t\t\t\t\toptions?.transitionDuration,\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t// on/off \"transitions\" are usually fast\n\t\t\t\t\t\t\ttransition: \"fast\",\n\t\t\t\t\t\t});\n\t\t\t\t\t} else {\n\t\t\t\t\t\t// For multicasts, do not schedule a refresh - this could cause a LOT of traffic\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t};\n\t\t}\n\t};\n\n\tprotected get [POLL_VALUE](): PollValueImplementation {\n\t\treturn async function(this: BinarySwitchCCAPI, { property }) {\n\t\t\tswitch (property) {\n\t\t\t\tcase \"currentValue\":\n\t\t\t\tcase \"targetValue\":\n\t\t\t\tcase \"duration\":\n\t\t\t\t\treturn (await this.get())?.[property];\n\t\t\t\tdefault:\n\t\t\t\t\tthrowUnsupportedProperty(this.ccId, property);\n\t\t\t}\n\t\t};\n\t}\n}\n\n@commandClass(CommandClasses[\"Binary Switch\"])\n@implementedVersion(2)\n@ccValues(BinarySwitchCCValues)\nexport class BinarySwitchCC extends CommandClass {\n\tdeclare ccCommand: BinarySwitchCommand;\n\n\tpublic async interview(\n\t\tctx: InterviewContext,\n\t): Promise<void> {\n\t\tconst node = this.getNode(ctx)!;\n\n\t\tctx.logNode(node.id, {\n\t\t\tendpoint: this.endpointIndex,\n\t\t\tmessage: `Interviewing ${this.ccName}...`,\n\t\t\tdirection: \"none\",\n\t\t});\n\n\t\tawait this.refreshValues(ctx);\n\n\t\t// Remember that the interview is complete\n\t\tthis.setInterviewComplete(ctx, true);\n\t}\n\n\tpublic async refreshValues(\n\t\tctx: RefreshValuesContext,\n\t): Promise<void> {\n\t\tconst node = this.getNode(ctx)!;\n\t\tconst endpoint = this.getEndpoint(ctx)!;\n\t\tconst api = CCAPI.create(\n\t\t\tCommandClasses[\"Binary Switch\"],\n\t\t\tctx,\n\t\t\tendpoint,\n\t\t).withOptions({\n\t\t\tpriority: MessagePriority.NodeQuery,\n\t\t});\n\n\t\t// Query the current state\n\t\tctx.logNode(node.id, {\n\t\t\tendpoint: this.endpointIndex,\n\t\t\tmessage: \"querying Binary Switch state...\",\n\t\t\tdirection: \"outbound\",\n\t\t});\n\n\t\tconst resp = await api.get();\n\t\tif (resp) {\n\t\t\tlet logMessage = `received Binary Switch state:\ncurrent value: ${resp.currentValue}`;\n\t\t\tif (resp.targetValue != undefined) {\n\t\t\t\tlogMessage += `\ntarget value: ${resp.targetValue}\nremaining duration: ${resp.duration?.toString() ?? \"undefined\"}`;\n\t\t\t}\n\t\t\tctx.logNode(node.id, {\n\t\t\t\tendpoint: this.endpointIndex,\n\t\t\t\tmessage: logMessage,\n\t\t\t\tdirection: \"inbound\",\n\t\t\t});\n\t\t}\n\t}\n\n\tpublic setMappedBasicValue(\n\t\tctx: GetValueDB,\n\t\tvalue: number,\n\t): boolean {\n\t\tthis.setValue(ctx, BinarySwitchCCValues.currentValue, value > 0);\n\t\treturn true;\n\t}\n}\n\n// @publicAPI\nexport interface BinarySwitchCCSetOptions {\n\ttargetValue: boolean;\n\tduration?: Duration | string;\n}\n\n@CCCommand(BinarySwitchCommand.Set)\n@useSupervision()\nexport class BinarySwitchCCSet extends BinarySwitchCC {\n\tpublic constructor(\n\t\toptions: WithAddress<BinarySwitchCCSetOptions>,\n\t) {\n\t\tsuper(options);\n\t\tthis.targetValue = options.targetValue;\n\t\tthis.duration = Duration.from(options.duration);\n\t}\n\n\tpublic static from(raw: CCRaw, ctx: CCParsingContext): BinarySwitchCCSet {\n\t\tvalidatePayload(raw.payload.length >= 1);\n\t\tconst targetValue = !!raw.payload[0];\n\t\tlet duration: Duration | undefined;\n\n\t\tif (raw.payload.length >= 2) {\n\t\t\tduration = Duration.parseSet(raw.payload[1]);\n\t\t}\n\n\t\treturn new this({\n\t\t\tnodeId: ctx.sourceNodeId,\n\t\t\ttargetValue,\n\t\t\tduration,\n\t\t});\n\t}\n\n\tpublic targetValue: boolean;\n\tpublic duration: Duration | undefined;\n\n\tpublic serialize(ctx: CCEncodingContext): Bytes {\n\t\tthis.payload = Bytes.from([\n\t\t\tthis.targetValue ? 0xff : 0x00,\n\t\t\t(this.duration ?? Duration.default()).serializeSet(),\n\t\t]);\n\n\t\tconst ccVersion = getEffectiveCCVersion(ctx, this);\n\t\tif (\n\t\t\tccVersion < 2 && ctx.getDeviceConfig?.(\n\t\t\t\tthis.nodeId as number,\n\t\t\t)?.compat?.encodeCCsUsingTargetVersion\n\t\t) {\n\t\t\t// When forcing CC version 1, only send the target value\n\t\t\tthis.payload = this.payload.subarray(0, 1);\n\t\t}\n\n\t\treturn super.serialize(ctx);\n\t}\n\n\tpublic toLogEntry(ctx?: GetValueDB): MessageOrCCLogEntry {\n\t\tconst message: MessageRecord = {\n\t\t\t\"target value\": this.targetValue,\n\t\t};\n\t\tif (this.duration != undefined) {\n\t\t\tmessage.duration = this.duration.toString();\n\t\t}\n\t\treturn {\n\t\t\t...super.toLogEntry(ctx),\n\t\t\tmessage,\n\t\t};\n\t}\n}\n\n// @publicAPI\nexport interface BinarySwitchCCReportOptions {\n\tcurrentValue?: MaybeUnknown<boolean>;\n\ttargetValue?: MaybeUnknown<boolean>;\n\tduration?: Duration | string;\n}\n\n@CCCommand(BinarySwitchCommand.Report)\n@ccValueProperty(\"currentValue\", BinarySwitchCCValues.currentValue)\n@ccValueProperty(\"targetValue\", BinarySwitchCCValues.targetValue)\n@ccValueProperty(\"duration\", BinarySwitchCCValues.duration)\nexport class BinarySwitchCCReport extends BinarySwitchCC {\n\tpublic constructor(\n\t\toptions: WithAddress<BinarySwitchCCReportOptions>,\n\t) {\n\t\tsuper(options);\n\n\t\tthis.currentValue = options.currentValue;\n\t\tthis.targetValue = options.targetValue;\n\t\tthis.duration = Duration.from(options.duration);\n\t}\n\n\tpublic static from(\n\t\traw: CCRaw,\n\t\tctx: CCParsingContext,\n\t): BinarySwitchCCReport {\n\t\tvalidatePayload(raw.payload.length >= 1);\n\t\tconst currentValue: MaybeUnknown<boolean> | undefined =\n\t\t\tparseMaybeBoolean(\n\t\t\t\traw.payload[0],\n\t\t\t);\n\t\tlet targetValue: MaybeUnknown<boolean> | undefined;\n\t\tlet duration: Duration | undefined;\n\n\t\tif (raw.payload.length >= 3) {\n\t\t\ttargetValue = parseMaybeBoolean(raw.payload[1]);\n\t\t\tduration = Duration.parseReport(raw.payload[2]);\n\t\t}\n\n\t\treturn new this({\n\t\t\tnodeId: ctx.sourceNodeId,\n\t\t\tcurrentValue,\n\t\t\ttargetValue,\n\t\t\tduration,\n\t\t});\n\t}\n\n\tpublic readonly currentValue: MaybeUnknown<boolean> | undefined;\n\n\tpublic readonly targetValue: MaybeUnknown<boolean> | undefined;\n\n\tpublic readonly duration: Duration | undefined;\n\n\tpublic serialize(ctx: CCEncodingContext): Bytes {\n\t\tthis.payload = Bytes.from([\n\t\t\tencodeMaybeBoolean(this.currentValue ?? UNKNOWN_STATE),\n\t\t]);\n\t\tif (this.targetValue !== undefined) {\n\t\t\tthis.payload = Bytes.concat([\n\t\t\t\tthis.payload,\n\t\t\t\tBytes.from([\n\t\t\t\t\tencodeMaybeBoolean(this.targetValue),\n\t\t\t\t\t(this.duration ?? Duration.default()).serializeReport(),\n\t\t\t\t]),\n\t\t\t]);\n\t\t}\n\t\treturn super.serialize(ctx);\n\t}\n\n\tpublic toLogEntry(ctx?: GetValueDB): MessageOrCCLogEntry {\n\t\tconst message: MessageRecord = {\n\t\t\t\"current value\": maybeUnknownToString(this.currentValue),\n\t\t};\n\t\tif (this.targetValue !== undefined) {\n\t\t\tmessage[\"target value\"] = maybeUnknownToString(this.targetValue);\n\t\t}\n\t\tif (this.duration != undefined) {\n\t\t\tmessage.duration = this.duration.toString();\n\t\t}\n\t\treturn {\n\t\t\t...super.toLogEntry(ctx),\n\t\t\tmessage,\n\t\t};\n\t}\n}\n\n@CCCommand(BinarySwitchCommand.Get)\n@expectedCCResponse(BinarySwitchCCReport)\nexport class BinarySwitchCCGet extends BinarySwitchCC {}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,kBAgBO;AAMP,IAAAA,eAAsB;AAEtB,iBAUO;AACP,0BAMO;AACP,oCASO;AACP,oBAAkB;AAClB,mBAAoC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAE7B,MAAM,uBAAuB,OAAO,OAAO;EACjD,GAAG,gBAAE,qBAAqB,2BAAe,eAAe,GAAG;IAC1D,GAAG,gBAAE,eACJ,gBACA;MACC,GAAG,0BAAc;MACjB,OAAO;KACE;IAGX,GAAG,gBAAE,eACJ,eACA;MACC,GAAG,0BAAc;MACjB,OAAO;MACP,oBAAoB,CAAC,oBAAoB;KAChC;IAGX,GAAG,gBAAE,eACJ,YACA;MACC,GAAG,0BAAc;MACjB,OAAO;OAER,EAAE,YAAY,EAAC,CAAW;GAE3B;CACD;IAGY,qBAAiB,MAAA;8BAD7B,mCAAI,2BAAe,eAAe,CAAC,CAAC;;;;oBACE;yCAAA,YAAK;;;;;;AAA5C,mBAAA,MAAA,mBAAA,EAAA,OAAA,WAAA,GAAA,kBAAA,EAAA,MAAA,SAAA,MAAA,WAAA,MAAA,UAAA,UAAA,GAAA,MAAA,uBAAA;;;AAAa,wBAAA,YAAA,uBAAA;;IACL,gBAAgB,KAAwB;AAC9C,cAAQ,KAAK;QACZ,KAAK,iCAAoB;AACxB,iBAAO,KAAK,aAAY;QACzB,KAAK,iCAAoB;AACxB,iBAAO;MACT;AACA,aAAO,MAAM,gBAAgB,GAAG;IACjC;;IAGO,MAAM,MAAG;AACf,WAAK,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AO,GAAI,aAAY;OAClD;AAED,YAAM,gBAAY,2CAAsB,KAAK,IAAI;AACjD,UACC,YAAY,KAAK,IAAI,kBACpB,KAAK,MAAgB,GACnB,QAAQ,6BACV;AAED,aAAK,UAAU,KAAK,QAAQ,SAAS,GAAG,CAAC;MAC1C;
|
|
4
|
+
"sourcesContent": ["import {\n\tCommandClasses,\n\tDuration,\n\ttype MaybeNotKnown,\n\ttype MaybeUnknown,\n\ttype MessageOrCCLogEntry,\n\tMessagePriority,\n\ttype MessageRecord,\n\ttype SupervisionResult,\n\tUNKNOWN_STATE,\n\tValueMetadata,\n\ttype WithAddress,\n\tencodeMaybeBoolean,\n\tmaybeUnknownToString,\n\tparseMaybeBoolean,\n\tvalidatePayload,\n} from \"@zwave-js/core/safe\";\nimport type {\n\tCCEncodingContext,\n\tCCParsingContext,\n\tGetValueDB,\n} from \"@zwave-js/host/safe\";\nimport { Bytes } from \"@zwave-js/shared/safe\";\nimport { validateArgs } from \"@zwave-js/transformers\";\nimport {\n\tCCAPI,\n\tPOLL_VALUE,\n\ttype PollValueImplementation,\n\tSET_VALUE,\n\tSET_VALUE_HOOKS,\n\ttype SetValueImplementation,\n\ttype SetValueImplementationHooksFactory,\n\tthrowUnsupportedProperty,\n\tthrowWrongValueType,\n} from \"../lib/API.js\";\nimport {\n\ttype CCRaw,\n\tCommandClass,\n\ttype InterviewContext,\n\ttype RefreshValuesContext,\n\tgetEffectiveCCVersion,\n} from \"../lib/CommandClass.js\";\nimport {\n\tAPI,\n\tCCCommand,\n\tccValueProperty,\n\tccValues,\n\tcommandClass,\n\texpectedCCResponse,\n\timplementedVersion,\n\tuseSupervision,\n} from \"../lib/CommandClassDecorators.js\";\nimport { V } from \"../lib/Values.js\";\nimport { BinarySwitchCommand } from \"../lib/_Types.js\";\n\nexport const BinarySwitchCCValues = Object.freeze({\n\t...V.defineStaticCCValues(CommandClasses[\"Binary Switch\"], {\n\t\t...V.staticProperty(\n\t\t\t\"currentValue\",\n\t\t\t{\n\t\t\t\t...ValueMetadata.ReadOnlyBoolean,\n\t\t\t\tlabel: \"Current value\",\n\t\t\t} as const,\n\t\t),\n\n\t\t...V.staticProperty(\n\t\t\t\"targetValue\",\n\t\t\t{\n\t\t\t\t...ValueMetadata.Boolean,\n\t\t\t\tlabel: \"Target value\",\n\t\t\t\tvalueChangeOptions: [\"transitionDuration\"],\n\t\t\t} as const,\n\t\t),\n\n\t\t...V.staticProperty(\n\t\t\t\"duration\",\n\t\t\t{\n\t\t\t\t...ValueMetadata.ReadOnlyDuration,\n\t\t\t\tlabel: \"Remaining duration\",\n\t\t\t} as const,\n\t\t\t{ minVersion: 2 } as const,\n\t\t),\n\t}),\n});\n\n@API(CommandClasses[\"Binary Switch\"])\nexport class BinarySwitchCCAPI extends CCAPI {\n\tpublic supportsCommand(cmd: BinarySwitchCommand): MaybeNotKnown<boolean> {\n\t\tswitch (cmd) {\n\t\t\tcase BinarySwitchCommand.Get:\n\t\t\t\treturn this.isSinglecast();\n\t\t\tcase BinarySwitchCommand.Set:\n\t\t\t\treturn true;\n\t\t}\n\t\treturn super.supportsCommand(cmd);\n\t}\n\n\t// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types\n\tpublic async get() {\n\t\tthis.assertSupportsCommand(\n\t\t\tBinarySwitchCommand,\n\t\t\tBinarySwitchCommand.Get,\n\t\t);\n\n\t\tconst cc = new BinarySwitchCCGet({\n\t\t\tnodeId: this.endpoint.nodeId,\n\t\t\tendpointIndex: this.endpoint.index,\n\t\t});\n\t\tconst response = await this.host.sendCommand<BinarySwitchCCReport>(\n\t\t\tcc,\n\t\t\tthis.commandOptions,\n\t\t);\n\t\tif (response) {\n\t\t\treturn {\n\t\t\t\t// interpret unknown values as false\n\t\t\t\tcurrentValue: response.currentValue || false,\n\t\t\t\ttargetValue: response.targetValue,\n\t\t\t\tduration: response.duration,\n\t\t\t};\n\t\t}\n\t}\n\n\t/**\n\t * Sets the switch to the given value\n\t * @param targetValue The target value to set\n\t * @param duration The duration after which the target value should be reached. Can be a Duration instance or a user-friendly duration string like `\"1m17s\"`. Only supported in V2 and above.\n\t */\n\t@validateArgs()\n\tpublic async set(\n\t\ttargetValue: boolean,\n\t\tduration?: Duration | string,\n\t): Promise<SupervisionResult | undefined> {\n\t\tthis.assertSupportsCommand(\n\t\t\tBinarySwitchCommand,\n\t\t\tBinarySwitchCommand.Set,\n\t\t);\n\n\t\tconst cc = new BinarySwitchCCSet({\n\t\t\tnodeId: this.endpoint.nodeId,\n\t\t\tendpointIndex: this.endpoint.index,\n\t\t\ttargetValue,\n\t\t\tduration,\n\t\t});\n\t\treturn this.host.sendCommand(cc, this.commandOptions);\n\t}\n\n\tprotected override get [SET_VALUE](): SetValueImplementation {\n\t\treturn async function(\n\t\t\tthis: BinarySwitchCCAPI,\n\t\t\t{ property },\n\t\t\tvalue,\n\t\t\toptions,\n\t\t) {\n\t\t\tif (property !== \"targetValue\") {\n\t\t\t\tthrowUnsupportedProperty(this.ccId, property);\n\t\t\t}\n\t\t\tif (typeof value !== \"boolean\") {\n\t\t\t\tthrowWrongValueType(\n\t\t\t\t\tthis.ccId,\n\t\t\t\t\tproperty,\n\t\t\t\t\t\"boolean\",\n\t\t\t\t\ttypeof value,\n\t\t\t\t);\n\t\t\t}\n\t\t\tconst duration = Duration.from(options?.transitionDuration);\n\t\t\treturn this.set(value, duration);\n\t\t};\n\t}\n\n\tprotected [SET_VALUE_HOOKS]: SetValueImplementationHooksFactory = (\n\t\t{ property },\n\t\tvalue,\n\t\toptions,\n\t) => {\n\t\tif (property === \"targetValue\") {\n\t\t\tconst currentValueValueId = BinarySwitchCCValues.currentValue\n\t\t\t\t.endpoint(this.endpoint.index);\n\n\t\t\treturn {\n\t\t\t\toptimisticallyUpdateRelatedValues: (\n\t\t\t\t\t_supervisedAndSuccessful,\n\t\t\t\t) => {\n\t\t\t\t\t// After setting targetValue, optimistically update currentValue\n\t\t\t\t\tif (this.isSinglecast()) {\n\t\t\t\t\t\tthis.tryGetValueDB()?.setValue(\n\t\t\t\t\t\t\tcurrentValueValueId,\n\t\t\t\t\t\t\tvalue,\n\t\t\t\t\t\t);\n\t\t\t\t\t} else if (this.isMulticast()) {\n\t\t\t\t\t\t// Figure out which nodes were affected by this command\n\t\t\t\t\t\tconst affectedNodes = this.endpoint.node.physicalNodes\n\t\t\t\t\t\t\t.filter((node) =>\n\t\t\t\t\t\t\t\tnode\n\t\t\t\t\t\t\t\t\t.getEndpoint(this.endpoint.index)\n\t\t\t\t\t\t\t\t\t?.supportsCC(this.ccId)\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t// and optimistically update the currentValue\n\t\t\t\t\t\tfor (const node of affectedNodes) {\n\t\t\t\t\t\t\tthis.host\n\t\t\t\t\t\t\t\t.tryGetValueDB(node.id)\n\t\t\t\t\t\t\t\t?.setValue(currentValueValueId, value);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t},\n\n\t\t\t\tverifyChanges: () => {\n\t\t\t\t\tif (this.isSinglecast()) {\n\t\t\t\t\t\t// We query currentValue instead of targetValue to make sure that unsolicited updates cancel the scheduled poll\n\t\t\t\t\t\tthis.schedulePoll(currentValueValueId, value, {\n\t\t\t\t\t\t\tduration: Duration.from(\n\t\t\t\t\t\t\t\toptions?.transitionDuration,\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t// on/off \"transitions\" are usually fast\n\t\t\t\t\t\t\ttransition: \"fast\",\n\t\t\t\t\t\t});\n\t\t\t\t\t} else {\n\t\t\t\t\t\t// For multicasts, do not schedule a refresh - this could cause a LOT of traffic\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t};\n\t\t}\n\t};\n\n\tprotected get [POLL_VALUE](): PollValueImplementation {\n\t\treturn async function(this: BinarySwitchCCAPI, { property }) {\n\t\t\tswitch (property) {\n\t\t\t\tcase \"currentValue\":\n\t\t\t\tcase \"targetValue\":\n\t\t\t\tcase \"duration\":\n\t\t\t\t\treturn (await this.get())?.[property];\n\t\t\t\tdefault:\n\t\t\t\t\tthrowUnsupportedProperty(this.ccId, property);\n\t\t\t}\n\t\t};\n\t}\n}\n\n@commandClass(CommandClasses[\"Binary Switch\"])\n@implementedVersion(2)\n@ccValues(BinarySwitchCCValues)\nexport class BinarySwitchCC extends CommandClass {\n\tdeclare ccCommand: BinarySwitchCommand;\n\n\tpublic async interview(\n\t\tctx: InterviewContext,\n\t): Promise<void> {\n\t\tconst node = this.getNode(ctx)!;\n\n\t\tctx.logNode(node.id, {\n\t\t\tendpoint: this.endpointIndex,\n\t\t\tmessage: `Interviewing ${this.ccName}...`,\n\t\t\tdirection: \"none\",\n\t\t});\n\n\t\tawait this.refreshValues(ctx);\n\n\t\t// Remember that the interview is complete\n\t\tthis.setInterviewComplete(ctx, true);\n\t}\n\n\tpublic async refreshValues(\n\t\tctx: RefreshValuesContext,\n\t): Promise<void> {\n\t\tconst node = this.getNode(ctx)!;\n\t\tconst endpoint = this.getEndpoint(ctx)!;\n\t\tconst api = CCAPI.create(\n\t\t\tCommandClasses[\"Binary Switch\"],\n\t\t\tctx,\n\t\t\tendpoint,\n\t\t).withOptions({\n\t\t\tpriority: MessagePriority.NodeQuery,\n\t\t});\n\n\t\t// Query the current state\n\t\tctx.logNode(node.id, {\n\t\t\tendpoint: this.endpointIndex,\n\t\t\tmessage: \"querying Binary Switch state...\",\n\t\t\tdirection: \"outbound\",\n\t\t});\n\n\t\tconst resp = await api.get();\n\t\tif (resp) {\n\t\t\tlet logMessage = `received Binary Switch state:\ncurrent value: ${resp.currentValue}`;\n\t\t\tif (resp.targetValue != undefined) {\n\t\t\t\tlogMessage += `\ntarget value: ${resp.targetValue}\nremaining duration: ${resp.duration?.toString() ?? \"undefined\"}`;\n\t\t\t}\n\t\t\tctx.logNode(node.id, {\n\t\t\t\tendpoint: this.endpointIndex,\n\t\t\t\tmessage: logMessage,\n\t\t\t\tdirection: \"inbound\",\n\t\t\t});\n\t\t}\n\t}\n\n\tpublic setMappedBasicValue(\n\t\tctx: GetValueDB,\n\t\tvalue: number,\n\t): boolean {\n\t\tthis.setValue(ctx, BinarySwitchCCValues.currentValue, value > 0);\n\t\treturn true;\n\t}\n}\n\n// @publicAPI\nexport interface BinarySwitchCCSetOptions {\n\ttargetValue: boolean;\n\tduration?: Duration | string;\n}\n\n@CCCommand(BinarySwitchCommand.Set)\n@useSupervision()\nexport class BinarySwitchCCSet extends BinarySwitchCC {\n\tpublic constructor(\n\t\toptions: WithAddress<BinarySwitchCCSetOptions>,\n\t) {\n\t\tsuper(options);\n\t\tthis.targetValue = options.targetValue;\n\t\tthis.duration = Duration.from(options.duration);\n\t}\n\n\tpublic static from(raw: CCRaw, ctx: CCParsingContext): BinarySwitchCCSet {\n\t\tvalidatePayload(raw.payload.length >= 1);\n\t\tconst targetValue = !!raw.payload[0];\n\t\tlet duration: Duration | undefined;\n\n\t\tif (raw.payload.length >= 2) {\n\t\t\tduration = Duration.parseSet(raw.payload[1]);\n\t\t}\n\n\t\treturn new this({\n\t\t\tnodeId: ctx.sourceNodeId,\n\t\t\ttargetValue,\n\t\t\tduration,\n\t\t});\n\t}\n\n\tpublic targetValue: boolean;\n\tpublic duration: Duration | undefined;\n\n\tpublic serialize(ctx: CCEncodingContext): Bytes {\n\t\tthis.payload = Bytes.from([\n\t\t\tthis.targetValue ? 0xff : 0x00,\n\t\t\t(this.duration ?? Duration.default()).serializeSet(),\n\t\t]);\n\n\t\tconst ccVersion = getEffectiveCCVersion(ctx, this);\n\t\tif (\n\t\t\tccVersion < 2 && ctx.getDeviceConfig?.(\n\t\t\t\tthis.nodeId as number,\n\t\t\t)?.compat?.encodeCCsUsingTargetVersion\n\t\t) {\n\t\t\t// When forcing CC version 1, only send the target value\n\t\t\tthis.payload = this.payload.subarray(0, 1);\n\t\t}\n\n\t\t// eslint-disable-next-line @typescript-eslint/no-deprecated\n\t\treturn super.serialize(ctx);\n\t}\n\n\tpublic toLogEntry(ctx?: GetValueDB): MessageOrCCLogEntry {\n\t\tconst message: MessageRecord = {\n\t\t\t\"target value\": this.targetValue,\n\t\t};\n\t\tif (this.duration != undefined) {\n\t\t\tmessage.duration = this.duration.toString();\n\t\t}\n\t\treturn {\n\t\t\t...super.toLogEntry(ctx),\n\t\t\tmessage,\n\t\t};\n\t}\n}\n\n// @publicAPI\nexport interface BinarySwitchCCReportOptions {\n\tcurrentValue?: MaybeUnknown<boolean>;\n\ttargetValue?: MaybeUnknown<boolean>;\n\tduration?: Duration | string;\n}\n\n@CCCommand(BinarySwitchCommand.Report)\n@ccValueProperty(\"currentValue\", BinarySwitchCCValues.currentValue)\n@ccValueProperty(\"targetValue\", BinarySwitchCCValues.targetValue)\n@ccValueProperty(\"duration\", BinarySwitchCCValues.duration)\nexport class BinarySwitchCCReport extends BinarySwitchCC {\n\tpublic constructor(\n\t\toptions: WithAddress<BinarySwitchCCReportOptions>,\n\t) {\n\t\tsuper(options);\n\n\t\tthis.currentValue = options.currentValue;\n\t\tthis.targetValue = options.targetValue;\n\t\tthis.duration = Duration.from(options.duration);\n\t}\n\n\tpublic static from(\n\t\traw: CCRaw,\n\t\tctx: CCParsingContext,\n\t): BinarySwitchCCReport {\n\t\tvalidatePayload(raw.payload.length >= 1);\n\t\tconst currentValue: MaybeUnknown<boolean> | undefined =\n\t\t\tparseMaybeBoolean(\n\t\t\t\traw.payload[0],\n\t\t\t);\n\t\tlet targetValue: MaybeUnknown<boolean> | undefined;\n\t\tlet duration: Duration | undefined;\n\n\t\tif (raw.payload.length >= 3) {\n\t\t\ttargetValue = parseMaybeBoolean(raw.payload[1]);\n\t\t\tduration = Duration.parseReport(raw.payload[2]);\n\t\t}\n\n\t\treturn new this({\n\t\t\tnodeId: ctx.sourceNodeId,\n\t\t\tcurrentValue,\n\t\t\ttargetValue,\n\t\t\tduration,\n\t\t});\n\t}\n\n\tpublic readonly currentValue: MaybeUnknown<boolean> | undefined;\n\n\tpublic readonly targetValue: MaybeUnknown<boolean> | undefined;\n\n\tpublic readonly duration: Duration | undefined;\n\n\tpublic serialize(ctx: CCEncodingContext): Bytes {\n\t\tthis.payload = Bytes.from([\n\t\t\tencodeMaybeBoolean(this.currentValue ?? UNKNOWN_STATE),\n\t\t]);\n\t\tif (this.targetValue !== undefined) {\n\t\t\tthis.payload = Bytes.concat([\n\t\t\t\tthis.payload,\n\t\t\t\tBytes.from([\n\t\t\t\t\tencodeMaybeBoolean(this.targetValue),\n\t\t\t\t\t(this.duration ?? Duration.default()).serializeReport(),\n\t\t\t\t]),\n\t\t\t]);\n\t\t}\n\t\t// eslint-disable-next-line @typescript-eslint/no-deprecated\n\t\treturn super.serialize(ctx);\n\t}\n\n\tpublic toLogEntry(ctx?: GetValueDB): MessageOrCCLogEntry {\n\t\tconst message: MessageRecord = {\n\t\t\t\"current value\": maybeUnknownToString(this.currentValue),\n\t\t};\n\t\tif (this.targetValue !== undefined) {\n\t\t\tmessage[\"target value\"] = maybeUnknownToString(this.targetValue);\n\t\t}\n\t\tif (this.duration != undefined) {\n\t\t\tmessage.duration = this.duration.toString();\n\t\t}\n\t\treturn {\n\t\t\t...super.toLogEntry(ctx),\n\t\t\tmessage,\n\t\t};\n\t}\n}\n\n@CCCommand(BinarySwitchCommand.Get)\n@expectedCCResponse(BinarySwitchCCReport)\nexport class BinarySwitchCCGet extends BinarySwitchCC {}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,kBAgBO;AAMP,IAAAA,eAAsB;AAEtB,iBAUO;AACP,0BAMO;AACP,oCASO;AACP,oBAAkB;AAClB,mBAAoC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAE7B,MAAM,uBAAuB,OAAO,OAAO;EACjD,GAAG,gBAAE,qBAAqB,2BAAe,eAAe,GAAG;IAC1D,GAAG,gBAAE,eACJ,gBACA;MACC,GAAG,0BAAc;MACjB,OAAO;KACE;IAGX,GAAG,gBAAE,eACJ,eACA;MACC,GAAG,0BAAc;MACjB,OAAO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F;;;;IAKY,qBAAiB,MAAA;8BAF7B,yCAAU,iCAAoB,GAAG,OACjC,kDAAmB,oBAAoB,CAAC;;;;oBACF;yCAAA,YAAc;;;;;;AAArD,mBAAA,MAAA,mBAAA,EAAA,OAAA,WAAA,GAAA,kBAAA,EAAA,MAAA,SAAA,MAAA,WAAA,MAAA,UAAA,UAAA,GAAA,MAAA,uBAAA;;;AAAa,wBAAA,YAAA,uBAAA;;;;;",
|
|
6
6
|
"names": ["import_safe"]
|
|
7
7
|
}
|
|
@@ -20,9 +20,13 @@ export interface CRC16CCCommandEncapsulationOptions {
|
|
|
20
20
|
}
|
|
21
21
|
export declare class CRC16CCCommandEncapsulation extends CRC16CC {
|
|
22
22
|
constructor(options: WithAddress<CRC16CCCommandEncapsulationOptions>);
|
|
23
|
+
/** @deprecated Use {@link fromAsync} instead */
|
|
23
24
|
static from(raw: CCRaw, ctx: CCParsingContext): CRC16CCCommandEncapsulation;
|
|
25
|
+
static fromAsync(raw: CCRaw, ctx: CCParsingContext): Promise<CRC16CCCommandEncapsulation>;
|
|
24
26
|
encapsulated: CommandClass;
|
|
27
|
+
/** @deprecated Use {@link serializeAsync} instead */
|
|
25
28
|
serialize(ctx: CCEncodingContext): Bytes;
|
|
29
|
+
serializeAsync(ctx: CCEncodingContext): Promise<Bytes>;
|
|
26
30
|
protected computeEncapsulationOverhead(): number;
|
|
27
31
|
toLogEntry(ctx?: GetValueDB): MessageOrCCLogEntry;
|
|
28
32
|
}
|
package/build/cjs/cc/CRC16CC.js
CHANGED
|
@@ -164,6 +164,7 @@ let CRC16CCCommandEncapsulation = (() => {
|
|
|
164
164
|
this.encapsulated = options.encapsulated;
|
|
165
165
|
this.encapsulated.encapsulatingCC = this;
|
|
166
166
|
}
|
|
167
|
+
/** @deprecated Use {@link fromAsync} instead */
|
|
167
168
|
static from(raw, ctx) {
|
|
168
169
|
(0, import_safe.validatePayload)(raw.payload.length >= 3);
|
|
169
170
|
const ccBuffer = raw.payload.subarray(0, -2);
|
|
@@ -177,7 +178,21 @@ let CRC16CCCommandEncapsulation = (() => {
|
|
|
177
178
|
encapsulated
|
|
178
179
|
});
|
|
179
180
|
}
|
|
181
|
+
static async fromAsync(raw, ctx) {
|
|
182
|
+
(0, import_safe.validatePayload)(raw.payload.length >= 3);
|
|
183
|
+
const ccBuffer = raw.payload.subarray(0, -2);
|
|
184
|
+
let expectedCRC = (0, import_safe.CRC16_CCITT)(headerBuffer);
|
|
185
|
+
expectedCRC = (0, import_safe.CRC16_CCITT)(ccBuffer, expectedCRC);
|
|
186
|
+
const actualCRC = raw.payload.readUInt16BE(raw.payload.length - 2);
|
|
187
|
+
(0, import_safe.validatePayload)(expectedCRC === actualCRC);
|
|
188
|
+
const encapsulated = await import_CommandClass.CommandClass.parseAsync(ccBuffer, ctx);
|
|
189
|
+
return new this({
|
|
190
|
+
nodeId: ctx.sourceNodeId,
|
|
191
|
+
encapsulated
|
|
192
|
+
});
|
|
193
|
+
}
|
|
180
194
|
encapsulated;
|
|
195
|
+
/** @deprecated Use {@link serializeAsync} instead */
|
|
181
196
|
serialize(ctx) {
|
|
182
197
|
const commandBuffer = this.encapsulated.serialize(ctx);
|
|
183
198
|
this.payload = import_safe2.Bytes.concat([commandBuffer, new import_safe2.Bytes(2)]);
|
|
@@ -186,6 +201,14 @@ let CRC16CCCommandEncapsulation = (() => {
|
|
|
186
201
|
this.payload.writeUInt16BE(crc, this.payload.length - 2);
|
|
187
202
|
return super.serialize(ctx);
|
|
188
203
|
}
|
|
204
|
+
async serializeAsync(ctx) {
|
|
205
|
+
const commandBuffer = await this.encapsulated.serializeAsync(ctx);
|
|
206
|
+
this.payload = import_safe2.Bytes.concat([commandBuffer, new import_safe2.Bytes(2)]);
|
|
207
|
+
let crc = (0, import_safe.CRC16_CCITT)(headerBuffer);
|
|
208
|
+
crc = (0, import_safe.CRC16_CCITT)(commandBuffer, crc);
|
|
209
|
+
this.payload.writeUInt16BE(crc, this.payload.length - 2);
|
|
210
|
+
return super.serializeAsync(ctx);
|
|
211
|
+
}
|
|
189
212
|
computeEncapsulationOverhead() {
|
|
190
213
|
return super.computeEncapsulationOverhead() + 2;
|
|
191
214
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/cc/CRC16CC.ts"],
|
|
4
|
-
"sourcesContent": ["import {\n\tCRC16_CCITT,\n\tCommandClasses,\n\tEncapsulationFlags,\n\ttype MaybeNotKnown,\n\ttype MessageOrCCLogEntry,\n\ttype WithAddress,\n\tvalidatePayload,\n} from \"@zwave-js/core/safe\";\nimport type {\n\tCCEncodingContext,\n\tCCParsingContext,\n\tGetValueDB,\n} from \"@zwave-js/host/safe\";\nimport { CCAPI } from \"../lib/API.js\";\nimport { type CCRaw, CommandClass } from \"../lib/CommandClass.js\";\nimport {\n\tAPI,\n\tCCCommand,\n\tcommandClass,\n\texpectedCCResponse,\n\timplementedVersion,\n} from \"../lib/CommandClassDecorators.js\";\n\nimport { Bytes } from \"@zwave-js/shared/safe\";\nimport { CRC16Command } from \"../lib/_Types.js\";\n\nconst headerBuffer = Bytes.from([\n\tCommandClasses[\"CRC-16 Encapsulation\"],\n\tCRC16Command.CommandEncapsulation,\n]);\n\n// @noSetValueAPI\n// @noInterview This CC only has a single encapsulation command\n\n// Encapsulation CCs are used internally and too frequently that we\n// want to pay the cost of validating each call\n/* eslint-disable @zwave-js/ccapi-validate-args */\n\n@API(CommandClasses[\"CRC-16 Encapsulation\"])\nexport class CRC16CCAPI extends CCAPI {\n\tpublic supportsCommand(_cmd: CRC16Command): MaybeNotKnown<boolean> {\n\t\t// switch (cmd) {\n\t\t// \tcase CRC16Command.CommandEncapsulation:\n\t\treturn true; // This is mandatory\n\t\t// }\n\t\t// return super.supportsCommand(cmd);\n\t}\n\n\tpublic async sendEncapsulated(encapsulatedCC: CommandClass): Promise<void> {\n\t\tthis.assertSupportsCommand(\n\t\t\tCRC16Command,\n\t\t\tCRC16Command.CommandEncapsulation,\n\t\t);\n\n\t\tconst cc = new CRC16CCCommandEncapsulation({\n\t\t\tnodeId: this.endpoint.nodeId,\n\t\t\tendpointIndex: this.endpoint.index,\n\t\t\tencapsulated: encapsulatedCC,\n\t\t});\n\t\tawait this.host.sendCommand(cc, this.commandOptions);\n\t}\n}\n\n@commandClass(CommandClasses[\"CRC-16 Encapsulation\"])\n@implementedVersion(1)\nexport class CRC16CC extends CommandClass {\n\tdeclare ccCommand: CRC16Command;\n\n\t/** Tests if a command should be supervised and thus requires encapsulation */\n\tpublic static requiresEncapsulation(cc: CommandClass): boolean {\n\t\treturn (\n\t\t\t!!(cc.encapsulationFlags & EncapsulationFlags.CRC16)\n\t\t\t&& !(cc instanceof CRC16CCCommandEncapsulation)\n\t\t);\n\t}\n\n\t/** Encapsulates a command in a CRC-16 CC */\n\tpublic static encapsulate(\n\t\tcc: CommandClass,\n\t): CRC16CCCommandEncapsulation {\n\t\tconst ret = new CRC16CCCommandEncapsulation({\n\t\t\tnodeId: cc.nodeId,\n\t\t\tencapsulated: cc,\n\t\t});\n\n\t\t// Copy the encapsulation flags from the encapsulated command\n\t\t// but omit CRC-16, since we're doing that right now\n\t\tret.encapsulationFlags = cc.encapsulationFlags\n\t\t\t& ~EncapsulationFlags.CRC16;\n\n\t\treturn ret;\n\t}\n}\n\n// @publicAPI\nexport interface CRC16CCCommandEncapsulationOptions {\n\tencapsulated: CommandClass;\n}\n\nfunction getCCResponseForCommandEncapsulation(\n\tsent: CRC16CCCommandEncapsulation,\n) {\n\tif (sent.encapsulated?.expectsCCResponse()) {\n\t\treturn CRC16CCCommandEncapsulation;\n\t}\n}\n\n@CCCommand(CRC16Command.CommandEncapsulation)\n@expectedCCResponse(\n\tgetCCResponseForCommandEncapsulation,\n\t() => \"checkEncapsulated\",\n)\nexport class CRC16CCCommandEncapsulation extends CRC16CC {\n\tpublic constructor(\n\t\toptions: WithAddress<CRC16CCCommandEncapsulationOptions>,\n\t) {\n\t\tsuper(options);\n\t\tthis.encapsulated = options.encapsulated;\n\t\tthis.encapsulated.encapsulatingCC = this as any;\n\t}\n\n\tpublic static from(\n\t\traw: CCRaw,\n\t\tctx: CCParsingContext,\n\t): CRC16CCCommandEncapsulation {\n\t\tvalidatePayload(raw.payload.length >= 3);\n\n\t\tconst ccBuffer = raw.payload.subarray(0, -2);\n\n\t\t// Verify the CRC\n\t\tlet expectedCRC = CRC16_CCITT(headerBuffer);\n\t\texpectedCRC = CRC16_CCITT(ccBuffer, expectedCRC);\n\t\tconst actualCRC = raw.payload.readUInt16BE(\n\t\t\traw.payload.length - 2,\n\t\t);\n\t\tvalidatePayload(expectedCRC === actualCRC);\n\n\t\tconst encapsulated = CommandClass.parse(ccBuffer, ctx);\n\t\treturn new this({\n\t\t\tnodeId: ctx.sourceNodeId,\n\t\t\tencapsulated,\n\t\t});\n\t}\n\n\tpublic encapsulated: CommandClass;\n\n\tpublic serialize(ctx: CCEncodingContext): Bytes {\n\t\tconst commandBuffer = this.encapsulated.serialize(ctx);\n\t\t// Reserve 2 bytes for the CRC\n\t\tthis.payload = Bytes.concat([commandBuffer, new Bytes(2)]);\n\n\t\t// Compute and save the CRC16 in the payload\n\t\t// The CC header is included in the CRC computation\n\t\tlet crc = CRC16_CCITT(headerBuffer);\n\t\tcrc = CRC16_CCITT(commandBuffer, crc);\n\t\tthis.payload.writeUInt16BE(crc, this.payload.length - 2);\n\n\t\treturn super.serialize(ctx);\n\t}\n\n\tprotected computeEncapsulationOverhead(): number {\n\t\t// CRC16 adds two bytes CRC to the default overhead\n\t\treturn super.computeEncapsulationOverhead() + 2;\n\t}\n\n\tpublic toLogEntry(ctx?: GetValueDB): MessageOrCCLogEntry {\n\t\treturn {\n\t\t\t...super.toLogEntry(ctx),\n\t\t\t// Hide the default payload line\n\t\t\tmessage: undefined,\n\t\t};\n\t}\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;AAAA,kBAQO;AAMP,iBAAsB;AACtB,0BAAyC;AACz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C;AAEjC,MAAI,KAAK,cAAc,kBAAiB,GAAI;AAC3C,WAAO;EACR;AACD;IAOa,+BAA2B,MAAA;8BALvC,yCAAU,0BAAa,oBAAoB,OAC3C,kDACA,sCACA,MAAM,mBAAmB,CACzB;;;;oBACgD;mDAAA,YAAO;;;;;;AAAxD,mBAAA,MAAA,mBAAA,EAAA,OAAA,WAAA,GAAA,kBAAA,EAAA,MAAA,SAAA,MAAA,WAAA,MAAA,UAAA,UAAA,GAAA,MAAA,uBAAA;;;AAAa,wBAAA,YAAA,uBAAA;;IACZ,YACC,SAAwD;AAExD,YAAM,OAAO;AACb,WAAK,eAAe,QAAQ;AAC5B,WAAK,aAAa,kBAAkB;IACrC
|
|
4
|
+
"sourcesContent": ["import {\n\tCRC16_CCITT,\n\tCommandClasses,\n\tEncapsulationFlags,\n\ttype MaybeNotKnown,\n\ttype MessageOrCCLogEntry,\n\ttype WithAddress,\n\tvalidatePayload,\n} from \"@zwave-js/core/safe\";\nimport type {\n\tCCEncodingContext,\n\tCCParsingContext,\n\tGetValueDB,\n} from \"@zwave-js/host/safe\";\nimport { CCAPI } from \"../lib/API.js\";\nimport { type CCRaw, CommandClass } from \"../lib/CommandClass.js\";\nimport {\n\tAPI,\n\tCCCommand,\n\tcommandClass,\n\texpectedCCResponse,\n\timplementedVersion,\n} from \"../lib/CommandClassDecorators.js\";\n\nimport { Bytes } from \"@zwave-js/shared/safe\";\nimport { CRC16Command } from \"../lib/_Types.js\";\n\nconst headerBuffer = Bytes.from([\n\tCommandClasses[\"CRC-16 Encapsulation\"],\n\tCRC16Command.CommandEncapsulation,\n]);\n\n// @noSetValueAPI\n// @noInterview This CC only has a single encapsulation command\n\n// Encapsulation CCs are used internally and too frequently that we\n// want to pay the cost of validating each call\n/* eslint-disable @zwave-js/ccapi-validate-args */\n\n@API(CommandClasses[\"CRC-16 Encapsulation\"])\nexport class CRC16CCAPI extends CCAPI {\n\tpublic supportsCommand(_cmd: CRC16Command): MaybeNotKnown<boolean> {\n\t\t// switch (cmd) {\n\t\t// \tcase CRC16Command.CommandEncapsulation:\n\t\treturn true; // This is mandatory\n\t\t// }\n\t\t// return super.supportsCommand(cmd);\n\t}\n\n\tpublic async sendEncapsulated(encapsulatedCC: CommandClass): Promise<void> {\n\t\tthis.assertSupportsCommand(\n\t\t\tCRC16Command,\n\t\t\tCRC16Command.CommandEncapsulation,\n\t\t);\n\n\t\tconst cc = new CRC16CCCommandEncapsulation({\n\t\t\tnodeId: this.endpoint.nodeId,\n\t\t\tendpointIndex: this.endpoint.index,\n\t\t\tencapsulated: encapsulatedCC,\n\t\t});\n\t\tawait this.host.sendCommand(cc, this.commandOptions);\n\t}\n}\n\n@commandClass(CommandClasses[\"CRC-16 Encapsulation\"])\n@implementedVersion(1)\nexport class CRC16CC extends CommandClass {\n\tdeclare ccCommand: CRC16Command;\n\n\t/** Tests if a command should be supervised and thus requires encapsulation */\n\tpublic static requiresEncapsulation(cc: CommandClass): boolean {\n\t\treturn (\n\t\t\t!!(cc.encapsulationFlags & EncapsulationFlags.CRC16)\n\t\t\t&& !(cc instanceof CRC16CCCommandEncapsulation)\n\t\t);\n\t}\n\n\t/** Encapsulates a command in a CRC-16 CC */\n\tpublic static encapsulate(\n\t\tcc: CommandClass,\n\t): CRC16CCCommandEncapsulation {\n\t\tconst ret = new CRC16CCCommandEncapsulation({\n\t\t\tnodeId: cc.nodeId,\n\t\t\tencapsulated: cc,\n\t\t});\n\n\t\t// Copy the encapsulation flags from the encapsulated command\n\t\t// but omit CRC-16, since we're doing that right now\n\t\tret.encapsulationFlags = cc.encapsulationFlags\n\t\t\t& ~EncapsulationFlags.CRC16;\n\n\t\treturn ret;\n\t}\n}\n\n// @publicAPI\nexport interface CRC16CCCommandEncapsulationOptions {\n\tencapsulated: CommandClass;\n}\n\nfunction getCCResponseForCommandEncapsulation(\n\tsent: CRC16CCCommandEncapsulation,\n) {\n\tif (sent.encapsulated?.expectsCCResponse()) {\n\t\treturn CRC16CCCommandEncapsulation;\n\t}\n}\n\n@CCCommand(CRC16Command.CommandEncapsulation)\n@expectedCCResponse(\n\tgetCCResponseForCommandEncapsulation,\n\t() => \"checkEncapsulated\",\n)\nexport class CRC16CCCommandEncapsulation extends CRC16CC {\n\tpublic constructor(\n\t\toptions: WithAddress<CRC16CCCommandEncapsulationOptions>,\n\t) {\n\t\tsuper(options);\n\t\tthis.encapsulated = options.encapsulated;\n\t\tthis.encapsulated.encapsulatingCC = this as any;\n\t}\n\n\t/** @deprecated Use {@link fromAsync} instead */\n\tpublic static from(\n\t\traw: CCRaw,\n\t\tctx: CCParsingContext,\n\t): CRC16CCCommandEncapsulation {\n\t\tvalidatePayload(raw.payload.length >= 3);\n\n\t\tconst ccBuffer = raw.payload.subarray(0, -2);\n\n\t\t// Verify the CRC\n\t\tlet expectedCRC = CRC16_CCITT(headerBuffer);\n\t\texpectedCRC = CRC16_CCITT(ccBuffer, expectedCRC);\n\t\tconst actualCRC = raw.payload.readUInt16BE(\n\t\t\traw.payload.length - 2,\n\t\t);\n\t\tvalidatePayload(expectedCRC === actualCRC);\n\n\t\t// eslint-disable-next-line @typescript-eslint/no-deprecated\n\t\tconst encapsulated = CommandClass.parse(ccBuffer, ctx);\n\t\treturn new this({\n\t\t\tnodeId: ctx.sourceNodeId,\n\t\t\tencapsulated,\n\t\t});\n\t}\n\n\tpublic static async fromAsync(\n\t\traw: CCRaw,\n\t\tctx: CCParsingContext,\n\t): Promise<CRC16CCCommandEncapsulation> {\n\t\tvalidatePayload(raw.payload.length >= 3);\n\n\t\tconst ccBuffer = raw.payload.subarray(0, -2);\n\n\t\t// Verify the CRC\n\t\tlet expectedCRC = CRC16_CCITT(headerBuffer);\n\t\texpectedCRC = CRC16_CCITT(ccBuffer, expectedCRC);\n\t\tconst actualCRC = raw.payload.readUInt16BE(\n\t\t\traw.payload.length - 2,\n\t\t);\n\t\tvalidatePayload(expectedCRC === actualCRC);\n\n\t\tconst encapsulated = await CommandClass.parseAsync(ccBuffer, ctx);\n\t\treturn new this({\n\t\t\tnodeId: ctx.sourceNodeId,\n\t\t\tencapsulated,\n\t\t});\n\t}\n\n\tpublic encapsulated: CommandClass;\n\n\t/** @deprecated Use {@link serializeAsync} instead */\n\tpublic serialize(ctx: CCEncodingContext): Bytes {\n\t\t// eslint-disable-next-line @typescript-eslint/no-deprecated\n\t\tconst commandBuffer = this.encapsulated.serialize(ctx);\n\t\t// Reserve 2 bytes for the CRC\n\t\tthis.payload = Bytes.concat([commandBuffer, new Bytes(2)]);\n\n\t\t// Compute and save the CRC16 in the payload\n\t\t// The CC header is included in the CRC computation\n\t\tlet crc = CRC16_CCITT(headerBuffer);\n\t\tcrc = CRC16_CCITT(commandBuffer, crc);\n\t\tthis.payload.writeUInt16BE(crc, this.payload.length - 2);\n\n\t\t// eslint-disable-next-line @typescript-eslint/no-deprecated\n\t\treturn super.serialize(ctx);\n\t}\n\n\tpublic async serializeAsync(ctx: CCEncodingContext): Promise<Bytes> {\n\t\tconst commandBuffer = await this.encapsulated.serializeAsync(ctx);\n\t\t// Reserve 2 bytes for the CRC\n\t\tthis.payload = Bytes.concat([commandBuffer, new Bytes(2)]);\n\n\t\t// Compute and save the CRC16 in the payload\n\t\t// The CC header is included in the CRC computation\n\t\tlet crc = CRC16_CCITT(headerBuffer);\n\t\tcrc = CRC16_CCITT(commandBuffer, crc);\n\t\tthis.payload.writeUInt16BE(crc, this.payload.length - 2);\n\n\t\treturn super.serializeAsync(ctx);\n\t}\n\n\tprotected computeEncapsulationOverhead(): number {\n\t\t// CRC16 adds two bytes CRC to the default overhead\n\t\treturn super.computeEncapsulationOverhead() + 2;\n\t}\n\n\tpublic toLogEntry(ctx?: GetValueDB): MessageOrCCLogEntry {\n\t\treturn {\n\t\t\t...super.toLogEntry(ctx),\n\t\t\t// Hide the default payload line\n\t\t\tmessage: undefined,\n\t\t};\n\t}\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;AAAA,kBAQO;AAMP,iBAAsB;AACtB,0B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A,UAAU,KAAsB;AAEtC,YAAM,gBAAgB,KAAK,aAAa,UAAU,GAAG;AAErD,WAAK,UAAU,mBAAM,OAAO,CAAC,eAAe,IAAI,mBAAM,CAAC,CAAC,CAAC;AAIzD,UAAI,UAAM,yBAAY,YAAY;AAClC,gBAAM,yBAAY,eAAe,GAAG;AACpC,WAAK,QAAQ,cAAc,KAAK,KAAK,QAAQ,SAAS,CAAC;AAGvD,aAAO,MAAM,UAAU,GAAG;IAC3B;IAEO,MAAM,eAAe,KAAsB;AACjD,YAAM,gBAAgB,MAAM,KAAK,aAAa,eAAe,GAAG;AAEhE,WAAK,UAAU,mBAAM,OAAO,CAAC,eAAe,IAAI,mBAAM,CAAC,CAAC,CAAC;AAIzD,UAAI,UAAM,yBAAY,YAAY;AAClC,gBAAM,yBAAY,eAAe,GAAG;AACpC,WAAK,QAAQ,cAAc,KAAK,KAAK,QAAQ,SAAS,CAAC;AAEvD,aAAO,MAAM,eAAe,GAAG;IAChC;IAEU,+BAA4B;AAErC,aAAO,MAAM,6BAA4B,IAAK;IAC/C;IAEO,WAAW,KAAgB;AACjC,aAAO;QACN,GAAG,MAAM,WAAW,GAAG;;QAEvB,SAAS;;IAEX;;;;",
|
|
6
6
|
"names": ["import_safe"]
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/cc/CentralSceneCC.ts"],
|
|
4
|
-
"sourcesContent": ["import {\n\tCommandClasses,\n\ttype MaybeNotKnown,\n\ttype MessageOrCCLogEntry,\n\tMessagePriority,\n\ttype MessageRecord,\n\ttype SupervisionResult,\n\tValueMetadata,\n\ttype WithAddress,\n\tZWaveError,\n\tZWaveErrorCodes,\n\tenumValuesToMetadataStates,\n\tgetCCName,\n\tmaybeUnknownToString,\n\tparseBitMask,\n\tvalidatePayload,\n} from \"@zwave-js/core/safe\";\nimport type {\n\tCCEncodingContext,\n\tCCParsingContext,\n\tGetValueDB,\n} from \"@zwave-js/host/safe\";\nimport { Bytes } from \"@zwave-js/shared/safe\";\nimport { getEnumMemberName, pick } from \"@zwave-js/shared/safe\";\nimport { validateArgs } from \"@zwave-js/transformers\";\nimport {\n\tCCAPI,\n\tPOLL_VALUE,\n\ttype PollValueImplementation,\n\tSET_VALUE,\n\ttype SetValueImplementation,\n\tthrowUnsupportedProperty,\n\tthrowWrongValueType,\n} from \"../lib/API.js\";\nimport {\n\ttype CCRaw,\n\tCommandClass,\n\ttype InterviewContext,\n\ttype PersistValuesContext,\n} from \"../lib/CommandClass.js\";\nimport {\n\tAPI,\n\tCCCommand,\n\tccValueProperty,\n\tccValues,\n\tcommandClass,\n\texpectedCCResponse,\n\timplementedVersion,\n\tuseSupervision,\n} from \"../lib/CommandClassDecorators.js\";\nimport { V } from \"../lib/Values.js\";\nimport { CentralSceneCommand, CentralSceneKeys } from \"../lib/_Types.js\";\nimport * as ccUtils from \"../lib/utils.js\";\n\nexport const CentralSceneCCValues = Object.freeze({\n\t...V.defineStaticCCValues(CommandClasses[\"Central Scene\"], {\n\t\t...V.staticProperty(\"sceneCount\", undefined, {\n\t\t\tinternal: true,\n\t\t}),\n\t\t...V.staticProperty(\"supportsSlowRefresh\", undefined, {\n\t\t\tinternal: true,\n\t\t}),\n\t\t...V.staticProperty(\"supportedKeyAttributes\", undefined, {\n\t\t\tinternal: true,\n\t\t}),\n\n\t\t...V.staticProperty(\n\t\t\t\"slowRefresh\",\n\t\t\t{\n\t\t\t\t...ValueMetadata.Boolean,\n\t\t\t\tlabel: \"Send held down notifications at a slow rate\",\n\t\t\t\tdescription:\n\t\t\t\t\t\"When this is true, KeyHeldDown notifications are sent every 55s. When this is false, the notifications are sent every 200ms.\",\n\t\t\t} as const,\n\t\t),\n\t}),\n\n\t...V.defineDynamicCCValues(CommandClasses[\"Central Scene\"], {\n\t\t...V.dynamicPropertyAndKeyWithName(\n\t\t\t\"scene\",\n\t\t\t\"scene\",\n\t\t\t(sceneNumber: number) => sceneNumber.toString().padStart(3, \"0\"),\n\t\t\t({ property, propertyKey }) =>\n\t\t\t\tproperty === \"scene\"\n\t\t\t\t&& typeof propertyKey === \"string\"\n\t\t\t\t&& /^\\d{3}$/.test(propertyKey),\n\t\t\t(sceneNumber: number) => ({\n\t\t\t\t...ValueMetadata.ReadOnlyUInt8,\n\t\t\t\tlabel: `Scene ${sceneNumber.toString().padStart(3, \"0\")}`,\n\t\t\t} as const),\n\t\t\t{ stateful: false } as const,\n\t\t),\n\t}),\n});\n\n@API(CommandClasses[\"Central Scene\"])\nexport class CentralSceneCCAPI extends CCAPI {\n\tpublic supportsCommand(cmd: CentralSceneCommand): MaybeNotKnown<boolean> {\n\t\tswitch (cmd) {\n\t\t\tcase CentralSceneCommand.SupportedGet:\n\t\t\t\treturn this.isSinglecast(); // this is mandatory\n\t\t\tcase CentralSceneCommand.ConfigurationGet:\n\t\t\t\treturn this.version >= 3 && this.isSinglecast();\n\t\t\tcase CentralSceneCommand.ConfigurationSet:\n\t\t\t\treturn this.version >= 3;\n\t\t}\n\t\treturn super.supportsCommand(cmd);\n\t}\n\n\t// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types\n\tpublic async getSupported() {\n\t\tthis.assertSupportsCommand(\n\t\t\tCentralSceneCommand,\n\t\t\tCentralSceneCommand.SupportedGet,\n\t\t);\n\n\t\tconst cc = new CentralSceneCCSupportedGet({\n\t\t\tnodeId: this.endpoint.nodeId,\n\t\t\tendpointIndex: this.endpoint.index,\n\t\t});\n\t\tconst response = await this.host.sendCommand<\n\t\t\tCentralSceneCCSupportedReport\n\t\t>(\n\t\t\tcc,\n\t\t\tthis.commandOptions,\n\t\t);\n\t\tif (response) {\n\t\t\treturn pick(response, [\n\t\t\t\t\"sceneCount\",\n\t\t\t\t\"supportsSlowRefresh\",\n\t\t\t\t\"supportedKeyAttributes\",\n\t\t\t]);\n\t\t}\n\t}\n\n\t// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types\n\tpublic async getConfiguration() {\n\t\tthis.assertSupportsCommand(\n\t\t\tCentralSceneCommand,\n\t\t\tCentralSceneCommand.ConfigurationGet,\n\t\t);\n\n\t\tconst cc = new CentralSceneCCConfigurationGet({\n\t\t\tnodeId: this.endpoint.nodeId,\n\t\t\tendpointIndex: this.endpoint.index,\n\t\t});\n\t\tconst response = await this.host.sendCommand<\n\t\t\tCentralSceneCCConfigurationReport\n\t\t>(\n\t\t\tcc,\n\t\t\tthis.commandOptions,\n\t\t);\n\t\tif (response) {\n\t\t\treturn pick(response, [\"slowRefresh\"]);\n\t\t}\n\t}\n\n\t@validateArgs()\n\tpublic async setConfiguration(\n\t\tslowRefresh: boolean,\n\t): Promise<SupervisionResult | undefined> {\n\t\tthis.assertSupportsCommand(\n\t\t\tCentralSceneCommand,\n\t\t\tCentralSceneCommand.ConfigurationSet,\n\t\t);\n\n\t\tconst cc = new CentralSceneCCConfigurationSet({\n\t\t\tnodeId: this.endpoint.nodeId,\n\t\t\tendpointIndex: this.endpoint.index,\n\t\t\tslowRefresh,\n\t\t});\n\t\treturn this.host.sendCommand(cc, this.commandOptions);\n\t}\n\n\tprotected override get [SET_VALUE](): SetValueImplementation {\n\t\treturn async function(this: CentralSceneCCAPI, { property }, value) {\n\t\t\tif (property !== \"slowRefresh\") {\n\t\t\t\tthrowUnsupportedProperty(this.ccId, property);\n\t\t\t}\n\t\t\tif (typeof value !== \"boolean\") {\n\t\t\t\tthrowWrongValueType(\n\t\t\t\t\tthis.ccId,\n\t\t\t\t\tproperty,\n\t\t\t\t\t\"boolean\",\n\t\t\t\t\ttypeof value,\n\t\t\t\t);\n\t\t\t}\n\t\t\treturn this.setConfiguration(value);\n\t\t};\n\t}\n\n\tprotected get [POLL_VALUE](): PollValueImplementation {\n\t\treturn async function(this: CentralSceneCCAPI, { property }) {\n\t\t\tif (property === \"slowRefresh\") {\n\t\t\t\treturn (await this.getConfiguration())?.[property];\n\t\t\t}\n\t\t\tthrowUnsupportedProperty(this.ccId, property);\n\t\t};\n\t}\n}\n\n@commandClass(CommandClasses[\"Central Scene\"])\n@implementedVersion(3)\n@ccValues(CentralSceneCCValues)\nexport class CentralSceneCC extends CommandClass {\n\tdeclare ccCommand: CentralSceneCommand;\n\n\tpublic determineRequiredCCInterviews(): readonly CommandClasses[] {\n\t\treturn [\n\t\t\t...super.determineRequiredCCInterviews(),\n\t\t\tCommandClasses.Association,\n\t\t\tCommandClasses[\"Multi Channel Association\"],\n\t\t\tCommandClasses[\"Association Group Information\"],\n\t\t];\n\t}\n\n\tpublic skipEndpointInterview(): boolean {\n\t\t// Central scene notifications are issued by the root device\n\t\treturn true;\n\t}\n\n\tpublic async interview(\n\t\tctx: InterviewContext,\n\t): Promise<void> {\n\t\tconst node = this.getNode(ctx)!;\n\t\tconst endpoint = this.getEndpoint(ctx)!;\n\t\tconst api = CCAPI.create(\n\t\t\tCommandClasses[\"Central Scene\"],\n\t\t\tctx,\n\t\t\tendpoint,\n\t\t).withOptions({\n\t\t\tpriority: MessagePriority.NodeQuery,\n\t\t});\n\n\t\tctx.logNode(node.id, {\n\t\t\tendpoint: this.endpointIndex,\n\t\t\tmessage: `Interviewing ${this.ccName}...`,\n\t\t\tdirection: \"none\",\n\t\t});\n\n\t\t// If one Association group issues CentralScene notifications,\n\t\t// we must associate ourselves with that channel\n\t\ttry {\n\t\t\tawait ccUtils.assignLifelineIssueingCommand(\n\t\t\t\tctx,\n\t\t\t\tendpoint,\n\t\t\t\tthis.ccId,\n\t\t\t\tCentralSceneCommand.Notification,\n\t\t\t);\n\t\t} catch {\n\t\t\tctx.logNode(node.id, {\n\t\t\t\tendpoint: endpoint.index,\n\t\t\t\tmessage: `Configuring associations to receive ${\n\t\t\t\t\tgetCCName(\n\t\t\t\t\t\tthis.ccId,\n\t\t\t\t\t)\n\t\t\t\t} commands failed!`,\n\t\t\t\tlevel: \"warn\",\n\t\t\t});\n\t\t}\n\n\t\tctx.logNode(node.id, {\n\t\t\tendpoint: this.endpointIndex,\n\t\t\tmessage: \"Querying supported scenes...\",\n\t\t\tdirection: \"outbound\",\n\t\t});\n\t\tconst ccSupported = await api.getSupported();\n\t\tif (ccSupported) {\n\t\t\tconst logMessage = `received supported scenes:\n# of scenes: ${ccSupported.sceneCount}\nsupports slow refresh: ${ccSupported.supportsSlowRefresh}`;\n\t\t\tctx.logNode(node.id, {\n\t\t\t\tendpoint: this.endpointIndex,\n\t\t\t\tmessage: logMessage,\n\t\t\t\tdirection: \"inbound\",\n\t\t\t});\n\t\t} else {\n\t\t\tctx.logNode(node.id, {\n\t\t\t\tendpoint: this.endpointIndex,\n\t\t\t\tmessage:\n\t\t\t\t\t\"Querying supported scenes timed out, skipping interview...\",\n\t\t\t\tlevel: \"warn\",\n\t\t\t});\n\t\t\treturn;\n\t\t}\n\n\t\t// The slow refresh capability should be enabled whenever possible\n\t\tif (api.version >= 3 && ccSupported?.supportsSlowRefresh) {\n\t\t\tctx.logNode(node.id, {\n\t\t\t\tendpoint: this.endpointIndex,\n\t\t\t\tmessage: \"Enabling slow refresh capability...\",\n\t\t\t\tdirection: \"outbound\",\n\t\t\t});\n\t\t\tawait api.setConfiguration(true);\n\t\t}\n\n\t\t// Remember that the interview is complete\n\t\tthis.setInterviewComplete(ctx, true);\n\t}\n}\n\n// @publicAPI\nexport interface CentralSceneCCNotificationOptions {\n\tsequenceNumber: number;\n\tkeyAttribute: CentralSceneKeys;\n\tsceneNumber: number;\n\tslowRefresh?: boolean;\n}\n\n@CCCommand(CentralSceneCommand.Notification)\nexport class CentralSceneCCNotification extends CentralSceneCC {\n\tpublic constructor(\n\t\toptions: WithAddress<CentralSceneCCNotificationOptions>,\n\t) {\n\t\tsuper(options);\n\n\t\t// TODO: Check implementation:\n\t\tthis.sequenceNumber = options.sequenceNumber;\n\t\tthis.keyAttribute = options.keyAttribute;\n\t\tthis.sceneNumber = options.sceneNumber;\n\t\tthis.slowRefresh = options.slowRefresh;\n\t}\n\n\tpublic static from(\n\t\traw: CCRaw,\n\t\tctx: CCParsingContext,\n\t): CentralSceneCCNotification {\n\t\tvalidatePayload(raw.payload.length >= 3);\n\t\tconst sequenceNumber = raw.payload[0];\n\t\tconst keyAttribute: CentralSceneKeys = raw.payload[1] & 0b111;\n\t\tconst sceneNumber = raw.payload[2];\n\t\tlet slowRefresh: boolean | undefined;\n\t\tif (keyAttribute === CentralSceneKeys.KeyHeldDown) {\n\t\t\t// A receiving node MUST ignore this field if the command is not\n\t\t\t// carrying the Key Held Down key attribute.\n\t\t\tslowRefresh = !!(raw.payload[1] & 0b1000_0000);\n\t\t}\n\n\t\treturn new this({\n\t\t\tnodeId: ctx.sourceNodeId,\n\t\t\tsequenceNumber,\n\t\t\tkeyAttribute,\n\t\t\tsceneNumber,\n\t\t\tslowRefresh,\n\t\t});\n\t}\n\n\tpublic persistValues(ctx: PersistValuesContext): boolean {\n\t\tif (!super.persistValues(ctx)) return false;\n\n\t\t// In case the interview is not yet completed, we still create some basic metadata\n\t\tconst sceneValue = CentralSceneCCValues.scene(this.sceneNumber);\n\t\tthis.ensureMetadata(ctx, sceneValue);\n\n\t\t// The spec behavior is pretty complicated, so we cannot just store\n\t\t// the value and call it a day. Handling of these notifications will\n\t\t// happen in the receiving node class\n\n\t\treturn true;\n\t}\n\n\tpublic readonly sequenceNumber: number;\n\tpublic readonly keyAttribute: CentralSceneKeys;\n\tpublic readonly sceneNumber: number;\n\tpublic readonly slowRefresh: boolean | undefined;\n\n\tpublic toLogEntry(ctx?: GetValueDB): MessageOrCCLogEntry {\n\t\tconst message: MessageRecord = {\n\t\t\t\"sequence number\": this.sequenceNumber,\n\t\t\t\"key attribute\": getEnumMemberName(\n\t\t\t\tCentralSceneKeys,\n\t\t\t\tthis.keyAttribute,\n\t\t\t),\n\t\t\t\"scene number\": this.sceneNumber,\n\t\t};\n\t\tif (this.slowRefresh != undefined) {\n\t\t\tmessage[\"slow refresh\"] = this.slowRefresh;\n\t\t}\n\t\treturn {\n\t\t\t...super.toLogEntry(ctx),\n\t\t\tmessage,\n\t\t};\n\t}\n}\n\n// @publicAPI\nexport interface CentralSceneCCSupportedReportOptions {\n\tsceneCount: number;\n\tsupportsSlowRefresh: MaybeNotKnown<boolean>;\n\tsupportedKeyAttributes: Record<number, readonly CentralSceneKeys[]>;\n}\n\n@CCCommand(CentralSceneCommand.SupportedReport)\n@ccValueProperty(\"sceneCount\", CentralSceneCCValues.sceneCount)\n@ccValueProperty(\n\t\"supportsSlowRefresh\",\n\tCentralSceneCCValues.supportsSlowRefresh,\n)\n@ccValueProperty(\n\t\"supportedKeyAttributes\",\n\tCentralSceneCCValues.supportedKeyAttributes,\n)\nexport class CentralSceneCCSupportedReport extends CentralSceneCC {\n\tpublic constructor(\n\t\toptions: WithAddress<CentralSceneCCSupportedReportOptions>,\n\t) {\n\t\tsuper(options);\n\n\t\t// TODO: Check implementation:\n\t\tthis.sceneCount = options.sceneCount;\n\t\tthis.supportsSlowRefresh = options.supportsSlowRefresh;\n\t\tfor (\n\t\t\tconst [scene, keys] of Object.entries(\n\t\t\t\toptions.supportedKeyAttributes,\n\t\t\t)\n\t\t) {\n\t\t\tthis._supportedKeyAttributes.set(\n\t\t\t\tparseInt(scene),\n\t\t\t\tkeys,\n\t\t\t);\n\t\t}\n\t}\n\n\tpublic static from(\n\t\traw: CCRaw,\n\t\tctx: CCParsingContext,\n\t): CentralSceneCCSupportedReport {\n\t\tvalidatePayload(raw.payload.length >= 2);\n\t\tconst sceneCount = raw.payload[0];\n\t\tconst supportsSlowRefresh: MaybeNotKnown<boolean> =\n\t\t\t!!(raw.payload[1] & 0b1000_0000);\n\t\tconst bitMaskBytes = (raw.payload[1] & 0b110) >>> 1;\n\t\tconst identicalKeyAttributes = !!(raw.payload[1] & 0b1);\n\t\tconst numEntries = identicalKeyAttributes ? 1 : sceneCount;\n\t\tvalidatePayload(raw.payload.length >= 2 + bitMaskBytes * numEntries);\n\t\tconst supportedKeyAttributes: Record<\n\t\t\tnumber,\n\t\t\treadonly CentralSceneKeys[]\n\t\t> = {};\n\t\tfor (let i = 0; i < numEntries; i++) {\n\t\t\tconst mask = raw.payload.subarray(\n\t\t\t\t2 + i * bitMaskBytes,\n\t\t\t\t2 + (i + 1) * bitMaskBytes,\n\t\t\t);\n\t\t\tsupportedKeyAttributes[i + 1] = parseBitMask(\n\t\t\t\tmask,\n\t\t\t\tCentralSceneKeys.KeyPressed,\n\t\t\t);\n\t\t}\n\n\t\tif (identicalKeyAttributes) {\n\t\t\t// The key attributes are only transmitted for scene 1, copy them to the others\n\t\t\tfor (let i = 2; i <= sceneCount; i++) {\n\t\t\t\tsupportedKeyAttributes[i] = supportedKeyAttributes[1];\n\t\t\t}\n\t\t}\n\n\t\treturn new this({\n\t\t\tnodeId: ctx.sourceNodeId,\n\t\t\tsceneCount,\n\t\t\tsupportsSlowRefresh,\n\t\t\tsupportedKeyAttributes,\n\t\t});\n\t}\n\n\tpublic persistValues(ctx: PersistValuesContext): boolean {\n\t\tif (!super.persistValues(ctx)) return false;\n\n\t\t// Create/extend metadata for all scenes\n\t\tfor (let i = 1; i <= this.sceneCount; i++) {\n\t\t\tconst sceneValue = CentralSceneCCValues.scene(i);\n\t\t\tthis.setMetadata(ctx, sceneValue, {\n\t\t\t\t...sceneValue.meta,\n\t\t\t\tstates: enumValuesToMetadataStates(\n\t\t\t\t\tCentralSceneKeys,\n\t\t\t\t\tthis._supportedKeyAttributes.get(i),\n\t\t\t\t),\n\t\t\t});\n\t\t}\n\n\t\treturn true;\n\t}\n\n\tpublic readonly sceneCount: number;\n\n\t// TODO: Only offer `slowRefresh` if this is true\n\n\tpublic readonly supportsSlowRefresh: MaybeNotKnown<boolean>;\n\n\tprivate _supportedKeyAttributes = new Map<\n\t\tnumber,\n\t\treadonly CentralSceneKeys[]\n\t>();\n\n\tpublic get supportedKeyAttributes(): ReadonlyMap<\n\t\tnumber,\n\t\treadonly CentralSceneKeys[]\n\t> {\n\t\treturn this._supportedKeyAttributes;\n\t}\n\n\tpublic toLogEntry(ctx?: GetValueDB): MessageOrCCLogEntry {\n\t\tconst message: MessageRecord = {\n\t\t\t\"scene count\": this.sceneCount,\n\t\t\t\"supports slow refresh\": maybeUnknownToString(\n\t\t\t\tthis.supportsSlowRefresh,\n\t\t\t),\n\t\t};\n\t\tfor (const [scene, keys] of this.supportedKeyAttributes) {\n\t\t\tmessage[`supported attributes (scene #${scene})`] = keys\n\t\t\t\t.map((k) => `\\n\u00B7 ${getEnumMemberName(CentralSceneKeys, k)}`)\n\t\t\t\t.join(\"\");\n\t\t}\n\t\treturn {\n\t\t\t...super.toLogEntry(ctx),\n\t\t\tmessage,\n\t\t};\n\t}\n}\n\n@CCCommand(CentralSceneCommand.SupportedGet)\n@expectedCCResponse(CentralSceneCCSupportedReport)\nexport class CentralSceneCCSupportedGet extends CentralSceneCC {}\n\n// @publicAPI\nexport interface CentralSceneCCConfigurationReportOptions {\n\tslowRefresh: boolean;\n}\n\n@CCCommand(CentralSceneCommand.ConfigurationReport)\n@ccValueProperty(\"slowRefresh\", CentralSceneCCValues.slowRefresh)\nexport class CentralSceneCCConfigurationReport extends CentralSceneCC {\n\tpublic constructor(\n\t\toptions: WithAddress<CentralSceneCCConfigurationReportOptions>,\n\t) {\n\t\tsuper(options);\n\n\t\t// TODO: Check implementation:\n\t\tthis.slowRefresh = options.slowRefresh;\n\t}\n\n\tpublic static from(\n\t\traw: CCRaw,\n\t\tctx: CCParsingContext,\n\t): CentralSceneCCConfigurationReport {\n\t\tvalidatePayload(raw.payload.length >= 1);\n\t\tconst slowRefresh = !!(raw.payload[0] & 0b1000_0000);\n\n\t\treturn new this({\n\t\t\tnodeId: ctx.sourceNodeId,\n\t\t\tslowRefresh,\n\t\t});\n\t}\n\n\tpublic readonly slowRefresh: boolean;\n\n\tpublic toLogEntry(ctx?: GetValueDB): MessageOrCCLogEntry {\n\t\treturn {\n\t\t\t...super.toLogEntry(ctx),\n\t\t\tmessage: { \"slow refresh\": this.slowRefresh },\n\t\t};\n\t}\n}\n\n@CCCommand(CentralSceneCommand.ConfigurationGet)\n@expectedCCResponse(CentralSceneCCConfigurationReport)\nexport class CentralSceneCCConfigurationGet extends CentralSceneCC {}\n\n// @publicAPI\nexport interface CentralSceneCCConfigurationSetOptions {\n\tslowRefresh: boolean;\n}\n\n@CCCommand(CentralSceneCommand.ConfigurationSet)\n@useSupervision()\nexport class CentralSceneCCConfigurationSet extends CentralSceneCC {\n\tpublic constructor(\n\t\toptions: WithAddress<CentralSceneCCConfigurationSetOptions>,\n\t) {\n\t\tsuper(options);\n\t\tthis.slowRefresh = options.slowRefresh;\n\t}\n\n\tpublic static from(\n\t\t_raw: CCRaw,\n\t\t_ctx: CCParsingContext,\n\t): CentralSceneCCConfigurationSet {\n\t\tthrow new ZWaveError(\n\t\t\t`${this.name}: deserialization not implemented`,\n\t\t\tZWaveErrorCodes.Deserialization_NotImplemented,\n\t\t);\n\n\t\t// return new CentralSceneCCConfigurationSet({\n\t\t// \tnodeId: ctx.sourceNodeId,\n\t\t// });\n\t}\n\n\tpublic slowRefresh: boolean;\n\n\tpublic serialize(ctx: CCEncodingContext): Bytes {\n\t\tthis.payload = Bytes.from([this.slowRefresh ? 0b1000_0000 : 0]);\n\t\treturn super.serialize(ctx);\n\t}\n\n\tpublic toLogEntry(ctx?: GetValueDB): MessageOrCCLogEntry {\n\t\treturn {\n\t\t\t...super.toLogEntry(ctx),\n\t\t\tmessage: { \"slow refresh\": this.slowRefresh },\n\t\t};\n\t}\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,kBAgBO;AAMP,IAAAA,eAAsB;AACtB,IAAAA,eAAwC;AAExC,iBAQO;AACP,0BAKO;AACP,oCASO;AACP,oBAAkB;AAClB,mBAAsD;AACtD,cAAyB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAElB,MAAM,uBAAuB,OAAO,OAAO;EACjD,GAAG,gBAAE,qBAAqB,2BAAe,eAAe,GAAG;IAC1D,GAAG,gBAAE,eAAe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CACZ,4BAAgB,8BAA8B;IAMhD;IAEO;IAEA,UAAU,KAAsB;AACtC,WAAK,UAAU,mBAAM,KAAK,CAAC,KAAK,cAAc,MAAc,CAAC,CAAC;
|
|
4
|
+
"sourcesContent": ["import {\n\tCommandClasses,\n\ttype MaybeNotKnown,\n\ttype MessageOrCCLogEntry,\n\tMessagePriority,\n\ttype MessageRecord,\n\ttype SupervisionResult,\n\tValueMetadata,\n\ttype WithAddress,\n\tZWaveError,\n\tZWaveErrorCodes,\n\tenumValuesToMetadataStates,\n\tgetCCName,\n\tmaybeUnknownToString,\n\tparseBitMask,\n\tvalidatePayload,\n} from \"@zwave-js/core/safe\";\nimport type {\n\tCCEncodingContext,\n\tCCParsingContext,\n\tGetValueDB,\n} from \"@zwave-js/host/safe\";\nimport { Bytes } from \"@zwave-js/shared/safe\";\nimport { getEnumMemberName, pick } from \"@zwave-js/shared/safe\";\nimport { validateArgs } from \"@zwave-js/transformers\";\nimport {\n\tCCAPI,\n\tPOLL_VALUE,\n\ttype PollValueImplementation,\n\tSET_VALUE,\n\ttype SetValueImplementation,\n\tthrowUnsupportedProperty,\n\tthrowWrongValueType,\n} from \"../lib/API.js\";\nimport {\n\ttype CCRaw,\n\tCommandClass,\n\ttype InterviewContext,\n\ttype PersistValuesContext,\n} from \"../lib/CommandClass.js\";\nimport {\n\tAPI,\n\tCCCommand,\n\tccValueProperty,\n\tccValues,\n\tcommandClass,\n\texpectedCCResponse,\n\timplementedVersion,\n\tuseSupervision,\n} from \"../lib/CommandClassDecorators.js\";\nimport { V } from \"../lib/Values.js\";\nimport { CentralSceneCommand, CentralSceneKeys } from \"../lib/_Types.js\";\nimport * as ccUtils from \"../lib/utils.js\";\n\nexport const CentralSceneCCValues = Object.freeze({\n\t...V.defineStaticCCValues(CommandClasses[\"Central Scene\"], {\n\t\t...V.staticProperty(\"sceneCount\", undefined, {\n\t\t\tinternal: true,\n\t\t}),\n\t\t...V.staticProperty(\"supportsSlowRefresh\", undefined, {\n\t\t\tinternal: true,\n\t\t}),\n\t\t...V.staticProperty(\"supportedKeyAttributes\", undefined, {\n\t\t\tinternal: true,\n\t\t}),\n\n\t\t...V.staticProperty(\n\t\t\t\"slowRefresh\",\n\t\t\t{\n\t\t\t\t...ValueMetadata.Boolean,\n\t\t\t\tlabel: \"Send held down notifications at a slow rate\",\n\t\t\t\tdescription:\n\t\t\t\t\t\"When this is true, KeyHeldDown notifications are sent every 55s. When this is false, the notifications are sent every 200ms.\",\n\t\t\t} as const,\n\t\t),\n\t}),\n\n\t...V.defineDynamicCCValues(CommandClasses[\"Central Scene\"], {\n\t\t...V.dynamicPropertyAndKeyWithName(\n\t\t\t\"scene\",\n\t\t\t\"scene\",\n\t\t\t(sceneNumber: number) => sceneNumber.toString().padStart(3, \"0\"),\n\t\t\t({ property, propertyKey }) =>\n\t\t\t\tproperty === \"scene\"\n\t\t\t\t&& typeof propertyKey === \"string\"\n\t\t\t\t&& /^\\d{3}$/.test(propertyKey),\n\t\t\t(sceneNumber: number) => ({\n\t\t\t\t...ValueMetadata.ReadOnlyUInt8,\n\t\t\t\tlabel: `Scene ${sceneNumber.toString().padStart(3, \"0\")}`,\n\t\t\t} as const),\n\t\t\t{ stateful: false } as const,\n\t\t),\n\t}),\n});\n\n@API(CommandClasses[\"Central Scene\"])\nexport class CentralSceneCCAPI extends CCAPI {\n\tpublic supportsCommand(cmd: CentralSceneCommand): MaybeNotKnown<boolean> {\n\t\tswitch (cmd) {\n\t\t\tcase CentralSceneCommand.SupportedGet:\n\t\t\t\treturn this.isSinglecast(); // this is mandatory\n\t\t\tcase CentralSceneCommand.ConfigurationGet:\n\t\t\t\treturn this.version >= 3 && this.isSinglecast();\n\t\t\tcase CentralSceneCommand.ConfigurationSet:\n\t\t\t\treturn this.version >= 3;\n\t\t}\n\t\treturn super.supportsCommand(cmd);\n\t}\n\n\t// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types\n\tpublic async getSupported() {\n\t\tthis.assertSupportsCommand(\n\t\t\tCentralSceneCommand,\n\t\t\tCentralSceneCommand.SupportedGet,\n\t\t);\n\n\t\tconst cc = new CentralSceneCCSupportedGet({\n\t\t\tnodeId: this.endpoint.nodeId,\n\t\t\tendpointIndex: this.endpoint.index,\n\t\t});\n\t\tconst response = await this.host.sendCommand<\n\t\t\tCentralSceneCCSupportedReport\n\t\t>(\n\t\t\tcc,\n\t\t\tthis.commandOptions,\n\t\t);\n\t\tif (response) {\n\t\t\treturn pick(response, [\n\t\t\t\t\"sceneCount\",\n\t\t\t\t\"supportsSlowRefresh\",\n\t\t\t\t\"supportedKeyAttributes\",\n\t\t\t]);\n\t\t}\n\t}\n\n\t// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types\n\tpublic async getConfiguration() {\n\t\tthis.assertSupportsCommand(\n\t\t\tCentralSceneCommand,\n\t\t\tCentralSceneCommand.ConfigurationGet,\n\t\t);\n\n\t\tconst cc = new CentralSceneCCConfigurationGet({\n\t\t\tnodeId: this.endpoint.nodeId,\n\t\t\tendpointIndex: this.endpoint.index,\n\t\t});\n\t\tconst response = await this.host.sendCommand<\n\t\t\tCentralSceneCCConfigurationReport\n\t\t>(\n\t\t\tcc,\n\t\t\tthis.commandOptions,\n\t\t);\n\t\tif (response) {\n\t\t\treturn pick(response, [\"slowRefresh\"]);\n\t\t}\n\t}\n\n\t@validateArgs()\n\tpublic async setConfiguration(\n\t\tslowRefresh: boolean,\n\t): Promise<SupervisionResult | undefined> {\n\t\tthis.assertSupportsCommand(\n\t\t\tCentralSceneCommand,\n\t\t\tCentralSceneCommand.ConfigurationSet,\n\t\t);\n\n\t\tconst cc = new CentralSceneCCConfigurationSet({\n\t\t\tnodeId: this.endpoint.nodeId,\n\t\t\tendpointIndex: this.endpoint.index,\n\t\t\tslowRefresh,\n\t\t});\n\t\treturn this.host.sendCommand(cc, this.commandOptions);\n\t}\n\n\tprotected override get [SET_VALUE](): SetValueImplementation {\n\t\treturn async function(this: CentralSceneCCAPI, { property }, value) {\n\t\t\tif (property !== \"slowRefresh\") {\n\t\t\t\tthrowUnsupportedProperty(this.ccId, property);\n\t\t\t}\n\t\t\tif (typeof value !== \"boolean\") {\n\t\t\t\tthrowWrongValueType(\n\t\t\t\t\tthis.ccId,\n\t\t\t\t\tproperty,\n\t\t\t\t\t\"boolean\",\n\t\t\t\t\ttypeof value,\n\t\t\t\t);\n\t\t\t}\n\t\t\treturn this.setConfiguration(value);\n\t\t};\n\t}\n\n\tprotected get [POLL_VALUE](): PollValueImplementation {\n\t\treturn async function(this: CentralSceneCCAPI, { property }) {\n\t\t\tif (property === \"slowRefresh\") {\n\t\t\t\treturn (await this.getConfiguration())?.[property];\n\t\t\t}\n\t\t\tthrowUnsupportedProperty(this.ccId, property);\n\t\t};\n\t}\n}\n\n@commandClass(CommandClasses[\"Central Scene\"])\n@implementedVersion(3)\n@ccValues(CentralSceneCCValues)\nexport class CentralSceneCC extends CommandClass {\n\tdeclare ccCommand: CentralSceneCommand;\n\n\tpublic determineRequiredCCInterviews(): readonly CommandClasses[] {\n\t\treturn [\n\t\t\t...super.determineRequiredCCInterviews(),\n\t\t\tCommandClasses.Association,\n\t\t\tCommandClasses[\"Multi Channel Association\"],\n\t\t\tCommandClasses[\"Association Group Information\"],\n\t\t];\n\t}\n\n\tpublic skipEndpointInterview(): boolean {\n\t\t// Central scene notifications are issued by the root device\n\t\treturn true;\n\t}\n\n\tpublic async interview(\n\t\tctx: InterviewContext,\n\t): Promise<void> {\n\t\tconst node = this.getNode(ctx)!;\n\t\tconst endpoint = this.getEndpoint(ctx)!;\n\t\tconst api = CCAPI.create(\n\t\t\tCommandClasses[\"Central Scene\"],\n\t\t\tctx,\n\t\t\tendpoint,\n\t\t).withOptions({\n\t\t\tpriority: MessagePriority.NodeQuery,\n\t\t});\n\n\t\tctx.logNode(node.id, {\n\t\t\tendpoint: this.endpointIndex,\n\t\t\tmessage: `Interviewing ${this.ccName}...`,\n\t\t\tdirection: \"none\",\n\t\t});\n\n\t\t// If one Association group issues CentralScene notifications,\n\t\t// we must associate ourselves with that channel\n\t\ttry {\n\t\t\tawait ccUtils.assignLifelineIssueingCommand(\n\t\t\t\tctx,\n\t\t\t\tendpoint,\n\t\t\t\tthis.ccId,\n\t\t\t\tCentralSceneCommand.Notification,\n\t\t\t);\n\t\t} catch {\n\t\t\tctx.logNode(node.id, {\n\t\t\t\tendpoint: endpoint.index,\n\t\t\t\tmessage: `Configuring associations to receive ${\n\t\t\t\t\tgetCCName(\n\t\t\t\t\t\tthis.ccId,\n\t\t\t\t\t)\n\t\t\t\t} commands failed!`,\n\t\t\t\tlevel: \"warn\",\n\t\t\t});\n\t\t}\n\n\t\tctx.logNode(node.id, {\n\t\t\tendpoint: this.endpointIndex,\n\t\t\tmessage: \"Querying supported scenes...\",\n\t\t\tdirection: \"outbound\",\n\t\t});\n\t\tconst ccSupported = await api.getSupported();\n\t\tif (ccSupported) {\n\t\t\tconst logMessage = `received supported scenes:\n# of scenes: ${ccSupported.sceneCount}\nsupports slow refresh: ${ccSupported.supportsSlowRefresh}`;\n\t\t\tctx.logNode(node.id, {\n\t\t\t\tendpoint: this.endpointIndex,\n\t\t\t\tmessage: logMessage,\n\t\t\t\tdirection: \"inbound\",\n\t\t\t});\n\t\t} else {\n\t\t\tctx.logNode(node.id, {\n\t\t\t\tendpoint: this.endpointIndex,\n\t\t\t\tmessage:\n\t\t\t\t\t\"Querying supported scenes timed out, skipping interview...\",\n\t\t\t\tlevel: \"warn\",\n\t\t\t});\n\t\t\treturn;\n\t\t}\n\n\t\t// The slow refresh capability should be enabled whenever possible\n\t\tif (api.version >= 3 && ccSupported?.supportsSlowRefresh) {\n\t\t\tctx.logNode(node.id, {\n\t\t\t\tendpoint: this.endpointIndex,\n\t\t\t\tmessage: \"Enabling slow refresh capability...\",\n\t\t\t\tdirection: \"outbound\",\n\t\t\t});\n\t\t\tawait api.setConfiguration(true);\n\t\t}\n\n\t\t// Remember that the interview is complete\n\t\tthis.setInterviewComplete(ctx, true);\n\t}\n}\n\n// @publicAPI\nexport interface CentralSceneCCNotificationOptions {\n\tsequenceNumber: number;\n\tkeyAttribute: CentralSceneKeys;\n\tsceneNumber: number;\n\tslowRefresh?: boolean;\n}\n\n@CCCommand(CentralSceneCommand.Notification)\nexport class CentralSceneCCNotification extends CentralSceneCC {\n\tpublic constructor(\n\t\toptions: WithAddress<CentralSceneCCNotificationOptions>,\n\t) {\n\t\tsuper(options);\n\n\t\t// TODO: Check implementation:\n\t\tthis.sequenceNumber = options.sequenceNumber;\n\t\tthis.keyAttribute = options.keyAttribute;\n\t\tthis.sceneNumber = options.sceneNumber;\n\t\tthis.slowRefresh = options.slowRefresh;\n\t}\n\n\tpublic static from(\n\t\traw: CCRaw,\n\t\tctx: CCParsingContext,\n\t): CentralSceneCCNotification {\n\t\tvalidatePayload(raw.payload.length >= 3);\n\t\tconst sequenceNumber = raw.payload[0];\n\t\tconst keyAttribute: CentralSceneKeys = raw.payload[1] & 0b111;\n\t\tconst sceneNumber = raw.payload[2];\n\t\tlet slowRefresh: boolean | undefined;\n\t\tif (keyAttribute === CentralSceneKeys.KeyHeldDown) {\n\t\t\t// A receiving node MUST ignore this field if the command is not\n\t\t\t// carrying the Key Held Down key attribute.\n\t\t\tslowRefresh = !!(raw.payload[1] & 0b1000_0000);\n\t\t}\n\n\t\treturn new this({\n\t\t\tnodeId: ctx.sourceNodeId,\n\t\t\tsequenceNumber,\n\t\t\tkeyAttribute,\n\t\t\tsceneNumber,\n\t\t\tslowRefresh,\n\t\t});\n\t}\n\n\tpublic persistValues(ctx: PersistValuesContext): boolean {\n\t\tif (!super.persistValues(ctx)) return false;\n\n\t\t// In case the interview is not yet completed, we still create some basic metadata\n\t\tconst sceneValue = CentralSceneCCValues.scene(this.sceneNumber);\n\t\tthis.ensureMetadata(ctx, sceneValue);\n\n\t\t// The spec behavior is pretty complicated, so we cannot just store\n\t\t// the value and call it a day. Handling of these notifications will\n\t\t// happen in the receiving node class\n\n\t\treturn true;\n\t}\n\n\tpublic readonly sequenceNumber: number;\n\tpublic readonly keyAttribute: CentralSceneKeys;\n\tpublic readonly sceneNumber: number;\n\tpublic readonly slowRefresh: boolean | undefined;\n\n\tpublic toLogEntry(ctx?: GetValueDB): MessageOrCCLogEntry {\n\t\tconst message: MessageRecord = {\n\t\t\t\"sequence number\": this.sequenceNumber,\n\t\t\t\"key attribute\": getEnumMemberName(\n\t\t\t\tCentralSceneKeys,\n\t\t\t\tthis.keyAttribute,\n\t\t\t),\n\t\t\t\"scene number\": this.sceneNumber,\n\t\t};\n\t\tif (this.slowRefresh != undefined) {\n\t\t\tmessage[\"slow refresh\"] = this.slowRefresh;\n\t\t}\n\t\treturn {\n\t\t\t...super.toLogEntry(ctx),\n\t\t\tmessage,\n\t\t};\n\t}\n}\n\n// @publicAPI\nexport interface CentralSceneCCSupportedReportOptions {\n\tsceneCount: number;\n\tsupportsSlowRefresh: MaybeNotKnown<boolean>;\n\tsupportedKeyAttributes: Record<number, readonly CentralSceneKeys[]>;\n}\n\n@CCCommand(CentralSceneCommand.SupportedReport)\n@ccValueProperty(\"sceneCount\", CentralSceneCCValues.sceneCount)\n@ccValueProperty(\n\t\"supportsSlowRefresh\",\n\tCentralSceneCCValues.supportsSlowRefresh,\n)\n@ccValueProperty(\n\t\"supportedKeyAttributes\",\n\tCentralSceneCCValues.supportedKeyAttributes,\n)\nexport class CentralSceneCCSupportedReport extends CentralSceneCC {\n\tpublic constructor(\n\t\toptions: WithAddress<CentralSceneCCSupportedReportOptions>,\n\t) {\n\t\tsuper(options);\n\n\t\t// TODO: Check implementation:\n\t\tthis.sceneCount = options.sceneCount;\n\t\tthis.supportsSlowRefresh = options.supportsSlowRefresh;\n\t\tfor (\n\t\t\tconst [scene, keys] of Object.entries(\n\t\t\t\toptions.supportedKeyAttributes,\n\t\t\t)\n\t\t) {\n\t\t\tthis._supportedKeyAttributes.set(\n\t\t\t\tparseInt(scene),\n\t\t\t\tkeys,\n\t\t\t);\n\t\t}\n\t}\n\n\tpublic static from(\n\t\traw: CCRaw,\n\t\tctx: CCParsingContext,\n\t): CentralSceneCCSupportedReport {\n\t\tvalidatePayload(raw.payload.length >= 2);\n\t\tconst sceneCount = raw.payload[0];\n\t\tconst supportsSlowRefresh: MaybeNotKnown<boolean> =\n\t\t\t!!(raw.payload[1] & 0b1000_0000);\n\t\tconst bitMaskBytes = (raw.payload[1] & 0b110) >>> 1;\n\t\tconst identicalKeyAttributes = !!(raw.payload[1] & 0b1);\n\t\tconst numEntries = identicalKeyAttributes ? 1 : sceneCount;\n\t\tvalidatePayload(raw.payload.length >= 2 + bitMaskBytes * numEntries);\n\t\tconst supportedKeyAttributes: Record<\n\t\t\tnumber,\n\t\t\treadonly CentralSceneKeys[]\n\t\t> = {};\n\t\tfor (let i = 0; i < numEntries; i++) {\n\t\t\tconst mask = raw.payload.subarray(\n\t\t\t\t2 + i * bitMaskBytes,\n\t\t\t\t2 + (i + 1) * bitMaskBytes,\n\t\t\t);\n\t\t\tsupportedKeyAttributes[i + 1] = parseBitMask(\n\t\t\t\tmask,\n\t\t\t\tCentralSceneKeys.KeyPressed,\n\t\t\t);\n\t\t}\n\n\t\tif (identicalKeyAttributes) {\n\t\t\t// The key attributes are only transmitted for scene 1, copy them to the others\n\t\t\tfor (let i = 2; i <= sceneCount; i++) {\n\t\t\t\tsupportedKeyAttributes[i] = supportedKeyAttributes[1];\n\t\t\t}\n\t\t}\n\n\t\treturn new this({\n\t\t\tnodeId: ctx.sourceNodeId,\n\t\t\tsceneCount,\n\t\t\tsupportsSlowRefresh,\n\t\t\tsupportedKeyAttributes,\n\t\t});\n\t}\n\n\tpublic persistValues(ctx: PersistValuesContext): boolean {\n\t\tif (!super.persistValues(ctx)) return false;\n\n\t\t// Create/extend metadata for all scenes\n\t\tfor (let i = 1; i <= this.sceneCount; i++) {\n\t\t\tconst sceneValue = CentralSceneCCValues.scene(i);\n\t\t\tthis.setMetadata(ctx, sceneValue, {\n\t\t\t\t...sceneValue.meta,\n\t\t\t\tstates: enumValuesToMetadataStates(\n\t\t\t\t\tCentralSceneKeys,\n\t\t\t\t\tthis._supportedKeyAttributes.get(i),\n\t\t\t\t),\n\t\t\t});\n\t\t}\n\n\t\treturn true;\n\t}\n\n\tpublic readonly sceneCount: number;\n\n\t// TODO: Only offer `slowRefresh` if this is true\n\n\tpublic readonly supportsSlowRefresh: MaybeNotKnown<boolean>;\n\n\tprivate _supportedKeyAttributes = new Map<\n\t\tnumber,\n\t\treadonly CentralSceneKeys[]\n\t>();\n\n\tpublic get supportedKeyAttributes(): ReadonlyMap<\n\t\tnumber,\n\t\treadonly CentralSceneKeys[]\n\t> {\n\t\treturn this._supportedKeyAttributes;\n\t}\n\n\tpublic toLogEntry(ctx?: GetValueDB): MessageOrCCLogEntry {\n\t\tconst message: MessageRecord = {\n\t\t\t\"scene count\": this.sceneCount,\n\t\t\t\"supports slow refresh\": maybeUnknownToString(\n\t\t\t\tthis.supportsSlowRefresh,\n\t\t\t),\n\t\t};\n\t\tfor (const [scene, keys] of this.supportedKeyAttributes) {\n\t\t\tmessage[`supported attributes (scene #${scene})`] = keys\n\t\t\t\t.map((k) => `\\n\u00B7 ${getEnumMemberName(CentralSceneKeys, k)}`)\n\t\t\t\t.join(\"\");\n\t\t}\n\t\treturn {\n\t\t\t...super.toLogEntry(ctx),\n\t\t\tmessage,\n\t\t};\n\t}\n}\n\n@CCCommand(CentralSceneCommand.SupportedGet)\n@expectedCCResponse(CentralSceneCCSupportedReport)\nexport class CentralSceneCCSupportedGet extends CentralSceneCC {}\n\n// @publicAPI\nexport interface CentralSceneCCConfigurationReportOptions {\n\tslowRefresh: boolean;\n}\n\n@CCCommand(CentralSceneCommand.ConfigurationReport)\n@ccValueProperty(\"slowRefresh\", CentralSceneCCValues.slowRefresh)\nexport class CentralSceneCCConfigurationReport extends CentralSceneCC {\n\tpublic constructor(\n\t\toptions: WithAddress<CentralSceneCCConfigurationReportOptions>,\n\t) {\n\t\tsuper(options);\n\n\t\t// TODO: Check implementation:\n\t\tthis.slowRefresh = options.slowRefresh;\n\t}\n\n\tpublic static from(\n\t\traw: CCRaw,\n\t\tctx: CCParsingContext,\n\t): CentralSceneCCConfigurationReport {\n\t\tvalidatePayload(raw.payload.length >= 1);\n\t\tconst slowRefresh = !!(raw.payload[0] & 0b1000_0000);\n\n\t\treturn new this({\n\t\t\tnodeId: ctx.sourceNodeId,\n\t\t\tslowRefresh,\n\t\t});\n\t}\n\n\tpublic readonly slowRefresh: boolean;\n\n\tpublic toLogEntry(ctx?: GetValueDB): MessageOrCCLogEntry {\n\t\treturn {\n\t\t\t...super.toLogEntry(ctx),\n\t\t\tmessage: { \"slow refresh\": this.slowRefresh },\n\t\t};\n\t}\n}\n\n@CCCommand(CentralSceneCommand.ConfigurationGet)\n@expectedCCResponse(CentralSceneCCConfigurationReport)\nexport class CentralSceneCCConfigurationGet extends CentralSceneCC {}\n\n// @publicAPI\nexport interface CentralSceneCCConfigurationSetOptions {\n\tslowRefresh: boolean;\n}\n\n@CCCommand(CentralSceneCommand.ConfigurationSet)\n@useSupervision()\nexport class CentralSceneCCConfigurationSet extends CentralSceneCC {\n\tpublic constructor(\n\t\toptions: WithAddress<CentralSceneCCConfigurationSetOptions>,\n\t) {\n\t\tsuper(options);\n\t\tthis.slowRefresh = options.slowRefresh;\n\t}\n\n\tpublic static from(\n\t\t_raw: CCRaw,\n\t\t_ctx: CCParsingContext,\n\t): CentralSceneCCConfigurationSet {\n\t\tthrow new ZWaveError(\n\t\t\t`${this.name}: deserialization not implemented`,\n\t\t\tZWaveErrorCodes.Deserialization_NotImplemented,\n\t\t);\n\n\t\t// return new CentralSceneCCConfigurationSet({\n\t\t// \tnodeId: ctx.sourceNodeId,\n\t\t// });\n\t}\n\n\tpublic slowRefresh: boolean;\n\n\tpublic serialize(ctx: CCEncodingContext): Bytes {\n\t\tthis.payload = Bytes.from([this.slowRefresh ? 0b1000_0000 : 0]);\n\t\t// eslint-disable-next-line @typescript-eslint/no-deprecated\n\t\treturn super.serialize(ctx);\n\t}\n\n\tpublic toLogEnt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A,MAAA,SAAA,MAAA,WAAA,MAAA,UAAA,UAAA,GAAA,MAAA,uBAAA;;;AAAa,wBAAA,YAAA,uBAAA;;;;;IASA,kCAA8B,MAAA;8BAF1C,yCAAU,iCAAoB,gBAAgB,OAC9C,8CAAc,CAAE;;;;oBACmC;sDAAA,YAAc;;;;;;AAAlE,mBAAA,MAAA,mBAAA,EAAA,OAAA,WAAA,GAAA,kBAAA,EAAA,MAAA,SAAA,MAAA,WAAA,MAAA,UAAA,UAAA,GAAA,MAAA,uBAAA;;;AAAa,wBAAA,YAAA,uBAAA;;IACZ,YACC,SAA2D;AAE3D,YAAM,OAAO;AACb,WAAK,cAAc,QAAQ;IAC5B;IAEO,OAAO,KACb,MACA,MAAsB;AAEtB,YAAM,IAAI,uBACT,GAAG,KAAK,IAAI,qCACZ,4BAAgB,8BAA8B;IAMhD;IAEO;IAEA,UAAU,KAAsB;AACtC,WAAK,UAAU,mBAAM,KAAK,CAAC,KAAK,cAAc,MAAc,CAAC,CAAC;AAE9D,aAAO,MAAM,UAAU,GAAG;IAC3B;IAEO,WAAW,KAAgB;AACjC,aAAO;QACN,GAAG,MAAM,WAAW,GAAG;QACvB,SAAS,EAAE,gBAAgB,KAAK,YAAW;;IAE7C;;;;",
|
|
6
6
|
"names": ["import_safe"]
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/cc/ClimateControlScheduleCC.ts"],
|
|
4
|
-
"sourcesContent": ["import {\n\tCommandClasses,\n\ttype MaybeNotKnown,\n\ttype MessageOrCCLogEntry,\n\ttype SupervisionResult,\n\tValueMetadata,\n\ttype WithAddress,\n\tZWaveError,\n\tZWaveErrorCodes,\n\tenumValuesToMetadataStates,\n\tvalidatePayload,\n} from \"@zwave-js/core/safe\";\nimport type {\n\tCCEncodingContext,\n\tCCParsingContext,\n\tGetValueDB,\n} from \"@zwave-js/host/safe\";\nimport { Bytes } from \"@zwave-js/shared/safe\";\nimport { getEnumMemberName } from \"@zwave-js/shared/safe\";\nimport { validateArgs } from \"@zwave-js/transformers\";\nimport { CCAPI } from \"../lib/API.js\";\nimport { type CCRaw, CommandClass } from \"../lib/CommandClass.js\";\nimport {\n\tAPI,\n\tCCCommand,\n\tccValueProperty,\n\tccValues,\n\tcommandClass,\n\texpectedCCResponse,\n\timplementedVersion,\n\tuseSupervision,\n} from \"../lib/CommandClassDecorators.js\";\nimport { V } from \"../lib/Values.js\";\nimport {\n\tClimateControlScheduleCommand,\n\tScheduleOverrideType,\n\ttype SetbackState,\n\ttype Switchpoint,\n\tWeekday,\n} from \"../lib/_Types.js\";\nimport {\n\tdecodeSetbackState,\n\tdecodeSwitchpoint,\n\tencodeSetbackState,\n\tencodeSwitchpoint,\n} from \"../lib/serializers.js\";\n\nexport const ClimateControlScheduleCCValues = Object.freeze({\n\t...V.defineStaticCCValues(CommandClasses[\"Climate Control Schedule\"], {\n\t\t...V.staticProperty(\n\t\t\t\"overrideType\",\n\t\t\t{\n\t\t\t\t...ValueMetadata.Number,\n\t\t\t\tlabel: \"Override type\",\n\t\t\t\tstates: enumValuesToMetadataStates(ScheduleOverrideType),\n\t\t\t} as const,\n\t\t),\n\t\t...V.staticProperty(\n\t\t\t\"overrideState\",\n\t\t\t{\n\t\t\t\t...ValueMetadata.Number,\n\t\t\t\tlabel: \"Override state\",\n\t\t\t\tmin: -12.8,\n\t\t\t} as const,\n\t\t),\n\t}),\n\n\t...V.defineDynamicCCValues(CommandClasses[\"Climate Control Schedule\"], {\n\t\t...V.dynamicPropertyAndKeyWithName(\n\t\t\t\"schedule\",\n\t\t\t\"schedule\",\n\t\t\t(weekday: Weekday) => weekday,\n\t\t\t({ property, propertyKey }) =>\n\t\t\t\tproperty === \"switchPoints\"\n\t\t\t\t&& typeof propertyKey === \"number\"\n\t\t\t\t&& propertyKey >= Weekday.Monday\n\t\t\t\t&& propertyKey <= Weekday.Sunday,\n\t\t\t(weekday: Weekday) => ({\n\t\t\t\t...ValueMetadata.Any,\n\t\t\t\tlabel: `Schedule (${getEnumMemberName(Weekday, weekday)})`,\n\t\t\t} as const),\n\t\t),\n\t}),\n});\n\n@API(CommandClasses[\"Climate Control Schedule\"])\nexport class ClimateControlScheduleCCAPI extends CCAPI {\n\tpublic supportsCommand(\n\t\tcmd: ClimateControlScheduleCommand,\n\t): MaybeNotKnown<boolean> {\n\t\tswitch (cmd) {\n\t\t\tcase ClimateControlScheduleCommand.Set:\n\t\t\tcase ClimateControlScheduleCommand.OverrideSet:\n\t\t\t\treturn true; // mandatory\n\t\t\tcase ClimateControlScheduleCommand.Get:\n\t\t\tcase ClimateControlScheduleCommand.ChangedGet:\n\t\t\tcase ClimateControlScheduleCommand.OverrideGet:\n\t\t\t\treturn this.isSinglecast();\n\t\t}\n\t\treturn super.supportsCommand(cmd);\n\t}\n\n\t@validateArgs({ strictEnums: true })\n\tpublic async set(\n\t\tweekday: Weekday,\n\t\tswitchPoints: Switchpoint[],\n\t): Promise<SupervisionResult | undefined> {\n\t\tthis.assertSupportsCommand(\n\t\t\tClimateControlScheduleCommand,\n\t\t\tClimateControlScheduleCommand.Set,\n\t\t);\n\n\t\tconst cc = new ClimateControlScheduleCCSet({\n\t\t\tnodeId: this.endpoint.nodeId,\n\t\t\tendpointIndex: this.endpoint.index,\n\t\t\tweekday,\n\t\t\tswitchPoints,\n\t\t});\n\t\treturn this.host.sendCommand(cc, this.commandOptions);\n\t}\n\n\t@validateArgs({ strictEnums: true })\n\tpublic async get(\n\t\tweekday: Weekday,\n\t): Promise<MaybeNotKnown<readonly Switchpoint[]>> {\n\t\tthis.assertSupportsCommand(\n\t\t\tClimateControlScheduleCommand,\n\t\t\tClimateControlScheduleCommand.Get,\n\t\t);\n\n\t\tconst cc = new ClimateControlScheduleCCGet({\n\t\t\tnodeId: this.endpoint.nodeId,\n\t\t\tendpointIndex: this.endpoint.index,\n\t\t\tweekday,\n\t\t});\n\t\tconst response = await this.host.sendCommand<\n\t\t\tClimateControlScheduleCCReport\n\t\t>(\n\t\t\tcc,\n\t\t\tthis.commandOptions,\n\t\t);\n\t\treturn response?.schedule;\n\t}\n\n\tpublic async getChangeCounter(): Promise<MaybeNotKnown<number>> {\n\t\tthis.assertSupportsCommand(\n\t\t\tClimateControlScheduleCommand,\n\t\t\tClimateControlScheduleCommand.ChangedGet,\n\t\t);\n\n\t\tconst cc = new ClimateControlScheduleCCChangedGet({\n\t\t\tnodeId: this.endpoint.nodeId,\n\t\t\tendpointIndex: this.endpoint.index,\n\t\t});\n\t\tconst response = await this.host.sendCommand<\n\t\t\tClimateControlScheduleCCChangedReport\n\t\t>(\n\t\t\tcc,\n\t\t\tthis.commandOptions,\n\t\t);\n\t\treturn response?.changeCounter;\n\t}\n\n\t// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types\n\tpublic async getOverride() {\n\t\tthis.assertSupportsCommand(\n\t\t\tClimateControlScheduleCommand,\n\t\t\tClimateControlScheduleCommand.OverrideGet,\n\t\t);\n\n\t\tconst cc = new ClimateControlScheduleCCOverrideGet({\n\t\t\tnodeId: this.endpoint.nodeId,\n\t\t\tendpointIndex: this.endpoint.index,\n\t\t});\n\t\tconst response = await this.host.sendCommand<\n\t\t\tClimateControlScheduleCCOverrideReport\n\t\t>(\n\t\t\tcc,\n\t\t\tthis.commandOptions,\n\t\t);\n\t\tif (response) {\n\t\t\treturn {\n\t\t\t\ttype: response.overrideType,\n\t\t\t\tstate: response.overrideState,\n\t\t\t};\n\t\t}\n\t}\n\n\t@validateArgs({ strictEnums: true })\n\tpublic async setOverride(\n\t\ttype: ScheduleOverrideType,\n\t\tstate: SetbackState,\n\t): Promise<SupervisionResult | undefined> {\n\t\tthis.assertSupportsCommand(\n\t\t\tClimateControlScheduleCommand,\n\t\t\tClimateControlScheduleCommand.OverrideSet,\n\t\t);\n\n\t\tconst cc = new ClimateControlScheduleCCOverrideSet({\n\t\t\tnodeId: this.endpoint.nodeId,\n\t\t\tendpointIndex: this.endpoint.index,\n\t\t\toverrideType: type,\n\t\t\toverrideState: state,\n\t\t});\n\t\treturn this.host.sendCommand(cc, this.commandOptions);\n\t}\n}\n\n@commandClass(CommandClasses[\"Climate Control Schedule\"])\n@implementedVersion(1)\n@ccValues(ClimateControlScheduleCCValues)\nexport class ClimateControlScheduleCC extends CommandClass {\n\tdeclare ccCommand: ClimateControlScheduleCommand;\n}\n\n// @publicAPI\nexport interface ClimateControlScheduleCCSetOptions {\n\tweekday: Weekday;\n\tswitchPoints: Switchpoint[];\n}\n\n@CCCommand(ClimateControlScheduleCommand.Set)\n@useSupervision()\nexport class ClimateControlScheduleCCSet extends ClimateControlScheduleCC {\n\tpublic constructor(\n\t\toptions: WithAddress<ClimateControlScheduleCCSetOptions>,\n\t) {\n\t\tsuper(options);\n\t\tthis.switchPoints = options.switchPoints;\n\t\tthis.weekday = options.weekday;\n\t}\n\n\tpublic static from(\n\t\t_raw: CCRaw,\n\t\t_ctx: CCParsingContext,\n\t): ClimateControlScheduleCCSet {\n\t\tthrow new ZWaveError(\n\t\t\t`${this.name}: deserialization not implemented`,\n\t\t\tZWaveErrorCodes.Deserialization_NotImplemented,\n\t\t);\n\n\t\t// return new ClimateControlScheduleCCSet({\n\t\t// \tnodeId: ctx.sourceNodeId,\n\t\t// });\n\t}\n\n\tpublic switchPoints: Switchpoint[];\n\tpublic weekday: Weekday;\n\n\tpublic serialize(ctx: CCEncodingContext): Bytes {\n\t\t// Make sure we have exactly 9 entries\n\t\tconst allSwitchPoints = this.switchPoints.slice(0, 9); // maximum 9\n\t\twhile (allSwitchPoints.length < 9) {\n\t\t\tallSwitchPoints.push({\n\t\t\t\thour: 0,\n\t\t\t\tminute: 0,\n\t\t\t\tstate: \"Unused\",\n\t\t\t});\n\t\t}\n\t\tthis.payload = Bytes.concat([\n\t\t\tBytes.from([this.weekday & 0b111]),\n\t\t\t...allSwitchPoints.map((sp) => encodeSwitchpoint(sp)),\n\t\t]);\n\t\treturn super.serialize(ctx);\n\t}\n\n\tpublic toLogEntry(ctx?: GetValueDB): MessageOrCCLogEntry {\n\t\treturn {\n\t\t\t...super.toLogEntry(ctx),\n\t\t\tmessage: {\n\t\t\t\tweekday: getEnumMemberName(Weekday, this.weekday),\n\t\t\t\tswitchpoints: `${\n\t\t\t\t\tthis.switchPoints\n\t\t\t\t\t\t.map(\n\t\t\t\t\t\t\t(sp) => `\n\u00B7 ${sp.hour.toString().padStart(2, \"0\")}:${\n\t\t\t\t\t\t\t\tsp.minute.toString().padStart(\n\t\t\t\t\t\t\t\t\t2,\n\t\t\t\t\t\t\t\t\t\"0\",\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t} --> ${sp.state}`,\n\t\t\t\t\t\t)\n\t\t\t\t\t\t.join(\"\")\n\t\t\t\t}`,\n\t\t\t},\n\t\t};\n\t}\n}\n\n// @publicAPI\nexport interface ClimateControlScheduleCCReportOptions {\n\tweekday: Weekday;\n\tschedule: Switchpoint[];\n}\n\n@CCCommand(ClimateControlScheduleCommand.Report)\n@ccValueProperty(\n\t\"schedule\",\n\tClimateControlScheduleCCValues.schedule,\n\t(self) => [self.weekday],\n)\nexport class ClimateControlScheduleCCReport extends ClimateControlScheduleCC {\n\tpublic constructor(\n\t\toptions: WithAddress<ClimateControlScheduleCCReportOptions>,\n\t) {\n\t\tsuper(options);\n\n\t\t// TODO: Check implementation:\n\t\tthis.weekday = options.weekday;\n\t\tthis.schedule = options.schedule;\n\t}\n\n\tpublic static from(\n\t\traw: CCRaw,\n\t\tctx: CCParsingContext,\n\t): ClimateControlScheduleCCReport {\n\t\tvalidatePayload(raw.payload.length >= 28);\n\t\tconst weekday: Weekday = raw.payload[0] & 0b111;\n\t\tconst allSwitchpoints: Switchpoint[] = [];\n\t\tfor (let i = 0; i <= 8; i++) {\n\t\t\tallSwitchpoints.push(\n\t\t\t\tdecodeSwitchpoint(raw.payload.subarray(1 + 3 * i)),\n\t\t\t);\n\t\t}\n\n\t\tconst schedule: Switchpoint[] = allSwitchpoints.filter((sp) =>\n\t\t\tsp.state !== \"Unused\"\n\t\t);\n\n\t\treturn new this({\n\t\t\tnodeId: ctx.sourceNodeId,\n\t\t\tweekday,\n\t\t\tschedule,\n\t\t});\n\t}\n\n\tpublic readonly weekday: Weekday;\n\n\tpublic readonly schedule: readonly Switchpoint[];\n\n\tpublic toLogEntry(ctx?: GetValueDB): MessageOrCCLogEntry {\n\t\treturn {\n\t\t\t...super.toLogEntry(ctx),\n\t\t\tmessage: {\n\t\t\t\tweekday: getEnumMemberName(Weekday, this.weekday),\n\t\t\t\tschedule: `${\n\t\t\t\t\tthis.schedule\n\t\t\t\t\t\t.map(\n\t\t\t\t\t\t\t(sp) => `\n\u00B7 ${sp.hour.toString().padStart(2, \"0\")}:${\n\t\t\t\t\t\t\t\tsp.minute.toString().padStart(\n\t\t\t\t\t\t\t\t\t2,\n\t\t\t\t\t\t\t\t\t\"0\",\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t} --> ${sp.state}`,\n\t\t\t\t\t\t)\n\t\t\t\t\t\t.join(\"\")\n\t\t\t\t}`,\n\t\t\t},\n\t\t};\n\t}\n}\n\n// @publicAPI\nexport interface ClimateControlScheduleCCGetOptions {\n\tweekday: Weekday;\n}\n\n@CCCommand(ClimateControlScheduleCommand.Get)\n@expectedCCResponse(ClimateControlScheduleCCReport)\nexport class ClimateControlScheduleCCGet extends ClimateControlScheduleCC {\n\tpublic constructor(\n\t\toptions: WithAddress<ClimateControlScheduleCCGetOptions>,\n\t) {\n\t\tsuper(options);\n\t\tthis.weekday = options.weekday;\n\t}\n\n\tpublic static from(\n\t\t_raw: CCRaw,\n\t\t_ctx: CCParsingContext,\n\t): ClimateControlScheduleCCGet {\n\t\tthrow new ZWaveError(\n\t\t\t`${this.name}: deserialization not implemented`,\n\t\t\tZWaveErrorCodes.Deserialization_NotImplemented,\n\t\t);\n\n\t\t// return new ClimateControlScheduleCCGet({\n\t\t// \tnodeId: ctx.sourceNodeId,\n\t\t// });\n\t}\n\n\tpublic weekday: Weekday;\n\n\tpublic serialize(ctx: CCEncodingContext): Bytes {\n\t\tthis.payload = Bytes.from([this.weekday & 0b111]);\n\t\treturn super.serialize(ctx);\n\t}\n\n\tpublic toLogEntry(ctx?: GetValueDB): MessageOrCCLogEntry {\n\t\treturn {\n\t\t\t...super.toLogEntry(ctx),\n\t\t\tmessage: { weekday: getEnumMemberName(Weekday, this.weekday) },\n\t\t};\n\t}\n}\n\n// @publicAPI\nexport interface ClimateControlScheduleCCChangedReportOptions {\n\tchangeCounter: number;\n}\n\n@CCCommand(ClimateControlScheduleCommand.ChangedReport)\nexport class ClimateControlScheduleCCChangedReport\n\textends ClimateControlScheduleCC\n{\n\tpublic constructor(\n\t\toptions: WithAddress<ClimateControlScheduleCCChangedReportOptions>,\n\t) {\n\t\tsuper(options);\n\n\t\t// TODO: Check implementation:\n\t\tthis.changeCounter = options.changeCounter;\n\t}\n\n\tpublic static from(\n\t\traw: CCRaw,\n\t\tctx: CCParsingContext,\n\t): ClimateControlScheduleCCChangedReport {\n\t\tvalidatePayload(raw.payload.length >= 1);\n\t\tconst changeCounter = raw.payload[0];\n\n\t\treturn new this({\n\t\t\tnodeId: ctx.sourceNodeId,\n\t\t\tchangeCounter,\n\t\t});\n\t}\n\n\tpublic readonly changeCounter: number;\n\n\tpublic toLogEntry(ctx?: GetValueDB): MessageOrCCLogEntry {\n\t\treturn {\n\t\t\t...super.toLogEntry(ctx),\n\t\t\tmessage: { \"change counter\": this.changeCounter },\n\t\t};\n\t}\n}\n\n@CCCommand(ClimateControlScheduleCommand.ChangedGet)\n@expectedCCResponse(ClimateControlScheduleCCChangedReport)\nexport class ClimateControlScheduleCCChangedGet\n\textends ClimateControlScheduleCC\n{}\n\n// @publicAPI\nexport interface ClimateControlScheduleCCOverrideReportOptions {\n\toverrideType: ScheduleOverrideType;\n\toverrideState: SetbackState;\n}\n\n@CCCommand(ClimateControlScheduleCommand.OverrideReport)\n@ccValueProperty(\"overrideType\", ClimateControlScheduleCCValues.overrideType)\n@ccValueProperty(\"overrideState\", ClimateControlScheduleCCValues.overrideState)\nexport class ClimateControlScheduleCCOverrideReport\n\textends ClimateControlScheduleCC\n{\n\tpublic constructor(\n\t\toptions: WithAddress<ClimateControlScheduleCCOverrideReportOptions>,\n\t) {\n\t\tsuper(options);\n\n\t\t// TODO: Check implementation:\n\t\tthis.overrideType = options.overrideType;\n\t\tthis.overrideState = options.overrideState;\n\t}\n\n\tpublic static from(\n\t\traw: CCRaw,\n\t\tctx: CCParsingContext,\n\t): ClimateControlScheduleCCOverrideReport {\n\t\tvalidatePayload(raw.payload.length >= 2);\n\t\tconst overrideType: ScheduleOverrideType = raw.payload[0] & 0b11;\n\t\tconst overrideState: SetbackState = decodeSetbackState(raw.payload, 1)\n\t\t\t// If we receive an unknown setback state, return the raw value\n\t\t\t|| raw.payload.readInt8(1);\n\n\t\treturn new this({\n\t\t\tnodeId: ctx.sourceNodeId,\n\t\t\toverrideType,\n\t\t\toverrideState,\n\t\t});\n\t}\n\n\tpublic readonly overrideType: ScheduleOverrideType;\n\n\tpublic readonly overrideState: SetbackState;\n\n\tpublic toLogEntry(ctx?: GetValueDB): MessageOrCCLogEntry {\n\t\treturn {\n\t\t\t...super.toLogEntry(ctx),\n\t\t\tmessage: {\n\t\t\t\t\"override type\": getEnumMemberName(\n\t\t\t\t\tScheduleOverrideType,\n\t\t\t\t\tthis.overrideType,\n\t\t\t\t),\n\t\t\t\t\"override state\": this.overrideState,\n\t\t\t},\n\t\t};\n\t}\n}\n\n@CCCommand(ClimateControlScheduleCommand.OverrideGet)\n@expectedCCResponse(ClimateControlScheduleCCOverrideReport)\nexport class ClimateControlScheduleCCOverrideGet\n\textends ClimateControlScheduleCC\n{}\n\n// @publicAPI\nexport interface ClimateControlScheduleCCOverrideSetOptions {\n\toverrideType: ScheduleOverrideType;\n\toverrideState: SetbackState;\n}\n\n@CCCommand(ClimateControlScheduleCommand.OverrideSet)\n@useSupervision()\nexport class ClimateControlScheduleCCOverrideSet\n\textends ClimateControlScheduleCC\n{\n\tpublic constructor(\n\t\toptions: WithAddress<ClimateControlScheduleCCOverrideSetOptions>,\n\t) {\n\t\tsuper(options);\n\t\tthis.overrideType = options.overrideType;\n\t\tthis.overrideState = options.overrideState;\n\t}\n\n\tpublic static from(\n\t\t_raw: CCRaw,\n\t\t_ctx: CCParsingContext,\n\t): ClimateControlScheduleCCOverrideSet {\n\t\tthrow new ZWaveError(\n\t\t\t`${this.name}: deserialization not implemented`,\n\t\t\tZWaveErrorCodes.Deserialization_NotImplemented,\n\t\t);\n\n\t\t// return new ClimateControlScheduleCCOverrideSet({\n\t\t// \tnodeId: ctx.sourceNodeId,\n\t\t// });\n\t}\n\n\tpublic overrideType: ScheduleOverrideType;\n\tpublic overrideState: SetbackState;\n\n\tpublic serialize(ctx: CCEncodingContext): Bytes {\n\t\tthis.payload = Bytes.concat([\n\t\t\t[this.overrideType & 0b11],\n\t\t\tencodeSetbackState(this.overrideState),\n\t\t]);\n\t\treturn super.serialize(ctx);\n\t}\n\n\tpublic toLogEntry(ctx?: GetValueDB): MessageOrCCLogEntry {\n\t\treturn {\n\t\t\t...super.toLogEntry(ctx),\n\t\t\tmessage: {\n\t\t\t\t\"override type\": getEnumMemberName(\n\t\t\t\t\tScheduleOverrideType,\n\t\t\t\t\tthis.overrideType,\n\t\t\t\t),\n\t\t\t\t\"override state\": this.overrideState,\n\t\t\t},\n\t\t};\n\t}\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,kBAWO;AAMP,IAAAA,eAAsB;AACtB,IAAAA,eAAkC;AAElC,iBAAsB;AACtB,0BAAyC;AACzC,oCASO;AACP,oBAAkB;AAClB,mBAMO;AACP,yBAKO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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,kBAAA,EAAA,MAAA,SAAA,MAAA,WAAA,MAAA,UAAA,UAAA,GAAA,MAAA,uBAAA;;;AAAa,wBAAA,YAAA,uBAAA;;;;;IAYA,+BAA2B,MAAA;8BAFvC,yCAAU,2CAA8B,GAAG,OAC3C,8CAAc,CAAE;;;;oBACgC;mDAAA,YAAwB;;;;;;AAAzE,mBAAA,MAAA,mBAAA,EAAA,OAAA,WAAA,GAAA,kBAAA,EAAA,MAAA,SAAA,MAAA,WAAA,MAAA,UAAA,UAAA,GAAA,MAAA,uBAAA;;;AAAa,wBAAA,YAAA,uBAAA;;IACZ,YACC,SAAwD;AAExD,YAAM,OAAO;AACb,WAAK,eAAe,QAAQ;AAC5B,WAAK,UAAU,QAAQ;IACxB;IAEO,OAAO,KACb,MACA,MAAsB;AAEtB,YAAM,IAAI,uBACT,GAAG,KAAK,IAAI,qCACZ,4BAAgB,8BAA8B;IAMhD;IAEO;IACA;IAEA,UAAU,KAAsB;AAEtC,YAAM,kBAAkB,KAAK,aAAa,MAAM,GAAG,CAAC;AACpD,aAAO,gBAAgB,SAAS,GAAG;AAClC,wBAAgB,KAAK;UACpB,MAAM;UACN,QAAQ;UACR,OAAO;SACP;MACF;AACA,WAAK,UAAU,mBAAM,OAAO;QAC3B,mBAAM,KAAK,CAAC,KAAK,UAAU,CAAK,CAAC;QACjC,GAAG,gBAAgB,IAAI,CAAC,WAAO,sCAAkB,EAAE,CAAC;OACpD;
|
|
4
|
+
"sourcesContent": ["import {\n\tCommandClasses,\n\ttype MaybeNotKnown,\n\ttype MessageOrCCLogEntry,\n\ttype SupervisionResult,\n\tValueMetadata,\n\ttype WithAddress,\n\tZWaveError,\n\tZWaveErrorCodes,\n\tenumValuesToMetadataStates,\n\tvalidatePayload,\n} from \"@zwave-js/core/safe\";\nimport type {\n\tCCEncodingContext,\n\tCCParsingContext,\n\tGetValueDB,\n} from \"@zwave-js/host/safe\";\nimport { Bytes } from \"@zwave-js/shared/safe\";\nimport { getEnumMemberName } from \"@zwave-js/shared/safe\";\nimport { validateArgs } from \"@zwave-js/transformers\";\nimport { CCAPI } from \"../lib/API.js\";\nimport { type CCRaw, CommandClass } from \"../lib/CommandClass.js\";\nimport {\n\tAPI,\n\tCCCommand,\n\tccValueProperty,\n\tccValues,\n\tcommandClass,\n\texpectedCCResponse,\n\timplementedVersion,\n\tuseSupervision,\n} from \"../lib/CommandClassDecorators.js\";\nimport { V } from \"../lib/Values.js\";\nimport {\n\tClimateControlScheduleCommand,\n\tScheduleOverrideType,\n\ttype SetbackState,\n\ttype Switchpoint,\n\tWeekday,\n} from \"../lib/_Types.js\";\nimport {\n\tdecodeSetbackState,\n\tdecodeSwitchpoint,\n\tencodeSetbackState,\n\tencodeSwitchpoint,\n} from \"../lib/serializers.js\";\n\nexport const ClimateControlScheduleCCValues = Object.freeze({\n\t...V.defineStaticCCValues(CommandClasses[\"Climate Control Schedule\"], {\n\t\t...V.staticProperty(\n\t\t\t\"overrideType\",\n\t\t\t{\n\t\t\t\t...ValueMetadata.Number,\n\t\t\t\tlabel: \"Override type\",\n\t\t\t\tstates: enumValuesToMetadataStates(ScheduleOverrideType),\n\t\t\t} as const,\n\t\t),\n\t\t...V.staticProperty(\n\t\t\t\"overrideState\",\n\t\t\t{\n\t\t\t\t...ValueMetadata.Number,\n\t\t\t\tlabel: \"Override state\",\n\t\t\t\tmin: -12.8,\n\t\t\t} as const,\n\t\t),\n\t}),\n\n\t...V.defineDynamicCCValues(CommandClasses[\"Climate Control Schedule\"], {\n\t\t...V.dynamicPropertyAndKeyWithName(\n\t\t\t\"schedule\",\n\t\t\t\"schedule\",\n\t\t\t(weekday: Weekday) => weekday,\n\t\t\t({ property, propertyKey }) =>\n\t\t\t\tproperty === \"switchPoints\"\n\t\t\t\t&& typeof propertyKey === \"number\"\n\t\t\t\t&& propertyKey >= Weekday.Monday\n\t\t\t\t&& propertyKey <= Weekday.Sunday,\n\t\t\t(weekday: Weekday) => ({\n\t\t\t\t...ValueMetadata.Any,\n\t\t\t\tlabel: `Schedule (${getEnumMemberName(Weekday, weekday)})`,\n\t\t\t} as const),\n\t\t),\n\t}),\n});\n\n@API(CommandClasses[\"Climate Control Schedule\"])\nexport class ClimateControlScheduleCCAPI extends CCAPI {\n\tpublic supportsCommand(\n\t\tcmd: ClimateControlScheduleCommand,\n\t): MaybeNotKnown<boolean> {\n\t\tswitch (cmd) {\n\t\t\tcase ClimateControlScheduleCommand.Set:\n\t\t\tcase ClimateControlScheduleCommand.OverrideSet:\n\t\t\t\treturn true; // mandatory\n\t\t\tcase ClimateControlScheduleCommand.Get:\n\t\t\tcase ClimateControlScheduleCommand.ChangedGet:\n\t\t\tcase ClimateControlScheduleCommand.OverrideGet:\n\t\t\t\treturn this.isSinglecast();\n\t\t}\n\t\treturn super.supportsCommand(cmd);\n\t}\n\n\t@validateArgs({ strictEnums: true })\n\tpublic async set(\n\t\tweekday: Weekday,\n\t\tswitchPoints: Switchpoint[],\n\t): Promise<SupervisionResult | undefined> {\n\t\tthis.assertSupportsCommand(\n\t\t\tClimateControlScheduleCommand,\n\t\t\tClimateControlScheduleCommand.Set,\n\t\t);\n\n\t\tconst cc = new ClimateControlScheduleCCSet({\n\t\t\tnodeId: this.endpoint.nodeId,\n\t\t\tendpointIndex: this.endpoint.index,\n\t\t\tweekday,\n\t\t\tswitchPoints,\n\t\t});\n\t\treturn this.host.sendCommand(cc, this.commandOptions);\n\t}\n\n\t@validateArgs({ strictEnums: true })\n\tpublic async get(\n\t\tweekday: Weekday,\n\t): Promise<MaybeNotKnown<readonly Switchpoint[]>> {\n\t\tthis.assertSupportsCommand(\n\t\t\tClimateControlScheduleCommand,\n\t\t\tClimateControlScheduleCommand.Get,\n\t\t);\n\n\t\tconst cc = new ClimateControlScheduleCCGet({\n\t\t\tnodeId: this.endpoint.nodeId,\n\t\t\tendpointIndex: this.endpoint.index,\n\t\t\tweekday,\n\t\t});\n\t\tconst response = await this.host.sendCommand<\n\t\t\tClimateControlScheduleCCReport\n\t\t>(\n\t\t\tcc,\n\t\t\tthis.commandOptions,\n\t\t);\n\t\treturn response?.schedule;\n\t}\n\n\tpublic async getChangeCounter(): Promise<MaybeNotKnown<number>> {\n\t\tthis.assertSupportsCommand(\n\t\t\tClimateControlScheduleCommand,\n\t\t\tClimateControlScheduleCommand.ChangedGet,\n\t\t);\n\n\t\tconst cc = new ClimateControlScheduleCCChangedGet({\n\t\t\tnodeId: this.endpoint.nodeId,\n\t\t\tendpointIndex: this.endpoint.index,\n\t\t});\n\t\tconst response = await this.host.sendCommand<\n\t\t\tClimateControlScheduleCCChangedReport\n\t\t>(\n\t\t\tcc,\n\t\t\tthis.commandOptions,\n\t\t);\n\t\treturn response?.changeCounter;\n\t}\n\n\t// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types\n\tpublic async getOverride() {\n\t\tthis.assertSupportsCommand(\n\t\t\tClimateControlScheduleCommand,\n\t\t\tClimateControlScheduleCommand.OverrideGet,\n\t\t);\n\n\t\tconst cc = new ClimateControlScheduleCCOverrideGet({\n\t\t\tnodeId: this.endpoint.nodeId,\n\t\t\tendpointIndex: this.endpoint.index,\n\t\t});\n\t\tconst response = await this.host.sendCommand<\n\t\t\tClimateControlScheduleCCOverrideReport\n\t\t>(\n\t\t\tcc,\n\t\t\tthis.commandOptions,\n\t\t);\n\t\tif (response) {\n\t\t\treturn {\n\t\t\t\ttype: response.overrideType,\n\t\t\t\tstate: response.overrideState,\n\t\t\t};\n\t\t}\n\t}\n\n\t@validateArgs({ strictEnums: true })\n\tpublic async setOverride(\n\t\ttype: ScheduleOverrideType,\n\t\tstate: SetbackState,\n\t): Promise<SupervisionResult | undefined> {\n\t\tthis.assertSupportsCommand(\n\t\t\tClimateControlScheduleCommand,\n\t\t\tClimateControlScheduleCommand.OverrideSet,\n\t\t);\n\n\t\tconst cc = new ClimateControlScheduleCCOverrideSet({\n\t\t\tnodeId: this.endpoint.nodeId,\n\t\t\tendpointIndex: this.endpoint.index,\n\t\t\toverrideType: type,\n\t\t\toverrideState: state,\n\t\t});\n\t\treturn this.host.sendCommand(cc, this.commandOptions);\n\t}\n}\n\n@commandClass(CommandClasses[\"Climate Control Schedule\"])\n@implementedVersion(1)\n@ccValues(ClimateControlScheduleCCValues)\nexport class ClimateControlScheduleCC extends CommandClass {\n\tdeclare ccCommand: ClimateControlScheduleCommand;\n}\n\n// @publicAPI\nexport interface ClimateControlScheduleCCSetOptions {\n\tweekday: Weekday;\n\tswitchPoints: Switchpoint[];\n}\n\n@CCCommand(ClimateControlScheduleCommand.Set)\n@useSupervision()\nexport class ClimateControlScheduleCCSet extends ClimateControlScheduleCC {\n\tpublic constructor(\n\t\toptions: WithAddress<ClimateControlScheduleCCSetOptions>,\n\t) {\n\t\tsuper(options);\n\t\tthis.switchPoints = options.switchPoints;\n\t\tthis.weekday = options.weekday;\n\t}\n\n\tpublic static from(\n\t\t_raw: CCRaw,\n\t\t_ctx: CCParsingContext,\n\t): ClimateControlScheduleCCSet {\n\t\tthrow new ZWaveError(\n\t\t\t`${this.name}: deserialization not implemented`,\n\t\t\tZWaveErrorCodes.Deserialization_NotImplemented,\n\t\t);\n\n\t\t// return new ClimateControlScheduleCCSet({\n\t\t// \tnodeId: ctx.sourceNodeId,\n\t\t// });\n\t}\n\n\tpublic switchPoints: Switchpoint[];\n\tpublic weekday: Weekday;\n\n\tpublic serialize(ctx: CCEncodingContext): Bytes {\n\t\t// Make sure we have exactly 9 entries\n\t\tconst allSwitchPoints = this.switchPoints.slice(0, 9); // maximum 9\n\t\twhile (allSwitchPoints.length < 9) {\n\t\t\tallSwitchPoints.push({\n\t\t\t\thour: 0,\n\t\t\t\tminute: 0,\n\t\t\t\tstate: \"Unused\",\n\t\t\t});\n\t\t}\n\t\tthis.payload = Bytes.concat([\n\t\t\tBytes.from([this.weekday & 0b111]),\n\t\t\t...allSwitchPoints.map((sp) => encodeSwitchpoint(sp)),\n\t\t]);\n\t\t// eslint-disable-next-line @typescript-eslint/no-deprecated\n\t\treturn super.serialize(ctx);\n\t}\n\n\tpublic toLogEntry(ctx?: GetValueDB): MessageOrCCLogEntry {\n\t\treturn {\n\t\t\t...super.toLogEntry(ctx),\n\t\t\tmessage: {\n\t\t\t\tweekday: getEnumMemberName(Weekday, this.weekday),\n\t\t\t\tswitchpoints: `${\n\t\t\t\t\tthis.switchPoints\n\t\t\t\t\t\t.map(\n\t\t\t\t\t\t\t(sp) => `\n\u00B7 ${sp.hour.toString().padStart(2, \"0\")}:${\n\t\t\t\t\t\t\t\tsp.minute.toString().padStart(\n\t\t\t\t\t\t\t\t\t2,\n\t\t\t\t\t\t\t\t\t\"0\",\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t} --> ${sp.state}`,\n\t\t\t\t\t\t)\n\t\t\t\t\t\t.join(\"\")\n\t\t\t\t}`,\n\t\t\t},\n\t\t};\n\t}\n}\n\n// @publicAPI\nexport interface ClimateControlScheduleCCReportOptions {\n\tweekday: Weekday;\n\tschedule: Switchpoint[];\n}\n\n@CCCommand(ClimateControlScheduleCommand.Report)\n@ccValueProperty(\n\t\"schedule\",\n\tClimateControlScheduleCCValues.schedule,\n\t(self) => [self.weekday],\n)\nexport class ClimateControlScheduleCCReport extends ClimateControlScheduleCC {\n\tpublic constructor(\n\t\toptions: WithAddress<ClimateControlScheduleCCReportOptions>,\n\t) {\n\t\tsuper(options);\n\n\t\t// TODO: Check implementation:\n\t\tthis.weekday = options.weekday;\n\t\tthis.schedule = options.schedule;\n\t}\n\n\tpublic static from(\n\t\traw: CCRaw,\n\t\tctx: CCParsingContext,\n\t): ClimateControlScheduleCCReport {\n\t\tvalidatePayload(raw.payload.length >= 28);\n\t\tconst weekday: Weekday = raw.payload[0] & 0b111;\n\t\tconst allSwitchpoints: Switchpoint[] = [];\n\t\tfor (let i = 0; i <= 8; i++) {\n\t\t\tallSwitchpoints.push(\n\t\t\t\tdecodeSwitchpoint(raw.payload.subarray(1 + 3 * i)),\n\t\t\t);\n\t\t}\n\n\t\tconst schedule: Switchpoint[] = allSwitchpoints.filter((sp) =>\n\t\t\tsp.state !== \"Unused\"\n\t\t);\n\n\t\treturn new this({\n\t\t\tnodeId: ctx.sourceNodeId,\n\t\t\tweekday,\n\t\t\tschedule,\n\t\t});\n\t}\n\n\tpublic readonly weekday: Weekday;\n\n\tpublic readonly schedule: readonly Switchpoint[];\n\n\tpublic toLogEntry(ctx?: GetValueDB): MessageOrCCLogEntry {\n\t\treturn {\n\t\t\t...super.toLogEntry(ctx),\n\t\t\tmessage: {\n\t\t\t\tweekday: getEnumMemberName(Weekday, this.weekday),\n\t\t\t\tschedule: `${\n\t\t\t\t\tthis.schedule\n\t\t\t\t\t\t.map(\n\t\t\t\t\t\t\t(sp) => `\n\u00B7 ${sp.hour.toString().padStart(2, \"0\")}:${\n\t\t\t\t\t\t\t\tsp.minute.toString().padStart(\n\t\t\t\t\t\t\t\t\t2,\n\t\t\t\t\t\t\t\t\t\"0\",\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t} --> ${sp.state}`,\n\t\t\t\t\t\t)\n\t\t\t\t\t\t.join(\"\")\n\t\t\t\t}`,\n\t\t\t},\n\t\t};\n\t}\n}\n\n// @publicAPI\nexport interface ClimateControlScheduleCCGetOptions {\n\tweekday: Weekday;\n}\n\n@CCCommand(ClimateControlScheduleCommand.Get)\n@expectedCCResponse(ClimateControlScheduleCCReport)\nexport class ClimateControlScheduleCCGet extends ClimateControlScheduleCC {\n\tpublic constructor(\n\t\toptions: WithAddress<ClimateControlScheduleCCGetOptions>,\n\t) {\n\t\tsuper(options);\n\t\tthis.weekday = options.weekday;\n\t}\n\n\tpublic static from(\n\t\t_raw: CCRaw,\n\t\t_ctx: CCParsingContext,\n\t): ClimateControlScheduleCCGet {\n\t\tthrow new ZWaveError(\n\t\t\t`${this.name}: deserialization not implemented`,\n\t\t\tZWaveErrorCodes.Deserialization_NotImplemented,\n\t\t);\n\n\t\t// return new ClimateControlScheduleCCGet({\n\t\t// \tnodeId: ctx.sourceNodeId,\n\t\t// });\n\t}\n\n\tpublic weekday: Weekday;\n\n\tpublic serialize(ctx: CCEncodingContext): Bytes {\n\t\tthis.payload = Bytes.from([this.weekday & 0b111]);\n\t\t// eslint-disable-next-line @typescript-eslint/no-deprecated\n\t\treturn super.serialize(ctx);\n\t}\n\n\tpublic toLogEntry(ctx?: GetValueDB): MessageOrCCLogEntry {\n\t\treturn {\n\t\t\t...super.toLogEntry(ctx),\n\t\t\tmessage: { weekday: getEnumMemberName(Weekday, this.weekday) },\n\t\t};\n\t}\n}\n\n// @publicAPI\nexport interface ClimateControlScheduleCCChangedReportOptions {\n\tchangeCounter: number;\n}\n\n@CCCommand(ClimateControlScheduleCommand.ChangedReport)\nexport class ClimateControlScheduleCCChangedReport\n\textends ClimateControlScheduleCC\n{\n\tpublic constructor(\n\t\toptions: WithAddress<ClimateControlScheduleCCChangedReportOptions>,\n\t) {\n\t\tsuper(options);\n\n\t\t// TODO: Check implementation:\n\t\tthis.changeCounter = options.changeCounter;\n\t}\n\n\tpublic static from(\n\t\traw: CCRaw,\n\t\tctx: CCParsingContext,\n\t): ClimateControlScheduleCCChangedReport {\n\t\tvalidatePayload(raw.payload.length >= 1);\n\t\tconst changeCounter = raw.payload[0];\n\n\t\treturn new this({\n\t\t\tnodeId: ctx.sourceNodeId,\n\t\t\tchangeCounter,\n\t\t});\n\t}\n\n\tpublic readonly changeCounter: number;\n\n\tpublic toLogEntry(ctx?: GetValueDB): MessageOrCCLogEntry {\n\t\treturn {\n\t\t\t...super.toLogEntry(ctx),\n\t\t\tmessage: { \"change counter\": this.changeCounter },\n\t\t};\n\t}\n}\n\n@CCCommand(ClimateControlScheduleCommand.ChangedGet)\n@expectedCCResponse(ClimateControlScheduleCCChangedReport)\nexport class ClimateControlScheduleCCChangedGet\n\textends ClimateControlScheduleCC\n{}\n\n// @publicAPI\nexport interface ClimateControlScheduleCCOverrideReportOptions {\n\toverrideType: ScheduleOverrideType;\n\toverrideState: SetbackState;\n}\n\n@CCCommand(ClimateControlScheduleCommand.OverrideReport)\n@ccValueProperty(\"overrideType\", ClimateControlScheduleCCValues.overrideType)\n@ccValueProperty(\"overrideState\", ClimateControlScheduleCCValues.overrideState)\nexport class ClimateControlScheduleCCOverrideReport\n\textends ClimateControlScheduleCC\n{\n\tpublic constructor(\n\t\toptions: WithAddress<ClimateControlScheduleCCOverrideReportOptions>,\n\t) {\n\t\tsuper(options);\n\n\t\t// TODO: Check implementation:\n\t\tthis.overrideType = options.overrideType;\n\t\tthis.overrideState = options.overrideState;\n\t}\n\n\tpublic static from(\n\t\traw: CCRaw,\n\t\tctx: CCParsingContext,\n\t): ClimateControlScheduleCCOverrideReport {\n\t\tvalidatePayload(raw.payload.length >= 2);\n\t\tconst overrideType: ScheduleOverrideType = raw.payload[0] & 0b11;\n\t\tconst overrideState: SetbackState = decodeSetbackState(raw.payload, 1)\n\t\t\t// If we receive an unknown setback state, return the raw value\n\t\t\t|| raw.payload.readInt8(1);\n\n\t\treturn new this({\n\t\t\tnodeId: ctx.sourceNodeId,\n\t\t\toverrideType,\n\t\t\toverrideState,\n\t\t});\n\t}\n\n\tpublic readonly overrideType: ScheduleOverrideType;\n\n\tpublic readonly overrideState: SetbackState;\n\n\tpublic toLogEntry(ctx?: GetValueDB): MessageOrCCLogEntry {\n\t\treturn {\n\t\t\t...super.toLogEntry(ctx),\n\t\t\tmessage: {\n\t\t\t\t\"override type\": getEnumMemberName(\n\t\t\t\t\tScheduleOverrideType,\n\t\t\t\t\tthis.overrideType,\n\t\t\t\t),\n\t\t\t\t\"override state\": this.overrideState,\n\t\t\t},\n\t\t};\n\t}\n}\n\n@CCCommand(ClimateControlScheduleCommand.OverrideGet)\n@expectedCCResponse(ClimateControlScheduleCCOverrideReport)\nexport class ClimateControlScheduleCCOverrideGet\n\textends ClimateControlScheduleCC\n{}\n\n// @publicAPI\nexport interface ClimateControlScheduleCCOverrideSetOptions {\n\toverrideType: ScheduleOverrideType;\n\toverrideState: SetbackState;\n}\n\n@CCCommand(ClimateControlScheduleCommand.OverrideSet)\n@useSupervision()\nexport class ClimateControlScheduleCCOverrideSet\n\textends ClimateControlScheduleCC\n{\n\tpublic constructor(\n\t\toptions: WithAddress<ClimateControlScheduleCCOverrideSetOptions>,\n\t) {\n\t\tsuper(options);\n\t\tthis.overrideType = options.overrideType;\n\t\tthis.overrideState = options.overrideState;\n\t}\n\n\tpublic static from(\n\t\t_raw: CCRaw,\n\t\t_ctx: CCParsingContext,\n\t): ClimateControlScheduleCCOverrideSet {\n\t\tthrow new ZWaveError(\n\t\t\t`${this.name}: deserialization not implemented`,\n\t\t\tZWaveErrorCodes.Deserialization_NotImplemented,\n\t\t);\n\n\t\t// return new ClimateControlScheduleCCOverrideSet({\n\t\t// \tnodeId: ctx.sourceNodeId,\n\t\t// });\n\t}\n\n\tpublic overrideType: ScheduleOverrideType;\n\tpublic overrideState: SetbackState;\n\n\tpublic serialize(ctx: CCEncodingContext): Bytes {\n\t\tthis.payload = Bytes.concat([\n\t\t\t[this.overrideType & 0b11],\n\t\t\tencodeSetbackState(this.overrideState),\n\t\t]);\n\t\t// eslint-disable-next-line @typescript-eslint/no-deprecated\n\t\treturn super.serialize(ctx);\n\t}\n\n\tpublic toLogEntry(ctx?: GetValueDB): MessageOrCCLogEntry {\n\t\treturn {\n\t\t\t...super.toLogEntry(ctx),\n\t\t\tmessage: {\n\t\t\t\t\"override type\": getEnumMemberName(\n\t\t\t\t\tScheduleOverrideType,\n\t\t\t\t\tthis.overrideType,\n\t\t\t\t),\n\t\t\t\t\"override state\": this.overrideState,\n\t\t\t},\n\t\t};\n\t}\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,kBAWO;AAMP,IAAAA,eAAsB;AACtB,IAAAA,eAAkC;AAElC,iBAAsB;AACtB,0BAAyC;AACzC,oCASO;AACP,oBAAkB;AAClB,mBAMO;AACP,yBAKO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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mB,sCAAsC,CAAC;;;;oBAElD;2DAAA,YAAwB;;;;;;AADjC,mBAAA,MAAA,mBAAA,EAAA,OAAA,WAAA,GAAA,kBAAA,EAAA,MAAA,SAAA,MAAA,WAAA,MAAA,UAAA,UAAA,GAAA,MAAA,uBAAA;;;AAAa,wBAAA,YAAA,uBAAA;;;;;IAYA,uCAAmC,MAAA;8BAF/C,yCAAU,2CAA8B,WAAW,OACnD,8CAAc,CAAE;;;;oBAER;2DAAA,YAAwB;;;;;;AADjC,mBAAA,MAAA,mBAAA,EAAA,OAAA,WAAA,GAAA,kBAAA,EAAA,MAAA,SAAA,MAAA,WAAA,MAAA,UAAA,UAAA,GAAA,MAAA,uBAAA;;;AAAa,wBAAA,YAAA,uBAAA;;IAGZ,YACC,SAAgE;AAEhE,YAAM,OAAO;AACb,WAAK,eAAe,QAAQ;AAC5B,WAAK,gBAAgB,QAAQ;IAC9B;IAEO,OAAO,KACb,MACA,MAAsB;AAEtB,YAAM,IAAI,uBACT,GAAG,KAAK,IAAI,qCACZ,4BAAgB,8BAA8B;IAMhD;IAEO;IACA;IAEA,UAAU,KAAsB;AACtC,WAAK,UAAU,mBAAM,OAAO;QAC3B,CAAC,KAAK,eAAe,CAAI;YACzB,uCAAmB,KAAK,aAAa;OACrC;AAED,aAAO,MAAM,UAAU,GAAG;IAC3B;IAEO,WAAW,KAAgB;AACjC,aAAO;QACN,GAAG,MAAM,WAAW,GAAG;QACvB,SAAS;UACR,qBAAiB,gCAChB,mCACA,KAAK,YAAY;UAElB,kBAAkB,KAAK;;;IAG1B;;;;",
|
|
6
6
|
"names": ["import_safe"]
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/cc/ClockCC.ts"],
|
|
4
|
-
"sourcesContent": ["import type {\n\tMessageOrCCLogEntry,\n\tSupervisionResult,\n\tWithAddress,\n} from \"@zwave-js/core/safe\";\nimport {\n\tCommandClasses,\n\ttype MaybeNotKnown,\n\tMessagePriority,\n\tZWaveError,\n\tZWaveErrorCodes,\n\tvalidatePayload,\n} from \"@zwave-js/core/safe\";\nimport type {\n\tCCEncodingContext,\n\tCCParsingContext,\n\tGetValueDB,\n} from \"@zwave-js/host/safe\";\nimport { Bytes } from \"@zwave-js/shared/safe\";\nimport { getEnumMemberName, pick } from \"@zwave-js/shared/safe\";\nimport { validateArgs } from \"@zwave-js/transformers\";\nimport { CCAPI } from \"../lib/API.js\";\nimport {\n\ttype CCRaw,\n\tCommandClass,\n\ttype InterviewContext,\n\ttype RefreshValuesContext,\n} from \"../lib/CommandClass.js\";\nimport {\n\tAPI,\n\tCCCommand,\n\tcommandClass,\n\texpectedCCResponse,\n\timplementedVersion,\n\tuseSupervision,\n} from \"../lib/CommandClassDecorators.js\";\nimport { ClockCommand, Weekday } from \"../lib/_Types.js\";\n\n// @noSetValueAPI - This CC has no simple value to set\n\n@API(CommandClasses.Clock)\nexport class ClockCCAPI extends CCAPI {\n\tpublic supportsCommand(cmd: ClockCommand): MaybeNotKnown<boolean> {\n\t\tswitch (cmd) {\n\t\t\tcase ClockCommand.Get:\n\t\t\t\treturn this.isSinglecast();\n\t\t\tcase ClockCommand.Set:\n\t\t\t\treturn true; // This is mandatory\n\t\t}\n\t\treturn super.supportsCommand(cmd);\n\t}\n\n\t// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types\n\tpublic async get() {\n\t\tthis.assertSupportsCommand(ClockCommand, ClockCommand.Get);\n\n\t\tconst cc = new ClockCCGet({\n\t\t\tnodeId: this.endpoint.nodeId,\n\t\t\tendpointIndex: this.endpoint.index,\n\t\t});\n\t\tconst response = await this.host.sendCommand<ClockCCReport>(\n\t\t\tcc,\n\t\t\tthis.commandOptions,\n\t\t);\n\t\tif (response) {\n\t\t\treturn pick(response, [\"weekday\", \"hour\", \"minute\"]);\n\t\t}\n\t}\n\n\t@validateArgs({ strictEnums: true })\n\tpublic async set(\n\t\thour: number,\n\t\tminute: number,\n\t\tweekday?: Weekday,\n\t): Promise<SupervisionResult | undefined> {\n\t\tthis.assertSupportsCommand(ClockCommand, ClockCommand.Set);\n\n\t\tconst cc = new ClockCCSet({\n\t\t\tnodeId: this.endpoint.nodeId,\n\t\t\tendpointIndex: this.endpoint.index,\n\t\t\thour,\n\t\t\tminute,\n\t\t\tweekday: weekday ?? Weekday.Unknown,\n\t\t});\n\t\treturn this.host.sendCommand(cc, this.commandOptions);\n\t}\n}\n\n@commandClass(CommandClasses.Clock)\n@implementedVersion(1)\nexport class ClockCC extends CommandClass {\n\tdeclare ccCommand: ClockCommand;\n\n\tpublic async interview(\n\t\tctx: InterviewContext,\n\t): Promise<void> {\n\t\tconst node = this.getNode(ctx)!;\n\n\t\tctx.logNode(node.id, {\n\t\t\tendpoint: this.endpointIndex,\n\t\t\tmessage: `Interviewing ${this.ccName}...`,\n\t\t\tdirection: \"none\",\n\t\t});\n\n\t\tawait this.refreshValues(ctx);\n\n\t\t// Remember that the interview is complete\n\t\tthis.setInterviewComplete(ctx, true);\n\t}\n\n\tpublic async refreshValues(\n\t\tctx: RefreshValuesContext,\n\t): Promise<void> {\n\t\tconst node = this.getNode(ctx)!;\n\t\tconst endpoint = this.getEndpoint(ctx)!;\n\t\tconst api = CCAPI.create(\n\t\t\tCommandClasses.Clock,\n\t\t\tctx,\n\t\t\tendpoint,\n\t\t).withOptions({\n\t\t\tpriority: MessagePriority.NodeQuery,\n\t\t});\n\n\t\tctx.logNode(node.id, {\n\t\t\tmessage: \"requesting current clock setting...\",\n\t\t\tdirection: \"outbound\",\n\t\t});\n\t\tconst response = await api.get();\n\t\tif (response) {\n\t\t\tconst logMessage = `received current clock setting: ${\n\t\t\t\tresponse.weekday !== Weekday.Unknown\n\t\t\t\t\t? Weekday[response.weekday] + \", \"\n\t\t\t\t\t: \"\"\n\t\t\t}${response.hour < 10 ? \"0\" : \"\"}${response.hour}:${\n\t\t\t\tresponse.minute < 10 ? \"0\" : \"\"\n\t\t\t}${response.minute}`;\n\t\t\tctx.logNode(node.id, {\n\t\t\t\tmessage: logMessage,\n\t\t\t\tdirection: \"inbound\",\n\t\t\t});\n\t\t}\n\t}\n}\n\n// @publicAPI\nexport interface ClockCCSetOptions {\n\tweekday: Weekday;\n\thour: number;\n\tminute: number;\n}\n\n@CCCommand(ClockCommand.Set)\n@useSupervision()\nexport class ClockCCSet extends ClockCC {\n\tpublic constructor(\n\t\toptions: WithAddress<ClockCCSetOptions>,\n\t) {\n\t\tsuper(options);\n\t\tthis.weekday = options.weekday;\n\t\tthis.hour = options.hour;\n\t\tthis.minute = options.minute;\n\t}\n\n\tpublic static from(_raw: CCRaw, _ctx: CCParsingContext): ClockCCSet {\n\t\t// TODO: Deserialize payload\n\t\tthrow new ZWaveError(\n\t\t\t`${this.name}: deserialization not implemented`,\n\t\t\tZWaveErrorCodes.Deserialization_NotImplemented,\n\t\t);\n\n\t\t// return new ClockCCSet({\n\t\t// \tnodeId: ctx.sourceNodeId,\n\t\t// });\n\t}\n\n\tpublic weekday: Weekday;\n\tpublic hour: number;\n\tpublic minute: number;\n\n\tpublic serialize(ctx: CCEncodingContext): Bytes {\n\t\tthis.payload = Bytes.from([\n\t\t\t((this.weekday & 0b111) << 5) | (this.hour & 0b11111),\n\t\t\tthis.minute,\n\t\t]);\n\t\treturn super.serialize(ctx);\n\t}\n\n\tpublic toLogEntry(ctx?: GetValueDB): MessageOrCCLogEntry {\n\t\treturn {\n\t\t\t...super.toLogEntry(ctx),\n\t\t\tmessage: {\n\t\t\t\t\"clock setting\": `${\n\t\t\t\t\tgetEnumMemberName(\n\t\t\t\t\t\tWeekday,\n\t\t\t\t\t\tthis.weekday,\n\t\t\t\t\t)\n\t\t\t\t}, ${this.hour.toString().padStart(2, \"0\")}:${\n\t\t\t\t\tthis.minute.toString().padStart(\n\t\t\t\t\t\t2,\n\t\t\t\t\t\t\"0\",\n\t\t\t\t\t)\n\t\t\t\t}`,\n\t\t\t},\n\t\t};\n\t}\n}\n\n// @publicAPI\nexport interface ClockCCReportOptions {\n\tweekday: Weekday;\n\thour: number;\n\tminute: number;\n}\n\n@CCCommand(ClockCommand.Report)\nexport class ClockCCReport extends ClockCC {\n\tpublic constructor(\n\t\toptions: WithAddress<ClockCCReportOptions>,\n\t) {\n\t\tsuper(options);\n\n\t\t// TODO: Check implementation:\n\t\tthis.weekday = options.weekday;\n\t\tthis.hour = options.hour;\n\t\tthis.minute = options.minute;\n\t}\n\n\tpublic static from(raw: CCRaw, ctx: CCParsingContext): ClockCCReport {\n\t\tvalidatePayload(raw.payload.length >= 2);\n\t\tconst weekday: Weekday = raw.payload[0] >>> 5;\n\t\tconst hour = raw.payload[0] & 0b11111;\n\t\tconst minute = raw.payload[1];\n\t\tvalidatePayload(\n\t\t\tweekday <= Weekday.Sunday,\n\t\t\thour <= 23,\n\t\t\tminute <= 59,\n\t\t);\n\n\t\treturn new this({\n\t\t\tnodeId: ctx.sourceNodeId,\n\t\t\tweekday,\n\t\t\thour,\n\t\t\tminute,\n\t\t});\n\t}\n\n\tpublic readonly weekday: Weekday;\n\tpublic readonly hour: number;\n\tpublic readonly minute: number;\n\n\tpublic toLogEntry(ctx?: GetValueDB): MessageOrCCLogEntry {\n\t\treturn {\n\t\t\t...super.toLogEntry(ctx),\n\t\t\tmessage: {\n\t\t\t\t\"clock setting\": `${\n\t\t\t\t\tgetEnumMemberName(\n\t\t\t\t\t\tWeekday,\n\t\t\t\t\t\tthis.weekday,\n\t\t\t\t\t)\n\t\t\t\t}, ${this.hour.toString().padStart(2, \"0\")}:${\n\t\t\t\t\tthis.minute.toString().padStart(\n\t\t\t\t\t\t2,\n\t\t\t\t\t\t\"0\",\n\t\t\t\t\t)\n\t\t\t\t}`,\n\t\t\t},\n\t\t};\n\t}\n}\n\n@CCCommand(ClockCommand.Get)\n@expectedCCResponse(ClockCCReport)\nexport class ClockCCGet extends ClockCC {}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;AAKA,kBAOO;AAM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AM,OAAO;AACb,WAAK,UAAU,QAAQ;AACvB,WAAK,OAAO,QAAQ;AACpB,WAAK,SAAS,QAAQ;IACvB;IAEO,OAAO,KAAK,MAAa,MAAsB;AAErD,YAAM,IAAI,uBACT,GAAG,KAAK,IAAI,qCACZ,4BAAgB,8BAA8B;IAMhD;IAEO;IACA;IACA;IAEA,UAAU,KAAsB;AACtC,WAAK,UAAU,mBAAM,KAAK;SACvB,KAAK,UAAU,MAAU,IAAM,KAAK,OAAO;QAC7C,KAAK;OACL;
|
|
4
|
+
"sourcesContent": ["import type {\n\tMessageOrCCLogEntry,\n\tSupervisionResult,\n\tWithAddress,\n} from \"@zwave-js/core/safe\";\nimport {\n\tCommandClasses,\n\ttype MaybeNotKnown,\n\tMessagePriority,\n\tZWaveError,\n\tZWaveErrorCodes,\n\tvalidatePayload,\n} from \"@zwave-js/core/safe\";\nimport type {\n\tCCEncodingContext,\n\tCCParsingContext,\n\tGetValueDB,\n} from \"@zwave-js/host/safe\";\nimport { Bytes } from \"@zwave-js/shared/safe\";\nimport { getEnumMemberName, pick } from \"@zwave-js/shared/safe\";\nimport { validateArgs } from \"@zwave-js/transformers\";\nimport { CCAPI } from \"../lib/API.js\";\nimport {\n\ttype CCRaw,\n\tCommandClass,\n\ttype InterviewContext,\n\ttype RefreshValuesContext,\n} from \"../lib/CommandClass.js\";\nimport {\n\tAPI,\n\tCCCommand,\n\tcommandClass,\n\texpectedCCResponse,\n\timplementedVersion,\n\tuseSupervision,\n} from \"../lib/CommandClassDecorators.js\";\nimport { ClockCommand, Weekday } from \"../lib/_Types.js\";\n\n// @noSetValueAPI - This CC has no simple value to set\n\n@API(CommandClasses.Clock)\nexport class ClockCCAPI extends CCAPI {\n\tpublic supportsCommand(cmd: ClockCommand): MaybeNotKnown<boolean> {\n\t\tswitch (cmd) {\n\t\t\tcase ClockCommand.Get:\n\t\t\t\treturn this.isSinglecast();\n\t\t\tcase ClockCommand.Set:\n\t\t\t\treturn true; // This is mandatory\n\t\t}\n\t\treturn super.supportsCommand(cmd);\n\t}\n\n\t// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types\n\tpublic async get() {\n\t\tthis.assertSupportsCommand(ClockCommand, ClockCommand.Get);\n\n\t\tconst cc = new ClockCCGet({\n\t\t\tnodeId: this.endpoint.nodeId,\n\t\t\tendpointIndex: this.endpoint.index,\n\t\t});\n\t\tconst response = await this.host.sendCommand<ClockCCReport>(\n\t\t\tcc,\n\t\t\tthis.commandOptions,\n\t\t);\n\t\tif (response) {\n\t\t\treturn pick(response, [\"weekday\", \"hour\", \"minute\"]);\n\t\t}\n\t}\n\n\t@validateArgs({ strictEnums: true })\n\tpublic async set(\n\t\thour: number,\n\t\tminute: number,\n\t\tweekday?: Weekday,\n\t): Promise<SupervisionResult | undefined> {\n\t\tthis.assertSupportsCommand(ClockCommand, ClockCommand.Set);\n\n\t\tconst cc = new ClockCCSet({\n\t\t\tnodeId: this.endpoint.nodeId,\n\t\t\tendpointIndex: this.endpoint.index,\n\t\t\thour,\n\t\t\tminute,\n\t\t\tweekday: weekday ?? Weekday.Unknown,\n\t\t});\n\t\treturn this.host.sendCommand(cc, this.commandOptions);\n\t}\n}\n\n@commandClass(CommandClasses.Clock)\n@implementedVersion(1)\nexport class ClockCC extends CommandClass {\n\tdeclare ccCommand: ClockCommand;\n\n\tpublic async interview(\n\t\tctx: InterviewContext,\n\t): Promise<void> {\n\t\tconst node = this.getNode(ctx)!;\n\n\t\tctx.logNode(node.id, {\n\t\t\tendpoint: this.endpointIndex,\n\t\t\tmessage: `Interviewing ${this.ccName}...`,\n\t\t\tdirection: \"none\",\n\t\t});\n\n\t\tawait this.refreshValues(ctx);\n\n\t\t// Remember that the interview is complete\n\t\tthis.setInterviewComplete(ctx, true);\n\t}\n\n\tpublic async refreshValues(\n\t\tctx: RefreshValuesContext,\n\t): Promise<void> {\n\t\tconst node = this.getNode(ctx)!;\n\t\tconst endpoint = this.getEndpoint(ctx)!;\n\t\tconst api = CCAPI.create(\n\t\t\tCommandClasses.Clock,\n\t\t\tctx,\n\t\t\tendpoint,\n\t\t).withOptions({\n\t\t\tpriority: MessagePriority.NodeQuery,\n\t\t});\n\n\t\tctx.logNode(node.id, {\n\t\t\tmessage: \"requesting current clock setting...\",\n\t\t\tdirection: \"outbound\",\n\t\t});\n\t\tconst response = await api.get();\n\t\tif (response) {\n\t\t\tconst logMessage = `received current clock setting: ${\n\t\t\t\tresponse.weekday !== Weekday.Unknown\n\t\t\t\t\t? Weekday[response.weekday] + \", \"\n\t\t\t\t\t: \"\"\n\t\t\t}${response.hour < 10 ? \"0\" : \"\"}${response.hour}:${\n\t\t\t\tresponse.minute < 10 ? \"0\" : \"\"\n\t\t\t}${response.minute}`;\n\t\t\tctx.logNode(node.id, {\n\t\t\t\tmessage: logMessage,\n\t\t\t\tdirection: \"inbound\",\n\t\t\t});\n\t\t}\n\t}\n}\n\n// @publicAPI\nexport interface ClockCCSetOptions {\n\tweekday: Weekday;\n\thour: number;\n\tminute: number;\n}\n\n@CCCommand(ClockCommand.Set)\n@useSupervision()\nexport class ClockCCSet extends ClockCC {\n\tpublic constructor(\n\t\toptions: WithAddress<ClockCCSetOptions>,\n\t) {\n\t\tsuper(options);\n\t\tthis.weekday = options.weekday;\n\t\tthis.hour = options.hour;\n\t\tthis.minute = options.minute;\n\t}\n\n\tpublic static from(_raw: CCRaw, _ctx: CCParsingContext): ClockCCSet {\n\t\t// TODO: Deserialize payload\n\t\tthrow new ZWaveError(\n\t\t\t`${this.name}: deserialization not implemented`,\n\t\t\tZWaveErrorCodes.Deserialization_NotImplemented,\n\t\t);\n\n\t\t// return new ClockCCSet({\n\t\t// \tnodeId: ctx.sourceNodeId,\n\t\t// });\n\t}\n\n\tpublic weekday: Weekday;\n\tpublic hour: number;\n\tpublic minute: number;\n\n\tpublic serialize(ctx: CCEncodingContext): Bytes {\n\t\tthis.payload = Bytes.from([\n\t\t\t((this.weekday & 0b111) << 5) | (this.hour & 0b11111),\n\t\t\tthis.minute,\n\t\t]);\n\t\t// eslint-disable-next-line @typescript-eslint/no-deprecated\n\t\treturn super.serialize(ctx);\n\t}\n\n\tpublic toLogEntry(ctx?: GetValueDB): MessageOrCCLogEntry {\n\t\treturn {\n\t\t\t...super.toLogEntry(ctx),\n\t\t\tmessage: {\n\t\t\t\t\"clock setting\": `${\n\t\t\t\t\tgetEnumMemberName(\n\t\t\t\t\t\tWeekday,\n\t\t\t\t\t\tthis.weekday,\n\t\t\t\t\t)\n\t\t\t\t}, ${this.hour.toString().padStart(2, \"0\")}:${\n\t\t\t\t\tthis.minute.toString().padStart(\n\t\t\t\t\t\t2,\n\t\t\t\t\t\t\"0\",\n\t\t\t\t\t)\n\t\t\t\t}`,\n\t\t\t},\n\t\t};\n\t}\n}\n\n// @publicAPI\nexport interface ClockCCReportOptions {\n\tweekday: Weekday;\n\thour: number;\n\tminute: number;\n}\n\n@CCCommand(ClockCommand.Report)\nexport class ClockCCReport extends ClockCC {\n\tpublic constructor(\n\t\toptions: WithAddress<ClockCCReportOptions>,\n\t) {\n\t\tsuper(options);\n\n\t\t// TODO: Check implementation:\n\t\tthis.weekday = options.weekday;\n\t\tthis.hour = options.hour;\n\t\tthis.minute = options.minute;\n\t}\n\n\tpublic static from(raw: CCRaw, ctx: CCParsingContext): ClockCCReport {\n\t\tvalidatePayload(raw.payload.length >= 2);\n\t\tconst weekday: Weekday = raw.payload[0] >>> 5;\n\t\tconst hour = raw.payload[0] & 0b11111;\n\t\tconst minute = raw.payload[1];\n\t\tvalidatePayload(\n\t\t\tweekday <= Weekday.Sunday,\n\t\t\thour <= 23,\n\t\t\tminute <= 59,\n\t\t);\n\n\t\treturn new this({\n\t\t\tnodeId: ctx.sourceNodeId,\n\t\t\tweekday,\n\t\t\thour,\n\t\t\tminute,\n\t\t});\n\t}\n\n\tpublic readonly weekday: Weekday;\n\tpublic readonly hour: number;\n\tpublic readonly minute: number;\n\n\tpublic toLogEntry(ctx?: GetValueDB): MessageOrCCLogEntry {\n\t\treturn {\n\t\t\t...super.toLogEntry(ctx),\n\t\t\tmessage: {\n\t\t\t\t\"clock setting\": `${\n\t\t\t\t\tgetEnumMemberName(\n\t\t\t\t\t\tWeekday,\n\t\t\t\t\t\tthis.weekday,\n\t\t\t\t\t)\n\t\t\t\t}, ${this.hour.toString().padStart(2, \"0\")}:${\n\t\t\t\t\tthis.minute.toString().padStart(\n\t\t\t\t\t\t2,\n\t\t\t\t\t\t\"0\",\n\t\t\t\t\t)\n\t\t\t\t}`,\n\t\t\t},\n\t\t};\n\t}\n}\n\n@CCCommand(ClockCommand.Get)\n@expectedCCResponse(ClockCCReport)\nexport class ClockCCGet extends ClockCC {}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;AAKA,kBAOO;AAMP,IAAAA,eAAsB;AACtB,IAAAA,eAAwC;AAExC,iBAAsB;AACtB,0BAKO;AACP,oCAOO;AACP,mBAAsC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAKzB,cAAU,MAAA;8BADtB,mCAAI,2BAAe,KAAK,CAAC;;;;oBACM;kCAAA,YAAK;;;;;;AAArC,mBAAA,MAAA,mBAAA,EAAA,OAAA,WAAA,GAAA,kBAAA,EAAA,MAAA,SAAA,MAAA,WAAA,MAAA,UAAA,UAAA,GAAA,MAAA,uBAAA;;;AAAa,wBAAA,YAAA,uBAAA;;IACL,gBAAgB,KAAiB;AACvC,cAAQ,KAAK;QACZ,KAAK,0BAAa;AACjB,iBAAO,KAAK,aAAY;QACzB,KAAK,0BAAa;AACjB,iBAAO;MACT;AACA,aAAO,MAAM,gBAAgB,GAAG;IACjC;;IAGO,MAAM,MAAG;AACf,WAAK,sBAAsB,2BAAc,0BAAa,GAAG;AAEzD,YAAM,KAAK,IAAI,WAAW;QACzB,QAAQ,KAAK,SAAS;QACtB,eAAe,KAAK,SAAS;OAC7B;AACD,YAAM,WAAW,MAAM,KAAK,KAAK,YAChC,IACA,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