@zwave-js/cc 15.1.1 → 15.2.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.d.ts +7 -7
- package/build/cjs/cc/AlarmSensorCC.js +22 -23
- package/build/cjs/cc/AlarmSensorCC.js.map +3 -3
- package/build/cjs/cc/AssociationCC.d.ts +8 -9
- package/build/cjs/cc/AssociationCC.js +29 -29
- package/build/cjs/cc/AssociationCC.js.map +3 -3
- package/build/cjs/cc/AssociationGroupInfoCC.d.ts +7 -7
- package/build/cjs/cc/AssociationGroupInfoCC.js +31 -32
- package/build/cjs/cc/AssociationGroupInfoCC.js.map +3 -3
- package/build/cjs/cc/BarrierOperatorCC.d.ts +8 -8
- package/build/cjs/cc/BarrierOperatorCC.js +35 -36
- package/build/cjs/cc/BarrierOperatorCC.js.map +3 -3
- package/build/cjs/cc/BasicCC.d.ts +4 -4
- package/build/cjs/cc/BasicCC.js +23 -24
- package/build/cjs/cc/BasicCC.js.map +3 -3
- package/build/cjs/cc/BasicWindowCoveringCC._validateArgs.d.ts +3 -0
- package/build/cjs/cc/BasicWindowCoveringCC._validateArgs.js +64 -0
- package/build/cjs/cc/BasicWindowCoveringCC._validateArgs.js.map +7 -0
- package/build/cjs/cc/BasicWindowCoveringCC.d.ts +90 -0
- package/build/cjs/cc/BasicWindowCoveringCC.js +273 -0
- package/build/cjs/cc/BasicWindowCoveringCC.js.map +7 -0
- package/build/cjs/cc/BatteryCC.d.ts +4 -7
- package/build/cjs/cc/BatteryCC.js +18 -20
- package/build/cjs/cc/BatteryCC.js.map +3 -3
- package/build/cjs/cc/BinarySensorCC.d.ts +5 -5
- package/build/cjs/cc/BinarySensorCC.js +20 -21
- package/build/cjs/cc/BinarySensorCC.js.map +3 -3
- package/build/cjs/cc/BinarySwitchCC._validateArgs.js +2 -2
- package/build/cjs/cc/BinarySwitchCC.d.ts +6 -6
- package/build/cjs/cc/BinarySwitchCC.js +26 -26
- package/build/cjs/cc/BinarySwitchCC.js.map +3 -3
- package/build/cjs/cc/CRC16CC.d.ts +3 -3
- package/build/cjs/cc/CRC16CC.js +15 -15
- package/build/cjs/cc/CRC16CC.js.map +3 -3
- package/build/cjs/cc/CentralSceneCC.d.ts +8 -8
- package/build/cjs/cc/CentralSceneCC.js +23 -24
- package/build/cjs/cc/CentralSceneCC.js.map +3 -3
- package/build/cjs/cc/ClimateControlScheduleCC.d.ts +6 -6
- package/build/cjs/cc/ClimateControlScheduleCC.js +19 -20
- package/build/cjs/cc/ClimateControlScheduleCC.js.map +3 -3
- package/build/cjs/cc/ClockCC.d.ts +3 -4
- package/build/cjs/cc/ClockCC.js +13 -14
- package/build/cjs/cc/ClockCC.js.map +3 -3
- package/build/cjs/cc/ColorSwitchCC.d.ts +3 -4
- package/build/cjs/cc/ColorSwitchCC.js +22 -24
- package/build/cjs/cc/ColorSwitchCC.js.map +3 -3
- package/build/cjs/cc/ConfigurationCC.d.ts +3 -3
- package/build/cjs/cc/ConfigurationCC.js +114 -115
- package/build/cjs/cc/ConfigurationCC.js.map +3 -3
- package/build/cjs/cc/DeviceResetLocallyCC.d.ts +2 -2
- package/build/cjs/cc/DeviceResetLocallyCC.js +5 -5
- package/build/cjs/cc/DeviceResetLocallyCC.js.map +1 -1
- package/build/cjs/cc/DoorLockCC.d.ts +29 -29
- package/build/cjs/cc/DoorLockCC.js +39 -40
- package/build/cjs/cc/DoorLockCC.js.map +3 -3
- package/build/cjs/cc/DoorLockLoggingCC.d.ts +4 -4
- package/build/cjs/cc/DoorLockLoggingCC.js +13 -14
- package/build/cjs/cc/DoorLockLoggingCC.js.map +3 -3
- package/build/cjs/cc/EnergyProductionCC.d.ts +2 -3
- package/build/cjs/cc/EnergyProductionCC.js.map +2 -2
- package/build/cjs/cc/EntryControlCC.d.ts +8 -8
- package/build/cjs/cc/EntryControlCC.js +41 -42
- package/build/cjs/cc/EntryControlCC.js.map +3 -3
- package/build/cjs/cc/FirmwareUpdateMetaDataCC.d.ts +9 -10
- package/build/cjs/cc/FirmwareUpdateMetaDataCC.js +52 -53
- package/build/cjs/cc/FirmwareUpdateMetaDataCC.js.map +3 -3
- package/build/cjs/cc/HailCC.js +2 -2
- package/build/cjs/cc/HailCC.js.map +1 -1
- package/build/cjs/cc/HumidityControlModeCC.d.ts +5 -5
- package/build/cjs/cc/HumidityControlModeCC.js +20 -21
- package/build/cjs/cc/HumidityControlModeCC.js.map +3 -3
- package/build/cjs/cc/HumidityControlOperatingStateCC.d.ts +3 -3
- package/build/cjs/cc/HumidityControlOperatingStateCC.js +9 -9
- package/build/cjs/cc/HumidityControlOperatingStateCC.js.map +3 -3
- package/build/cjs/cc/HumidityControlSetpointCC.d.ts +6 -6
- package/build/cjs/cc/HumidityControlSetpointCC.js +43 -44
- package/build/cjs/cc/HumidityControlSetpointCC.js.map +3 -3
- package/build/cjs/cc/InclusionControllerCC.d.ts +2 -3
- package/build/cjs/cc/InclusionControllerCC.js.map +2 -2
- package/build/cjs/cc/IndicatorCC.d.ts +3 -3
- package/build/cjs/cc/IndicatorCC.js +50 -52
- package/build/cjs/cc/IndicatorCC.js.map +3 -3
- package/build/cjs/cc/IrrigationCC.d.ts +3 -3
- package/build/cjs/cc/IrrigationCC.js +74 -75
- package/build/cjs/cc/IrrigationCC.js.map +3 -3
- package/build/cjs/cc/LanguageCC.d.ts +5 -6
- package/build/cjs/cc/LanguageCC.js +14 -15
- package/build/cjs/cc/LanguageCC.js.map +3 -3
- package/build/cjs/cc/LockCC.d.ts +4 -4
- package/build/cjs/cc/LockCC.js +10 -10
- package/build/cjs/cc/LockCC.js.map +3 -3
- package/build/cjs/cc/ManufacturerProprietaryCC.d.ts +3 -3
- package/build/cjs/cc/ManufacturerProprietaryCC.js +10 -10
- package/build/cjs/cc/ManufacturerProprietaryCC.js.map +3 -3
- package/build/cjs/cc/ManufacturerSpecificCC.d.ts +7 -8
- package/build/cjs/cc/ManufacturerSpecificCC.js +20 -21
- package/build/cjs/cc/ManufacturerSpecificCC.js.map +3 -3
- package/build/cjs/cc/MeterCC.d.ts +4 -6
- package/build/cjs/cc/MeterCC.js +52 -54
- package/build/cjs/cc/MeterCC.js.map +3 -3
- package/build/cjs/cc/MultiChannelAssociationCC.d.ts +7 -8
- package/build/cjs/cc/MultiChannelAssociationCC.js +34 -35
- package/build/cjs/cc/MultiChannelAssociationCC.js.map +3 -3
- package/build/cjs/cc/MultiChannelCC.d.ts +11 -11
- package/build/cjs/cc/MultiChannelCC.js +53 -53
- package/build/cjs/cc/MultiChannelCC.js.map +3 -3
- package/build/cjs/cc/MultiCommandCC.d.ts +3 -3
- package/build/cjs/cc/MultiCommandCC.js +13 -13
- package/build/cjs/cc/MultiCommandCC.js.map +3 -3
- package/build/cjs/cc/MultilevelSensorCC.d.ts +4 -7
- package/build/cjs/cc/MultilevelSensorCC.js +26 -28
- package/build/cjs/cc/MultilevelSensorCC.js.map +3 -3
- package/build/cjs/cc/MultilevelSwitchCC._validateArgs.js +3 -3
- package/build/cjs/cc/MultilevelSwitchCC.d.ts +13 -13
- package/build/cjs/cc/MultilevelSwitchCC.js +36 -37
- package/build/cjs/cc/MultilevelSwitchCC.js.map +3 -3
- package/build/cjs/cc/NoOperationCC.js +4 -4
- package/build/cjs/cc/NoOperationCC.js.map +1 -1
- package/build/cjs/cc/NodeNamingCC.d.ts +5 -5
- package/build/cjs/cc/NodeNamingCC.js +20 -20
- package/build/cjs/cc/NodeNamingCC.js.map +3 -3
- package/build/cjs/cc/NotificationCC.d.ts +4 -5
- package/build/cjs/cc/NotificationCC.js +66 -68
- package/build/cjs/cc/NotificationCC.js.map +3 -3
- package/build/cjs/cc/PowerlevelCC.d.ts +3 -3
- package/build/cjs/cc/PowerlevelCC.js +25 -26
- package/build/cjs/cc/PowerlevelCC.js.map +3 -3
- package/build/cjs/cc/ProtectionCC._validateArgs.js +2 -2
- package/build/cjs/cc/ProtectionCC.d.ts +11 -11
- package/build/cjs/cc/ProtectionCC.js +35 -36
- package/build/cjs/cc/ProtectionCC.js.map +3 -3
- package/build/cjs/cc/SceneActivationCC._validateArgs.js +2 -2
- package/build/cjs/cc/SceneActivationCC.d.ts +5 -6
- package/build/cjs/cc/SceneActivationCC.js +10 -10
- package/build/cjs/cc/SceneActivationCC.js.map +3 -3
- package/build/cjs/cc/SceneActuatorConfigurationCC._validateArgs.js +2 -2
- package/build/cjs/cc/SceneActuatorConfigurationCC.d.ts +5 -5
- package/build/cjs/cc/SceneActuatorConfigurationCC.js +19 -20
- package/build/cjs/cc/SceneActuatorConfigurationCC.js.map +3 -3
- package/build/cjs/cc/SceneControllerConfigurationCC._validateArgs.js +2 -2
- package/build/cjs/cc/SceneControllerConfigurationCC.d.ts +6 -6
- package/build/cjs/cc/SceneControllerConfigurationCC.js +25 -26
- package/build/cjs/cc/SceneControllerConfigurationCC.js.map +3 -3
- package/build/cjs/cc/ScheduleEntryLockCC.d.ts +2 -3
- package/build/cjs/cc/ScheduleEntryLockCC.js.map +2 -2
- package/build/cjs/cc/Security2CC.d.ts +3 -4
- package/build/cjs/cc/Security2CC.js +60 -62
- package/build/cjs/cc/Security2CC.js.map +3 -3
- package/build/cjs/cc/SecurityCC.d.ts +3 -4
- package/build/cjs/cc/SecurityCC.js +25 -26
- package/build/cjs/cc/SecurityCC.js.map +3 -3
- package/build/cjs/cc/SoundSwitchCC.d.ts +7 -7
- package/build/cjs/cc/SoundSwitchCC.js +28 -29
- package/build/cjs/cc/SoundSwitchCC.js.map +3 -3
- package/build/cjs/cc/SupervisionCC.d.ts +4 -4
- package/build/cjs/cc/SupervisionCC.js +28 -29
- package/build/cjs/cc/SupervisionCC.js.map +3 -3
- package/build/cjs/cc/ThermostatFanModeCC.d.ts +6 -6
- package/build/cjs/cc/ThermostatFanModeCC.js +21 -22
- package/build/cjs/cc/ThermostatFanModeCC.js.map +3 -3
- package/build/cjs/cc/ThermostatFanStateCC.d.ts +3 -3
- package/build/cjs/cc/ThermostatFanStateCC.js +9 -9
- package/build/cjs/cc/ThermostatFanStateCC.js.map +3 -3
- package/build/cjs/cc/ThermostatModeCC.d.ts +6 -6
- package/build/cjs/cc/ThermostatModeCC.js +30 -31
- package/build/cjs/cc/ThermostatModeCC.js.map +3 -3
- package/build/cjs/cc/ThermostatOperatingStateCC.d.ts +3 -4
- package/build/cjs/cc/ThermostatOperatingStateCC.js +9 -9
- package/build/cjs/cc/ThermostatOperatingStateCC.js.map +3 -3
- package/build/cjs/cc/ThermostatSetbackCC.d.ts +3 -3
- package/build/cjs/cc/ThermostatSetbackCC.js +14 -15
- package/build/cjs/cc/ThermostatSetbackCC.js.map +3 -3
- package/build/cjs/cc/ThermostatSetpointCC.d.ts +6 -6
- package/build/cjs/cc/ThermostatSetpointCC.js +48 -49
- package/build/cjs/cc/ThermostatSetpointCC.js.map +3 -3
- package/build/cjs/cc/TimeCC.d.ts +3 -4
- package/build/cjs/cc/TimeCC.js +9 -10
- package/build/cjs/cc/TimeCC.js.map +3 -3
- package/build/cjs/cc/TimeParametersCC.d.ts +3 -4
- package/build/cjs/cc/TimeParametersCC.js +2 -2
- package/build/cjs/cc/TimeParametersCC.js.map +2 -2
- package/build/cjs/cc/TransportServiceCC.d.ts +3 -3
- package/build/cjs/cc/TransportServiceCC.js +44 -45
- package/build/cjs/cc/TransportServiceCC.js.map +3 -3
- package/build/cjs/cc/UserCodeCC.d.ts +19 -19
- package/build/cjs/cc/UserCodeCC.js +102 -103
- package/build/cjs/cc/UserCodeCC.js.map +3 -3
- package/build/cjs/cc/VersionCC.d.ts +17 -17
- package/build/cjs/cc/VersionCC.js +46 -47
- package/build/cjs/cc/VersionCC.js.map +3 -3
- package/build/cjs/cc/WakeUpCC.d.ts +6 -6
- package/build/cjs/cc/WakeUpCC.js +16 -17
- package/build/cjs/cc/WakeUpCC.js.map +3 -3
- package/build/cjs/cc/WindowCoveringCC.d.ts +3 -4
- package/build/cjs/cc/WindowCoveringCC.js +17 -18
- package/build/cjs/cc/WindowCoveringCC.js.map +3 -3
- package/build/cjs/cc/ZWavePlusCC.d.ts +8 -8
- package/build/cjs/cc/ZWavePlusCC.js +15 -16
- package/build/cjs/cc/ZWavePlusCC.js.map +3 -3
- package/build/cjs/cc/ZWaveProtocolCC.d.ts +2 -2
- package/build/cjs/cc/ZWaveProtocolCC.js +35 -35
- package/build/cjs/cc/ZWaveProtocolCC.js.map +2 -2
- package/build/cjs/cc/_CCValues.generated.d.ts +124 -0
- package/build/cjs/cc/_CCValues.generated.js +93 -26
- package/build/cjs/cc/_CCValues.generated.js.map +3 -3
- package/build/cjs/cc/index.d.ts +2 -0
- package/build/cjs/cc/index.js +9 -0
- package/build/cjs/cc/index.js.map +2 -2
- package/build/cjs/cc/manufacturerProprietary/FibaroCC.d.ts +3 -3
- package/build/cjs/cc/manufacturerProprietary/FibaroCC.js +14 -14
- package/build/cjs/cc/manufacturerProprietary/FibaroCC.js.map +1 -1
- package/build/cjs/lib/API.d.ts +5 -3
- package/build/cjs/lib/API.js.map +2 -2
- package/build/cjs/lib/CommandClass.d.ts +5 -6
- package/build/cjs/lib/CommandClass.js +45 -45
- package/build/cjs/lib/CommandClass.js.map +3 -3
- package/build/cjs/lib/CommandClassDecorators.d.ts +2 -2
- package/build/cjs/lib/CommandClassDecorators.js +3 -3
- package/build/cjs/lib/CommandClassDecorators.js.map +2 -2
- package/build/cjs/lib/Security2/Extension.d.ts +2 -2
- package/build/cjs/lib/Security2/Extension.js +17 -17
- package/build/cjs/lib/Security2/Extension.js.map +3 -3
- package/build/cjs/lib/SetValueResult.d.ts +1 -1
- package/build/cjs/lib/SetValueResult.js.map +1 -1
- package/build/cjs/lib/Values.d.ts +3 -3
- package/build/cjs/lib/Values.js +6 -6
- package/build/cjs/lib/Values.js.map +2 -2
- package/build/cjs/lib/_Types.d.ts +6 -2
- package/build/cjs/lib/_Types.js +10 -3
- package/build/cjs/lib/_Types.js.map +3 -3
- package/build/cjs/lib/serializers.d.ts +1 -1
- package/build/cjs/lib/serializers.js +5 -5
- package/build/cjs/lib/serializers.js.map +2 -2
- package/build/cjs/lib/traits.d.ts +2 -2
- package/build/cjs/lib/utils.d.ts +2 -2
- package/build/cjs/lib/utils.js +60 -60
- package/build/cjs/lib/utils.js.map +3 -3
- package/build/esm/cc/AlarmSensorCC.d.ts +7 -7
- package/build/esm/cc/AlarmSensorCC.d.ts.map +1 -1
- package/build/esm/cc/AlarmSensorCC.js +2 -3
- package/build/esm/cc/AlarmSensorCC.js.map +1 -1
- package/build/esm/cc/AssociationCC.d.ts +8 -9
- package/build/esm/cc/AssociationCC.d.ts.map +1 -1
- package/build/esm/cc/AssociationCC.js +2 -2
- package/build/esm/cc/AssociationCC.js.map +1 -1
- package/build/esm/cc/AssociationGroupInfoCC.d.ts +7 -7
- package/build/esm/cc/AssociationGroupInfoCC.d.ts.map +1 -1
- package/build/esm/cc/AssociationGroupInfoCC.js +2 -3
- package/build/esm/cc/AssociationGroupInfoCC.js.map +1 -1
- package/build/esm/cc/BarrierOperatorCC.d.ts +8 -8
- package/build/esm/cc/BarrierOperatorCC.d.ts.map +1 -1
- package/build/esm/cc/BarrierOperatorCC.js +2 -3
- package/build/esm/cc/BarrierOperatorCC.js.map +1 -1
- package/build/esm/cc/BasicCC.d.ts +4 -4
- package/build/esm/cc/BasicCC.d.ts.map +1 -1
- package/build/esm/cc/BasicCC.js +2 -3
- package/build/esm/cc/BasicCC.js.map +1 -1
- package/build/esm/cc/BasicWindowCoveringCC._validateArgs.d.ts +3 -0
- package/build/esm/cc/BasicWindowCoveringCC._validateArgs.d.ts.map +1 -0
- package/build/esm/cc/BasicWindowCoveringCC._validateArgs.js +22 -0
- package/build/esm/cc/BasicWindowCoveringCC._validateArgs.js.map +1 -0
- package/build/esm/cc/BasicWindowCoveringCC.d.ts +90 -0
- package/build/esm/cc/BasicWindowCoveringCC.d.ts.map +1 -0
- package/build/esm/cc/BasicWindowCoveringCC.js +215 -0
- package/build/esm/cc/BasicWindowCoveringCC.js.map +1 -0
- package/build/esm/cc/BatteryCC.d.ts +4 -7
- package/build/esm/cc/BatteryCC.d.ts.map +1 -1
- package/build/esm/cc/BatteryCC.js +2 -4
- package/build/esm/cc/BatteryCC.js.map +1 -1
- package/build/esm/cc/BinarySensorCC.d.ts +5 -5
- package/build/esm/cc/BinarySensorCC.d.ts.map +1 -1
- package/build/esm/cc/BinarySensorCC.js +2 -3
- package/build/esm/cc/BinarySensorCC.js.map +1 -1
- package/build/esm/cc/BinarySwitchCC._validateArgs.js +1 -1
- package/build/esm/cc/BinarySwitchCC._validateArgs.js.map +1 -1
- package/build/esm/cc/BinarySwitchCC.d.ts +6 -6
- package/build/esm/cc/BinarySwitchCC.d.ts.map +1 -1
- package/build/esm/cc/BinarySwitchCC.js +2 -2
- package/build/esm/cc/BinarySwitchCC.js.map +1 -1
- package/build/esm/cc/CRC16CC.d.ts +3 -3
- package/build/esm/cc/CRC16CC.d.ts.map +1 -1
- package/build/esm/cc/CRC16CC.js +2 -2
- package/build/esm/cc/CRC16CC.js.map +1 -1
- package/build/esm/cc/CentralSceneCC.d.ts +8 -8
- package/build/esm/cc/CentralSceneCC.d.ts.map +1 -1
- package/build/esm/cc/CentralSceneCC.js +2 -3
- package/build/esm/cc/CentralSceneCC.js.map +1 -1
- package/build/esm/cc/ClimateControlScheduleCC.d.ts +6 -6
- package/build/esm/cc/ClimateControlScheduleCC.d.ts.map +1 -1
- package/build/esm/cc/ClimateControlScheduleCC.js +2 -3
- package/build/esm/cc/ClimateControlScheduleCC.js.map +1 -1
- package/build/esm/cc/ClockCC.d.ts +3 -4
- package/build/esm/cc/ClockCC.d.ts.map +1 -1
- package/build/esm/cc/ClockCC.js +2 -3
- package/build/esm/cc/ClockCC.js.map +1 -1
- package/build/esm/cc/ColorSwitchCC.d.ts +3 -4
- package/build/esm/cc/ColorSwitchCC.d.ts.map +1 -1
- package/build/esm/cc/ColorSwitchCC.js +2 -4
- package/build/esm/cc/ColorSwitchCC.js.map +1 -1
- package/build/esm/cc/ConfigurationCC.d.ts +3 -3
- package/build/esm/cc/ConfigurationCC.d.ts.map +1 -1
- package/build/esm/cc/ConfigurationCC.js +2 -3
- package/build/esm/cc/ConfigurationCC.js.map +1 -1
- package/build/esm/cc/DeviceResetLocallyCC.d.ts +2 -2
- package/build/esm/cc/DeviceResetLocallyCC.d.ts.map +1 -1
- package/build/esm/cc/DeviceResetLocallyCC.js +1 -1
- package/build/esm/cc/DeviceResetLocallyCC.js.map +1 -1
- package/build/esm/cc/DoorLockCC.d.ts +29 -29
- package/build/esm/cc/DoorLockCC.d.ts.map +1 -1
- package/build/esm/cc/DoorLockCC.js +2 -3
- package/build/esm/cc/DoorLockCC.js.map +1 -1
- package/build/esm/cc/DoorLockLoggingCC.d.ts +4 -4
- package/build/esm/cc/DoorLockLoggingCC.d.ts.map +1 -1
- package/build/esm/cc/DoorLockLoggingCC.js +2 -3
- package/build/esm/cc/DoorLockLoggingCC.js.map +1 -1
- package/build/esm/cc/EnergyProductionCC.d.ts +2 -3
- package/build/esm/cc/EnergyProductionCC.d.ts.map +1 -1
- package/build/esm/cc/EnergyProductionCC.js.map +1 -1
- package/build/esm/cc/EntryControlCC.d.ts +8 -8
- package/build/esm/cc/EntryControlCC.d.ts.map +1 -1
- package/build/esm/cc/EntryControlCC.js +2 -3
- package/build/esm/cc/EntryControlCC.js.map +1 -1
- package/build/esm/cc/FirmwareUpdateMetaDataCC.d.ts +9 -10
- package/build/esm/cc/FirmwareUpdateMetaDataCC.d.ts.map +1 -1
- package/build/esm/cc/FirmwareUpdateMetaDataCC.js +2 -3
- package/build/esm/cc/FirmwareUpdateMetaDataCC.js.map +1 -1
- package/build/esm/cc/HailCC.js +1 -1
- package/build/esm/cc/HailCC.js.map +1 -1
- package/build/esm/cc/HumidityControlModeCC.d.ts +5 -5
- package/build/esm/cc/HumidityControlModeCC.d.ts.map +1 -1
- package/build/esm/cc/HumidityControlModeCC.js +2 -3
- package/build/esm/cc/HumidityControlModeCC.js.map +1 -1
- package/build/esm/cc/HumidityControlOperatingStateCC.d.ts +3 -3
- package/build/esm/cc/HumidityControlOperatingStateCC.d.ts.map +1 -1
- package/build/esm/cc/HumidityControlOperatingStateCC.js +2 -2
- package/build/esm/cc/HumidityControlOperatingStateCC.js.map +1 -1
- package/build/esm/cc/HumidityControlSetpointCC.d.ts +6 -6
- package/build/esm/cc/HumidityControlSetpointCC.d.ts.map +1 -1
- package/build/esm/cc/HumidityControlSetpointCC.js +2 -3
- package/build/esm/cc/HumidityControlSetpointCC.js.map +1 -1
- package/build/esm/cc/InclusionControllerCC.d.ts +2 -3
- package/build/esm/cc/InclusionControllerCC.d.ts.map +1 -1
- package/build/esm/cc/InclusionControllerCC.js.map +1 -1
- package/build/esm/cc/IndicatorCC.d.ts +3 -3
- package/build/esm/cc/IndicatorCC.d.ts.map +1 -1
- package/build/esm/cc/IndicatorCC.js +2 -4
- package/build/esm/cc/IndicatorCC.js.map +1 -1
- package/build/esm/cc/IrrigationCC.d.ts +3 -3
- package/build/esm/cc/IrrigationCC.d.ts.map +1 -1
- package/build/esm/cc/IrrigationCC.js +2 -3
- package/build/esm/cc/IrrigationCC.js.map +1 -1
- package/build/esm/cc/LanguageCC.d.ts +5 -6
- package/build/esm/cc/LanguageCC.d.ts.map +1 -1
- package/build/esm/cc/LanguageCC.js +2 -3
- package/build/esm/cc/LanguageCC.js.map +1 -1
- package/build/esm/cc/LockCC.d.ts +4 -4
- package/build/esm/cc/LockCC.d.ts.map +1 -1
- package/build/esm/cc/LockCC.js +2 -2
- package/build/esm/cc/LockCC.js.map +1 -1
- package/build/esm/cc/ManufacturerProprietaryCC.d.ts +3 -3
- package/build/esm/cc/ManufacturerProprietaryCC.d.ts.map +1 -1
- package/build/esm/cc/ManufacturerProprietaryCC.js +2 -2
- package/build/esm/cc/ManufacturerProprietaryCC.js.map +1 -1
- package/build/esm/cc/ManufacturerSpecificCC.d.ts +7 -8
- package/build/esm/cc/ManufacturerSpecificCC.d.ts.map +1 -1
- package/build/esm/cc/ManufacturerSpecificCC.js +2 -3
- package/build/esm/cc/ManufacturerSpecificCC.js.map +1 -1
- package/build/esm/cc/MeterCC.d.ts +4 -6
- package/build/esm/cc/MeterCC.d.ts.map +1 -1
- package/build/esm/cc/MeterCC.js +2 -4
- package/build/esm/cc/MeterCC.js.map +1 -1
- package/build/esm/cc/MultiChannelAssociationCC.d.ts +7 -8
- package/build/esm/cc/MultiChannelAssociationCC.d.ts.map +1 -1
- package/build/esm/cc/MultiChannelAssociationCC.js +2 -3
- package/build/esm/cc/MultiChannelAssociationCC.js.map +1 -1
- package/build/esm/cc/MultiChannelCC.d.ts +11 -11
- package/build/esm/cc/MultiChannelCC.d.ts.map +1 -1
- package/build/esm/cc/MultiChannelCC.js +2 -2
- package/build/esm/cc/MultiChannelCC.js.map +1 -1
- package/build/esm/cc/MultiCommandCC.d.ts +3 -3
- package/build/esm/cc/MultiCommandCC.d.ts.map +1 -1
- package/build/esm/cc/MultiCommandCC.js +2 -2
- package/build/esm/cc/MultiCommandCC.js.map +1 -1
- package/build/esm/cc/MultilevelSensorCC.d.ts +4 -7
- package/build/esm/cc/MultilevelSensorCC.d.ts.map +1 -1
- package/build/esm/cc/MultilevelSensorCC.js +2 -4
- package/build/esm/cc/MultilevelSensorCC.js.map +1 -1
- package/build/esm/cc/MultilevelSwitchCC._validateArgs.js +1 -1
- package/build/esm/cc/MultilevelSwitchCC._validateArgs.js.map +1 -1
- package/build/esm/cc/MultilevelSwitchCC.d.ts +13 -13
- package/build/esm/cc/MultilevelSwitchCC.d.ts.map +1 -1
- package/build/esm/cc/MultilevelSwitchCC.js +2 -3
- package/build/esm/cc/MultilevelSwitchCC.js.map +1 -1
- package/build/esm/cc/NoOperationCC.js +1 -1
- package/build/esm/cc/NoOperationCC.js.map +1 -1
- package/build/esm/cc/NodeNamingCC.d.ts +5 -5
- package/build/esm/cc/NodeNamingCC.d.ts.map +1 -1
- package/build/esm/cc/NodeNamingCC.js +2 -2
- package/build/esm/cc/NodeNamingCC.js.map +1 -1
- package/build/esm/cc/NotificationCC.d.ts +4 -5
- package/build/esm/cc/NotificationCC.d.ts.map +1 -1
- package/build/esm/cc/NotificationCC.js +2 -4
- package/build/esm/cc/NotificationCC.js.map +1 -1
- package/build/esm/cc/PowerlevelCC.d.ts +3 -3
- package/build/esm/cc/PowerlevelCC.d.ts.map +1 -1
- package/build/esm/cc/PowerlevelCC.js +2 -3
- package/build/esm/cc/PowerlevelCC.js.map +1 -1
- package/build/esm/cc/ProtectionCC._validateArgs.js +1 -1
- package/build/esm/cc/ProtectionCC._validateArgs.js.map +1 -1
- package/build/esm/cc/ProtectionCC.d.ts +11 -11
- package/build/esm/cc/ProtectionCC.d.ts.map +1 -1
- package/build/esm/cc/ProtectionCC.js +2 -3
- package/build/esm/cc/ProtectionCC.js.map +1 -1
- package/build/esm/cc/SceneActivationCC._validateArgs.js +1 -1
- package/build/esm/cc/SceneActivationCC._validateArgs.js.map +1 -1
- package/build/esm/cc/SceneActivationCC.d.ts +5 -6
- package/build/esm/cc/SceneActivationCC.d.ts.map +1 -1
- package/build/esm/cc/SceneActivationCC.js +2 -2
- package/build/esm/cc/SceneActivationCC.js.map +1 -1
- package/build/esm/cc/SceneActuatorConfigurationCC._validateArgs.js +1 -1
- package/build/esm/cc/SceneActuatorConfigurationCC._validateArgs.js.map +1 -1
- package/build/esm/cc/SceneActuatorConfigurationCC.d.ts +5 -5
- package/build/esm/cc/SceneActuatorConfigurationCC.d.ts.map +1 -1
- package/build/esm/cc/SceneActuatorConfigurationCC.js +2 -3
- package/build/esm/cc/SceneActuatorConfigurationCC.js.map +1 -1
- package/build/esm/cc/SceneControllerConfigurationCC._validateArgs.js +1 -1
- package/build/esm/cc/SceneControllerConfigurationCC._validateArgs.js.map +1 -1
- package/build/esm/cc/SceneControllerConfigurationCC.d.ts +6 -6
- package/build/esm/cc/SceneControllerConfigurationCC.d.ts.map +1 -1
- package/build/esm/cc/SceneControllerConfigurationCC.js +2 -3
- package/build/esm/cc/SceneControllerConfigurationCC.js.map +1 -1
- package/build/esm/cc/ScheduleEntryLockCC.d.ts +2 -3
- package/build/esm/cc/ScheduleEntryLockCC.d.ts.map +1 -1
- package/build/esm/cc/ScheduleEntryLockCC.js.map +1 -1
- package/build/esm/cc/Security2CC.d.ts +3 -4
- package/build/esm/cc/Security2CC.d.ts.map +1 -1
- package/build/esm/cc/Security2CC.js +2 -4
- package/build/esm/cc/Security2CC.js.map +1 -1
- package/build/esm/cc/SecurityCC.d.ts +3 -4
- package/build/esm/cc/SecurityCC.d.ts.map +1 -1
- package/build/esm/cc/SecurityCC.js +1 -2
- package/build/esm/cc/SecurityCC.js.map +1 -1
- package/build/esm/cc/SoundSwitchCC.d.ts +7 -7
- package/build/esm/cc/SoundSwitchCC.d.ts.map +1 -1
- package/build/esm/cc/SoundSwitchCC.js +2 -3
- package/build/esm/cc/SoundSwitchCC.js.map +1 -1
- package/build/esm/cc/SupervisionCC.d.ts +4 -4
- package/build/esm/cc/SupervisionCC.d.ts.map +1 -1
- package/build/esm/cc/SupervisionCC.js +2 -3
- package/build/esm/cc/SupervisionCC.js.map +1 -1
- package/build/esm/cc/ThermostatFanModeCC.d.ts +6 -6
- package/build/esm/cc/ThermostatFanModeCC.d.ts.map +1 -1
- package/build/esm/cc/ThermostatFanModeCC.js +2 -3
- package/build/esm/cc/ThermostatFanModeCC.js.map +1 -1
- package/build/esm/cc/ThermostatFanStateCC.d.ts +3 -3
- package/build/esm/cc/ThermostatFanStateCC.d.ts.map +1 -1
- package/build/esm/cc/ThermostatFanStateCC.js +2 -2
- package/build/esm/cc/ThermostatFanStateCC.js.map +1 -1
- package/build/esm/cc/ThermostatModeCC.d.ts +6 -6
- package/build/esm/cc/ThermostatModeCC.d.ts.map +1 -1
- package/build/esm/cc/ThermostatModeCC.js +2 -3
- package/build/esm/cc/ThermostatModeCC.js.map +1 -1
- package/build/esm/cc/ThermostatOperatingStateCC.d.ts +3 -4
- package/build/esm/cc/ThermostatOperatingStateCC.d.ts.map +1 -1
- package/build/esm/cc/ThermostatOperatingStateCC.js +2 -2
- package/build/esm/cc/ThermostatOperatingStateCC.js.map +1 -1
- package/build/esm/cc/ThermostatSetbackCC.d.ts +3 -3
- package/build/esm/cc/ThermostatSetbackCC.d.ts.map +1 -1
- package/build/esm/cc/ThermostatSetbackCC.js +2 -3
- package/build/esm/cc/ThermostatSetbackCC.js.map +1 -1
- package/build/esm/cc/ThermostatSetpointCC.d.ts +6 -6
- package/build/esm/cc/ThermostatSetpointCC.d.ts.map +1 -1
- package/build/esm/cc/ThermostatSetpointCC.js +2 -3
- package/build/esm/cc/ThermostatSetpointCC.js.map +1 -1
- package/build/esm/cc/TimeCC.d.ts +3 -4
- package/build/esm/cc/TimeCC.d.ts.map +1 -1
- package/build/esm/cc/TimeCC.js +1 -2
- package/build/esm/cc/TimeCC.js.map +1 -1
- package/build/esm/cc/TimeParametersCC.d.ts +3 -4
- package/build/esm/cc/TimeParametersCC.d.ts.map +1 -1
- package/build/esm/cc/TimeParametersCC.js +1 -1
- package/build/esm/cc/TimeParametersCC.js.map +1 -1
- package/build/esm/cc/TransportServiceCC.d.ts +3 -3
- package/build/esm/cc/TransportServiceCC.d.ts.map +1 -1
- package/build/esm/cc/TransportServiceCC.js +2 -3
- package/build/esm/cc/TransportServiceCC.js.map +1 -1
- package/build/esm/cc/UserCodeCC.d.ts +19 -19
- package/build/esm/cc/UserCodeCC.d.ts.map +1 -1
- package/build/esm/cc/UserCodeCC.js +2 -3
- package/build/esm/cc/UserCodeCC.js.map +1 -1
- package/build/esm/cc/VersionCC.d.ts +17 -17
- package/build/esm/cc/VersionCC.d.ts.map +1 -1
- package/build/esm/cc/VersionCC.js +2 -3
- package/build/esm/cc/VersionCC.js.map +1 -1
- package/build/esm/cc/WakeUpCC.d.ts +6 -6
- package/build/esm/cc/WakeUpCC.d.ts.map +1 -1
- package/build/esm/cc/WakeUpCC.js +2 -3
- package/build/esm/cc/WakeUpCC.js.map +1 -1
- package/build/esm/cc/WindowCoveringCC.d.ts +3 -4
- package/build/esm/cc/WindowCoveringCC.d.ts.map +1 -1
- package/build/esm/cc/WindowCoveringCC.js +1 -2
- package/build/esm/cc/WindowCoveringCC.js.map +1 -1
- package/build/esm/cc/ZWavePlusCC.d.ts +8 -8
- package/build/esm/cc/ZWavePlusCC.d.ts.map +1 -1
- package/build/esm/cc/ZWavePlusCC.js +2 -3
- package/build/esm/cc/ZWavePlusCC.js.map +1 -1
- package/build/esm/cc/ZWaveProtocolCC.d.ts +2 -2
- package/build/esm/cc/ZWaveProtocolCC.d.ts.map +1 -1
- package/build/esm/cc/ZWaveProtocolCC.js +1 -1
- package/build/esm/cc/ZWaveProtocolCC.js.map +1 -1
- package/build/esm/cc/_CCValues.generated.d.ts +124 -0
- package/build/esm/cc/_CCValues.generated.d.ts.map +1 -1
- package/build/esm/cc/_CCValues.generated.js +75 -4
- package/build/esm/cc/_CCValues.generated.js.map +1 -1
- package/build/esm/cc/index.d.ts +2 -0
- package/build/esm/cc/index.d.ts.map +1 -1
- package/build/esm/cc/index.js +1 -0
- package/build/esm/cc/index.js.map +1 -1
- package/build/esm/cc/manufacturerProprietary/FibaroCC.d.ts +3 -3
- package/build/esm/cc/manufacturerProprietary/FibaroCC.d.ts.map +1 -1
- package/build/esm/cc/manufacturerProprietary/FibaroCC.js +1 -1
- package/build/esm/cc/manufacturerProprietary/FibaroCC.js.map +1 -1
- package/build/esm/lib/API.d.ts +5 -3
- package/build/esm/lib/API.d.ts.map +1 -1
- package/build/esm/lib/API.js.map +1 -1
- package/build/esm/lib/CommandClass.d.ts +5 -6
- package/build/esm/lib/CommandClass.d.ts.map +1 -1
- package/build/esm/lib/CommandClass.js +2 -2
- package/build/esm/lib/CommandClass.js.map +1 -1
- package/build/esm/lib/CommandClassDecorators.d.ts +2 -2
- package/build/esm/lib/CommandClassDecorators.d.ts.map +1 -1
- package/build/esm/lib/CommandClassDecorators.js +1 -1
- package/build/esm/lib/CommandClassDecorators.js.map +1 -1
- package/build/esm/lib/Security2/Extension.d.ts +2 -2
- package/build/esm/lib/Security2/Extension.d.ts.map +1 -1
- package/build/esm/lib/Security2/Extension.js +2 -2
- package/build/esm/lib/Security2/Extension.js.map +1 -1
- package/build/esm/lib/SetValueResult.d.ts +1 -1
- package/build/esm/lib/SetValueResult.d.ts.map +1 -1
- package/build/esm/lib/Values.d.ts +3 -3
- package/build/esm/lib/Values.d.ts.map +1 -1
- package/build/esm/lib/Values.js +1 -1
- package/build/esm/lib/Values.js.map +1 -1
- package/build/esm/lib/_Types.d.ts +6 -2
- package/build/esm/lib/_Types.d.ts.map +1 -1
- package/build/esm/lib/_Types.js +6 -1
- package/build/esm/lib/_Types.js.map +1 -1
- package/build/esm/lib/serializers.d.ts +1 -1
- package/build/esm/lib/serializers.d.ts.map +1 -1
- package/build/esm/lib/serializers.js +1 -1
- package/build/esm/lib/serializers.js.map +1 -1
- package/build/esm/lib/traits.d.ts +2 -2
- package/build/esm/lib/traits.d.ts.map +1 -1
- package/build/esm/lib/utils.d.ts +2 -2
- package/build/esm/lib/utils.d.ts.map +1 -1
- package/build/esm/lib/utils.js +2 -2
- package/build/esm/lib/utils.js.map +1 -1
- package/package.json +6 -6
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/cc/BatteryCC.ts"],
|
|
4
|
-
"sourcesContent": ["import { type CCEncodingContext, type CCParsingContext } from \"@zwave-js/cc\";\nimport { type GetDeviceConfig } from \"@zwave-js/config\";\nimport {\n\ttype GetNode,\n\ttype GetSupportedCCVersion,\n\ttype GetValueDB,\n\ttype WithAddress,\n\tencodeFloatWithScale,\n\ttimespan,\n} from \"@zwave-js/core\";\nimport type {\n\tControlsCC,\n\tEndpointId,\n\tGetEndpoint,\n\tMessageOrCCLogEntry,\n\tMessageRecord,\n\tNodeId,\n\tSinglecastCC,\n\tSupportsCC,\n} from \"@zwave-js/core/safe\";\nimport {\n\tCommandClasses,\n\ttype MaybeNotKnown,\n\tMessagePriority,\n\tValueMetadata,\n\tenumValuesToMetadataStates,\n\tparseFloatWithScale,\n\tvalidatePayload,\n} from \"@zwave-js/core/safe\";\nimport { Bytes } from \"@zwave-js/shared/safe\";\nimport { type AllOrNone, getEnumMemberName, pick } from \"@zwave-js/shared/safe\";\nimport {\n\tCCAPI,\n\tPOLL_VALUE,\n\tPhysicalCCAPI,\n\ttype PollValueImplementation,\n\tthrowUnsupportedProperty,\n} from \"../lib/API.js\";\nimport {\n\ttype CCRaw,\n\tCommandClass,\n\ttype InterviewContext,\n\ttype PersistValuesContext,\n\ttype RefreshValuesContext,\n} from \"../lib/CommandClass.js\";\nimport {\n\tAPI,\n\tCCCommand,\n\tccValueProperty,\n\tccValues,\n\tcommandClass,\n\texpectedCCResponse,\n\timplementedVersion,\n} from \"../lib/CommandClassDecorators.js\";\nimport { V } from \"../lib/Values.js\";\nimport {\n\tBatteryChargingStatus,\n\tBatteryCommand,\n\tBatteryReplacementStatus,\n} from \"../lib/_Types.js\";\nimport { NotificationCCValues } from \"./NotificationCC.js\";\n\nexport const BatteryCCValues = V.defineCCValues(CommandClasses.Battery, {\n\t...V.staticProperty(\n\t\t\"level\",\n\t\t{\n\t\t\t...ValueMetadata.ReadOnlyUInt8,\n\t\t\tmax: 100,\n\t\t\tunit: \"%\",\n\t\t\tlabel: \"Battery level\",\n\t\t} as const,\n\t),\n\n\t...V.staticProperty(\n\t\t\"isLow\",\n\t\t{\n\t\t\t...ValueMetadata.ReadOnlyBoolean,\n\t\t\tlabel: \"Low battery level\",\n\t\t} as const,\n\t),\n\n\t...V.staticProperty(\n\t\t\"maximumCapacity\",\n\t\t{\n\t\t\t...ValueMetadata.ReadOnlyUInt8,\n\t\t\tmax: 100,\n\t\t\tunit: \"%\",\n\t\t\tlabel: \"Maximum capacity\",\n\t\t} as const,\n\t\t{\n\t\t\tminVersion: 2,\n\t\t} as const,\n\t),\n\n\t...V.staticProperty(\n\t\t\"temperature\",\n\t\t{\n\t\t\t...ValueMetadata.ReadOnlyInt8,\n\t\t\tlabel: \"Temperature\",\n\t\t\t// For now, only \u00B0C is specified as a valid unit\n\t\t\t// If this ever changes, update the unit in persistValues on the fly\n\t\t\tunit: \"\u00B0C\",\n\t\t} as const,\n\t\t{\n\t\t\tminVersion: 2,\n\t\t} as const,\n\t),\n\n\t...V.staticProperty(\n\t\t\"chargingStatus\",\n\t\t{\n\t\t\t...ValueMetadata.ReadOnlyUInt8,\n\t\t\tlabel: \"Charging status\",\n\t\t\tstates: enumValuesToMetadataStates(BatteryChargingStatus),\n\t\t} as const,\n\t\t{\n\t\t\tminVersion: 2,\n\t\t} as const,\n\t),\n\n\t...V.staticProperty(\n\t\t\"rechargeable\",\n\t\t{\n\t\t\t...ValueMetadata.ReadOnlyBoolean,\n\t\t\tlabel: \"Rechargeable\",\n\t\t} as const,\n\t\t{\n\t\t\tminVersion: 2,\n\t\t} as const,\n\t),\n\n\t...V.staticProperty(\n\t\t\"backup\",\n\t\t{\n\t\t\t...ValueMetadata.ReadOnlyBoolean,\n\t\t\tlabel: \"Used as backup\",\n\t\t} as const,\n\t\t{\n\t\t\tminVersion: 2,\n\t\t} as const,\n\t),\n\n\t...V.staticProperty(\n\t\t\"overheating\",\n\t\t{\n\t\t\t...ValueMetadata.ReadOnlyBoolean,\n\t\t\tlabel: \"Overheating\",\n\t\t} as const,\n\t\t{\n\t\t\tminVersion: 2,\n\t\t} as const,\n\t),\n\n\t...V.staticProperty(\n\t\t\"lowFluid\",\n\t\t{\n\t\t\t...ValueMetadata.ReadOnlyBoolean,\n\t\t\tlabel: \"Fluid is low\",\n\t\t} as const,\n\t\t{\n\t\t\tminVersion: 2,\n\t\t} as const,\n\t),\n\n\t...V.staticProperty(\n\t\t\"rechargeOrReplace\",\n\t\t{\n\t\t\t...ValueMetadata.ReadOnlyUInt8,\n\t\t\tlabel: \"Recharge or replace\",\n\t\t\tstates: enumValuesToMetadataStates(BatteryReplacementStatus),\n\t\t} as const,\n\t\t{\n\t\t\tminVersion: 2,\n\t\t} as const,\n\t),\n\n\t...V.staticProperty(\n\t\t\"disconnected\",\n\t\t{\n\t\t\t...ValueMetadata.ReadOnlyBoolean,\n\t\t\tlabel: \"Battery is disconnected\",\n\t\t} as const,\n\t\t{\n\t\t\tminVersion: 2,\n\t\t} as const,\n\t),\n\n\t...V.staticProperty(\n\t\t\"lowTemperatureStatus\",\n\t\t{\n\t\t\t...ValueMetadata.ReadOnlyBoolean,\n\t\t\tlabel: \"Battery temperature is low\",\n\t\t} as const,\n\t\t{\n\t\t\tminVersion: 3,\n\t\t} as const,\n\t),\n});\n\n// @noSetValueAPI This CC is read-only\n\n@API(CommandClasses.Battery)\nexport class BatteryCCAPI extends PhysicalCCAPI {\n\tpublic supportsCommand(cmd: BatteryCommand): MaybeNotKnown<boolean> {\n\t\tswitch (cmd) {\n\t\t\tcase BatteryCommand.Get:\n\t\t\t\treturn true; // This is mandatory\n\t\t\tcase BatteryCommand.HealthGet:\n\t\t\t\treturn this.version >= 2;\n\t\t}\n\t\treturn super.supportsCommand(cmd);\n\t}\n\n\tprotected get [POLL_VALUE](): PollValueImplementation {\n\t\treturn async function(this: BatteryCCAPI, { property }) {\n\t\t\tswitch (property) {\n\t\t\t\tcase \"level\":\n\t\t\t\tcase \"isLow\":\n\t\t\t\tcase \"chargingStatus\":\n\t\t\t\tcase \"rechargeable\":\n\t\t\t\tcase \"backup\":\n\t\t\t\tcase \"overheating\":\n\t\t\t\tcase \"lowFluid\":\n\t\t\t\tcase \"rechargeOrReplace\":\n\t\t\t\tcase \"lowTemperatureStatus\":\n\t\t\t\tcase \"disconnected\":\n\t\t\t\t\treturn (await this.get())?.[property];\n\n\t\t\t\tcase \"maximumCapacity\":\n\t\t\t\tcase \"temperature\":\n\t\t\t\t\treturn (await this.getHealth())?.[property];\n\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\t// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types\n\tpublic async get() {\n\t\tthis.assertSupportsCommand(BatteryCommand, BatteryCommand.Get);\n\n\t\tconst cc = new BatteryCCGet({\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<BatteryCCReport>(\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\"level\",\n\t\t\t\t\"isLow\",\n\t\t\t\t\"chargingStatus\",\n\t\t\t\t\"rechargeable\",\n\t\t\t\t\"backup\",\n\t\t\t\t\"overheating\",\n\t\t\t\t\"lowFluid\",\n\t\t\t\t\"rechargeOrReplace\",\n\t\t\t\t\"lowTemperatureStatus\",\n\t\t\t\t\"disconnected\",\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 getHealth() {\n\t\tthis.assertSupportsCommand(BatteryCommand, BatteryCommand.HealthGet);\n\n\t\tconst cc = new BatteryCCHealthGet({\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<BatteryCCHealthReport>(\n\t\t\tcc,\n\t\t\tthis.commandOptions,\n\t\t);\n\t\tif (response) {\n\t\t\treturn pick(response, [\"maximumCapacity\", \"temperature\"]);\n\t\t}\n\t}\n}\n\n@commandClass(CommandClasses.Battery)\n@implementedVersion(3)\n@ccValues(BatteryCCValues)\nexport class BatteryCC extends CommandClass {\n\tdeclare ccCommand: BatteryCommand;\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\t// Query the Battery status\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.Battery,\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: \"querying battery status...\",\n\t\t\tdirection: \"outbound\",\n\t\t});\n\n\t\tconst batteryStatus = await api.get();\n\t\tif (batteryStatus) {\n\t\t\tlet logMessage = `received response for battery information:\nlevel: ${batteryStatus.level}${\n\t\t\t\tbatteryStatus.isLow ? \" (low)\" : \"\"\n\t\t\t}`;\n\t\t\tif (api.version >= 2) {\n\t\t\t\tlogMessage += `\nstatus: ${\n\t\t\t\t\tBatteryChargingStatus[batteryStatus.chargingStatus!]\n\t\t\t\t}\nrechargeable: ${batteryStatus.rechargeable}\nis backup: ${batteryStatus.backup}\nis overheating: ${batteryStatus.overheating}\nfluid is low: ${batteryStatus.lowFluid}\nneeds to be replaced or charged: ${\n\t\t\t\t\tBatteryReplacementStatus[batteryStatus.rechargeOrReplace!]\n\t\t\t\t}\nis low temperature ${batteryStatus.lowTemperatureStatus}\nis disconnected: ${batteryStatus.disconnected}`;\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\n\t\tif (api.version >= 2) {\n\t\t\t// always query the health\n\t\t\tctx.logNode(node.id, {\n\t\t\t\tendpoint: this.endpointIndex,\n\t\t\t\tmessage: \"querying battery health...\",\n\t\t\t\tdirection: \"outbound\",\n\t\t\t});\n\n\t\t\tconst batteryHealth = await api.getHealth();\n\t\t\tif (batteryHealth) {\n\t\t\t\tconst logMessage = `received response for battery health:\nmax. capacity: ${batteryHealth.maximumCapacity} %\ntemperature: ${batteryHealth.temperature} \u00B0C`;\n\t\t\t\tctx.logNode(node.id, {\n\t\t\t\t\tendpoint: this.endpointIndex,\n\t\t\t\t\tmessage: logMessage,\n\t\t\t\t\tdirection: \"inbound\",\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\t}\n\n\tpublic shouldRefreshValues(\n\t\tthis: SinglecastCC<this>,\n\t\tctx:\n\t\t\t& GetValueDB\n\t\t\t& GetSupportedCCVersion\n\t\t\t& GetDeviceConfig\n\t\t\t& GetNode<\n\t\t\t\tNodeId & GetEndpoint<EndpointId & SupportsCC & ControlsCC>\n\t\t\t>,\n\t): boolean {\n\t\t// Check when the battery state was last updated\n\t\tconst valueDB = ctx.tryGetValueDB(this.nodeId);\n\t\tif (!valueDB) return true;\n\n\t\tconst lastUpdated = valueDB.getTimestamp(\n\t\t\tBatteryCCValues.level.endpoint(this.endpointIndex),\n\t\t);\n\t\treturn (\n\t\t\tlastUpdated == undefined\n\t\t\t// The specs say once per month, but that's a bit too unfrequent IMO\n\t\t\t// Also the maximum that setInterval supports is ~24.85 days\n\t\t\t|| Date.now() - lastUpdated > timespan.days(7)\n\t\t);\n\t}\n}\n\n// @publicAPI\nexport type BatteryCCReportOptions =\n\t& (\n\t\t| {\n\t\t\tisLow?: false;\n\t\t\tlevel: number;\n\t\t}\n\t\t| {\n\t\t\tisLow: true;\n\t\t\tlevel?: undefined;\n\t\t}\n\t)\n\t& AllOrNone<{\n\t\t// V2+\n\t\tchargingStatus: BatteryChargingStatus;\n\t\trechargeable: boolean;\n\t\tbackup: boolean;\n\t\toverheating: boolean;\n\t\tlowFluid: boolean;\n\t\trechargeOrReplace: BatteryReplacementStatus;\n\t\tdisconnected: boolean;\n\t}>\n\t& AllOrNone<{\n\t\t// V3+\n\t\tlowTemperatureStatus: boolean;\n\t}>;\n\n@CCCommand(BatteryCommand.Report)\n@ccValueProperty(\"level\", BatteryCCValues.level)\n@ccValueProperty(\"isLow\", BatteryCCValues.isLow)\n@ccValueProperty(\"chargingStatus\", BatteryCCValues.chargingStatus)\n@ccValueProperty(\"rechargeable\", BatteryCCValues.rechargeable)\n@ccValueProperty(\"backup\", BatteryCCValues.backup)\n@ccValueProperty(\"overheating\", BatteryCCValues.overheating)\n@ccValueProperty(\"lowFluid\", BatteryCCValues.lowFluid)\n@ccValueProperty(\"rechargeOrReplace\", BatteryCCValues.rechargeOrReplace)\n@ccValueProperty(\"disconnected\", BatteryCCValues.disconnected)\n@ccValueProperty(\"lowTemperatureStatus\", BatteryCCValues.lowTemperatureStatus)\nexport class BatteryCCReport extends BatteryCC {\n\tpublic constructor(\n\t\toptions: WithAddress<BatteryCCReportOptions>,\n\t) {\n\t\tsuper(options);\n\n\t\tthis.level = options.isLow ? 0 : options.level;\n\t\tthis.isLow = !!options.isLow;\n\t\tthis.chargingStatus = options.chargingStatus;\n\t\tthis.rechargeable = options.rechargeable;\n\t\tthis.backup = options.backup;\n\t\tthis.overheating = options.overheating;\n\t\tthis.lowFluid = options.lowFluid;\n\t\tthis.rechargeOrReplace = options.rechargeOrReplace;\n\t\tthis.disconnected = options.disconnected;\n\t\tthis.lowTemperatureStatus = options.lowTemperatureStatus;\n\t}\n\n\tpublic static from(raw: CCRaw, ctx: CCParsingContext): BatteryCCReport {\n\t\tlet ccOptions: BatteryCCReportOptions;\n\n\t\tvalidatePayload(raw.payload.length >= 1);\n\t\tconst level = raw.payload[0];\n\n\t\tif (level === 0xff) {\n\t\t\tccOptions = {\n\t\t\t\tisLow: true,\n\t\t\t};\n\t\t} else {\n\t\t\tccOptions = {\n\t\t\t\tisLow: false,\n\t\t\t\tlevel,\n\t\t\t};\n\t\t}\n\n\t\tif (raw.payload.length >= 3) {\n\t\t\t// Starting with V2\n\t\t\tconst chargingStatus: BatteryChargingStatus = raw.payload[1] >>> 6;\n\t\t\tconst rechargeable = !!(raw.payload[1] & 0b0010_0000);\n\t\t\tconst backup = !!(raw.payload[1] & 0b0001_0000);\n\t\t\tconst overheating = !!(raw.payload[1] & 0b1000);\n\t\t\tconst lowFluid = !!(raw.payload[1] & 0b0100);\n\t\t\tconst rechargeOrReplace: BatteryReplacementStatus =\n\t\t\t\t!!(raw.payload[1] & 0b10)\n\t\t\t\t\t? BatteryReplacementStatus.Now\n\t\t\t\t\t: !!(raw.payload[1] & 0b1)\n\t\t\t\t\t? BatteryReplacementStatus.Soon\n\t\t\t\t\t: BatteryReplacementStatus.No;\n\t\t\tconst lowTemperatureStatus = !!(raw.payload[2] & 0b10);\n\t\t\tconst disconnected = !!(raw.payload[2] & 0b1);\n\n\t\t\tccOptions = {\n\t\t\t\t...ccOptions,\n\t\t\t\tchargingStatus,\n\t\t\t\trechargeable,\n\t\t\t\tbackup,\n\t\t\t\toverheating,\n\t\t\t\tlowFluid,\n\t\t\t\trechargeOrReplace,\n\t\t\t\tlowTemperatureStatus,\n\t\t\t\tdisconnected,\n\t\t\t};\n\t\t}\n\n\t\treturn new this({\n\t\t\tnodeId: ctx.sourceNodeId,\n\t\t\t...ccOptions,\n\t\t});\n\t}\n\n\tpublic persistValues(ctx: PersistValuesContext): boolean {\n\t\tif (!super.persistValues(ctx)) return false;\n\n\t\t// Na\u00EFve heuristic for a full battery\n\t\tif (this.level >= 90) {\n\t\t\t// Some devices send Notification CC Reports with battery information,\n\t\t\t// or this information is mapped from legacy V1 alarm values.\n\t\t\t// We may need to idle the corresponding values when the battery is full\n\t\t\tconst notificationCCVersion = ctx.getSupportedCCVersion(\n\t\t\t\tCommandClasses.Notification,\n\t\t\t\tthis.nodeId as number,\n\t\t\t\tthis.endpointIndex,\n\t\t\t);\n\t\t\tif (\n\t\t\t\t// supported\n\t\t\t\tnotificationCCVersion > 0\n\t\t\t\t// but idling is not required\n\t\t\t\t&& notificationCCVersion < 8\n\t\t\t) {\n\t\t\t\tconst batteryLevelStatusValue = NotificationCCValues\n\t\t\t\t\t.notificationVariable(\n\t\t\t\t\t\t\"Power Management\",\n\t\t\t\t\t\t\"Battery level status\",\n\t\t\t\t\t);\n\t\t\t\t// If not undefined and not idle\n\t\t\t\tif (this.getValue(ctx, batteryLevelStatusValue)) {\n\t\t\t\t\tthis.setValue(\n\t\t\t\t\t\tctx,\n\t\t\t\t\t\tbatteryLevelStatusValue,\n\t\t\t\t\t\t0, /* idle */\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn true;\n\t}\n\n\tpublic readonly level: number;\n\n\tpublic readonly isLow: boolean;\n\n\tpublic readonly chargingStatus: BatteryChargingStatus | undefined;\n\n\tpublic readonly rechargeable: boolean | undefined;\n\n\tpublic readonly backup: boolean | undefined;\n\n\tpublic readonly overheating: boolean | undefined;\n\n\tpublic readonly lowFluid: boolean | undefined;\n\n\tpublic readonly rechargeOrReplace: BatteryReplacementStatus | undefined;\n\n\tpublic readonly disconnected: boolean | undefined;\n\n\tpublic readonly lowTemperatureStatus: boolean | undefined;\n\n\tpublic serialize(ctx: CCEncodingContext): Promise<Bytes> {\n\t\tthis.payload = Bytes.from([this.isLow ? 0xff : this.level]);\n\t\tif (this.chargingStatus != 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\t(this.chargingStatus << 6)\n\t\t\t\t\t+ (this.rechargeable ? 0b0010_0000 : 0)\n\t\t\t\t\t+ (this.backup ? 0b0001_0000 : 0)\n\t\t\t\t\t+ (this.overheating ? 0b1000 : 0)\n\t\t\t\t\t+ (this.lowFluid ? 0b0100 : 0)\n\t\t\t\t\t+ (this.rechargeOrReplace === BatteryReplacementStatus.Now\n\t\t\t\t\t\t? 0b10\n\t\t\t\t\t\t: this.rechargeOrReplace\n\t\t\t\t\t\t\t\t=== BatteryReplacementStatus.Soon\n\t\t\t\t\t\t? 0b1\n\t\t\t\t\t\t: 0),\n\t\t\t\t\t(this.lowTemperatureStatus ? 0b10 : 0)\n\t\t\t\t\t+ (this.disconnected ? 0b1 : 0),\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\tlevel: this.level,\n\t\t\t\"is low\": this.isLow,\n\t\t};\n\t\tif (this.chargingStatus != undefined) {\n\t\t\tmessage[\"charging status\"] = getEnumMemberName(\n\t\t\t\tBatteryChargingStatus,\n\t\t\t\tthis.chargingStatus,\n\t\t\t);\n\t\t}\n\t\tif (this.rechargeable != undefined) {\n\t\t\tmessage.rechargeable = this.rechargeable;\n\t\t}\n\t\tif (this.backup != undefined) {\n\t\t\tmessage.backup = this.backup;\n\t\t}\n\t\tif (this.overheating != undefined) {\n\t\t\tmessage.overheating = this.overheating;\n\t\t}\n\t\tif (this.lowFluid != undefined) {\n\t\t\tmessage[\"low fluid\"] = this.lowFluid;\n\t\t}\n\t\tif (this.rechargeOrReplace != undefined) {\n\t\t\tmessage[\"recharge or replace\"] = getEnumMemberName(\n\t\t\t\tBatteryReplacementStatus,\n\t\t\t\tthis.rechargeOrReplace,\n\t\t\t);\n\t\t}\n\t\tif (this.lowTemperatureStatus != undefined) {\n\t\t\tmessage.lowTemperatureStatus = this.lowTemperatureStatus;\n\t\t}\n\t\tif (this.disconnected != undefined) {\n\t\t\tmessage.disconnected = this.disconnected;\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(BatteryCommand.Get)\n@expectedCCResponse(BatteryCCReport)\nexport class BatteryCCGet extends BatteryCC {}\n\n// @publicAPI\nexport interface BatteryCCHealthReportOptions {\n\tmaximumCapacity?: number;\n\ttemperature?: number;\n\ttemperatureScale?: number;\n}\n\n@CCCommand(BatteryCommand.HealthReport)\n@ccValueProperty(\"maximumCapacity\", BatteryCCValues.maximumCapacity)\n@ccValueProperty(\"temperature\", BatteryCCValues.temperature)\nexport class BatteryCCHealthReport extends BatteryCC {\n\tpublic constructor(\n\t\toptions: WithAddress<BatteryCCHealthReportOptions>,\n\t) {\n\t\tsuper(options);\n\n\t\t// TODO: Check implementation:\n\t\tthis.maximumCapacity = options.maximumCapacity;\n\t\tthis.temperature = options.temperature;\n\t\tthis.temperatureScale = options.temperatureScale;\n\t}\n\n\tpublic static from(\n\t\traw: CCRaw,\n\t\tctx: CCParsingContext,\n\t): BatteryCCHealthReport {\n\t\tvalidatePayload(raw.payload.length >= 2);\n\t\t// Parse maximum capacity. 0xff means unknown\n\t\tlet maximumCapacity: number | undefined = raw.payload[0];\n\t\tif (maximumCapacity === 0xff) maximumCapacity = undefined;\n\t\tconst {\n\t\t\tvalue: temperature,\n\t\t\tscale: temperatureScale,\n\t\t} = parseFloatWithScale(\n\t\t\traw.payload.subarray(1),\n\t\t\ttrue, // The temperature field may be omitted\n\t\t);\n\n\t\treturn new this({\n\t\t\tnodeId: ctx.sourceNodeId,\n\t\t\tmaximumCapacity,\n\t\t\ttemperature,\n\t\t\ttemperatureScale,\n\t\t});\n\t}\n\n\tpublic readonly maximumCapacity: number | undefined;\n\tpublic readonly temperature: number | undefined;\n\tprivate readonly temperatureScale: number | undefined;\n\n\tpublic serialize(ctx: CCEncodingContext): Promise<Bytes> {\n\t\tconst temperature = this.temperature != undefined\n\t\t\t? encodeFloatWithScale(\n\t\t\t\tthis.temperature,\n\t\t\t\tthis.temperatureScale ?? 0x00,\n\t\t\t)\n\t\t\t// size, precision and scale must be 0 if the temperature is omitted\n\t\t\t: Bytes.from([0x00]);\n\n\t\tthis.payload = Bytes.concat([\n\t\t\t[this.maximumCapacity ?? 0xff],\n\t\t\ttemperature,\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\ttemperature: this.temperature != undefined\n\t\t\t\t\t? this.temperature\n\t\t\t\t\t: \"unknown\",\n\t\t\t\t\"max capacity\": this.maximumCapacity != undefined\n\t\t\t\t\t? `${this.maximumCapacity} %`\n\t\t\t\t\t: \"unknown\",\n\t\t\t},\n\t\t};\n\t}\n}\n\n@CCCommand(BatteryCommand.HealthGet)\n@expectedCCResponse(BatteryCCHealthReport)\nexport class BatteryCCHealthGet extends BatteryCC {}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,
|
|
6
|
-
"names": [
|
|
4
|
+
"sourcesContent": ["import type { CCEncodingContext, CCParsingContext } from \"@zwave-js/cc\";\nimport type { GetDeviceConfig } from \"@zwave-js/config\";\nimport {\n\tCommandClasses,\n\ttype ControlsCC,\n\ttype EndpointId,\n\ttype GetEndpoint,\n\ttype GetNode,\n\ttype GetSupportedCCVersion,\n\ttype GetValueDB,\n\ttype MaybeNotKnown,\n\ttype MessageOrCCLogEntry,\n\tMessagePriority,\n\ttype MessageRecord,\n\ttype NodeId,\n\ttype SinglecastCC,\n\ttype SupportsCC,\n\tValueMetadata,\n\ttype WithAddress,\n\tencodeFloatWithScale,\n\tenumValuesToMetadataStates,\n\tparseFloatWithScale,\n\ttimespan,\n\tvalidatePayload,\n} from \"@zwave-js/core\";\nimport {\n\ttype AllOrNone,\n\tBytes,\n\tgetEnumMemberName,\n\tpick,\n} from \"@zwave-js/shared\";\nimport {\n\tCCAPI,\n\tPOLL_VALUE,\n\tPhysicalCCAPI,\n\ttype PollValueImplementation,\n\tthrowUnsupportedProperty,\n} from \"../lib/API.js\";\nimport {\n\ttype CCRaw,\n\tCommandClass,\n\ttype InterviewContext,\n\ttype PersistValuesContext,\n\ttype RefreshValuesContext,\n} from \"../lib/CommandClass.js\";\nimport {\n\tAPI,\n\tCCCommand,\n\tccValueProperty,\n\tccValues,\n\tcommandClass,\n\texpectedCCResponse,\n\timplementedVersion,\n} from \"../lib/CommandClassDecorators.js\";\nimport { V } from \"../lib/Values.js\";\nimport {\n\tBatteryChargingStatus,\n\tBatteryCommand,\n\tBatteryReplacementStatus,\n} from \"../lib/_Types.js\";\nimport { NotificationCCValues } from \"./NotificationCC.js\";\n\nexport const BatteryCCValues = V.defineCCValues(CommandClasses.Battery, {\n\t...V.staticProperty(\n\t\t\"level\",\n\t\t{\n\t\t\t...ValueMetadata.ReadOnlyUInt8,\n\t\t\tmax: 100,\n\t\t\tunit: \"%\",\n\t\t\tlabel: \"Battery level\",\n\t\t} as const,\n\t),\n\n\t...V.staticProperty(\n\t\t\"isLow\",\n\t\t{\n\t\t\t...ValueMetadata.ReadOnlyBoolean,\n\t\t\tlabel: \"Low battery level\",\n\t\t} as const,\n\t),\n\n\t...V.staticProperty(\n\t\t\"maximumCapacity\",\n\t\t{\n\t\t\t...ValueMetadata.ReadOnlyUInt8,\n\t\t\tmax: 100,\n\t\t\tunit: \"%\",\n\t\t\tlabel: \"Maximum capacity\",\n\t\t} as const,\n\t\t{\n\t\t\tminVersion: 2,\n\t\t} as const,\n\t),\n\n\t...V.staticProperty(\n\t\t\"temperature\",\n\t\t{\n\t\t\t...ValueMetadata.ReadOnlyInt8,\n\t\t\tlabel: \"Temperature\",\n\t\t\t// For now, only \u00B0C is specified as a valid unit\n\t\t\t// If this ever changes, update the unit in persistValues on the fly\n\t\t\tunit: \"\u00B0C\",\n\t\t} as const,\n\t\t{\n\t\t\tminVersion: 2,\n\t\t} as const,\n\t),\n\n\t...V.staticProperty(\n\t\t\"chargingStatus\",\n\t\t{\n\t\t\t...ValueMetadata.ReadOnlyUInt8,\n\t\t\tlabel: \"Charging status\",\n\t\t\tstates: enumValuesToMetadataStates(BatteryChargingStatus),\n\t\t} as const,\n\t\t{\n\t\t\tminVersion: 2,\n\t\t} as const,\n\t),\n\n\t...V.staticProperty(\n\t\t\"rechargeable\",\n\t\t{\n\t\t\t...ValueMetadata.ReadOnlyBoolean,\n\t\t\tlabel: \"Rechargeable\",\n\t\t} as const,\n\t\t{\n\t\t\tminVersion: 2,\n\t\t} as const,\n\t),\n\n\t...V.staticProperty(\n\t\t\"backup\",\n\t\t{\n\t\t\t...ValueMetadata.ReadOnlyBoolean,\n\t\t\tlabel: \"Used as backup\",\n\t\t} as const,\n\t\t{\n\t\t\tminVersion: 2,\n\t\t} as const,\n\t),\n\n\t...V.staticProperty(\n\t\t\"overheating\",\n\t\t{\n\t\t\t...ValueMetadata.ReadOnlyBoolean,\n\t\t\tlabel: \"Overheating\",\n\t\t} as const,\n\t\t{\n\t\t\tminVersion: 2,\n\t\t} as const,\n\t),\n\n\t...V.staticProperty(\n\t\t\"lowFluid\",\n\t\t{\n\t\t\t...ValueMetadata.ReadOnlyBoolean,\n\t\t\tlabel: \"Fluid is low\",\n\t\t} as const,\n\t\t{\n\t\t\tminVersion: 2,\n\t\t} as const,\n\t),\n\n\t...V.staticProperty(\n\t\t\"rechargeOrReplace\",\n\t\t{\n\t\t\t...ValueMetadata.ReadOnlyUInt8,\n\t\t\tlabel: \"Recharge or replace\",\n\t\t\tstates: enumValuesToMetadataStates(BatteryReplacementStatus),\n\t\t} as const,\n\t\t{\n\t\t\tminVersion: 2,\n\t\t} as const,\n\t),\n\n\t...V.staticProperty(\n\t\t\"disconnected\",\n\t\t{\n\t\t\t...ValueMetadata.ReadOnlyBoolean,\n\t\t\tlabel: \"Battery is disconnected\",\n\t\t} as const,\n\t\t{\n\t\t\tminVersion: 2,\n\t\t} as const,\n\t),\n\n\t...V.staticProperty(\n\t\t\"lowTemperatureStatus\",\n\t\t{\n\t\t\t...ValueMetadata.ReadOnlyBoolean,\n\t\t\tlabel: \"Battery temperature is low\",\n\t\t} as const,\n\t\t{\n\t\t\tminVersion: 3,\n\t\t} as const,\n\t),\n});\n\n// @noSetValueAPI This CC is read-only\n\n@API(CommandClasses.Battery)\nexport class BatteryCCAPI extends PhysicalCCAPI {\n\tpublic supportsCommand(cmd: BatteryCommand): MaybeNotKnown<boolean> {\n\t\tswitch (cmd) {\n\t\t\tcase BatteryCommand.Get:\n\t\t\t\treturn true; // This is mandatory\n\t\t\tcase BatteryCommand.HealthGet:\n\t\t\t\treturn this.version >= 2;\n\t\t}\n\t\treturn super.supportsCommand(cmd);\n\t}\n\n\tprotected get [POLL_VALUE](): PollValueImplementation {\n\t\treturn async function(this: BatteryCCAPI, { property }) {\n\t\t\tswitch (property) {\n\t\t\t\tcase \"level\":\n\t\t\t\tcase \"isLow\":\n\t\t\t\tcase \"chargingStatus\":\n\t\t\t\tcase \"rechargeable\":\n\t\t\t\tcase \"backup\":\n\t\t\t\tcase \"overheating\":\n\t\t\t\tcase \"lowFluid\":\n\t\t\t\tcase \"rechargeOrReplace\":\n\t\t\t\tcase \"lowTemperatureStatus\":\n\t\t\t\tcase \"disconnected\":\n\t\t\t\t\treturn (await this.get())?.[property];\n\n\t\t\t\tcase \"maximumCapacity\":\n\t\t\t\tcase \"temperature\":\n\t\t\t\t\treturn (await this.getHealth())?.[property];\n\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\t// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types\n\tpublic async get() {\n\t\tthis.assertSupportsCommand(BatteryCommand, BatteryCommand.Get);\n\n\t\tconst cc = new BatteryCCGet({\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<BatteryCCReport>(\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\"level\",\n\t\t\t\t\"isLow\",\n\t\t\t\t\"chargingStatus\",\n\t\t\t\t\"rechargeable\",\n\t\t\t\t\"backup\",\n\t\t\t\t\"overheating\",\n\t\t\t\t\"lowFluid\",\n\t\t\t\t\"rechargeOrReplace\",\n\t\t\t\t\"lowTemperatureStatus\",\n\t\t\t\t\"disconnected\",\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 getHealth() {\n\t\tthis.assertSupportsCommand(BatteryCommand, BatteryCommand.HealthGet);\n\n\t\tconst cc = new BatteryCCHealthGet({\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<BatteryCCHealthReport>(\n\t\t\tcc,\n\t\t\tthis.commandOptions,\n\t\t);\n\t\tif (response) {\n\t\t\treturn pick(response, [\"maximumCapacity\", \"temperature\"]);\n\t\t}\n\t}\n}\n\n@commandClass(CommandClasses.Battery)\n@implementedVersion(3)\n@ccValues(BatteryCCValues)\nexport class BatteryCC extends CommandClass {\n\tdeclare ccCommand: BatteryCommand;\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\t// Query the Battery status\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.Battery,\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: \"querying battery status...\",\n\t\t\tdirection: \"outbound\",\n\t\t});\n\n\t\tconst batteryStatus = await api.get();\n\t\tif (batteryStatus) {\n\t\t\tlet logMessage = `received response for battery information:\nlevel: ${batteryStatus.level}${\n\t\t\t\tbatteryStatus.isLow ? \" (low)\" : \"\"\n\t\t\t}`;\n\t\t\tif (api.version >= 2) {\n\t\t\t\tlogMessage += `\nstatus: ${\n\t\t\t\t\tBatteryChargingStatus[batteryStatus.chargingStatus!]\n\t\t\t\t}\nrechargeable: ${batteryStatus.rechargeable}\nis backup: ${batteryStatus.backup}\nis overheating: ${batteryStatus.overheating}\nfluid is low: ${batteryStatus.lowFluid}\nneeds to be replaced or charged: ${\n\t\t\t\t\tBatteryReplacementStatus[batteryStatus.rechargeOrReplace!]\n\t\t\t\t}\nis low temperature ${batteryStatus.lowTemperatureStatus}\nis disconnected: ${batteryStatus.disconnected}`;\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\n\t\tif (api.version >= 2) {\n\t\t\t// always query the health\n\t\t\tctx.logNode(node.id, {\n\t\t\t\tendpoint: this.endpointIndex,\n\t\t\t\tmessage: \"querying battery health...\",\n\t\t\t\tdirection: \"outbound\",\n\t\t\t});\n\n\t\t\tconst batteryHealth = await api.getHealth();\n\t\t\tif (batteryHealth) {\n\t\t\t\tconst logMessage = `received response for battery health:\nmax. capacity: ${batteryHealth.maximumCapacity} %\ntemperature: ${batteryHealth.temperature} \u00B0C`;\n\t\t\t\tctx.logNode(node.id, {\n\t\t\t\t\tendpoint: this.endpointIndex,\n\t\t\t\t\tmessage: logMessage,\n\t\t\t\t\tdirection: \"inbound\",\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\t}\n\n\tpublic shouldRefreshValues(\n\t\tthis: SinglecastCC<this>,\n\t\tctx:\n\t\t\t& GetValueDB\n\t\t\t& GetSupportedCCVersion\n\t\t\t& GetDeviceConfig\n\t\t\t& GetNode<\n\t\t\t\tNodeId & GetEndpoint<EndpointId & SupportsCC & ControlsCC>\n\t\t\t>,\n\t): boolean {\n\t\t// Check when the battery state was last updated\n\t\tconst valueDB = ctx.tryGetValueDB(this.nodeId);\n\t\tif (!valueDB) return true;\n\n\t\tconst lastUpdated = valueDB.getTimestamp(\n\t\t\tBatteryCCValues.level.endpoint(this.endpointIndex),\n\t\t);\n\t\treturn (\n\t\t\tlastUpdated == undefined\n\t\t\t// The specs say once per month, but that's a bit too unfrequent IMO\n\t\t\t// Also the maximum that setInterval supports is ~24.85 days\n\t\t\t|| Date.now() - lastUpdated > timespan.days(7)\n\t\t);\n\t}\n}\n\n// @publicAPI\nexport type BatteryCCReportOptions =\n\t& (\n\t\t| {\n\t\t\tisLow?: false;\n\t\t\tlevel: number;\n\t\t}\n\t\t| {\n\t\t\tisLow: true;\n\t\t\tlevel?: undefined;\n\t\t}\n\t)\n\t& AllOrNone<{\n\t\t// V2+\n\t\tchargingStatus: BatteryChargingStatus;\n\t\trechargeable: boolean;\n\t\tbackup: boolean;\n\t\toverheating: boolean;\n\t\tlowFluid: boolean;\n\t\trechargeOrReplace: BatteryReplacementStatus;\n\t\tdisconnected: boolean;\n\t}>\n\t& AllOrNone<{\n\t\t// V3+\n\t\tlowTemperatureStatus: boolean;\n\t}>;\n\n@CCCommand(BatteryCommand.Report)\n@ccValueProperty(\"level\", BatteryCCValues.level)\n@ccValueProperty(\"isLow\", BatteryCCValues.isLow)\n@ccValueProperty(\"chargingStatus\", BatteryCCValues.chargingStatus)\n@ccValueProperty(\"rechargeable\", BatteryCCValues.rechargeable)\n@ccValueProperty(\"backup\", BatteryCCValues.backup)\n@ccValueProperty(\"overheating\", BatteryCCValues.overheating)\n@ccValueProperty(\"lowFluid\", BatteryCCValues.lowFluid)\n@ccValueProperty(\"rechargeOrReplace\", BatteryCCValues.rechargeOrReplace)\n@ccValueProperty(\"disconnected\", BatteryCCValues.disconnected)\n@ccValueProperty(\"lowTemperatureStatus\", BatteryCCValues.lowTemperatureStatus)\nexport class BatteryCCReport extends BatteryCC {\n\tpublic constructor(\n\t\toptions: WithAddress<BatteryCCReportOptions>,\n\t) {\n\t\tsuper(options);\n\n\t\tthis.level = options.isLow ? 0 : options.level;\n\t\tthis.isLow = !!options.isLow;\n\t\tthis.chargingStatus = options.chargingStatus;\n\t\tthis.rechargeable = options.rechargeable;\n\t\tthis.backup = options.backup;\n\t\tthis.overheating = options.overheating;\n\t\tthis.lowFluid = options.lowFluid;\n\t\tthis.rechargeOrReplace = options.rechargeOrReplace;\n\t\tthis.disconnected = options.disconnected;\n\t\tthis.lowTemperatureStatus = options.lowTemperatureStatus;\n\t}\n\n\tpublic static from(raw: CCRaw, ctx: CCParsingContext): BatteryCCReport {\n\t\tlet ccOptions: BatteryCCReportOptions;\n\n\t\tvalidatePayload(raw.payload.length >= 1);\n\t\tconst level = raw.payload[0];\n\n\t\tif (level === 0xff) {\n\t\t\tccOptions = {\n\t\t\t\tisLow: true,\n\t\t\t};\n\t\t} else {\n\t\t\tccOptions = {\n\t\t\t\tisLow: false,\n\t\t\t\tlevel,\n\t\t\t};\n\t\t}\n\n\t\tif (raw.payload.length >= 3) {\n\t\t\t// Starting with V2\n\t\t\tconst chargingStatus: BatteryChargingStatus = raw.payload[1] >>> 6;\n\t\t\tconst rechargeable = !!(raw.payload[1] & 0b0010_0000);\n\t\t\tconst backup = !!(raw.payload[1] & 0b0001_0000);\n\t\t\tconst overheating = !!(raw.payload[1] & 0b1000);\n\t\t\tconst lowFluid = !!(raw.payload[1] & 0b0100);\n\t\t\tconst rechargeOrReplace: BatteryReplacementStatus =\n\t\t\t\t!!(raw.payload[1] & 0b10)\n\t\t\t\t\t? BatteryReplacementStatus.Now\n\t\t\t\t\t: !!(raw.payload[1] & 0b1)\n\t\t\t\t\t? BatteryReplacementStatus.Soon\n\t\t\t\t\t: BatteryReplacementStatus.No;\n\t\t\tconst lowTemperatureStatus = !!(raw.payload[2] & 0b10);\n\t\t\tconst disconnected = !!(raw.payload[2] & 0b1);\n\n\t\t\tccOptions = {\n\t\t\t\t...ccOptions,\n\t\t\t\tchargingStatus,\n\t\t\t\trechargeable,\n\t\t\t\tbackup,\n\t\t\t\toverheating,\n\t\t\t\tlowFluid,\n\t\t\t\trechargeOrReplace,\n\t\t\t\tlowTemperatureStatus,\n\t\t\t\tdisconnected,\n\t\t\t};\n\t\t}\n\n\t\treturn new this({\n\t\t\tnodeId: ctx.sourceNodeId,\n\t\t\t...ccOptions,\n\t\t});\n\t}\n\n\tpublic persistValues(ctx: PersistValuesContext): boolean {\n\t\tif (!super.persistValues(ctx)) return false;\n\n\t\t// Na\u00EFve heuristic for a full battery\n\t\tif (this.level >= 90) {\n\t\t\t// Some devices send Notification CC Reports with battery information,\n\t\t\t// or this information is mapped from legacy V1 alarm values.\n\t\t\t// We may need to idle the corresponding values when the battery is full\n\t\t\tconst notificationCCVersion = ctx.getSupportedCCVersion(\n\t\t\t\tCommandClasses.Notification,\n\t\t\t\tthis.nodeId as number,\n\t\t\t\tthis.endpointIndex,\n\t\t\t);\n\t\t\tif (\n\t\t\t\t// supported\n\t\t\t\tnotificationCCVersion > 0\n\t\t\t\t// but idling is not required\n\t\t\t\t&& notificationCCVersion < 8\n\t\t\t) {\n\t\t\t\tconst batteryLevelStatusValue = NotificationCCValues\n\t\t\t\t\t.notificationVariable(\n\t\t\t\t\t\t\"Power Management\",\n\t\t\t\t\t\t\"Battery level status\",\n\t\t\t\t\t);\n\t\t\t\t// If not undefined and not idle\n\t\t\t\tif (this.getValue(ctx, batteryLevelStatusValue)) {\n\t\t\t\t\tthis.setValue(\n\t\t\t\t\t\tctx,\n\t\t\t\t\t\tbatteryLevelStatusValue,\n\t\t\t\t\t\t0, /* idle */\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn true;\n\t}\n\n\tpublic readonly level: number;\n\n\tpublic readonly isLow: boolean;\n\n\tpublic readonly chargingStatus: BatteryChargingStatus | undefined;\n\n\tpublic readonly rechargeable: boolean | undefined;\n\n\tpublic readonly backup: boolean | undefined;\n\n\tpublic readonly overheating: boolean | undefined;\n\n\tpublic readonly lowFluid: boolean | undefined;\n\n\tpublic readonly rechargeOrReplace: BatteryReplacementStatus | undefined;\n\n\tpublic readonly disconnected: boolean | undefined;\n\n\tpublic readonly lowTemperatureStatus: boolean | undefined;\n\n\tpublic serialize(ctx: CCEncodingContext): Promise<Bytes> {\n\t\tthis.payload = Bytes.from([this.isLow ? 0xff : this.level]);\n\t\tif (this.chargingStatus != 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\t(this.chargingStatus << 6)\n\t\t\t\t\t+ (this.rechargeable ? 0b0010_0000 : 0)\n\t\t\t\t\t+ (this.backup ? 0b0001_0000 : 0)\n\t\t\t\t\t+ (this.overheating ? 0b1000 : 0)\n\t\t\t\t\t+ (this.lowFluid ? 0b0100 : 0)\n\t\t\t\t\t+ (this.rechargeOrReplace === BatteryReplacementStatus.Now\n\t\t\t\t\t\t? 0b10\n\t\t\t\t\t\t: this.rechargeOrReplace\n\t\t\t\t\t\t\t\t=== BatteryReplacementStatus.Soon\n\t\t\t\t\t\t? 0b1\n\t\t\t\t\t\t: 0),\n\t\t\t\t\t(this.lowTemperatureStatus ? 0b10 : 0)\n\t\t\t\t\t+ (this.disconnected ? 0b1 : 0),\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\tlevel: this.level,\n\t\t\t\"is low\": this.isLow,\n\t\t};\n\t\tif (this.chargingStatus != undefined) {\n\t\t\tmessage[\"charging status\"] = getEnumMemberName(\n\t\t\t\tBatteryChargingStatus,\n\t\t\t\tthis.chargingStatus,\n\t\t\t);\n\t\t}\n\t\tif (this.rechargeable != undefined) {\n\t\t\tmessage.rechargeable = this.rechargeable;\n\t\t}\n\t\tif (this.backup != undefined) {\n\t\t\tmessage.backup = this.backup;\n\t\t}\n\t\tif (this.overheating != undefined) {\n\t\t\tmessage.overheating = this.overheating;\n\t\t}\n\t\tif (this.lowFluid != undefined) {\n\t\t\tmessage[\"low fluid\"] = this.lowFluid;\n\t\t}\n\t\tif (this.rechargeOrReplace != undefined) {\n\t\t\tmessage[\"recharge or replace\"] = getEnumMemberName(\n\t\t\t\tBatteryReplacementStatus,\n\t\t\t\tthis.rechargeOrReplace,\n\t\t\t);\n\t\t}\n\t\tif (this.lowTemperatureStatus != undefined) {\n\t\t\tmessage.lowTemperatureStatus = this.lowTemperatureStatus;\n\t\t}\n\t\tif (this.disconnected != undefined) {\n\t\t\tmessage.disconnected = this.disconnected;\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(BatteryCommand.Get)\n@expectedCCResponse(BatteryCCReport)\nexport class BatteryCCGet extends BatteryCC {}\n\n// @publicAPI\nexport interface BatteryCCHealthReportOptions {\n\tmaximumCapacity?: number;\n\ttemperature?: number;\n\ttemperatureScale?: number;\n}\n\n@CCCommand(BatteryCommand.HealthReport)\n@ccValueProperty(\"maximumCapacity\", BatteryCCValues.maximumCapacity)\n@ccValueProperty(\"temperature\", BatteryCCValues.temperature)\nexport class BatteryCCHealthReport extends BatteryCC {\n\tpublic constructor(\n\t\toptions: WithAddress<BatteryCCHealthReportOptions>,\n\t) {\n\t\tsuper(options);\n\n\t\t// TODO: Check implementation:\n\t\tthis.maximumCapacity = options.maximumCapacity;\n\t\tthis.temperature = options.temperature;\n\t\tthis.temperatureScale = options.temperatureScale;\n\t}\n\n\tpublic static from(\n\t\traw: CCRaw,\n\t\tctx: CCParsingContext,\n\t): BatteryCCHealthReport {\n\t\tvalidatePayload(raw.payload.length >= 2);\n\t\t// Parse maximum capacity. 0xff means unknown\n\t\tlet maximumCapacity: number | undefined = raw.payload[0];\n\t\tif (maximumCapacity === 0xff) maximumCapacity = undefined;\n\t\tconst {\n\t\t\tvalue: temperature,\n\t\t\tscale: temperatureScale,\n\t\t} = parseFloatWithScale(\n\t\t\traw.payload.subarray(1),\n\t\t\ttrue, // The temperature field may be omitted\n\t\t);\n\n\t\treturn new this({\n\t\t\tnodeId: ctx.sourceNodeId,\n\t\t\tmaximumCapacity,\n\t\t\ttemperature,\n\t\t\ttemperatureScale,\n\t\t});\n\t}\n\n\tpublic readonly maximumCapacity: number | undefined;\n\tpublic readonly temperature: number | undefined;\n\tprivate readonly temperatureScale: number | undefined;\n\n\tpublic serialize(ctx: CCEncodingContext): Promise<Bytes> {\n\t\tconst temperature = this.temperature != undefined\n\t\t\t? encodeFloatWithScale(\n\t\t\t\tthis.temperature,\n\t\t\t\tthis.temperatureScale ?? 0x00,\n\t\t\t)\n\t\t\t// size, precision and scale must be 0 if the temperature is omitted\n\t\t\t: Bytes.from([0x00]);\n\n\t\tthis.payload = Bytes.concat([\n\t\t\t[this.maximumCapacity ?? 0xff],\n\t\t\ttemperature,\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\ttemperature: this.temperature != undefined\n\t\t\t\t\t? this.temperature\n\t\t\t\t\t: \"unknown\",\n\t\t\t\t\"max capacity\": this.maximumCapacity != undefined\n\t\t\t\t\t? `${this.maximumCapacity} %`\n\t\t\t\t\t: \"unknown\",\n\t\t\t},\n\t\t};\n\t}\n}\n\n@CCCommand(BatteryCommand.HealthGet)\n@expectedCCResponse(BatteryCCHealthReport)\nexport class BatteryCCHealthGet extends BatteryCC {}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,kBAsBO;AACP,oBAKO;AACP,iBAMO;AACP,0BAMO;AACP,oCAQO;AACP,oBAAkB;AAClB,mBAIO;AACP,4BAAqC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IA8IxB,gBAAY,MAAA;8BADxB,mCAAI,2BAAe,OAAO,CAAC;;;;oBACM;oCAAA,YAAa;WAAA;;;;;;;;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I,kBAAsC,IAAI,QAAQ,CAAC;AACvD,UAAI,oBAAoB;AAAM,0BAAkB;AAChD,YAAM,EACL,OAAO,aACP,OAAO,iBAAgB,QACpB,iCACH,IAAI,QAAQ,SAAS,CAAC,GACtB,IAAI;AAGL,aAAO,IAAI,KAAK;QACf,QAAQ,IAAI;QACZ;QACA;QACA;OACA;IACF;IAEgB;IACA;IACC;IAEV,UAAU,KAAsB;AACtC,YAAM,cAAc,KAAK,eAAe,aACrC,kCACD,KAAK,aACL,KAAK,oBAAoB,CAAI,IAG5B,oBAAM,KAAK,CAAC,CAAI,CAAC;AAEpB,WAAK,UAAU,oBAAM,OAAO;QAC3B,CAAC,KAAK,mBAAmB,GAAI;QAC7B;OACA;AACD,aAAO,MAAM,UAAU,GAAG;IAC3B;IAEO,WAAW,KAAgB;AACjC,aAAO;QACN,GAAG,MAAM,WAAW,GAAG;QACvB,SAAS;UACR,aAAa,KAAK,eAAe,SAC9B,KAAK,cACL;UACH,gBAAgB,KAAK,mBAAmB,SACrC,GAAG,KAAK,eAAe,OACvB;;;IAGN;;;;IAKY,sBAAkB,MAAA;8BAF9B,yCAAU,4BAAe,SAAS,OAClC,kDAAmB,qBAAqB,CAAC;;;;oBACF;0CAAA,YAAS;WAAA;;;;;;;;AAAjD,mBAAA,MAAA,mBAAA,EAAA,OAAA,WAAA,GAAA,kBAAA,EAAA,MAAA,SAAA,MAAA,WAAA,MAAA,UAAA,UAAA,GAAA,MAAA,uBAAA;;;AAAa,wBAAA,YAAA,uBAAA;;;;;",
|
|
6
|
+
"names": []
|
|
7
7
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { CommandClasses, type EndpointId, type GetValueDB, type MaybeNotKnown, type MessageOrCCLogEntry, type SupervisionResult, type WithAddress } from "@zwave-js/core
|
|
3
|
-
import { Bytes } from "@zwave-js/shared
|
|
1
|
+
import type { CCEncodingContext, CCParsingContext } from "@zwave-js/cc";
|
|
2
|
+
import { CommandClasses, type EndpointId, type GetValueDB, type MaybeNotKnown, type MessageOrCCLogEntry, type SupervisionResult, type WithAddress } from "@zwave-js/core";
|
|
3
|
+
import { Bytes } from "@zwave-js/shared";
|
|
4
4
|
import { POLL_VALUE, PhysicalCCAPI, type PollValueImplementation } from "../lib/API.js";
|
|
5
5
|
import { type CCRaw, CommandClass, type InterviewContext, type PersistValuesContext, type RefreshValuesContext } from "../lib/CommandClass.js";
|
|
6
6
|
import { BinarySensorCommand, BinarySensorType } from "../lib/_Types.js";
|
|
@@ -15,7 +15,7 @@ export declare const BinarySensorCCValues: Readonly<{
|
|
|
15
15
|
readonly endpoint: number;
|
|
16
16
|
readonly property: "supportedSensorTypes";
|
|
17
17
|
};
|
|
18
|
-
is: (valueId: import("@zwave-js/core
|
|
18
|
+
is: (valueId: import("@zwave-js/core").ValueID) => boolean;
|
|
19
19
|
readonly meta: Readonly<{
|
|
20
20
|
readonly type: "any";
|
|
21
21
|
readonly readable: true;
|
|
@@ -50,7 +50,7 @@ export declare const BinarySensorCCValues: Readonly<{
|
|
|
50
50
|
readonly readable: true;
|
|
51
51
|
};
|
|
52
52
|
}) & {
|
|
53
|
-
is: (valueId: import("@zwave-js/core
|
|
53
|
+
is: (valueId: import("@zwave-js/core").ValueID) => boolean;
|
|
54
54
|
options: {
|
|
55
55
|
readonly internal: false;
|
|
56
56
|
readonly minVersion: 1;
|
|
@@ -39,9 +39,8 @@ __export(BinarySensorCC_exports, {
|
|
|
39
39
|
});
|
|
40
40
|
module.exports = __toCommonJS(BinarySensorCC_exports);
|
|
41
41
|
var __validateArgs = __toESM(require("./BinarySensorCC._validateArgs.js"), 1);
|
|
42
|
-
var
|
|
43
|
-
var
|
|
44
|
-
var import_safe3 = require("@zwave-js/shared/safe");
|
|
42
|
+
var import_core = require("@zwave-js/core");
|
|
43
|
+
var import_shared = require("@zwave-js/shared");
|
|
45
44
|
var import_API = require("../lib/API.js");
|
|
46
45
|
var import_CommandClass = require("../lib/CommandClass.js");
|
|
47
46
|
var import_CommandClassDecorators = require("../lib/CommandClassDecorators.js");
|
|
@@ -90,7 +89,7 @@ var __esDecorate = function(ctor, descriptorIn, decorators, contextIn, initializ
|
|
|
90
89
|
};
|
|
91
90
|
const { validateArgs_BinarySensorCCAPI_get, validateArgs_BinarySensorCCAPI_sendReport, validateArgs_BinarySensorCCAPI_reportSupportedSensorTypes } = __validateArgs;
|
|
92
91
|
let BinarySensorCCAPI = (() => {
|
|
93
|
-
let _classDecorators = [(0, import_CommandClassDecorators.API)(
|
|
92
|
+
let _classDecorators = [(0, import_CommandClassDecorators.API)(import_core.CommandClasses["Binary Sensor"])];
|
|
94
93
|
let _classDescriptor;
|
|
95
94
|
let _classExtraInitializers = [];
|
|
96
95
|
let _classThis;
|
|
@@ -191,7 +190,7 @@ let BinarySensorCCAPI = (() => {
|
|
|
191
190
|
return BinarySensorCCAPI2 = _classThis;
|
|
192
191
|
})();
|
|
193
192
|
let BinarySensorCC = (() => {
|
|
194
|
-
let _classDecorators = [(0, import_CommandClassDecorators.commandClass)(
|
|
193
|
+
let _classDecorators = [(0, import_CommandClassDecorators.commandClass)(import_core.CommandClasses["Binary Sensor"]), (0, import_CommandClassDecorators.implementedVersion)(2), (0, import_CommandClassDecorators.ccValues)(import_CCValues_generated.BinarySensorCCValues)];
|
|
195
194
|
let _classDescriptor;
|
|
196
195
|
let _classExtraInitializers = [];
|
|
197
196
|
let _classThis;
|
|
@@ -213,8 +212,8 @@ let BinarySensorCC = (() => {
|
|
|
213
212
|
async interview(ctx) {
|
|
214
213
|
const node = this.getNode(ctx);
|
|
215
214
|
const endpoint = this.getEndpoint(ctx);
|
|
216
|
-
const api = import_API.CCAPI.create(
|
|
217
|
-
priority:
|
|
215
|
+
const api = import_API.CCAPI.create(import_core.CommandClasses["Binary Sensor"], ctx, endpoint).withOptions({
|
|
216
|
+
priority: import_core.MessagePriority.NodeQuery
|
|
218
217
|
});
|
|
219
218
|
ctx.logNode(node.id, {
|
|
220
219
|
endpoint: this.endpointIndex,
|
|
@@ -229,7 +228,7 @@ let BinarySensorCC = (() => {
|
|
|
229
228
|
});
|
|
230
229
|
const supportedSensorTypes = await api.getSupportedSensorTypes();
|
|
231
230
|
if (supportedSensorTypes) {
|
|
232
|
-
const logMessage = `received supported sensor types: ${supportedSensorTypes.map((type) => (0,
|
|
231
|
+
const logMessage = `received supported sensor types: ${supportedSensorTypes.map((type) => (0, import_shared.getEnumMemberName)(import_Types.BinarySensorType, type)).map((name) => `
|
|
233
232
|
\xB7 ${name}`).join("")}`;
|
|
234
233
|
ctx.logNode(node.id, {
|
|
235
234
|
endpoint: this.endpointIndex,
|
|
@@ -251,8 +250,8 @@ let BinarySensorCC = (() => {
|
|
|
251
250
|
async refreshValues(ctx) {
|
|
252
251
|
const node = this.getNode(ctx);
|
|
253
252
|
const endpoint = this.getEndpoint(ctx);
|
|
254
|
-
const api = import_API.CCAPI.create(
|
|
255
|
-
priority:
|
|
253
|
+
const api = import_API.CCAPI.create(import_core.CommandClasses["Binary Sensor"], ctx, endpoint).withOptions({
|
|
254
|
+
priority: import_core.MessagePriority.NodeQuery
|
|
256
255
|
});
|
|
257
256
|
if (api.version === 1) {
|
|
258
257
|
ctx.logNode(node.id, {
|
|
@@ -271,9 +270,9 @@ let BinarySensorCC = (() => {
|
|
|
271
270
|
} else {
|
|
272
271
|
const supportedSensorTypes = this.getValue(ctx, import_CCValues_generated.BinarySensorCCValues.supportedSensorTypes) ?? [];
|
|
273
272
|
for (const type of supportedSensorTypes) {
|
|
274
|
-
if (!(0,
|
|
273
|
+
if (!(0, import_shared.isEnumMember)(import_Types.BinarySensorType, type))
|
|
275
274
|
continue;
|
|
276
|
-
const sensorName = (0,
|
|
275
|
+
const sensorName = (0, import_shared.getEnumMemberName)(import_Types.BinarySensorType, type);
|
|
277
276
|
ctx.logNode(node.id, {
|
|
278
277
|
endpoint: this.endpointIndex,
|
|
279
278
|
message: `querying current value for ${sensorName}...`,
|
|
@@ -330,7 +329,7 @@ let BinarySensorCCReport = (() => {
|
|
|
330
329
|
this.value = options.value;
|
|
331
330
|
}
|
|
332
331
|
static from(raw, ctx) {
|
|
333
|
-
(0,
|
|
332
|
+
(0, import_core.validatePayload)(raw.payload.length >= 1);
|
|
334
333
|
const value = raw.payload[0] === 255;
|
|
335
334
|
let type = import_Types.BinarySensorType.Any;
|
|
336
335
|
if (raw.payload.length >= 2) {
|
|
@@ -360,14 +359,14 @@ let BinarySensorCCReport = (() => {
|
|
|
360
359
|
type;
|
|
361
360
|
value;
|
|
362
361
|
serialize(ctx) {
|
|
363
|
-
this.payload =
|
|
362
|
+
this.payload = import_shared.Bytes.from([this.value ? 255 : 0, this.type]);
|
|
364
363
|
return super.serialize(ctx);
|
|
365
364
|
}
|
|
366
365
|
toLogEntry(ctx) {
|
|
367
366
|
return {
|
|
368
367
|
...super.toLogEntry(ctx),
|
|
369
368
|
message: {
|
|
370
|
-
type: (0,
|
|
369
|
+
type: (0, import_shared.getEnumMemberName)(import_Types.BinarySensorType, this.type),
|
|
371
370
|
value: this.value
|
|
372
371
|
}
|
|
373
372
|
};
|
|
@@ -415,14 +414,14 @@ let BinarySensorCCGet = (() => {
|
|
|
415
414
|
}
|
|
416
415
|
sensorType;
|
|
417
416
|
serialize(ctx) {
|
|
418
|
-
this.payload =
|
|
417
|
+
this.payload = import_shared.Bytes.from([this.sensorType ?? import_Types.BinarySensorType.Any]);
|
|
419
418
|
return super.serialize(ctx);
|
|
420
419
|
}
|
|
421
420
|
toLogEntry(ctx) {
|
|
422
421
|
return {
|
|
423
422
|
...super.toLogEntry(ctx),
|
|
424
423
|
message: {
|
|
425
|
-
type: (0,
|
|
424
|
+
type: (0, import_shared.getEnumMemberName)(import_Types.BinarySensorType, this.sensorType ?? import_Types.BinarySensorType.Any)
|
|
426
425
|
}
|
|
427
426
|
};
|
|
428
427
|
}
|
|
@@ -454,8 +453,8 @@ let BinarySensorCCSupportedReport = (() => {
|
|
|
454
453
|
this.supportedSensorTypes = options.supportedSensorTypes;
|
|
455
454
|
}
|
|
456
455
|
static from(raw, ctx) {
|
|
457
|
-
(0,
|
|
458
|
-
const supportedSensorTypes = (0,
|
|
456
|
+
(0, import_core.validatePayload)(raw.payload.length >= 1);
|
|
457
|
+
const supportedSensorTypes = (0, import_core.parseBitMask)(raw.payload, 0).filter((t) => t !== 0);
|
|
459
458
|
return new this({
|
|
460
459
|
nodeId: ctx.sourceNodeId,
|
|
461
460
|
supportedSensorTypes
|
|
@@ -463,14 +462,14 @@ let BinarySensorCCSupportedReport = (() => {
|
|
|
463
462
|
}
|
|
464
463
|
supportedSensorTypes;
|
|
465
464
|
serialize(ctx) {
|
|
466
|
-
this.payload = (0,
|
|
465
|
+
this.payload = (0, import_core.encodeBitMask)(this.supportedSensorTypes.filter((t) => t !== import_Types.BinarySensorType.Any), void 0, 0);
|
|
467
466
|
return super.serialize(ctx);
|
|
468
467
|
}
|
|
469
468
|
toLogEntry(ctx) {
|
|
470
469
|
return {
|
|
471
470
|
...super.toLogEntry(ctx),
|
|
472
471
|
message: {
|
|
473
|
-
"supported types": this.supportedSensorTypes.map((type) => (0,
|
|
472
|
+
"supported types": this.supportedSensorTypes.map((type) => (0, import_shared.getEnumMemberName)(import_Types.BinarySensorType, type)).join(", ")
|
|
474
473
|
}
|
|
475
474
|
};
|
|
476
475
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/cc/BinarySensorCC.ts"],
|
|
4
|
-
"sourcesContent": ["import { type CCEncodingContext, type CCParsingContext } from \"@zwave-js/cc\";\nimport {\n\tCommandClasses,\n\ttype EndpointId,\n\ttype GetValueDB,\n\ttype MaybeNotKnown,\n\ttype MessageOrCCLogEntry,\n\tMessagePriority,\n\ttype SupervisionResult,\n\tValueMetadata,\n\ttype WithAddress,\n\tencodeBitMask,\n\tparseBitMask,\n\tvalidatePayload,\n} from \"@zwave-js/core/safe\";\nimport { Bytes } from \"@zwave-js/shared/safe\";\nimport { getEnumMemberName, isEnumMember } from \"@zwave-js/shared/safe\";\nimport { validateArgs } from \"@zwave-js/transformers\";\nimport {\n\tCCAPI,\n\tPOLL_VALUE,\n\tPhysicalCCAPI,\n\ttype PollValueImplementation,\n\tthrowUnsupportedProperty,\n} from \"../lib/API.js\";\nimport {\n\ttype CCRaw,\n\tCommandClass,\n\ttype InterviewContext,\n\ttype PersistValuesContext,\n\ttype RefreshValuesContext,\n} from \"../lib/CommandClass.js\";\nimport {\n\tAPI,\n\tCCCommand,\n\tccValueProperty,\n\tccValues,\n\tcommandClass,\n\texpectedCCResponse,\n\timplementedVersion,\n} from \"../lib/CommandClassDecorators.js\";\nimport { V } from \"../lib/Values.js\";\nimport { BinarySensorCommand, BinarySensorType } from \"../lib/_Types.js\";\n\nexport const BinarySensorCCValues = V.defineCCValues(\n\tCommandClasses[\"Binary Sensor\"],\n\t{\n\t\t...V.staticProperty(\"supportedSensorTypes\", undefined, {\n\t\t\tinternal: true,\n\t\t}),\n\n\t\t...V.dynamicPropertyWithName(\n\t\t\t\"state\",\n\t\t\t/* property */ (sensorType: BinarySensorType) =>\n\t\t\t\tgetEnumMemberName(BinarySensorType, sensorType),\n\t\t\t({ property }) =>\n\t\t\t\ttypeof property === \"string\" && property in BinarySensorType,\n\t\t\t/* meta */ (sensorType: BinarySensorType) => ({\n\t\t\t\t...ValueMetadata.ReadOnlyBoolean,\n\t\t\t\tlabel: `Sensor state (${\n\t\t\t\t\tgetEnumMemberName(\n\t\t\t\t\t\tBinarySensorType,\n\t\t\t\t\t\tsensorType,\n\t\t\t\t\t)\n\t\t\t\t})`,\n\t\t\t\tccSpecific: { sensorType },\n\t\t\t} as const),\n\t\t),\n\t},\n);\n\n// @noSetValueAPI This CC is read-only\n\n@API(CommandClasses[\"Binary Sensor\"])\nexport class BinarySensorCCAPI extends PhysicalCCAPI {\n\tpublic supportsCommand(cmd: BinarySensorCommand): MaybeNotKnown<boolean> {\n\t\tswitch (cmd) {\n\t\t\tcase BinarySensorCommand.Get:\n\t\t\tcase BinarySensorCommand.Report:\n\t\t\t\treturn true; // This is mandatory\n\t\t\tcase BinarySensorCommand.SupportedGet:\n\t\t\tcase BinarySensorCommand.SupportedReport:\n\t\t\t\treturn this.version >= 2;\n\t\t}\n\t\treturn super.supportsCommand(cmd);\n\t}\n\n\tprotected get [POLL_VALUE](): PollValueImplementation {\n\t\treturn async function(this: BinarySensorCCAPI, { property }) {\n\t\t\tif (typeof property === \"string\") {\n\t\t\t\tconst sensorType = (BinarySensorType as any)[property] as\n\t\t\t\t\t| BinarySensorType\n\t\t\t\t\t| undefined;\n\t\t\t\tif (sensorType) return this.get(sensorType);\n\t\t\t}\n\t\t\tthrowUnsupportedProperty(this.ccId, property);\n\t\t};\n\t}\n\n\t/**\n\t * Retrieves the current value from this sensor\n\t * @param sensorType The (optional) sensor type to retrieve the value for\n\t */\n\t@validateArgs({ strictEnums: true })\n\tpublic async get(\n\t\tsensorType?: BinarySensorType,\n\t): Promise<MaybeNotKnown<boolean>> {\n\t\tthis.assertSupportsCommand(\n\t\t\tBinarySensorCommand,\n\t\t\tBinarySensorCommand.Get,\n\t\t);\n\n\t\tconst cc = new BinarySensorCCGet({\n\t\t\tnodeId: this.endpoint.nodeId,\n\t\t\tendpointIndex: this.endpoint.index,\n\t\t\tsensorType,\n\t\t});\n\t\tconst response = await this.host.sendCommand<BinarySensorCCReport>(\n\t\t\tcc,\n\t\t\tthis.commandOptions,\n\t\t);\n\t\t// We don't want to repeat the sensor type\n\t\treturn response?.value;\n\t}\n\n\t@validateArgs()\n\tpublic async sendReport(\n\t\tvalue: boolean,\n\t\tsensorType?: BinarySensorType,\n\t): Promise<SupervisionResult | undefined> {\n\t\tthis.assertSupportsCommand(\n\t\t\tBinarySensorCommand,\n\t\t\tBinarySensorCommand.Report,\n\t\t);\n\n\t\tconst cc = new BinarySensorCCReport({\n\t\t\tnodeId: this.endpoint.nodeId,\n\t\t\tendpointIndex: this.endpoint.index,\n\t\t\tvalue,\n\t\t\ttype: sensorType,\n\t\t});\n\t\treturn this.host.sendCommand(cc, this.commandOptions);\n\t}\n\n\tpublic async getSupportedSensorTypes(): Promise<\n\t\treadonly BinarySensorType[] | undefined\n\t> {\n\t\tthis.assertSupportsCommand(\n\t\t\tBinarySensorCommand,\n\t\t\tBinarySensorCommand.SupportedGet,\n\t\t);\n\n\t\tconst cc = new BinarySensorCCSupportedGet({\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\tBinarySensorCCSupportedReport\n\t\t>(\n\t\t\tcc,\n\t\t\tthis.commandOptions,\n\t\t);\n\t\t// We don't want to repeat the sensor type\n\t\treturn response?.supportedSensorTypes;\n\t}\n\n\t@validateArgs()\n\tpublic async reportSupportedSensorTypes(\n\t\tsupported: BinarySensorType[],\n\t): Promise<SupervisionResult | undefined> {\n\t\tthis.assertSupportsCommand(\n\t\t\tBinarySensorCommand,\n\t\t\tBinarySensorCommand.SupportedReport,\n\t\t);\n\n\t\tconst cc = new BinarySensorCCSupportedReport({\n\t\t\tnodeId: this.endpoint.nodeId,\n\t\t\tendpointIndex: this.endpoint.index,\n\t\t\tsupportedSensorTypes: supported,\n\t\t});\n\t\treturn this.host.sendCommand(cc, this.commandOptions);\n\t}\n}\n\n@commandClass(CommandClasses[\"Binary Sensor\"])\n@implementedVersion(2)\n@ccValues(BinarySensorCCValues)\nexport class BinarySensorCC extends CommandClass {\n\tdeclare ccCommand: BinarySensorCommand;\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[\"Binary Sensor\"],\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// Find out which sensor types this sensor supports\n\t\tif (api.version >= 2) {\n\t\t\tctx.logNode(node.id, {\n\t\t\t\tendpoint: this.endpointIndex,\n\t\t\t\tmessage: \"querying supported sensor types...\",\n\t\t\t\tdirection: \"outbound\",\n\t\t\t});\n\t\t\tconst supportedSensorTypes = await api.getSupportedSensorTypes();\n\t\t\tif (supportedSensorTypes) {\n\t\t\t\tconst logMessage = `received supported sensor types: ${\n\t\t\t\t\tsupportedSensorTypes\n\t\t\t\t\t\t.map((type) =>\n\t\t\t\t\t\t\tgetEnumMemberName(BinarySensorType, type)\n\t\t\t\t\t\t)\n\t\t\t\t\t\t.map((name) => `\\n\u00B7 ${name}`)\n\t\t\t\t\t\t.join(\"\")\n\t\t\t\t}`;\n\t\t\t\tctx.logNode(node.id, {\n\t\t\t\t\tendpoint: this.endpointIndex,\n\t\t\t\t\tmessage: logMessage,\n\t\t\t\t\tdirection: \"inbound\",\n\t\t\t\t});\n\t\t\t} else {\n\t\t\t\tctx.logNode(node.id, {\n\t\t\t\t\tendpoint: this.endpointIndex,\n\t\t\t\t\tmessage:\n\t\t\t\t\t\t\"Querying supported sensor types timed out, skipping interview...\",\n\t\t\t\t\tlevel: \"warn\",\n\t\t\t\t});\n\t\t\t\treturn;\n\t\t\t}\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 Sensor\"],\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 (all of) the sensor's current value(s)\n\t\tif (api.version === 1) {\n\t\t\tctx.logNode(node.id, {\n\t\t\t\tendpoint: this.endpointIndex,\n\t\t\t\tmessage: \"querying current value...\",\n\t\t\t\tdirection: \"outbound\",\n\t\t\t});\n\t\t\tconst currentValue = await api.get();\n\t\t\tif (currentValue != undefined) {\n\t\t\t\tctx.logNode(node.id, {\n\t\t\t\t\tendpoint: this.endpointIndex,\n\t\t\t\t\tmessage: `received current value: ${currentValue}`,\n\t\t\t\t\tdirection: \"inbound\",\n\t\t\t\t});\n\t\t\t}\n\t\t} else {\n\t\t\tconst supportedSensorTypes: readonly BinarySensorType[] =\n\t\t\t\tthis.getValue(\n\t\t\t\t\tctx,\n\t\t\t\t\tBinarySensorCCValues.supportedSensorTypes,\n\t\t\t\t) ?? [];\n\n\t\t\tfor (const type of supportedSensorTypes) {\n\t\t\t\t// Some devices report invalid sensor types, but the CC API checks\n\t\t\t\t// for valid values and throws otherwise.\n\t\t\t\tif (!isEnumMember(BinarySensorType, type)) continue;\n\n\t\t\t\tconst sensorName = getEnumMemberName(BinarySensorType, type);\n\t\t\t\tctx.logNode(node.id, {\n\t\t\t\t\tendpoint: this.endpointIndex,\n\t\t\t\t\tmessage: `querying current value for ${sensorName}...`,\n\t\t\t\t\tdirection: \"outbound\",\n\t\t\t\t});\n\t\t\t\tconst currentValue = await api.get(type);\n\t\t\t\tif (currentValue != undefined) {\n\t\t\t\t\tctx.logNode(node.id, {\n\t\t\t\t\t\tendpoint: this.endpointIndex,\n\t\t\t\t\t\tmessage:\n\t\t\t\t\t\t\t`received current value for ${sensorName}: ${currentValue}`,\n\t\t\t\t\t\tdirection: \"inbound\",\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Returns which sensor types are supported.\n\t * This only works AFTER the interview process\n\t */\n\tpublic static getSupportedSensorTypesCached(\n\t\tctx: GetValueDB,\n\t\tendpoint: EndpointId,\n\t): MaybeNotKnown<BinarySensorType[]> {\n\t\treturn ctx\n\t\t\t.getValueDB(endpoint.nodeId)\n\t\t\t.getValue(\n\t\t\t\tBinarySensorCCValues.supportedSensorTypes.endpoint(\n\t\t\t\t\tendpoint.index,\n\t\t\t\t),\n\t\t\t);\n\t}\n\n\tpublic setMappedBasicValue(\n\t\tctx: GetValueDB,\n\t\tvalue: number,\n\t): boolean {\n\t\tthis.setValue(\n\t\t\tctx,\n\t\t\tBinarySensorCCValues.state(BinarySensorType.Any),\n\t\t\tvalue > 0,\n\t\t);\n\t\treturn true;\n\t}\n}\n\n// @publicAPI\nexport interface BinarySensorCCReportOptions {\n\ttype?: BinarySensorType;\n\tvalue: boolean;\n}\n\n@CCCommand(BinarySensorCommand.Report)\nexport class BinarySensorCCReport extends BinarySensorCC {\n\tpublic constructor(\n\t\toptions: WithAddress<BinarySensorCCReportOptions>,\n\t) {\n\t\tsuper(options);\n\n\t\tthis.type = options.type ?? BinarySensorType.Any;\n\t\tthis.value = options.value;\n\t}\n\n\tpublic static from(\n\t\traw: CCRaw,\n\t\tctx: CCParsingContext,\n\t): BinarySensorCCReport {\n\t\tvalidatePayload(raw.payload.length >= 1);\n\t\tconst value = raw.payload[0] === 0xff;\n\t\tlet type: BinarySensorType = BinarySensorType.Any;\n\n\t\tif (raw.payload.length >= 2) {\n\t\t\ttype = raw.payload[1];\n\t\t}\n\n\t\treturn new this({\n\t\t\tnodeId: ctx.sourceNodeId,\n\t\t\tvalue,\n\t\t\ttype,\n\t\t});\n\t}\n\n\tpublic persistValues(ctx: PersistValuesContext): boolean {\n\t\tif (!super.persistValues(ctx)) return false;\n\n\t\t// Workaround for devices reporting with sensor type Any -> find first supported sensor type and use that\n\t\tlet sensorType = this.type;\n\t\tif (sensorType === BinarySensorType.Any) {\n\t\t\tconst supportedSensorTypes = this.getValue<BinarySensorType[]>(\n\t\t\t\tctx,\n\t\t\t\tBinarySensorCCValues.supportedSensorTypes,\n\t\t\t);\n\t\t\tif (supportedSensorTypes?.length) {\n\t\t\t\tsensorType = supportedSensorTypes[0];\n\t\t\t}\n\t\t}\n\n\t\tconst binarySensorValue = BinarySensorCCValues.state(sensorType);\n\t\tthis.setMetadata(ctx, binarySensorValue, binarySensorValue.meta);\n\t\tthis.setValue(ctx, binarySensorValue, this.value);\n\n\t\treturn true;\n\t}\n\n\tpublic type: BinarySensorType;\n\tpublic value: boolean;\n\n\tpublic serialize(ctx: CCEncodingContext): Promise<Bytes> {\n\t\tthis.payload = Bytes.from([this.value ? 0xff : 0x00, this.type]);\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\ttype: getEnumMemberName(BinarySensorType, this.type),\n\t\t\t\tvalue: this.value,\n\t\t\t},\n\t\t};\n\t}\n}\n\nfunction testResponseForBinarySensorGet(\n\tsent: BinarySensorCCGet,\n\treceived: BinarySensorCCReport,\n) {\n\t// We expect a Binary Sensor Report that matches the requested sensor type (if a type was requested)\n\treturn (\n\t\tsent.sensorType == undefined\n\t\t|| sent.sensorType === BinarySensorType.Any\n\t\t|| received.type === sent.sensorType\n\t\t// This is technically not correct, but some devices do this anyways\n\t\t|| received.type === BinarySensorType.Any\n\t);\n}\n\n// @publicAPI\nexport interface BinarySensorCCGetOptions {\n\tsensorType?: BinarySensorType;\n}\n\n@CCCommand(BinarySensorCommand.Get)\n@expectedCCResponse(BinarySensorCCReport, testResponseForBinarySensorGet)\nexport class BinarySensorCCGet extends BinarySensorCC {\n\tpublic constructor(\n\t\toptions: WithAddress<BinarySensorCCGetOptions>,\n\t) {\n\t\tsuper(options);\n\t\tthis.sensorType = options.sensorType;\n\t}\n\n\tpublic static from(raw: CCRaw, ctx: CCParsingContext): BinarySensorCCGet {\n\t\tlet sensorType: BinarySensorType | undefined;\n\n\t\tif (raw.payload.length >= 1) {\n\t\t\tsensorType = raw.payload[0];\n\t\t}\n\n\t\treturn new this({\n\t\t\tnodeId: ctx.sourceNodeId,\n\t\t\tsensorType,\n\t\t});\n\t}\n\n\tpublic sensorType: BinarySensorType | undefined;\n\n\tpublic serialize(ctx: CCEncodingContext): Promise<Bytes> {\n\t\tthis.payload = Bytes.from([this.sensorType ?? BinarySensorType.Any]);\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\ttype: getEnumMemberName(\n\t\t\t\t\tBinarySensorType,\n\t\t\t\t\tthis.sensorType ?? BinarySensorType.Any,\n\t\t\t\t),\n\t\t\t},\n\t\t};\n\t}\n}\n\n// @publicAPI\nexport interface BinarySensorCCSupportedReportOptions {\n\tsupportedSensorTypes: BinarySensorType[];\n}\n\n@CCCommand(BinarySensorCommand.SupportedReport)\n@ccValueProperty(\n\t\"supportedSensorTypes\",\n\tBinarySensorCCValues.supportedSensorTypes,\n)\nexport class BinarySensorCCSupportedReport extends BinarySensorCC {\n\tpublic constructor(\n\t\toptions: WithAddress<BinarySensorCCSupportedReportOptions>,\n\t) {\n\t\tsuper(options);\n\n\t\tthis.supportedSensorTypes = options.supportedSensorTypes;\n\t}\n\n\tpublic static from(\n\t\traw: CCRaw,\n\t\tctx: CCParsingContext,\n\t): BinarySensorCCSupportedReport {\n\t\tvalidatePayload(raw.payload.length >= 1);\n\t\t// The enumeration starts at 1, but the first (reserved) bit is included\n\t\t// in the report\n\t\tconst supportedSensorTypes: BinarySensorType[] = parseBitMask(\n\t\t\traw.payload,\n\t\t\t0,\n\t\t)\n\t\t\t.filter(\n\t\t\t\t(t) => t !== 0,\n\t\t\t);\n\n\t\treturn new this({\n\t\t\tnodeId: ctx.sourceNodeId,\n\t\t\tsupportedSensorTypes,\n\t\t});\n\t}\n\n\tpublic supportedSensorTypes: BinarySensorType[];\n\n\tpublic serialize(ctx: CCEncodingContext): Promise<Bytes> {\n\t\tthis.payload = encodeBitMask(\n\t\t\tthis.supportedSensorTypes.filter((t) => t !== BinarySensorType.Any),\n\t\t\tundefined,\n\t\t\t0,\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\"supported types\": this.supportedSensorTypes\n\t\t\t\t\t.map((type) => getEnumMemberName(BinarySensorType, type))\n\t\t\t\t\t.join(\", \"),\n\t\t\t},\n\t\t};\n\t}\n}\n\n@CCCommand(BinarySensorCommand.SupportedGet)\n@expectedCCResponse(BinarySensorCCSupportedReport)\nexport class BinarySensorCCSupportedGet extends BinarySensorCC {}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,kBAaO;AACP,
|
|
6
|
-
"names": [
|
|
4
|
+
"sourcesContent": ["import type { CCEncodingContext, CCParsingContext } from \"@zwave-js/cc\";\nimport {\n\tCommandClasses,\n\ttype EndpointId,\n\ttype GetValueDB,\n\ttype MaybeNotKnown,\n\ttype MessageOrCCLogEntry,\n\tMessagePriority,\n\ttype SupervisionResult,\n\tValueMetadata,\n\ttype WithAddress,\n\tencodeBitMask,\n\tparseBitMask,\n\tvalidatePayload,\n} from \"@zwave-js/core\";\nimport { Bytes, getEnumMemberName, isEnumMember } from \"@zwave-js/shared\";\nimport { validateArgs } from \"@zwave-js/transformers\";\nimport {\n\tCCAPI,\n\tPOLL_VALUE,\n\tPhysicalCCAPI,\n\ttype PollValueImplementation,\n\tthrowUnsupportedProperty,\n} from \"../lib/API.js\";\nimport {\n\ttype CCRaw,\n\tCommandClass,\n\ttype InterviewContext,\n\ttype PersistValuesContext,\n\ttype RefreshValuesContext,\n} from \"../lib/CommandClass.js\";\nimport {\n\tAPI,\n\tCCCommand,\n\tccValueProperty,\n\tccValues,\n\tcommandClass,\n\texpectedCCResponse,\n\timplementedVersion,\n} from \"../lib/CommandClassDecorators.js\";\nimport { V } from \"../lib/Values.js\";\nimport { BinarySensorCommand, BinarySensorType } from \"../lib/_Types.js\";\n\nexport const BinarySensorCCValues = V.defineCCValues(\n\tCommandClasses[\"Binary Sensor\"],\n\t{\n\t\t...V.staticProperty(\"supportedSensorTypes\", undefined, {\n\t\t\tinternal: true,\n\t\t}),\n\n\t\t...V.dynamicPropertyWithName(\n\t\t\t\"state\",\n\t\t\t/* property */ (sensorType: BinarySensorType) =>\n\t\t\t\tgetEnumMemberName(BinarySensorType, sensorType),\n\t\t\t({ property }) =>\n\t\t\t\ttypeof property === \"string\" && property in BinarySensorType,\n\t\t\t/* meta */ (sensorType: BinarySensorType) => ({\n\t\t\t\t...ValueMetadata.ReadOnlyBoolean,\n\t\t\t\tlabel: `Sensor state (${\n\t\t\t\t\tgetEnumMemberName(\n\t\t\t\t\t\tBinarySensorType,\n\t\t\t\t\t\tsensorType,\n\t\t\t\t\t)\n\t\t\t\t})`,\n\t\t\t\tccSpecific: { sensorType },\n\t\t\t} as const),\n\t\t),\n\t},\n);\n\n// @noSetValueAPI This CC is read-only\n\n@API(CommandClasses[\"Binary Sensor\"])\nexport class BinarySensorCCAPI extends PhysicalCCAPI {\n\tpublic supportsCommand(cmd: BinarySensorCommand): MaybeNotKnown<boolean> {\n\t\tswitch (cmd) {\n\t\t\tcase BinarySensorCommand.Get:\n\t\t\tcase BinarySensorCommand.Report:\n\t\t\t\treturn true; // This is mandatory\n\t\t\tcase BinarySensorCommand.SupportedGet:\n\t\t\tcase BinarySensorCommand.SupportedReport:\n\t\t\t\treturn this.version >= 2;\n\t\t}\n\t\treturn super.supportsCommand(cmd);\n\t}\n\n\tprotected get [POLL_VALUE](): PollValueImplementation {\n\t\treturn async function(this: BinarySensorCCAPI, { property }) {\n\t\t\tif (typeof property === \"string\") {\n\t\t\t\tconst sensorType = (BinarySensorType as any)[property] as\n\t\t\t\t\t| BinarySensorType\n\t\t\t\t\t| undefined;\n\t\t\t\tif (sensorType) return this.get(sensorType);\n\t\t\t}\n\t\t\tthrowUnsupportedProperty(this.ccId, property);\n\t\t};\n\t}\n\n\t/**\n\t * Retrieves the current value from this sensor\n\t * @param sensorType The (optional) sensor type to retrieve the value for\n\t */\n\t@validateArgs({ strictEnums: true })\n\tpublic async get(\n\t\tsensorType?: BinarySensorType,\n\t): Promise<MaybeNotKnown<boolean>> {\n\t\tthis.assertSupportsCommand(\n\t\t\tBinarySensorCommand,\n\t\t\tBinarySensorCommand.Get,\n\t\t);\n\n\t\tconst cc = new BinarySensorCCGet({\n\t\t\tnodeId: this.endpoint.nodeId,\n\t\t\tendpointIndex: this.endpoint.index,\n\t\t\tsensorType,\n\t\t});\n\t\tconst response = await this.host.sendCommand<BinarySensorCCReport>(\n\t\t\tcc,\n\t\t\tthis.commandOptions,\n\t\t);\n\t\t// We don't want to repeat the sensor type\n\t\treturn response?.value;\n\t}\n\n\t@validateArgs()\n\tpublic async sendReport(\n\t\tvalue: boolean,\n\t\tsensorType?: BinarySensorType,\n\t): Promise<SupervisionResult | undefined> {\n\t\tthis.assertSupportsCommand(\n\t\t\tBinarySensorCommand,\n\t\t\tBinarySensorCommand.Report,\n\t\t);\n\n\t\tconst cc = new BinarySensorCCReport({\n\t\t\tnodeId: this.endpoint.nodeId,\n\t\t\tendpointIndex: this.endpoint.index,\n\t\t\tvalue,\n\t\t\ttype: sensorType,\n\t\t});\n\t\treturn this.host.sendCommand(cc, this.commandOptions);\n\t}\n\n\tpublic async getSupportedSensorTypes(): Promise<\n\t\treadonly BinarySensorType[] | undefined\n\t> {\n\t\tthis.assertSupportsCommand(\n\t\t\tBinarySensorCommand,\n\t\t\tBinarySensorCommand.SupportedGet,\n\t\t);\n\n\t\tconst cc = new BinarySensorCCSupportedGet({\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\tBinarySensorCCSupportedReport\n\t\t>(\n\t\t\tcc,\n\t\t\tthis.commandOptions,\n\t\t);\n\t\t// We don't want to repeat the sensor type\n\t\treturn response?.supportedSensorTypes;\n\t}\n\n\t@validateArgs()\n\tpublic async reportSupportedSensorTypes(\n\t\tsupported: BinarySensorType[],\n\t): Promise<SupervisionResult | undefined> {\n\t\tthis.assertSupportsCommand(\n\t\t\tBinarySensorCommand,\n\t\t\tBinarySensorCommand.SupportedReport,\n\t\t);\n\n\t\tconst cc = new BinarySensorCCSupportedReport({\n\t\t\tnodeId: this.endpoint.nodeId,\n\t\t\tendpointIndex: this.endpoint.index,\n\t\t\tsupportedSensorTypes: supported,\n\t\t});\n\t\treturn this.host.sendCommand(cc, this.commandOptions);\n\t}\n}\n\n@commandClass(CommandClasses[\"Binary Sensor\"])\n@implementedVersion(2)\n@ccValues(BinarySensorCCValues)\nexport class BinarySensorCC extends CommandClass {\n\tdeclare ccCommand: BinarySensorCommand;\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[\"Binary Sensor\"],\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// Find out which sensor types this sensor supports\n\t\tif (api.version >= 2) {\n\t\t\tctx.logNode(node.id, {\n\t\t\t\tendpoint: this.endpointIndex,\n\t\t\t\tmessage: \"querying supported sensor types...\",\n\t\t\t\tdirection: \"outbound\",\n\t\t\t});\n\t\t\tconst supportedSensorTypes = await api.getSupportedSensorTypes();\n\t\t\tif (supportedSensorTypes) {\n\t\t\t\tconst logMessage = `received supported sensor types: ${\n\t\t\t\t\tsupportedSensorTypes\n\t\t\t\t\t\t.map((type) =>\n\t\t\t\t\t\t\tgetEnumMemberName(BinarySensorType, type)\n\t\t\t\t\t\t)\n\t\t\t\t\t\t.map((name) => `\\n\u00B7 ${name}`)\n\t\t\t\t\t\t.join(\"\")\n\t\t\t\t}`;\n\t\t\t\tctx.logNode(node.id, {\n\t\t\t\t\tendpoint: this.endpointIndex,\n\t\t\t\t\tmessage: logMessage,\n\t\t\t\t\tdirection: \"inbound\",\n\t\t\t\t});\n\t\t\t} else {\n\t\t\t\tctx.logNode(node.id, {\n\t\t\t\t\tendpoint: this.endpointIndex,\n\t\t\t\t\tmessage:\n\t\t\t\t\t\t\"Querying supported sensor types timed out, skipping interview...\",\n\t\t\t\t\tlevel: \"warn\",\n\t\t\t\t});\n\t\t\t\treturn;\n\t\t\t}\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 Sensor\"],\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 (all of) the sensor's current value(s)\n\t\tif (api.version === 1) {\n\t\t\tctx.logNode(node.id, {\n\t\t\t\tendpoint: this.endpointIndex,\n\t\t\t\tmessage: \"querying current value...\",\n\t\t\t\tdirection: \"outbound\",\n\t\t\t});\n\t\t\tconst currentValue = await api.get();\n\t\t\tif (currentValue != undefined) {\n\t\t\t\tctx.logNode(node.id, {\n\t\t\t\t\tendpoint: this.endpointIndex,\n\t\t\t\t\tmessage: `received current value: ${currentValue}`,\n\t\t\t\t\tdirection: \"inbound\",\n\t\t\t\t});\n\t\t\t}\n\t\t} else {\n\t\t\tconst supportedSensorTypes: readonly BinarySensorType[] =\n\t\t\t\tthis.getValue(\n\t\t\t\t\tctx,\n\t\t\t\t\tBinarySensorCCValues.supportedSensorTypes,\n\t\t\t\t) ?? [];\n\n\t\t\tfor (const type of supportedSensorTypes) {\n\t\t\t\t// Some devices report invalid sensor types, but the CC API checks\n\t\t\t\t// for valid values and throws otherwise.\n\t\t\t\tif (!isEnumMember(BinarySensorType, type)) continue;\n\n\t\t\t\tconst sensorName = getEnumMemberName(BinarySensorType, type);\n\t\t\t\tctx.logNode(node.id, {\n\t\t\t\t\tendpoint: this.endpointIndex,\n\t\t\t\t\tmessage: `querying current value for ${sensorName}...`,\n\t\t\t\t\tdirection: \"outbound\",\n\t\t\t\t});\n\t\t\t\tconst currentValue = await api.get(type);\n\t\t\t\tif (currentValue != undefined) {\n\t\t\t\t\tctx.logNode(node.id, {\n\t\t\t\t\t\tendpoint: this.endpointIndex,\n\t\t\t\t\t\tmessage:\n\t\t\t\t\t\t\t`received current value for ${sensorName}: ${currentValue}`,\n\t\t\t\t\t\tdirection: \"inbound\",\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Returns which sensor types are supported.\n\t * This only works AFTER the interview process\n\t */\n\tpublic static getSupportedSensorTypesCached(\n\t\tctx: GetValueDB,\n\t\tendpoint: EndpointId,\n\t): MaybeNotKnown<BinarySensorType[]> {\n\t\treturn ctx\n\t\t\t.getValueDB(endpoint.nodeId)\n\t\t\t.getValue(\n\t\t\t\tBinarySensorCCValues.supportedSensorTypes.endpoint(\n\t\t\t\t\tendpoint.index,\n\t\t\t\t),\n\t\t\t);\n\t}\n\n\tpublic setMappedBasicValue(\n\t\tctx: GetValueDB,\n\t\tvalue: number,\n\t): boolean {\n\t\tthis.setValue(\n\t\t\tctx,\n\t\t\tBinarySensorCCValues.state(BinarySensorType.Any),\n\t\t\tvalue > 0,\n\t\t);\n\t\treturn true;\n\t}\n}\n\n// @publicAPI\nexport interface BinarySensorCCReportOptions {\n\ttype?: BinarySensorType;\n\tvalue: boolean;\n}\n\n@CCCommand(BinarySensorCommand.Report)\nexport class BinarySensorCCReport extends BinarySensorCC {\n\tpublic constructor(\n\t\toptions: WithAddress<BinarySensorCCReportOptions>,\n\t) {\n\t\tsuper(options);\n\n\t\tthis.type = options.type ?? BinarySensorType.Any;\n\t\tthis.value = options.value;\n\t}\n\n\tpublic static from(\n\t\traw: CCRaw,\n\t\tctx: CCParsingContext,\n\t): BinarySensorCCReport {\n\t\tvalidatePayload(raw.payload.length >= 1);\n\t\tconst value = raw.payload[0] === 0xff;\n\t\tlet type: BinarySensorType = BinarySensorType.Any;\n\n\t\tif (raw.payload.length >= 2) {\n\t\t\ttype = raw.payload[1];\n\t\t}\n\n\t\treturn new this({\n\t\t\tnodeId: ctx.sourceNodeId,\n\t\t\tvalue,\n\t\t\ttype,\n\t\t});\n\t}\n\n\tpublic persistValues(ctx: PersistValuesContext): boolean {\n\t\tif (!super.persistValues(ctx)) return false;\n\n\t\t// Workaround for devices reporting with sensor type Any -> find first supported sensor type and use that\n\t\tlet sensorType = this.type;\n\t\tif (sensorType === BinarySensorType.Any) {\n\t\t\tconst supportedSensorTypes = this.getValue<BinarySensorType[]>(\n\t\t\t\tctx,\n\t\t\t\tBinarySensorCCValues.supportedSensorTypes,\n\t\t\t);\n\t\t\tif (supportedSensorTypes?.length) {\n\t\t\t\tsensorType = supportedSensorTypes[0];\n\t\t\t}\n\t\t}\n\n\t\tconst binarySensorValue = BinarySensorCCValues.state(sensorType);\n\t\tthis.setMetadata(ctx, binarySensorValue, binarySensorValue.meta);\n\t\tthis.setValue(ctx, binarySensorValue, this.value);\n\n\t\treturn true;\n\t}\n\n\tpublic type: BinarySensorType;\n\tpublic value: boolean;\n\n\tpublic serialize(ctx: CCEncodingContext): Promise<Bytes> {\n\t\tthis.payload = Bytes.from([this.value ? 0xff : 0x00, this.type]);\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\ttype: getEnumMemberName(BinarySensorType, this.type),\n\t\t\t\tvalue: this.value,\n\t\t\t},\n\t\t};\n\t}\n}\n\nfunction testResponseForBinarySensorGet(\n\tsent: BinarySensorCCGet,\n\treceived: BinarySensorCCReport,\n) {\n\t// We expect a Binary Sensor Report that matches the requested sensor type (if a type was requested)\n\treturn (\n\t\tsent.sensorType == undefined\n\t\t|| sent.sensorType === BinarySensorType.Any\n\t\t|| received.type === sent.sensorType\n\t\t// This is technically not correct, but some devices do this anyways\n\t\t|| received.type === BinarySensorType.Any\n\t);\n}\n\n// @publicAPI\nexport interface BinarySensorCCGetOptions {\n\tsensorType?: BinarySensorType;\n}\n\n@CCCommand(BinarySensorCommand.Get)\n@expectedCCResponse(BinarySensorCCReport, testResponseForBinarySensorGet)\nexport class BinarySensorCCGet extends BinarySensorCC {\n\tpublic constructor(\n\t\toptions: WithAddress<BinarySensorCCGetOptions>,\n\t) {\n\t\tsuper(options);\n\t\tthis.sensorType = options.sensorType;\n\t}\n\n\tpublic static from(raw: CCRaw, ctx: CCParsingContext): BinarySensorCCGet {\n\t\tlet sensorType: BinarySensorType | undefined;\n\n\t\tif (raw.payload.length >= 1) {\n\t\t\tsensorType = raw.payload[0];\n\t\t}\n\n\t\treturn new this({\n\t\t\tnodeId: ctx.sourceNodeId,\n\t\t\tsensorType,\n\t\t});\n\t}\n\n\tpublic sensorType: BinarySensorType | undefined;\n\n\tpublic serialize(ctx: CCEncodingContext): Promise<Bytes> {\n\t\tthis.payload = Bytes.from([this.sensorType ?? BinarySensorType.Any]);\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\ttype: getEnumMemberName(\n\t\t\t\t\tBinarySensorType,\n\t\t\t\t\tthis.sensorType ?? BinarySensorType.Any,\n\t\t\t\t),\n\t\t\t},\n\t\t};\n\t}\n}\n\n// @publicAPI\nexport interface BinarySensorCCSupportedReportOptions {\n\tsupportedSensorTypes: BinarySensorType[];\n}\n\n@CCCommand(BinarySensorCommand.SupportedReport)\n@ccValueProperty(\n\t\"supportedSensorTypes\",\n\tBinarySensorCCValues.supportedSensorTypes,\n)\nexport class BinarySensorCCSupportedReport extends BinarySensorCC {\n\tpublic constructor(\n\t\toptions: WithAddress<BinarySensorCCSupportedReportOptions>,\n\t) {\n\t\tsuper(options);\n\n\t\tthis.supportedSensorTypes = options.supportedSensorTypes;\n\t}\n\n\tpublic static from(\n\t\traw: CCRaw,\n\t\tctx: CCParsingContext,\n\t): BinarySensorCCSupportedReport {\n\t\tvalidatePayload(raw.payload.length >= 1);\n\t\t// The enumeration starts at 1, but the first (reserved) bit is included\n\t\t// in the report\n\t\tconst supportedSensorTypes: BinarySensorType[] = parseBitMask(\n\t\t\traw.payload,\n\t\t\t0,\n\t\t)\n\t\t\t.filter(\n\t\t\t\t(t) => t !== 0,\n\t\t\t);\n\n\t\treturn new this({\n\t\t\tnodeId: ctx.sourceNodeId,\n\t\t\tsupportedSensorTypes,\n\t\t});\n\t}\n\n\tpublic supportedSensorTypes: BinarySensorType[];\n\n\tpublic serialize(ctx: CCEncodingContext): Promise<Bytes> {\n\t\tthis.payload = encodeBitMask(\n\t\t\tthis.supportedSensorTypes.filter((t) => t !== BinarySensorType.Any),\n\t\t\tundefined,\n\t\t\t0,\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\"supported types\": this.supportedSensorTypes\n\t\t\t\t\t.map((type) => getEnumMemberName(BinarySensorType, type))\n\t\t\t\t\t.join(\", \"),\n\t\t\t},\n\t\t};\n\t}\n}\n\n@CCCommand(BinarySensorCommand.SupportedGet)\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
|
34
34
|
module.exports = __toCommonJS(BinarySwitchCC_validateArgs_exports);
|
|
35
|
-
var
|
|
35
|
+
var import_core = require("@zwave-js/core");
|
|
36
36
|
var v = __toESM(require("@zwave-js/core/validation"), 1);
|
|
37
37
|
function validateArgs_BinarySwitchCCAPI_set() {
|
|
38
38
|
return (__decoratedMethod, { kind }) => {
|
|
39
39
|
if (kind === "method") {
|
|
40
40
|
return /* @__PURE__ */ __name(function set(targetValue, duration) {
|
|
41
|
-
v.assert(v.primitive({ kind: "parameter", name: "targetValue" }, "boolean")(targetValue), v.optional({ kind: "parameter", name: "duration" }, v.oneOf({ kind: "parameter", name: "duration" }, void 0, v.primitive({ kind: "parameter", name: "duration" }, "string"), v.class({ kind: "parameter", name: "duration" }, "Duration",
|
|
41
|
+
v.assert(v.primitive({ kind: "parameter", name: "targetValue" }, "boolean")(targetValue), v.optional({ kind: "parameter", name: "duration" }, v.oneOf({ kind: "parameter", name: "duration" }, void 0, v.primitive({ kind: "parameter", name: "duration" }, "string"), v.class({ kind: "parameter", name: "duration" }, "Duration", import_core.Duration)))(duration));
|
|
42
42
|
return __decoratedMethod.call(this, targetValue, duration);
|
|
43
43
|
}, "set");
|
|
44
44
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { CommandClasses, Duration, type GetValueDB, type MaybeNotKnown, type MaybeUnknown, type MessageOrCCLogEntry, type SupervisionResult, type WithAddress } from "@zwave-js/core
|
|
3
|
-
import { Bytes } from "@zwave-js/shared
|
|
1
|
+
import type { CCEncodingContext, CCParsingContext } from "@zwave-js/cc";
|
|
2
|
+
import { CommandClasses, Duration, type GetValueDB, type MaybeNotKnown, type MaybeUnknown, type MessageOrCCLogEntry, type SupervisionResult, type WithAddress } from "@zwave-js/core";
|
|
3
|
+
import { Bytes } from "@zwave-js/shared";
|
|
4
4
|
import { CCAPI, POLL_VALUE, type PollValueImplementation, SET_VALUE, SET_VALUE_HOOKS, type SetValueImplementation, type SetValueImplementationHooksFactory } from "../lib/API.js";
|
|
5
5
|
import { type CCRaw, CommandClass, type InterviewContext, type RefreshValuesContext } from "../lib/CommandClass.js";
|
|
6
6
|
import { BinarySwitchCommand } from "../lib/_Types.js";
|
|
@@ -15,7 +15,7 @@ export declare const BinarySwitchCCValues: Readonly<{
|
|
|
15
15
|
readonly endpoint: number;
|
|
16
16
|
readonly property: "currentValue";
|
|
17
17
|
};
|
|
18
|
-
is: (valueId: import("@zwave-js/core
|
|
18
|
+
is: (valueId: import("@zwave-js/core").ValueID) => boolean;
|
|
19
19
|
readonly meta: {
|
|
20
20
|
readonly label: "Current value";
|
|
21
21
|
readonly writeable: false;
|
|
@@ -41,7 +41,7 @@ export declare const BinarySwitchCCValues: Readonly<{
|
|
|
41
41
|
readonly endpoint: number;
|
|
42
42
|
readonly property: "targetValue";
|
|
43
43
|
};
|
|
44
|
-
is: (valueId: import("@zwave-js/core
|
|
44
|
+
is: (valueId: import("@zwave-js/core").ValueID) => boolean;
|
|
45
45
|
readonly meta: {
|
|
46
46
|
readonly label: "Target value";
|
|
47
47
|
readonly valueChangeOptions: readonly ["transitionDuration"];
|
|
@@ -68,7 +68,7 @@ export declare const BinarySwitchCCValues: Readonly<{
|
|
|
68
68
|
readonly endpoint: number;
|
|
69
69
|
readonly property: "duration";
|
|
70
70
|
};
|
|
71
|
-
is: (valueId: import("@zwave-js/core
|
|
71
|
+
is: (valueId: import("@zwave-js/core").ValueID) => boolean;
|
|
72
72
|
readonly meta: {
|
|
73
73
|
readonly label: "Remaining duration";
|
|
74
74
|
readonly writeable: false;
|