@zwave-js/cc 15.27.1 → 15.29.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/cjs/cc/AlarmSensorCC.js.map +2 -2
- package/build/cjs/cc/AssociationCC.js +6 -5
- package/build/cjs/cc/AssociationCC.js.map +2 -2
- package/build/cjs/cc/AssociationGroupInfoCC.js +5 -5
- package/build/cjs/cc/AssociationGroupInfoCC.js.map +2 -2
- package/build/cjs/cc/BarrierOperatorCC.js.map +2 -2
- package/build/cjs/cc/BasicCC.d.ts +4 -1
- package/build/cjs/cc/BasicCC.js +18 -0
- package/build/cjs/cc/BasicCC.js.map +3 -3
- package/build/cjs/cc/BasicWindowCoveringCC.js.map +2 -2
- package/build/cjs/cc/BatteryCC.js +18 -4
- package/build/cjs/cc/BatteryCC.js.map +2 -2
- package/build/cjs/cc/BinarySensorCC.js +5 -1
- package/build/cjs/cc/BinarySensorCC.js.map +2 -2
- package/build/cjs/cc/BinarySwitchCC.d.ts +4 -1
- package/build/cjs/cc/BinarySwitchCC.js +18 -0
- package/build/cjs/cc/BinarySwitchCC.js.map +3 -3
- package/build/cjs/cc/CRC16CC.d.ts +3 -2
- package/build/cjs/cc/CRC16CC.js +7 -1
- package/build/cjs/cc/CRC16CC.js.map +3 -3
- package/build/cjs/cc/CentralSceneCC.js.map +2 -2
- package/build/cjs/cc/ClimateControlScheduleCC.js.map +2 -2
- package/build/cjs/cc/ClockCC.js.map +2 -2
- package/build/cjs/cc/ColorSwitchCC.js +1 -4
- package/build/cjs/cc/ColorSwitchCC.js.map +2 -2
- package/build/cjs/cc/ConfigurationCC.js +16 -8
- package/build/cjs/cc/ConfigurationCC.js.map +2 -2
- package/build/cjs/cc/DeviceResetLocallyCC.js.map +2 -2
- package/build/cjs/cc/DoorLockCC.js +1 -1
- package/build/cjs/cc/DoorLockCC.js.map +2 -2
- package/build/cjs/cc/EntryControlCC.js.map +2 -2
- package/build/cjs/cc/FirmwareUpdateMetaDataCC.js +4 -16
- package/build/cjs/cc/FirmwareUpdateMetaDataCC.js.map +2 -2
- package/build/cjs/cc/HumidityControlSetpointCC.js +10 -4
- package/build/cjs/cc/HumidityControlSetpointCC.js.map +2 -2
- package/build/cjs/cc/IndicatorCC.js +5 -8
- package/build/cjs/cc/IndicatorCC.js.map +2 -2
- package/build/cjs/cc/IrrigationCC.js.map +2 -2
- package/build/cjs/cc/ManufacturerProprietaryCC.js.map +2 -2
- package/build/cjs/cc/ManufacturerSpecificCC._validateArgs.d.ts +1 -0
- package/build/cjs/cc/ManufacturerSpecificCC._validateArgs.js +13 -0
- package/build/cjs/cc/ManufacturerSpecificCC._validateArgs.js.map +2 -2
- package/build/cjs/cc/ManufacturerSpecificCC.d.ts +6 -4
- package/build/cjs/cc/ManufacturerSpecificCC.js +41 -8
- package/build/cjs/cc/ManufacturerSpecificCC.js.map +2 -2
- package/build/cjs/cc/MeterCC.js +18 -29
- package/build/cjs/cc/MeterCC.js.map +2 -2
- package/build/cjs/cc/MultiChannelAssociationCC.js +11 -7
- package/build/cjs/cc/MultiChannelAssociationCC.js.map +2 -2
- package/build/cjs/cc/MultiChannelCC.d.ts +3 -1
- package/build/cjs/cc/MultiChannelCC.js +21 -10
- package/build/cjs/cc/MultiChannelCC.js.map +3 -3
- package/build/cjs/cc/MultilevelSensorCC.js.map +2 -2
- package/build/cjs/cc/MultilevelSwitchCC.d.ts +5 -1
- package/build/cjs/cc/MultilevelSwitchCC.js +30 -0
- package/build/cjs/cc/MultilevelSwitchCC.js.map +3 -3
- package/build/cjs/cc/NotificationCC.js +29 -11
- package/build/cjs/cc/NotificationCC.js.map +2 -2
- package/build/cjs/cc/PowerlevelCC.js.map +1 -1
- package/build/cjs/cc/ProtectionCC.js +2 -0
- package/build/cjs/cc/ProtectionCC.js.map +2 -2
- package/build/cjs/cc/SceneActuatorConfigurationCC.js.map +2 -2
- package/build/cjs/cc/SceneControllerConfigurationCC.js.map +2 -2
- package/build/cjs/cc/ScheduleEntryLockCC.js.map +2 -2
- package/build/cjs/cc/Security2CC.d.ts +2 -1
- package/build/cjs/cc/Security2CC.js +31 -3
- package/build/cjs/cc/Security2CC.js.map +2 -2
- package/build/cjs/cc/SecurityCC.d.ts +3 -2
- package/build/cjs/cc/SecurityCC.js +7 -6
- package/build/cjs/cc/SecurityCC.js.map +2 -2
- package/build/cjs/cc/SoundSwitchCC.js +6 -6
- package/build/cjs/cc/SoundSwitchCC.js.map +2 -2
- package/build/cjs/cc/SupervisionCC.d.ts +2 -1
- package/build/cjs/cc/SupervisionCC.js +6 -0
- package/build/cjs/cc/SupervisionCC.js.map +3 -3
- package/build/cjs/cc/ThermostatFanModeCC.js.map +2 -2
- package/build/cjs/cc/ThermostatModeCC.js +1 -3
- package/build/cjs/cc/ThermostatModeCC.js.map +2 -2
- package/build/cjs/cc/ThermostatOperatingStateCC.js.map +2 -2
- package/build/cjs/cc/ThermostatSetpointCC.d.ts +4 -1
- package/build/cjs/cc/ThermostatSetpointCC.js +18 -0
- package/build/cjs/cc/ThermostatSetpointCC.js.map +3 -3
- package/build/cjs/cc/TimeCC.js.map +2 -2
- package/build/cjs/cc/TransportServiceCC.js.map +2 -2
- package/build/cjs/cc/UserCodeCC.js +3 -6
- package/build/cjs/cc/UserCodeCC.js.map +2 -2
- package/build/cjs/cc/UserCredentialCC.js +8 -6
- package/build/cjs/cc/UserCredentialCC.js.map +2 -2
- package/build/cjs/cc/VersionCC.js.map +2 -2
- package/build/cjs/cc/WindowCoveringCC.js +5 -1
- package/build/cjs/cc/WindowCoveringCC.js.map +2 -2
- package/build/cjs/cc/ZWaveProtocolCC.js +3 -11
- package/build/cjs/cc/ZWaveProtocolCC.js.map +2 -2
- package/build/cjs/cc/_CCValues.generated.d.ts +4 -4
- package/build/cjs/cc/_CCValues.generated.js +1 -1
- package/build/cjs/cc/_CCValues.generated.js.map +2 -2
- package/build/cjs/cc/index.d.ts +179 -179
- package/build/cjs/cc/index.js.map +1 -1
- package/build/cjs/cc/manufacturerProprietary/Decorators.js.map +2 -2
- package/build/cjs/lib/API.d.ts +3 -2
- package/build/cjs/lib/API.js.map +2 -2
- package/build/cjs/lib/CommandClass.d.ts +23 -1
- package/build/cjs/lib/CommandClass.js +63 -15
- package/build/cjs/lib/CommandClass.js.map +3 -3
- package/build/cjs/lib/CommandClassDecorators.js.map +2 -2
- package/build/cjs/lib/EncapsulatingCommandClass.js.map +2 -2
- package/build/cjs/lib/NotificationEventPayload.js.map +2 -2
- package/build/cjs/lib/Security2/Extension.js +1 -4
- package/build/cjs/lib/Security2/Extension.js.map +2 -2
- package/build/cjs/lib/Security2/shared.js.map +2 -2
- package/build/cjs/lib/SetValueResult.js.map +1 -1
- package/build/cjs/lib/Values.d.ts +1 -1
- package/build/cjs/lib/Values.js.map +2 -2
- package/build/cjs/lib/_CCAPI.generated.js.map +1 -1
- package/build/cjs/lib/_Types.d.ts +34 -30
- package/build/cjs/lib/_Types.js +7 -0
- package/build/cjs/lib/_Types.js.map +3 -3
- package/build/cjs/lib/serializers.js +1 -4
- package/build/cjs/lib/serializers.js.map +2 -2
- package/build/cjs/lib/utils.js.map +2 -2
- package/build/esm/cc/AlarmSensorCC.d.ts.map +1 -1
- package/build/esm/cc/AlarmSensorCC.js +1 -2
- package/build/esm/cc/AlarmSensorCC.js.map +1 -1
- package/build/esm/cc/AssociationCC.d.ts.map +1 -1
- package/build/esm/cc/AssociationCC.js +8 -7
- package/build/esm/cc/AssociationCC.js.map +1 -1
- package/build/esm/cc/AssociationGroupInfoCC.d.ts.map +1 -1
- package/build/esm/cc/AssociationGroupInfoCC.js +11 -12
- package/build/esm/cc/AssociationGroupInfoCC.js.map +1 -1
- package/build/esm/cc/BarrierOperatorCC.d.ts.map +1 -1
- package/build/esm/cc/BarrierOperatorCC.js +10 -9
- package/build/esm/cc/BarrierOperatorCC.js.map +1 -1
- package/build/esm/cc/BasicCC.d.ts +4 -1
- package/build/esm/cc/BasicCC.d.ts.map +1 -1
- package/build/esm/cc/BasicCC.js +30 -7
- package/build/esm/cc/BasicCC.js.map +1 -1
- package/build/esm/cc/BasicWindowCoveringCC.d.ts.map +1 -1
- package/build/esm/cc/BasicWindowCoveringCC.js +2 -5
- package/build/esm/cc/BasicWindowCoveringCC.js.map +1 -1
- package/build/esm/cc/BatteryCC.d.ts.map +1 -1
- package/build/esm/cc/BatteryCC.js +17 -14
- package/build/esm/cc/BatteryCC.js.map +1 -1
- package/build/esm/cc/BinarySensorCC.d.ts.map +1 -1
- package/build/esm/cc/BinarySensorCC.js +12 -7
- package/build/esm/cc/BinarySensorCC.js.map +1 -1
- package/build/esm/cc/BinarySwitchCC.d.ts +4 -1
- package/build/esm/cc/BinarySwitchCC.d.ts.map +1 -1
- package/build/esm/cc/BinarySwitchCC.js +31 -6
- package/build/esm/cc/BinarySwitchCC.js.map +1 -1
- package/build/esm/cc/CRC16CC.d.ts +3 -2
- package/build/esm/cc/CRC16CC.d.ts.map +1 -1
- package/build/esm/cc/CRC16CC.js +10 -4
- package/build/esm/cc/CRC16CC.js.map +1 -1
- package/build/esm/cc/CentralSceneCC.d.ts.map +1 -1
- package/build/esm/cc/CentralSceneCC.js +2 -1
- package/build/esm/cc/CentralSceneCC.js.map +1 -1
- package/build/esm/cc/ClimateControlScheduleCC.d.ts.map +1 -1
- package/build/esm/cc/ClimateControlScheduleCC.js +6 -2
- package/build/esm/cc/ClimateControlScheduleCC.js.map +1 -1
- package/build/esm/cc/ClockCC.d.ts.map +1 -1
- package/build/esm/cc/ClockCC.js +6 -2
- package/build/esm/cc/ClockCC.js.map +1 -1
- package/build/esm/cc/ColorSwitchCC.d.ts.map +1 -1
- package/build/esm/cc/ColorSwitchCC.js +17 -20
- package/build/esm/cc/ColorSwitchCC.js.map +1 -1
- package/build/esm/cc/ConfigurationCC.d.ts.map +1 -1
- package/build/esm/cc/ConfigurationCC.js +37 -33
- package/build/esm/cc/ConfigurationCC.js.map +1 -1
- package/build/esm/cc/DeviceResetLocallyCC.d.ts.map +1 -1
- package/build/esm/cc/DeviceResetLocallyCC.js +1 -2
- package/build/esm/cc/DeviceResetLocallyCC.js.map +1 -1
- package/build/esm/cc/DoorLockCC.d.ts.map +1 -1
- package/build/esm/cc/DoorLockCC.js +26 -30
- package/build/esm/cc/DoorLockCC.js.map +1 -1
- package/build/esm/cc/EntryControlCC.d.ts.map +1 -1
- package/build/esm/cc/EntryControlCC.js +10 -7
- package/build/esm/cc/EntryControlCC.js.map +1 -1
- package/build/esm/cc/FirmwareUpdateMetaDataCC.d.ts.map +1 -1
- package/build/esm/cc/FirmwareUpdateMetaDataCC.js +15 -27
- package/build/esm/cc/FirmwareUpdateMetaDataCC.js.map +1 -1
- package/build/esm/cc/HumidityControlSetpointCC.d.ts.map +1 -1
- package/build/esm/cc/HumidityControlSetpointCC.js +8 -9
- package/build/esm/cc/HumidityControlSetpointCC.js.map +1 -1
- package/build/esm/cc/IndicatorCC.d.ts.map +1 -1
- package/build/esm/cc/IndicatorCC.js +27 -42
- package/build/esm/cc/IndicatorCC.js.map +1 -1
- package/build/esm/cc/IrrigationCC.d.ts.map +1 -1
- package/build/esm/cc/IrrigationCC.js +8 -6
- package/build/esm/cc/IrrigationCC.js.map +1 -1
- package/build/esm/cc/ManufacturerProprietaryCC.d.ts.map +1 -1
- package/build/esm/cc/ManufacturerProprietaryCC.js +1 -2
- package/build/esm/cc/ManufacturerProprietaryCC.js.map +1 -1
- package/build/esm/cc/ManufacturerSpecificCC._validateArgs.d.ts +1 -0
- package/build/esm/cc/ManufacturerSpecificCC._validateArgs.d.ts.map +1 -1
- package/build/esm/cc/ManufacturerSpecificCC._validateArgs.js +10 -0
- package/build/esm/cc/ManufacturerSpecificCC._validateArgs.js.map +1 -1
- package/build/esm/cc/ManufacturerSpecificCC.d.ts +6 -4
- package/build/esm/cc/ManufacturerSpecificCC.d.ts.map +1 -1
- package/build/esm/cc/ManufacturerSpecificCC.js +54 -17
- package/build/esm/cc/ManufacturerSpecificCC.js.map +1 -1
- package/build/esm/cc/MeterCC.d.ts.map +1 -1
- package/build/esm/cc/MeterCC.js +28 -38
- package/build/esm/cc/MeterCC.js.map +1 -1
- package/build/esm/cc/MultiChannelAssociationCC.d.ts.map +1 -1
- package/build/esm/cc/MultiChannelAssociationCC.js +15 -20
- package/build/esm/cc/MultiChannelAssociationCC.js.map +1 -1
- package/build/esm/cc/MultiChannelCC.d.ts +3 -1
- package/build/esm/cc/MultiChannelCC.d.ts.map +1 -1
- package/build/esm/cc/MultiChannelCC.js +28 -22
- package/build/esm/cc/MultiChannelCC.js.map +1 -1
- package/build/esm/cc/MultilevelSensorCC.d.ts.map +1 -1
- package/build/esm/cc/MultilevelSensorCC.js +11 -11
- package/build/esm/cc/MultilevelSensorCC.js.map +1 -1
- package/build/esm/cc/MultilevelSwitchCC.d.ts +5 -1
- package/build/esm/cc/MultilevelSwitchCC.d.ts.map +1 -1
- package/build/esm/cc/MultilevelSwitchCC.js +56 -16
- package/build/esm/cc/MultilevelSwitchCC.js.map +1 -1
- package/build/esm/cc/NotificationCC.d.ts.map +1 -1
- package/build/esm/cc/NotificationCC.js +66 -55
- package/build/esm/cc/NotificationCC.js.map +1 -1
- package/build/esm/cc/PowerlevelCC.d.ts.map +1 -1
- package/build/esm/cc/ProtectionCC.d.ts.map +1 -1
- package/build/esm/cc/ProtectionCC.js +13 -9
- package/build/esm/cc/ProtectionCC.js.map +1 -1
- package/build/esm/cc/SceneActuatorConfigurationCC.d.ts.map +1 -1
- package/build/esm/cc/SceneActuatorConfigurationCC.js +5 -8
- package/build/esm/cc/SceneActuatorConfigurationCC.js.map +1 -1
- package/build/esm/cc/SceneControllerConfigurationCC.d.ts.map +1 -1
- package/build/esm/cc/SceneControllerConfigurationCC.js +10 -16
- package/build/esm/cc/SceneControllerConfigurationCC.js.map +1 -1
- package/build/esm/cc/ScheduleEntryLockCC.d.ts.map +1 -1
- package/build/esm/cc/ScheduleEntryLockCC.js +13 -20
- package/build/esm/cc/ScheduleEntryLockCC.js.map +1 -1
- package/build/esm/cc/Security2CC.d.ts +2 -1
- package/build/esm/cc/Security2CC.d.ts.map +1 -1
- package/build/esm/cc/Security2CC.js +68 -32
- package/build/esm/cc/Security2CC.js.map +1 -1
- package/build/esm/cc/SecurityCC.d.ts +3 -2
- package/build/esm/cc/SecurityCC.d.ts.map +1 -1
- package/build/esm/cc/SecurityCC.js +16 -11
- package/build/esm/cc/SecurityCC.js.map +1 -1
- package/build/esm/cc/SoundSwitchCC.js +2 -2
- package/build/esm/cc/SoundSwitchCC.js.map +1 -1
- package/build/esm/cc/SupervisionCC.d.ts +2 -1
- package/build/esm/cc/SupervisionCC.d.ts.map +1 -1
- package/build/esm/cc/SupervisionCC.js +13 -6
- package/build/esm/cc/SupervisionCC.js.map +1 -1
- package/build/esm/cc/ThermostatFanModeCC.d.ts.map +1 -1
- package/build/esm/cc/ThermostatFanModeCC.js +1 -2
- package/build/esm/cc/ThermostatFanModeCC.js.map +1 -1
- package/build/esm/cc/ThermostatModeCC.d.ts.map +1 -1
- package/build/esm/cc/ThermostatModeCC.js +1 -3
- package/build/esm/cc/ThermostatModeCC.js.map +1 -1
- package/build/esm/cc/ThermostatOperatingStateCC.d.ts.map +1 -1
- package/build/esm/cc/ThermostatOperatingStateCC.js +1 -2
- package/build/esm/cc/ThermostatOperatingStateCC.js.map +1 -1
- package/build/esm/cc/ThermostatSetpointCC.d.ts +4 -1
- package/build/esm/cc/ThermostatSetpointCC.d.ts.map +1 -1
- package/build/esm/cc/ThermostatSetpointCC.js +31 -19
- package/build/esm/cc/ThermostatSetpointCC.js.map +1 -1
- package/build/esm/cc/TimeCC.d.ts.map +1 -1
- package/build/esm/cc/TimeCC.js +6 -2
- package/build/esm/cc/TimeCC.js.map +1 -1
- package/build/esm/cc/TransportServiceCC.d.ts.map +1 -1
- package/build/esm/cc/TransportServiceCC.js +8 -8
- package/build/esm/cc/TransportServiceCC.js.map +1 -1
- package/build/esm/cc/UserCodeCC.d.ts.map +1 -1
- package/build/esm/cc/UserCodeCC.js +23 -30
- package/build/esm/cc/UserCodeCC.js.map +1 -1
- package/build/esm/cc/UserCredentialCC.d.ts.map +1 -1
- package/build/esm/cc/UserCredentialCC.js +49 -60
- package/build/esm/cc/UserCredentialCC.js.map +1 -1
- package/build/esm/cc/VersionCC.js +3 -3
- package/build/esm/cc/VersionCC.js.map +1 -1
- package/build/esm/cc/WindowCoveringCC.d.ts.map +1 -1
- package/build/esm/cc/WindowCoveringCC.js +10 -9
- package/build/esm/cc/WindowCoveringCC.js.map +1 -1
- package/build/esm/cc/ZWaveProtocolCC.d.ts.map +1 -1
- package/build/esm/cc/ZWaveProtocolCC.js +5 -26
- package/build/esm/cc/ZWaveProtocolCC.js.map +1 -1
- package/build/esm/cc/_CCValues.generated.d.ts +4 -4
- package/build/esm/cc/_CCValues.generated.d.ts.map +1 -1
- package/build/esm/cc/_CCValues.generated.js +638 -679
- package/build/esm/cc/_CCValues.generated.js.map +1 -1
- package/build/esm/cc/index.d.ts +179 -179
- package/build/esm/cc/index.d.ts.map +1 -1
- package/build/esm/cc/index.js +124 -124
- package/build/esm/cc/index.js.map +1 -1
- package/build/esm/cc/manufacturerProprietary/Decorators.d.ts.map +1 -1
- package/build/esm/cc/manufacturerProprietary/Decorators.js.map +1 -1
- package/build/esm/lib/API.d.ts +3 -2
- package/build/esm/lib/API.d.ts.map +1 -1
- package/build/esm/lib/API.js +1 -1
- package/build/esm/lib/API.js.map +1 -1
- package/build/esm/lib/CommandClass.d.ts +23 -1
- package/build/esm/lib/CommandClass.d.ts.map +1 -1
- package/build/esm/lib/CommandClass.js +61 -20
- package/build/esm/lib/CommandClass.js.map +1 -1
- package/build/esm/lib/CommandClassDecorators.d.ts.map +1 -1
- package/build/esm/lib/CommandClassDecorators.js +1 -2
- package/build/esm/lib/CommandClassDecorators.js.map +1 -1
- package/build/esm/lib/EncapsulatingCommandClass.d.ts.map +1 -1
- package/build/esm/lib/EncapsulatingCommandClass.js.map +1 -1
- package/build/esm/lib/NotificationEventPayload.d.ts.map +1 -1
- package/build/esm/lib/NotificationEventPayload.js.map +1 -1
- package/build/esm/lib/Security2/Extension.d.ts.map +1 -1
- package/build/esm/lib/Security2/Extension.js +2 -6
- package/build/esm/lib/Security2/Extension.js.map +1 -1
- package/build/esm/lib/Security2/shared.d.ts.map +1 -1
- package/build/esm/lib/Security2/shared.js.map +1 -1
- package/build/esm/lib/SetValueResult.d.ts.map +1 -1
- package/build/esm/lib/Values.d.ts +1 -1
- package/build/esm/lib/Values.d.ts.map +1 -1
- package/build/esm/lib/Values.js.map +1 -1
- package/build/esm/lib/_CCAPI.generated.d.ts.map +1 -1
- package/build/esm/lib/_Types.d.ts +34 -30
- package/build/esm/lib/_Types.d.ts.map +1 -1
- package/build/esm/lib/_Types.js +5 -0
- package/build/esm/lib/_Types.js.map +1 -1
- package/build/esm/lib/serializers.d.ts.map +1 -1
- package/build/esm/lib/serializers.js +1 -4
- package/build/esm/lib/serializers.js.map +1 -1
- package/build/esm/lib/traits.d.ts.map +1 -1
- package/build/esm/lib/utils.d.ts.map +1 -1
- package/build/esm/lib/utils.js +25 -31
- package/build/esm/lib/utils.js.map +1 -1
- package/package.json +7 -7
package/build/cjs/lib/API.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src_gen/lib/API.ts"],
|
|
4
|
-
"sourcesContent": ["import type { CompatOverrideQueries, GetDeviceConfig } from \"@zwave-js/config\";\nimport {\n\tCommandClasses,\n\ttype ControlsCC,\n\ttype Duration,\n\ttype EndpointId,\n\ttype GetEndpoint,\n\ttype GetNode,\n\ttype GetSafeCCVersion,\n\ttype GetSupportedCCVersion,\n\ttype GetValueDB,\n\ttype HostIDs,\n\ttype ListenBehavior,\n\ttype LogNode,\n\ttype MaybeNotKnown,\n\tNODE_ID_BROADCAST,\n\tNODE_ID_BROADCAST_LR,\n\tNOT_KNOWN,\n\ttype NodeId,\n\ttype PhysicalNodes,\n\ttype QueryNodeInterviewStage,\n\ttype QueryNodeStatus,\n\ttype SecurityManagers,\n\ttype SendCommandOptions,\n\ttype SupervisionResult,\n\ttype SupportsCC,\n\ttype TXReport,\n\ttype ValueChangeOptions,\n\ttype ValueDB,\n\ttype ValueID,\n\ttype VirtualEndpointId,\n\tZWaveError,\n\tZWaveErrorCodes,\n\tgetCCName,\n\tstripUndefined,\n} from \"@zwave-js/core\";\nimport {\n\ttype AllOrNone,\n\ttype OnlyMethods,\n\tgetEnumMemberName,\n\tgetErrorMessage,\n\tnum2hex,\n} from \"@zwave-js/shared\";\nimport { isArray } from \"alcalzone-shared/typeguards\";\nimport {\n\tgetAPI,\n\tgetCCValues,\n\tgetCommandClass,\n\tgetImplementedVersion,\n} from \"./CommandClassDecorators.js\";\nimport type { CCValue, StaticCCValue } from \"./Values.js\";\nimport type { SendCommand } from \"./traits.js\";\nimport type {\n\tGetRefreshValueTimeouts,\n\tGetUserPreferences,\n\tSchedulePoll,\n} from \"./traits.js\";\n\n// Import and re-export generated types\nimport type { CCAPIs, CCNameMap } from \"./_CCAPI.generated.js\";\nexport type { CCAPIs, CCNameMap };\n\nexport type ValueIDProperties = Pick<ValueID, \"property\" | \"propertyKey\">;\n\n/** Used to identify the method on the CC API class that handles setting values on nodes directly */\nexport const SET_VALUE: unique symbol = Symbol.for(\"CCAPI_SET_VALUE\");\n\nexport type SetValueImplementation = (\n\tproperty: ValueIDProperties,\n\tvalue: unknown,\n\toptions?: SetValueAPIOptions,\n) => Promise<SupervisionResult | undefined>;\n\nexport const SET_VALUE_HOOKS: unique symbol = Symbol.for(\n\t\"CCAPI_SET_VALUE_HOOKS\",\n);\n\nexport type SetValueImplementationHooks =\n\t& AllOrNone<{\n\t\t// Opt-in to and handle delayed supervision updates\n\t\tsupervisionDelayedUpdates: boolean;\n\t\tsupervisionOnSuccess: () => void | Promise<void>;\n\t\tsupervisionOnFailure: () => void | Promise<void>;\n\t}>\n\t& {\n\t\t// Whether the value is a target value for a CC using split\n\t\t// target/current values. If so, the value will be updated optimistically,\n\t\t// even if the device class does not support optimistic updates.\n\t\tisSplitStateTargetValue?: boolean;\n\t\t// Optimistically update related cached values (if allowed)\n\t\toptimisticallyUpdateRelatedValues?: (\n\t\t\tsupervisedAndSuccessful: boolean,\n\t\t) => void;\n\t\t// Check if a verification of the set value is required, even if the API response suggests otherwise\n\t\tforceVerifyChanges?: () => boolean;\n\t\t// Verify the changes\n\t\tverifyChanges?: (result?: SupervisionResult) => void | Promise<void>;\n\t};\n\nexport type SetValueImplementationHooksFactory = (\n\tproperty: ValueIDProperties,\n\tvalue: unknown,\n\toptions?: SetValueAPIOptions,\n) => SetValueImplementationHooks | undefined;\n\n/**\n * A generic options bag for the `setValue` API.\n * Each implementation will choose the options that are relevant for it, so you can use the same options everywhere.\n * @publicAPI\n */\nexport type SetValueAPIOptions =\n\t& Partial<ValueChangeOptions>\n\t& Pick<SendCommandOptions, \"onProgress\">;\n\n/** Used to identify the method on the CC API class that handles polling values from nodes */\nexport const POLL_VALUE: unique symbol = Symbol.for(\"CCAPI_POLL_VALUE\");\nexport type PollValueImplementation<T = unknown> = (\n\tproperty: ValueIDProperties,\n) => Promise<T | undefined>;\n\n// Since the setValue API is called from a point with very generic parameters,\n// we must do narrowing inside the API calls. These three methods are for convenience\nexport function throwUnsupportedProperty(\n\tcc: CommandClasses,\n\tproperty: string | number,\n): never {\n\tthrow new ZWaveError(\n\t\t`${CommandClasses[cc]}: \"${property}\" is not a supported property`,\n\t\tZWaveErrorCodes.Argument_Invalid,\n\t);\n}\n\nexport function throwUnsupportedPropertyKey(\n\tcc: CommandClasses,\n\tproperty: string | number,\n\tpropertyKey: string | number,\n): never {\n\tthrow new ZWaveError(\n\t\t`${\n\t\t\tCommandClasses[cc]\n\t\t}: \"${propertyKey}\" is not a supported property key for property \"${property}\"`,\n\t\tZWaveErrorCodes.Argument_Invalid,\n\t);\n}\n\nexport function throwMissingPropertyKey(\n\tcc: CommandClasses,\n\tproperty: string | number,\n): never {\n\tthrow new ZWaveError(\n\t\t`${\n\t\t\tCommandClasses[cc]\n\t\t}: property \"${property}\" requires a property key, but none was given`,\n\t\tZWaveErrorCodes.Argument_Invalid,\n\t);\n}\n\nexport function throwWrongValueType(\n\tcc: CommandClasses,\n\tproperty: string | number,\n\texpectedType: string,\n\treceivedType: string,\n): never {\n\tthrow new ZWaveError(\n\t\t`${\n\t\t\tCommandClasses[cc]\n\t\t}: \"${property}\" must be of type \"${expectedType}\", received \"${receivedType}\"`,\n\t\tZWaveErrorCodes.Argument_Invalid,\n\t);\n}\n\nexport interface CCAPISchedulePollOptions {\n\tduration?: Duration;\n\ttransition?: \"fast\" | \"slow\";\n}\n\n// Defines the necessary traits the host passed to a CC API must have\nexport type CCAPIHost<TNode extends CCAPINode = CCAPINode> =\n\t& HostIDs\n\t& GetNode<TNode>\n\t& GetValueDB\n\t& GetSupportedCCVersion\n\t& GetSafeCCVersion\n\t& SecurityManagers\n\t& GetDeviceConfig\n\t& SendCommand\n\t& GetRefreshValueTimeouts\n\t& GetUserPreferences\n\t& SchedulePoll\n\t& LogNode;\n\n// Defines the necessary traits a node passed to a CC API must have\nexport type CCAPINode =\n\t& NodeId\n\t& ListenBehavior\n\t& QueryNodeStatus\n\t& QueryNodeInterviewStage;\n\n// Defines the necessary traits an endpoint passed to a CC API must have\nexport type CCAPIEndpoint =\n\t& (\n\t\t| (\n\t\t\t// Physical endpoints must let us query their controlled CCs\n\t\t\tEndpointId & ControlsCC\n\t\t)\n\t\t| (\n\t\t\t// Virtual endpoints must let us query their physical nodes,\n\t\t\t// the CCs those nodes implement, and access the endpoints of those\n\t\t\t// physical nodes\n\t\t\tVirtualEndpointId & {\n\t\t\t\tnode: PhysicalNodes<\n\t\t\t\t\t& NodeId\n\t\t\t\t\t& SupportsCC\n\t\t\t\t\t& ControlsCC\n\t\t\t\t\t& GetEndpoint<EndpointId & SupportsCC & ControlsCC>\n\t\t\t\t>;\n\t\t\t}\n\t\t)\n\t)\n\t& SupportsCC;\n\nexport type PhysicalCCAPIEndpoint = CCAPIEndpoint & EndpointId;\nexport type VirtualCCAPIEndpoint = CCAPIEndpoint & VirtualEndpointId;\n\n/**\n * The base class for all CC APIs exposed via `Node.commandClasses.<CCName>`\n * @publicAPI\n */\nexport class CCAPI {\n\tpublic constructor(\n\t\tprotected readonly host: CCAPIHost,\n\t\tprotected readonly endpoint: CCAPIEndpoint,\n\t) {\n\t\tthis.ccId = getCommandClass(this);\n\t}\n\n\tpublic static create<T extends CommandClasses>(\n\t\tccId: T,\n\t\thost: CCAPIHost,\n\t\tendpoint: CCAPIEndpoint,\n\t\trequireSupport?: boolean,\n\t): CommandClasses extends T ? CCAPI : CCToAPI<T> {\n\t\tconst APIConstructor = getAPI(ccId);\n\t\tconst ccName = CommandClasses[ccId];\n\t\tif (APIConstructor == undefined) {\n\t\t\tthrow new ZWaveError(\n\t\t\t\t`Command Class ${ccName} (${\n\t\t\t\t\tnum2hex(\n\t\t\t\t\t\tccId,\n\t\t\t\t\t)\n\t\t\t\t}) has no associated API!`,\n\t\t\t\tZWaveErrorCodes.CC_NoAPI,\n\t\t\t);\n\t\t}\n\t\tconst apiInstance = new APIConstructor(host, endpoint);\n\n\t\t// Only require support for physical endpoints by default\n\t\trequireSupport ??= !endpoint.virtual;\n\n\t\tif (requireSupport) {\n\t\t\t// @ts-expect-error TS doesn't like assigning to conditional types\n\t\t\treturn new Proxy(apiInstance, {\n\t\t\t\tget: (target, property) => {\n\t\t\t\t\t// Forbid access to the API if it is not supported by the node\n\t\t\t\t\tif (\n\t\t\t\t\t\tproperty !== \"ccId\"\n\t\t\t\t\t\t&& property !== \"endpoint\"\n\t\t\t\t\t\t&& property !== \"isSupported\"\n\t\t\t\t\t\t&& property !== \"withOptions\"\n\t\t\t\t\t\t&& property !== \"commandOptions\"\n\t\t\t\t\t\t&& !target.isSupported()\n\t\t\t\t\t) {\n\t\t\t\t\t\tlet messageStart: string;\n\t\t\t\t\t\tif (endpoint.virtual) {\n\t\t\t\t\t\t\tconst hasNodeId =\n\t\t\t\t\t\t\t\ttypeof endpoint.nodeId === \"number\"\n\t\t\t\t\t\t\t\t&& endpoint.nodeId !== NODE_ID_BROADCAST\n\t\t\t\t\t\t\t\t&& endpoint.nodeId !== NODE_ID_BROADCAST_LR;\n\t\t\t\t\t\t\tmessageStart = `${\n\t\t\t\t\t\t\t\thasNodeId ? \"The\" : \"This\"\n\t\t\t\t\t\t\t} virtual node${\n\t\t\t\t\t\t\t\thasNodeId ? ` ${endpoint.nodeId}` : \"\"\n\t\t\t\t\t\t\t}`;\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tmessageStart = `Node ${endpoint.nodeId}`;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tthrow new ZWaveError(\n\t\t\t\t\t\t\t`${messageStart}${\n\t\t\t\t\t\t\t\tendpoint.index === 0\n\t\t\t\t\t\t\t\t\t? \"\"\n\t\t\t\t\t\t\t\t\t: ` (endpoint ${endpoint.index})`\n\t\t\t\t\t\t\t} does not support the Command Class ${ccName}!`,\n\t\t\t\t\t\t\tZWaveErrorCodes.CC_NotSupported,\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\n\t\t\t\t\t// If a device config defines overrides for an API call, return a wrapper method that applies them first before calling the actual method\n\t\t\t\t\tconst fallback = target[property as keyof CCAPI];\n\t\t\t\t\tif (\n\t\t\t\t\t\ttypeof property === \"string\"\n\t\t\t\t\t\t&& !endpoint.virtual\n\t\t\t\t\t\t&& typeof fallback === \"function\"\n\t\t\t\t\t) {\n\t\t\t\t\t\tconst overrides = host.getDeviceConfig?.(\n\t\t\t\t\t\t\tendpoint.nodeId,\n\t\t\t\t\t\t)?.compat?.overrideQueries;\n\t\t\t\t\t\tif (overrides?.hasOverride(ccId)) {\n\t\t\t\t\t\t\treturn overrideQueriesWrapper(\n\t\t\t\t\t\t\t\thost,\n\t\t\t\t\t\t\t\tendpoint,\n\t\t\t\t\t\t\t\tccId,\n\t\t\t\t\t\t\t\tproperty,\n\t\t\t\t\t\t\t\toverrides,\n\t\t\t\t\t\t\t\tfallback,\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\t// Else just access the property\n\t\t\t\t\treturn fallback;\n\t\t\t\t},\n\t\t\t});\n\t\t} else {\n\t\t\t// @ts-expect-error TS doesn't like assigning to conditional types\n\t\t\treturn apiInstance;\n\t\t}\n\t}\n\n\t/**\n\t * The identifier of the Command Class this API is for\n\t */\n\tpublic readonly ccId: CommandClasses;\n\n\tprotected get [SET_VALUE](): SetValueImplementation | undefined {\n\t\treturn undefined;\n\t}\n\n\t/**\n\t * Can be used on supported CC APIs to set a CC value by property name (and optionally the property key).\n\t * **WARNING:** This function is NOT bound to an API instance. It must be called with the correct `this` context!\n\t */\n\tpublic get setValue(): SetValueImplementation | undefined {\n\t\treturn this[SET_VALUE];\n\t}\n\n\tprotected [SET_VALUE_HOOKS]: SetValueImplementationHooksFactory | undefined;\n\t/**\n\t * Can be implemented by CC APIs to influence the behavior of the setValue API in regards to Supervision and verifying values.\n\t */\n\tpublic get setValueHooks(): SetValueImplementationHooksFactory | undefined {\n\t\treturn this[SET_VALUE_HOOKS];\n\t}\n\n\t/** Whether a successful setValue call should imply that the value was successfully updated */\n\t// oxlint-disable-next-line no-unused-vars\n\tpublic isSetValueOptimistic(valueId: ValueID): boolean {\n\t\treturn true;\n\t}\n\n\tprotected get [POLL_VALUE](): PollValueImplementation | undefined {\n\t\treturn undefined;\n\t}\n\t/**\n\t * Can be used on supported CC APIs to poll a CC value by property name (and optionally the property key)\n\t * **WARNING:** This function is NOT bound to an API instance. It must be called with the correct `this` context!\n\t */\n\tpublic get pollValue(): PollValueImplementation | undefined {\n\t\treturn this[POLL_VALUE];\n\t}\n\n\t/**\n\t * Schedules a value to be polled after a given time. Schedules are deduplicated on a per-property basis.\n\t * @returns `true` if the poll was scheduled, `false` otherwise\n\t */\n\tprotected schedulePoll(\n\t\t{ property, propertyKey }: ValueIDProperties,\n\t\texpectedValue: unknown,\n\t\t{ duration, transition = \"slow\" }: CCAPISchedulePollOptions = {},\n\t): boolean {\n\t\t// Figure out the delay. If a non-zero duration was given or this is a \"fast\" transition,\n\t\t// use/add the short delay. Otherwise, default to the long delay.\n\t\tconst durationMs = duration?.toMilliseconds() ?? 0;\n\t\tconst timeouts = this.host.getRefreshValueTimeouts();\n\t\tconst additionalDelay = !!durationMs || transition === \"fast\"\n\t\t\t? timeouts.refreshValueAfterTransition\n\t\t\t: timeouts.refreshValue;\n\t\tconst timeoutMs = durationMs + additionalDelay;\n\n\t\tif (this.isSinglecast()) {\n\t\t\tconst node = this.host.getNode(this.endpoint.nodeId);\n\t\t\tif (!node) return false;\n\n\t\t\treturn this.host.schedulePoll(\n\t\t\t\tnode.id,\n\t\t\t\t{\n\t\t\t\t\tcommandClass: this.ccId,\n\t\t\t\t\tendpoint: this.endpoint.index,\n\t\t\t\t\tproperty,\n\t\t\t\t\tpropertyKey,\n\t\t\t\t},\n\t\t\t\t{ timeoutMs, expectedValue },\n\t\t\t);\n\t\t} else if (this.isMulticast()) {\n\t\t\t// Only poll supporting nodes in multicast\n\t\t\tconst supportingNodes = this.endpoint.node.physicalNodes.filter(\n\t\t\t\t(node) =>\n\t\t\t\t\tnode\n\t\t\t\t\t\t.getEndpoint(this.endpoint.index)\n\t\t\t\t\t\t?.supportsCC(this.ccId),\n\t\t\t);\n\t\t\tlet ret = false;\n\t\t\tfor (const node of supportingNodes) {\n\t\t\t\tret ||= this.host.schedulePoll(\n\t\t\t\t\tnode.id,\n\t\t\t\t\t{\n\t\t\t\t\t\tcommandClass: this.ccId,\n\t\t\t\t\t\tendpoint: this.endpoint.index,\n\t\t\t\t\t\tproperty,\n\t\t\t\t\t\tpropertyKey,\n\t\t\t\t\t},\n\t\t\t\t\t{ timeoutMs, expectedValue },\n\t\t\t\t);\n\t\t\t}\n\t\t\treturn ret;\n\t\t} else {\n\t\t\t// Don't poll the broadcast node\n\t\t\treturn false;\n\t\t}\n\t}\n\n\t/**\n\t * Retrieves the version of the given CommandClass this endpoint implements\n\t */\n\tpublic get version(): number {\n\t\tif (this.isSinglecast()) {\n\t\t\treturn this.host.getSafeCCVersion(\n\t\t\t\tthis.ccId,\n\t\t\t\tthis.endpoint.nodeId,\n\t\t\t\tthis.endpoint.index,\n\t\t\t) ?? 0;\n\t\t} else {\n\t\t\treturn getImplementedVersion(this.ccId);\n\t\t}\n\t}\n\n\t/** Determines if this simplified API instance may be used. */\n\tpublic isSupported(): boolean {\n\t\treturn (\n\t\t\t// NoOperation is always supported\n\t\t\tthis.ccId === CommandClasses[\"No Operation\"]\n\t\t\t// Basic should always be supported. Since we are trying to hide it from library consumers\n\t\t\t// we cannot trust supportsCC to test it\n\t\t\t|| this.ccId === CommandClasses.Basic\n\t\t\t|| this.endpoint.supportsCC(this.ccId)\n\t\t);\n\t}\n\n\t/**\n\t * Determine whether the linked node supports a specific command of this command class.\n\t * {@link NOT_KNOWN} (`undefined`) means that the information has not been received yet\n\t */\n\t// oxlint-disable-next-line no-unused-vars\n\tpublic supportsCommand(command: number): MaybeNotKnown<boolean> {\n\t\t// This needs to be overwritten per command class. In the default implementation, we don't know anything!\n\t\treturn NOT_KNOWN;\n\t}\n\n\tprotected assertSupportsCommand(\n\t\tcommandEnum: unknown,\n\t\tcommand: number,\n\t): void {\n\t\tif (this.supportsCommand(command) !== true) {\n\t\t\tthrow new ZWaveError(\n\t\t\t\t`${\n\t\t\t\t\tthis.isSinglecast()\n\t\t\t\t\t\t? `Node #${this.endpoint.nodeId}`\n\t\t\t\t\t\t: \"This virtual node\"\n\t\t\t\t}${\n\t\t\t\t\tthis.endpoint.index > 0\n\t\t\t\t\t\t? ` (Endpoint ${this.endpoint.index})`\n\t\t\t\t\t\t: \"\"\n\t\t\t\t} does not support the command ${\n\t\t\t\t\tgetEnumMemberName(\n\t\t\t\t\t\tcommandEnum,\n\t\t\t\t\t\tcommand,\n\t\t\t\t\t)\n\t\t\t\t}!`,\n\t\t\t\tZWaveErrorCodes.CC_NotSupported,\n\t\t\t);\n\t\t}\n\t}\n\n\tprotected assertPhysicalEndpoint(\n\t\tendpoint: EndpointId | VirtualEndpointId,\n\t): asserts endpoint is EndpointId {\n\t\tif (endpoint.virtual) {\n\t\t\tthrow new ZWaveError(\n\t\t\t\t`This method is not supported for virtual nodes!`,\n\t\t\t\tZWaveErrorCodes.CC_NotSupported,\n\t\t\t);\n\t\t}\n\t}\n\n\t/** Returns the command options to use for sendCommand calls */\n\tprotected get commandOptions(): SendCommandOptions {\n\t\t// No default options\n\t\treturn {};\n\t}\n\n\t/** Creates an instance of this API, scoped to use the given options */\n\tpublic withOptions(options: SendCommandOptions): this {\n\t\tconst mergedOptions = {\n\t\t\t...this.commandOptions,\n\t\t\t...options,\n\t\t};\n\t\treturn new Proxy(this, {\n\t\t\tget: (target, property) => {\n\t\t\t\tif (property === \"commandOptions\") {\n\t\t\t\t\treturn mergedOptions;\n\t\t\t\t} else {\n\t\t\t\t\treturn (target as any)[property];\n\t\t\t\t}\n\t\t\t},\n\t\t});\n\t}\n\n\t/** Creates an instance of this API which (if supported) will return TX reports along with the result. */\n\tpublic withTXReport<T extends this>(): WithTXReport<T> {\n\t\tif (this.constructor === CCAPI) {\n\t\t\tthrow new ZWaveError(\n\t\t\t\t\"The withTXReport method may only be called on specific CC API implementations.\",\n\t\t\t\tZWaveErrorCodes.Driver_NotSupported,\n\t\t\t);\n\t\t}\n\n\t\t// Remember which properties need to be proxied\n\t\tconst proxiedProps = new Set([\n\t\t\t// These are the CC-specific methods\n\t\t\t...Object.getOwnPropertyNames(this.constructor.prototype),\n\t\t\t// as well as setValue and pollValue\n\t\t\t\"setValue\",\n\t\t\t\"pollValue\",\n\t\t]);\n\t\tproxiedProps.delete(\"constructor\");\n\n\t\tfunction wrapResult(result: unknown, txReport: TXReport): any {\n\t\t\t// Both the result and the TX report may be undefined (no response, no support)\n\t\t\treturn stripUndefined({\n\t\t\t\tresult,\n\t\t\t\ttxReport,\n\t\t\t});\n\t\t}\n\n\t\treturn new Proxy(this, {\n\t\t\tget: (target, prop) => {\n\t\t\t\tif (prop === \"withTXReport\") return undefined;\n\n\t\t\t\tlet original: any = (target as any)[prop];\n\t\t\t\tif (\n\t\t\t\t\tproxiedProps.has(prop as string)\n\t\t\t\t\t&& typeof original === \"function\"\n\t\t\t\t) {\n\t\t\t\t\t// This is a method that only exists in the specific implementation\n\n\t\t\t\t\t// Wrap each call with its own API proxy, so we don't mix up TX reports\n\t\t\t\t\tlet txReport: TXReport;\n\t\t\t\t\tconst api = target.withOptions({\n\t\t\t\t\t\tonTXReport: (report) => {\n\t\t\t\t\t\t\t// Remember the last status report\n\t\t\t\t\t\t\ttxReport = report;\n\t\t\t\t\t\t},\n\t\t\t\t\t});\n\t\t\t\t\toriginal = (api as any)[prop].bind(api);\n\n\t\t\t\t\t// Return a wrapper function that will add the status report after the call is complete\n\t\t\t\t\treturn (...args: any) => {\n\t\t\t\t\t\tlet result = original(...args);\n\t\t\t\t\t\tif (result instanceof Promise) {\n\t\t\t\t\t\t\tresult = result.then((res) =>\n\t\t\t\t\t\t\t\twrapResult(res, txReport)\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tresult = wrapResult(result, txReport);\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn result;\n\t\t\t\t\t};\n\t\t\t\t} else {\n\t\t\t\t\treturn original;\n\t\t\t\t}\n\t\t\t},\n\t\t}) as any;\n\t}\n\n\tprotected isSinglecast(): this is this & {\n\t\tendpoint: PhysicalCCAPIEndpoint;\n\t} {\n\t\treturn (\n\t\t\t!this.endpoint.virtual\n\t\t\t&& typeof this.endpoint.nodeId === \"number\"\n\t\t\t&& this.endpoint.nodeId !== NODE_ID_BROADCAST\n\t\t\t&& this.endpoint.nodeId !== NODE_ID_BROADCAST_LR\n\t\t);\n\t}\n\n\tprotected isMulticast(): this is this & {\n\t\tendpoint: VirtualCCAPIEndpoint & {\n\t\t\tnodeId: number[];\n\t\t};\n\t} {\n\t\treturn this.endpoint.virtual && isArray(this.endpoint.nodeId);\n\t}\n\n\tprotected isBroadcast(): this is this & {\n\t\tendpoint: VirtualCCAPIEndpoint & {\n\t\t\tnodeId: typeof NODE_ID_BROADCAST | typeof NODE_ID_BROADCAST_LR;\n\t\t};\n\t} {\n\t\treturn (\n\t\t\tthis.endpoint.virtual\n\t\t\t&& (this.endpoint.nodeId === NODE_ID_BROADCAST\n\t\t\t\t|| this.endpoint.nodeId === NODE_ID_BROADCAST_LR)\n\t\t);\n\t}\n\n\t/** Returns the value DB for this CC API's node (if it can be safely accessed) */\n\tprotected tryGetValueDB(): ValueDB | undefined {\n\t\tif (!this.isSinglecast()) return;\n\t\ttry {\n\t\t\treturn this.host.getValueDB(this.endpoint.nodeId);\n\t\t} catch {\n\t\t\treturn;\n\t\t}\n\t}\n\n\t/** Returns the value DB for this CC's node (or throws if it cannot be accessed) */\n\tprotected getValueDB(): ValueDB {\n\t\tif (this.isSinglecast()) {\n\t\t\ttry {\n\t\t\t\treturn this.host.getValueDB(this.endpoint.nodeId);\n\t\t\t} catch {\n\t\t\t\tthrow new ZWaveError(\n\t\t\t\t\t\"The node for this CC does not exist or the driver is not ready yet\",\n\t\t\t\t\tZWaveErrorCodes.Driver_NotReady,\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t\tthrow new ZWaveError(\n\t\t\t\"Cannot retrieve the value DB for non-singlecast CCs\",\n\t\t\tZWaveErrorCodes.CC_NoNodeID,\n\t\t);\n\t}\n}\n\nfunction overrideQueriesWrapper(\n\tctx: GetValueDB & LogNode,\n\tendpoint: PhysicalCCAPIEndpoint,\n\tccId: CommandClasses,\n\tmethod: string,\n\toverrides: CompatOverrideQueries,\n\tfallback: (...args: any[]) => any,\n): (...args: any[]) => any {\n\t// We must not capture the `this` context here, because the API methods are bound on use\n\treturn function(this: any, ...args: any[]) {\n\t\tconst match = overrides.matchOverride(\n\t\t\tccId,\n\t\t\tendpoint.index,\n\t\t\tmethod,\n\t\t\targs,\n\t\t);\n\t\tif (!match) return fallback.call(this, ...args);\n\n\t\tctx.logNode(endpoint.nodeId, {\n\t\t\tmessage: `API call ${method} for ${\n\t\t\t\tgetCCName(\n\t\t\t\t\tccId,\n\t\t\t\t)\n\t\t\t} CC overridden by a compat flag.`,\n\t\t\tlevel: \"debug\",\n\t\t\tdirection: \"none\",\n\t\t});\n\n\t\tconst ccValues = getCCValues(ccId);\n\t\tif (ccValues) {\n\t\t\tconst valueDB = ctx.getValueDB(endpoint.nodeId);\n\n\t\t\tconst prop2value = (prop: string): CCValue | undefined => {\n\t\t\t\t// We use a simplistic parser to support dynamic value IDs:\n\t\t\t\t// If end with round brackets with something inside, they are considered dynamic\n\t\t\t\t// Otherwise static\n\t\t\t\tconst argsMatch = prop.match(/^(.*)\\((.*)\\)$/);\n\t\t\t\tif (argsMatch) {\n\t\t\t\t\tconst methodName = argsMatch[1];\n\t\t\t\t\tconst methodArgs = JSON.parse(`[${argsMatch[2]}]`);\n\n\t\t\t\t\tconst dynValue = ccValues[methodName];\n\t\t\t\t\tif (typeof dynValue === \"function\") {\n\t\t\t\t\t\treturn dynValue(...methodArgs);\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tconst staticValue = ccValues[prop] as\n\t\t\t\t\t\t| StaticCCValue\n\t\t\t\t\t\t| undefined;\n\t\t\t\t\tif (typeof staticValue?.endpoint === \"function\") {\n\t\t\t\t\t\treturn staticValue;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t};\n\n\t\t\t// Persist values if necessary\n\t\t\tif (match.persistValues) {\n\t\t\t\tfor (\n\t\t\t\t\tconst [prop, value] of Object.entries(\n\t\t\t\t\t\tmatch.persistValues,\n\t\t\t\t\t)\n\t\t\t\t) {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tconst ccValue = prop2value(prop);\n\t\t\t\t\t\tif (ccValue) {\n\t\t\t\t\t\t\tvalueDB.setValue(\n\t\t\t\t\t\t\t\tccValue.endpoint(endpoint.index),\n\t\t\t\t\t\t\t\tvalue,\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tctx.logNode(endpoint.nodeId, {\n\t\t\t\t\t\t\t\tmessage:\n\t\t\t\t\t\t\t\t\t`Failed to persist value ${prop} during overridden API call: value does not exist`,\n\t\t\t\t\t\t\t\tlevel: \"error\",\n\t\t\t\t\t\t\t\tdirection: \"none\",\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t}\n\t\t\t\t\t} catch (e) {\n\t\t\t\t\t\tctx.logNode(endpoint.nodeId, {\n\t\t\t\t\t\t\tmessage:\n\t\t\t\t\t\t\t\t`Failed to persist value ${prop} during overridden API call: ${\n\t\t\t\t\t\t\t\t\tgetErrorMessage(\n\t\t\t\t\t\t\t\t\t\te,\n\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t}`,\n\t\t\t\t\t\t\tlevel: \"error\",\n\t\t\t\t\t\t\tdirection: \"none\",\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// As well as metadata\n\t\t\tif (match.extendMetadata) {\n\t\t\t\tfor (\n\t\t\t\t\tconst [prop, meta] of Object.entries(\n\t\t\t\t\t\tmatch.extendMetadata,\n\t\t\t\t\t)\n\t\t\t\t) {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tconst ccValue = prop2value(prop);\n\t\t\t\t\t\tif (ccValue) {\n\t\t\t\t\t\t\tvalueDB.setMetadata(\n\t\t\t\t\t\t\t\tccValue.endpoint(endpoint.index),\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t...ccValue.meta,\n\t\t\t\t\t\t\t\t\t...meta,\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tctx.logNode(endpoint.nodeId, {\n\t\t\t\t\t\t\t\tmessage:\n\t\t\t\t\t\t\t\t\t`Failed to extend value metadata ${prop} during overridden API call: value does not exist`,\n\t\t\t\t\t\t\t\tlevel: \"error\",\n\t\t\t\t\t\t\t\tdirection: \"none\",\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t}\n\t\t\t\t\t} catch (e) {\n\t\t\t\t\t\tctx.logNode(endpoint.nodeId, {\n\t\t\t\t\t\t\tmessage:\n\t\t\t\t\t\t\t\t`Failed to extend value metadata ${prop} during overridden API call: ${\n\t\t\t\t\t\t\t\t\tgetErrorMessage(\n\t\t\t\t\t\t\t\t\t\te,\n\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t}`,\n\t\t\t\t\t\t\tlevel: \"error\",\n\t\t\t\t\t\t\tdirection: \"none\",\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// API methods are always async\n\t\treturn Promise.resolve(match.result);\n\t};\n}\n\n/** A CC API that is only available for physical endpoints */\nexport class PhysicalCCAPI extends CCAPI {\n\tpublic constructor(\n\t\thost: CCAPIHost,\n\t\tendpoint: CCAPIEndpoint,\n\t) {\n\t\tsuper(host, endpoint);\n\t\tthis.assertPhysicalEndpoint(endpoint);\n\t}\n\n\tdeclare protected readonly endpoint: PhysicalCCAPIEndpoint;\n}\n\nexport type APIConstructor<T extends CCAPI = CCAPI> = new (\n\thost: CCAPIHost,\n\tendpoint: CCAPIEndpoint,\n) => T;\n\nexport type CCToName<CC extends CommandClasses> = {\n\t[K in keyof CCNameMap]: CCNameMap[K] extends CC ? K : never;\n}[keyof CCNameMap];\n\nexport type CCNameOrId = CommandClasses | Extract<keyof CCAPIs, string>;\n\nexport type CCToAPI<CC extends CCNameOrId> = CC extends CommandClasses\n\t? CCToName<CC> extends keyof CCAPIs ? CCAPIs[CCToName<CC>]\n\t: never\n\t: CC extends keyof CCAPIs ? CCAPIs[CC]\n\t: never;\n\nexport type APIMethodsOf<CC extends CCNameOrId> = Omit<\n\tOnlyMethods<CCToAPI<CC>>,\n\t| \"ccId\"\n\t| \"getNode\"\n\t| \"tryGetNode\"\n\t| \"isSetValueOptimistic\"\n\t| \"isSupported\"\n\t| \"pollValue\"\n\t| \"setValue\"\n\t| \"version\"\n\t| \"supportsCommand\"\n\t| \"withOptions\"\n\t| \"withTXReport\"\n>;\n\nexport type OwnMethodsOf<API extends CCAPI> = Omit<\n\tOnlyMethods<API>,\n\tkeyof OnlyMethods<CCAPI>\n>;\n\n// Wraps the given type in an object that contains a TX report\nexport type WrapWithTXReport<T> = [T] extends [Promise<infer U>]\n\t? Promise<WrapWithTXReport<U>>\n\t: [T] extends [void] ? { txReport: TXReport | undefined }\n\t: { result: T; txReport: TXReport | undefined };\n\nexport type ReturnWithTXReport<T> = T extends (...args: any[]) => any\n\t? (...args: Parameters<T>) => WrapWithTXReport<ReturnType<T>>\n\t: undefined;\n\n// Converts the type of the given API implementation so the API methods return an object including the TX report\nexport type WithTXReport<API extends CCAPI> =\n\t& Omit<\n\t\tAPI,\n\t\tkeyof OwnMethodsOf<API> | \"withOptions\" | \"withTXReport\" | \"setValue\"\n\t>\n\t& {\n\t\t[\n\t\t\tK in\n\t\t\t\t| keyof OwnMethodsOf<API>\n\t\t\t\t| \"setValue\"\n\t\t\t\t| \"pollValue\"\n\t\t]: ReturnWithTXReport<API[K]>;\n\t};\n\nexport function normalizeCCNameOrId(\n\tccNameOrId: number | string,\n): CommandClasses | undefined {\n\tif (!(ccNameOrId in CommandClasses)) return undefined;\n\n\tlet ret: CommandClasses | undefined;\n\tif (typeof ccNameOrId === \"string\") {\n\t\tif (/^\\d+$/.test(ccNameOrId)) {\n\t\t\t// This can happen on property access\n\t\t\tret = +ccNameOrId;\n\t\t} else if (typeof (CommandClasses as any)[ccNameOrId] === \"number\") {\n\t\t\tret = (CommandClasses as any)[ccNameOrId];\n\t\t}\n\t} else {\n\t\tret = ccNameOrId;\n\t}\n\n\treturn ret;\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;AACA;;;;;;;;;;;;;;AAAA,kBAkCO;AACP,oBAMO;AACP,wBAAwB;
|
|
4
|
+
"sourcesContent": ["import type { CompatOverrideQueries, GetDeviceConfig } from \"@zwave-js/config\";\nimport {\n\tCommandClasses,\n\ttype ControlsCC,\n\ttype Duration,\n\ttype EndpointId,\n\ttype GetEndpoint,\n\ttype GetNode,\n\ttype GetSafeCCVersion,\n\ttype GetSupportedCCVersion,\n\ttype GetValueDB,\n\ttype HostIDs,\n\ttype ListenBehavior,\n\ttype LogNode,\n\ttype MaybeNotKnown,\n\tNODE_ID_BROADCAST,\n\tNODE_ID_BROADCAST_LR,\n\tNOT_KNOWN,\n\ttype NodeId,\n\ttype PhysicalNodes,\n\ttype QueryNodeInterviewStage,\n\ttype QueryNodeStatus,\n\ttype SecurityManagers,\n\ttype SendCommandOptions,\n\ttype SupervisionResult,\n\ttype SupportsCC,\n\ttype TXReport,\n\ttype ValueChangeOptions,\n\ttype ValueDB,\n\ttype ValueID,\n\ttype VirtualEndpointId,\n\tZWaveError,\n\tZWaveErrorCodes,\n\tgetCCName,\n\tstripUndefined,\n} from \"@zwave-js/core\";\nimport {\n\ttype AllOrNone,\n\ttype OnlyMethods,\n\tgetEnumMemberName,\n\tgetErrorMessage,\n\tnum2hex,\n} from \"@zwave-js/shared\";\nimport { isArray } from \"alcalzone-shared/typeguards\";\n\nimport {\n\tgetAPI,\n\tgetCCValues,\n\tgetCommandClass,\n\tgetImplementedVersion,\n} from \"./CommandClassDecorators.js\";\nimport type { CCValue, StaticCCValue } from \"./Values.js\";\n// Import and re-export generated types\nimport type { CCAPIs, CCNameMap } from \"./_CCAPI.generated.js\";\nimport type { SendCommand } from \"./traits.js\";\nimport type {\n\tGetRefreshValueTimeouts,\n\tGetUserPreferences,\n\tSchedulePoll,\n} from \"./traits.js\";\nexport type { CCAPIs, CCNameMap };\n\nexport type ValueIDProperties = Pick<ValueID, \"property\" | \"propertyKey\">;\n\n/** Used to identify the method on the CC API class that handles setting values on nodes directly */\nexport const SET_VALUE: unique symbol = Symbol.for(\"CCAPI_SET_VALUE\");\n\nexport type SetValueImplementation = (\n\tproperty: ValueIDProperties,\n\tvalue: unknown,\n\toptions?: SetValueAPIOptions,\n) => Promise<SupervisionResult | undefined>;\n\nexport const SET_VALUE_HOOKS: unique symbol = Symbol.for(\n\t\"CCAPI_SET_VALUE_HOOKS\",\n);\n\nexport type SetValueImplementationHooks = AllOrNone<{\n\t// Opt-in to and handle delayed supervision updates\n\tsupervisionDelayedUpdates: boolean;\n\tsupervisionOnSuccess: () => void | Promise<void>;\n\tsupervisionOnFailure: () => void | Promise<void>;\n}> & {\n\t// Whether the value is a target value for a CC using split\n\t// target/current values. If so, the value will be updated optimistically,\n\t// even if the device class does not support optimistic updates.\n\tisSplitStateTargetValue?: boolean;\n\t// Optimistically update related cached values (if allowed)\n\toptimisticallyUpdateRelatedValues?: (\n\t\tsupervisedAndSuccessful: boolean,\n\t) => void;\n\t// Check if a verification of the set value is required, even if the API response suggests otherwise\n\tforceVerifyChanges?: () => boolean;\n\t// Verify the changes\n\tverifyChanges?: (result?: SupervisionResult) => void | Promise<void>;\n};\n\nexport type SetValueImplementationHooksFactory = (\n\tproperty: ValueIDProperties,\n\tvalue: unknown,\n\toptions?: SetValueAPIOptions,\n) => SetValueImplementationHooks | undefined;\n\n/**\n * A generic options bag for the `setValue` API.\n * Each implementation will choose the options that are relevant for it, so you can use the same options everywhere.\n * @publicAPI\n */\nexport type SetValueAPIOptions = Partial<ValueChangeOptions>\n\t& Pick<SendCommandOptions, \"onProgress\">;\n\n/** Used to identify the method on the CC API class that handles polling values from nodes */\nexport const POLL_VALUE: unique symbol = Symbol.for(\"CCAPI_POLL_VALUE\");\nexport type PollValueImplementation<T = unknown> = (\n\tproperty: ValueIDProperties,\n) => Promise<T | undefined>;\n\n// Since the setValue API is called from a point with very generic parameters,\n// we must do narrowing inside the API calls. These three methods are for convenience\nexport function throwUnsupportedProperty(\n\tcc: CommandClasses,\n\tproperty: string | number,\n): never {\n\tthrow new ZWaveError(\n\t\t`${CommandClasses[cc]}: \"${property}\" is not a supported property`,\n\t\tZWaveErrorCodes.Argument_Invalid,\n\t);\n}\n\nexport function throwUnsupportedPropertyKey(\n\tcc: CommandClasses,\n\tproperty: string | number,\n\tpropertyKey: string | number,\n): never {\n\tthrow new ZWaveError(\n\t\t`${\n\t\t\tCommandClasses[cc]\n\t\t}: \"${propertyKey}\" is not a supported property key for property \"${property}\"`,\n\t\tZWaveErrorCodes.Argument_Invalid,\n\t);\n}\n\nexport function throwMissingPropertyKey(\n\tcc: CommandClasses,\n\tproperty: string | number,\n): never {\n\tthrow new ZWaveError(\n\t\t`${\n\t\t\tCommandClasses[cc]\n\t\t}: property \"${property}\" requires a property key, but none was given`,\n\t\tZWaveErrorCodes.Argument_Invalid,\n\t);\n}\n\nexport function throwWrongValueType(\n\tcc: CommandClasses,\n\tproperty: string | number,\n\texpectedType: string,\n\treceivedType: string,\n): never {\n\tthrow new ZWaveError(\n\t\t`${\n\t\t\tCommandClasses[cc]\n\t\t}: \"${property}\" must be of type \"${expectedType}\", received \"${receivedType}\"`,\n\t\tZWaveErrorCodes.Argument_Invalid,\n\t);\n}\n\nexport interface CCAPISchedulePollOptions {\n\tduration?: Duration;\n\ttransition?: \"fast\" | \"slow\";\n}\n\n// Defines the necessary traits the host passed to a CC API must have\nexport type CCAPIHost<TNode extends CCAPINode = CCAPINode> = HostIDs\n\t& GetNode<TNode>\n\t& GetValueDB\n\t& GetSupportedCCVersion\n\t& GetSafeCCVersion\n\t& SecurityManagers\n\t& GetDeviceConfig\n\t& SendCommand\n\t& GetRefreshValueTimeouts\n\t& GetUserPreferences\n\t& SchedulePoll\n\t& LogNode;\n\n// Defines the necessary traits a node passed to a CC API must have\nexport type CCAPINode = NodeId\n\t& ListenBehavior\n\t& QueryNodeStatus\n\t& QueryNodeInterviewStage;\n\n// Defines the necessary traits an endpoint passed to a CC API must have\nexport type CCAPIEndpoint = (\n\t| // Physical endpoints must let us query their controlled CCs\n\t (EndpointId & ControlsCC)\n\t// Virtual endpoints must let us query their physical nodes,\n\t// the CCs those nodes implement, and access the endpoints of those\n\t// physical nodes\n\t| (VirtualEndpointId & {\n\t\t\tnode: PhysicalNodes<\n\t\t\t\tNodeId\n\t\t\t\t\t& SupportsCC\n\t\t\t\t\t& ControlsCC\n\t\t\t\t\t& GetEndpoint<EndpointId & SupportsCC & ControlsCC>\n\t\t\t>;\n\t })\n)\n\t& SupportsCC;\n\nexport type PhysicalCCAPIEndpoint = CCAPIEndpoint & EndpointId;\nexport type VirtualCCAPIEndpoint = CCAPIEndpoint & VirtualEndpointId;\n\n/**\n * The base class for all CC APIs exposed via `Node.commandClasses.<CCName>`\n * @publicAPI\n */\nexport class CCAPI {\n\tpublic constructor(\n\t\tprotected readonly host: CCAPIHost,\n\t\tprotected readonly endpoint: CCAPIEndpoint,\n\t) {\n\t\tthis.ccId = getCommandClass(this);\n\t}\n\n\tpublic static create<T extends CommandClasses>(\n\t\tccId: T,\n\t\thost: CCAPIHost,\n\t\tendpoint: CCAPIEndpoint,\n\t\trequireSupport?: boolean,\n\t): CommandClasses extends T ? CCAPI : CCToAPI<T> {\n\t\tconst APIConstructor = getAPI(ccId);\n\t\tconst ccName = CommandClasses[ccId];\n\t\tif (APIConstructor == undefined) {\n\t\t\tthrow new ZWaveError(\n\t\t\t\t`Command Class ${ccName} (${num2hex(\n\t\t\t\t\tccId,\n\t\t\t\t)}) has no associated API!`,\n\t\t\t\tZWaveErrorCodes.CC_NoAPI,\n\t\t\t);\n\t\t}\n\t\tconst apiInstance = new APIConstructor(host, endpoint);\n\n\t\t// Only require support for physical endpoints by default\n\t\trequireSupport ??= !endpoint.virtual;\n\n\t\tif (requireSupport) {\n\t\t\t// @ts-expect-error TS doesn't like assigning to conditional types\n\t\t\treturn new Proxy(apiInstance, {\n\t\t\t\tget: (target, property) => {\n\t\t\t\t\t// Forbid access to the API if it is not supported by the node\n\t\t\t\t\tif (\n\t\t\t\t\t\tproperty !== \"ccId\"\n\t\t\t\t\t\t&& property !== \"endpoint\"\n\t\t\t\t\t\t&& property !== \"isSupported\"\n\t\t\t\t\t\t&& property !== \"withOptions\"\n\t\t\t\t\t\t&& property !== \"commandOptions\"\n\t\t\t\t\t\t&& !target.isSupported()\n\t\t\t\t\t) {\n\t\t\t\t\t\tlet messageStart: string;\n\t\t\t\t\t\tif (endpoint.virtual) {\n\t\t\t\t\t\t\tconst hasNodeId =\n\t\t\t\t\t\t\t\ttypeof endpoint.nodeId === \"number\"\n\t\t\t\t\t\t\t\t&& endpoint.nodeId !== NODE_ID_BROADCAST\n\t\t\t\t\t\t\t\t&& endpoint.nodeId !== NODE_ID_BROADCAST_LR;\n\t\t\t\t\t\t\tmessageStart = `${\n\t\t\t\t\t\t\t\thasNodeId ? \"The\" : \"This\"\n\t\t\t\t\t\t\t} virtual node${\n\t\t\t\t\t\t\t\thasNodeId ? ` ${endpoint.nodeId}` : \"\"\n\t\t\t\t\t\t\t}`;\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tmessageStart = `Node ${endpoint.nodeId}`;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tthrow new ZWaveError(\n\t\t\t\t\t\t\t`${messageStart}${\n\t\t\t\t\t\t\t\tendpoint.index === 0\n\t\t\t\t\t\t\t\t\t? \"\"\n\t\t\t\t\t\t\t\t\t: ` (endpoint ${endpoint.index})`\n\t\t\t\t\t\t\t} does not support the Command Class ${ccName}!`,\n\t\t\t\t\t\t\tZWaveErrorCodes.CC_NotSupported,\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\n\t\t\t\t\t// If a device config defines overrides for an API call, return a wrapper method that applies them first before calling the actual method\n\t\t\t\t\tconst fallback = target[property as keyof CCAPI];\n\t\t\t\t\tif (\n\t\t\t\t\t\ttypeof property === \"string\"\n\t\t\t\t\t\t&& !endpoint.virtual\n\t\t\t\t\t\t&& typeof fallback === \"function\"\n\t\t\t\t\t) {\n\t\t\t\t\t\tconst overrides = host.getDeviceConfig?.(\n\t\t\t\t\t\t\tendpoint.nodeId,\n\t\t\t\t\t\t)?.compat?.overrideQueries;\n\t\t\t\t\t\tif (overrides?.hasOverride(ccId)) {\n\t\t\t\t\t\t\treturn overrideQueriesWrapper(\n\t\t\t\t\t\t\t\thost,\n\t\t\t\t\t\t\t\tendpoint,\n\t\t\t\t\t\t\t\tccId,\n\t\t\t\t\t\t\t\tproperty,\n\t\t\t\t\t\t\t\toverrides,\n\t\t\t\t\t\t\t\tfallback,\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\t// Else just access the property\n\t\t\t\t\treturn fallback;\n\t\t\t\t},\n\t\t\t});\n\t\t} else {\n\t\t\t// @ts-expect-error TS doesn't like assigning to conditional types\n\t\t\treturn apiInstance;\n\t\t}\n\t}\n\n\t/**\n\t * The identifier of the Command Class this API is for\n\t */\n\tpublic readonly ccId: CommandClasses;\n\n\tprotected get [SET_VALUE](): SetValueImplementation | undefined {\n\t\treturn undefined;\n\t}\n\n\t/**\n\t * Can be used on supported CC APIs to set a CC value by property name (and optionally the property key).\n\t * **WARNING:** This function is NOT bound to an API instance. It must be called with the correct `this` context!\n\t */\n\tpublic get setValue(): SetValueImplementation | undefined {\n\t\treturn this[SET_VALUE];\n\t}\n\n\tprotected [SET_VALUE_HOOKS]: SetValueImplementationHooksFactory | undefined;\n\t/**\n\t * Can be implemented by CC APIs to influence the behavior of the setValue API in regards to Supervision and verifying values.\n\t */\n\tpublic get setValueHooks(): SetValueImplementationHooksFactory | undefined {\n\t\treturn this[SET_VALUE_HOOKS];\n\t}\n\n\t/** Whether a successful setValue call should imply that the value was successfully updated */\n\t// oxlint-disable-next-line no-unused-vars\n\tpublic isSetValueOptimistic(valueId: ValueID): boolean {\n\t\treturn true;\n\t}\n\n\tprotected get [POLL_VALUE](): PollValueImplementation | undefined {\n\t\treturn undefined;\n\t}\n\t/**\n\t * Can be used on supported CC APIs to poll a CC value by property name (and optionally the property key)\n\t * **WARNING:** This function is NOT bound to an API instance. It must be called with the correct `this` context!\n\t */\n\tpublic get pollValue(): PollValueImplementation | undefined {\n\t\treturn this[POLL_VALUE];\n\t}\n\n\t/**\n\t * Schedules a value to be polled after a given time. Schedules are deduplicated on a per-property basis.\n\t * @returns `true` if the poll was scheduled, `false` otherwise\n\t */\n\tprotected schedulePoll(\n\t\t{ property, propertyKey }: ValueIDProperties,\n\t\texpectedValue: unknown,\n\t\t{ duration, transition = \"slow\" }: CCAPISchedulePollOptions = {},\n\t): boolean {\n\t\t// Figure out the delay. If a non-zero duration was given or this is a \"fast\" transition,\n\t\t// use/add the short delay. Otherwise, default to the long delay.\n\t\tconst durationMs = duration?.toMilliseconds() ?? 0;\n\t\tconst timeouts = this.host.getRefreshValueTimeouts();\n\t\tconst additionalDelay =\n\t\t\t!!durationMs || transition === \"fast\"\n\t\t\t\t? timeouts.refreshValueAfterTransition\n\t\t\t\t: timeouts.refreshValue;\n\t\tconst timeoutMs = durationMs + additionalDelay;\n\n\t\tif (this.isSinglecast()) {\n\t\t\tconst node = this.host.getNode(this.endpoint.nodeId);\n\t\t\tif (!node) return false;\n\n\t\t\treturn this.host.schedulePoll(\n\t\t\t\tnode.id,\n\t\t\t\t{\n\t\t\t\t\tcommandClass: this.ccId,\n\t\t\t\t\tendpoint: this.endpoint.index,\n\t\t\t\t\tproperty,\n\t\t\t\t\tpropertyKey,\n\t\t\t\t},\n\t\t\t\t{ timeoutMs, expectedValue },\n\t\t\t);\n\t\t} else if (this.isMulticast()) {\n\t\t\t// Only poll supporting nodes in multicast\n\t\t\tconst supportingNodes = this.endpoint.node.physicalNodes.filter(\n\t\t\t\t(node) =>\n\t\t\t\t\tnode\n\t\t\t\t\t\t.getEndpoint(this.endpoint.index)\n\t\t\t\t\t\t?.supportsCC(this.ccId),\n\t\t\t);\n\t\t\tlet ret = false;\n\t\t\tfor (const node of supportingNodes) {\n\t\t\t\tret ||= this.host.schedulePoll(\n\t\t\t\t\tnode.id,\n\t\t\t\t\t{\n\t\t\t\t\t\tcommandClass: this.ccId,\n\t\t\t\t\t\tendpoint: this.endpoint.index,\n\t\t\t\t\t\tproperty,\n\t\t\t\t\t\tpropertyKey,\n\t\t\t\t\t},\n\t\t\t\t\t{ timeoutMs, expectedValue },\n\t\t\t\t);\n\t\t\t}\n\t\t\treturn ret;\n\t\t} else {\n\t\t\t// Don't poll the broadcast node\n\t\t\treturn false;\n\t\t}\n\t}\n\n\t/**\n\t * Retrieves the version of the given CommandClass this endpoint implements\n\t */\n\tpublic get version(): number {\n\t\tif (this.isSinglecast()) {\n\t\t\treturn (\n\t\t\t\tthis.host.getSafeCCVersion(\n\t\t\t\t\tthis.ccId,\n\t\t\t\t\tthis.endpoint.nodeId,\n\t\t\t\t\tthis.endpoint.index,\n\t\t\t\t) ?? 0\n\t\t\t);\n\t\t} else {\n\t\t\treturn getImplementedVersion(this.ccId);\n\t\t}\n\t}\n\n\t/** Determines if this simplified API instance may be used. */\n\tpublic isSupported(): boolean {\n\t\treturn (\n\t\t\t// NoOperation is always supported\n\t\t\tthis.ccId === CommandClasses[\"No Operation\"]\n\t\t\t// Basic should always be supported. Since we are trying to hide it from library consumers\n\t\t\t// we cannot trust supportsCC to test it\n\t\t\t|| this.ccId === CommandClasses.Basic\n\t\t\t|| this.endpoint.supportsCC(this.ccId)\n\t\t);\n\t}\n\n\t/**\n\t * Determine whether the linked node supports a specific command of this command class.\n\t * {@link NOT_KNOWN} (`undefined`) means that the information has not been received yet\n\t */\n\t// oxlint-disable-next-line no-unused-vars\n\tpublic supportsCommand(command: number): MaybeNotKnown<boolean> {\n\t\t// This needs to be overwritten per command class. In the default implementation, we don't know anything!\n\t\treturn NOT_KNOWN;\n\t}\n\n\tprotected assertSupportsCommand(\n\t\tcommandEnum: unknown,\n\t\tcommand: number,\n\t): void {\n\t\tif (this.supportsCommand(command) !== true) {\n\t\t\tthrow new ZWaveError(\n\t\t\t\t`${\n\t\t\t\t\tthis.isSinglecast()\n\t\t\t\t\t\t? `Node #${this.endpoint.nodeId}`\n\t\t\t\t\t\t: \"This virtual node\"\n\t\t\t\t}${\n\t\t\t\t\tthis.endpoint.index > 0\n\t\t\t\t\t\t? ` (Endpoint ${this.endpoint.index})`\n\t\t\t\t\t\t: \"\"\n\t\t\t\t} does not support the command ${getEnumMemberName(\n\t\t\t\t\tcommandEnum,\n\t\t\t\t\tcommand,\n\t\t\t\t)}!`,\n\t\t\t\tZWaveErrorCodes.CC_NotSupported,\n\t\t\t);\n\t\t}\n\t}\n\n\tprotected assertPhysicalEndpoint(\n\t\tendpoint: EndpointId | VirtualEndpointId,\n\t): asserts endpoint is EndpointId {\n\t\tif (endpoint.virtual) {\n\t\t\tthrow new ZWaveError(\n\t\t\t\t`This method is not supported for virtual nodes!`,\n\t\t\t\tZWaveErrorCodes.CC_NotSupported,\n\t\t\t);\n\t\t}\n\t}\n\n\t/** Returns the command options to use for sendCommand calls */\n\tprotected get commandOptions(): SendCommandOptions {\n\t\t// No default options\n\t\treturn {};\n\t}\n\n\t/** Creates an instance of this API, scoped to use the given options */\n\tpublic withOptions(options: SendCommandOptions): this {\n\t\tconst mergedOptions = {\n\t\t\t...this.commandOptions,\n\t\t\t...options,\n\t\t};\n\t\treturn new Proxy(this, {\n\t\t\tget: (target, property) => {\n\t\t\t\tif (property === \"commandOptions\") {\n\t\t\t\t\treturn mergedOptions;\n\t\t\t\t} else {\n\t\t\t\t\treturn (target as any)[property];\n\t\t\t\t}\n\t\t\t},\n\t\t});\n\t}\n\n\t/** Creates an instance of this API which (if supported) will return TX reports along with the result. */\n\tpublic withTXReport<T extends this>(): WithTXReport<T> {\n\t\tif (this.constructor === CCAPI) {\n\t\t\tthrow new ZWaveError(\n\t\t\t\t\"The withTXReport method may only be called on specific CC API implementations.\",\n\t\t\t\tZWaveErrorCodes.Driver_NotSupported,\n\t\t\t);\n\t\t}\n\n\t\t// Remember which properties need to be proxied\n\t\tconst proxiedProps = new Set([\n\t\t\t// These are the CC-specific methods\n\t\t\t...Object.getOwnPropertyNames(this.constructor.prototype),\n\t\t\t// as well as setValue and pollValue\n\t\t\t\"setValue\",\n\t\t\t\"pollValue\",\n\t\t]);\n\t\tproxiedProps.delete(\"constructor\");\n\n\t\tfunction wrapResult(result: unknown, txReport: TXReport): any {\n\t\t\t// Both the result and the TX report may be undefined (no response, no support)\n\t\t\treturn stripUndefined({\n\t\t\t\tresult,\n\t\t\t\ttxReport,\n\t\t\t});\n\t\t}\n\n\t\treturn new Proxy(this, {\n\t\t\tget: (target, prop) => {\n\t\t\t\tif (prop === \"withTXReport\") return undefined;\n\n\t\t\t\tlet original: any = (target as any)[prop];\n\t\t\t\tif (\n\t\t\t\t\tproxiedProps.has(prop as string)\n\t\t\t\t\t&& typeof original === \"function\"\n\t\t\t\t) {\n\t\t\t\t\t// This is a method that only exists in the specific implementation\n\n\t\t\t\t\t// Wrap each call with its own API proxy, so we don't mix up TX reports\n\t\t\t\t\tlet txReport: TXReport;\n\t\t\t\t\tconst api = target.withOptions({\n\t\t\t\t\t\tonTXReport: (report) => {\n\t\t\t\t\t\t\t// Remember the last status report\n\t\t\t\t\t\t\ttxReport = report;\n\t\t\t\t\t\t},\n\t\t\t\t\t});\n\t\t\t\t\toriginal = (api as any)[prop].bind(api);\n\n\t\t\t\t\t// Return a wrapper function that will add the status report after the call is complete\n\t\t\t\t\treturn (...args: any) => {\n\t\t\t\t\t\tlet result = original(...args);\n\t\t\t\t\t\tif (result instanceof Promise) {\n\t\t\t\t\t\t\tresult = result.then((res) =>\n\t\t\t\t\t\t\t\twrapResult(res, txReport),\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tresult = wrapResult(result, txReport);\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn result;\n\t\t\t\t\t};\n\t\t\t\t} else {\n\t\t\t\t\treturn original;\n\t\t\t\t}\n\t\t\t},\n\t\t}) as any;\n\t}\n\n\tprotected isSinglecast(): this is this & {\n\t\tendpoint: PhysicalCCAPIEndpoint;\n\t} {\n\t\treturn (\n\t\t\t!this.endpoint.virtual\n\t\t\t&& typeof this.endpoint.nodeId === \"number\"\n\t\t\t&& this.endpoint.nodeId !== NODE_ID_BROADCAST\n\t\t\t&& this.endpoint.nodeId !== NODE_ID_BROADCAST_LR\n\t\t);\n\t}\n\n\tprotected isMulticast(): this is this & {\n\t\tendpoint: VirtualCCAPIEndpoint & {\n\t\t\tnodeId: number[];\n\t\t};\n\t} {\n\t\treturn this.endpoint.virtual && isArray(this.endpoint.nodeId);\n\t}\n\n\tprotected isBroadcast(): this is this & {\n\t\tendpoint: VirtualCCAPIEndpoint & {\n\t\t\tnodeId: typeof NODE_ID_BROADCAST | typeof NODE_ID_BROADCAST_LR;\n\t\t};\n\t} {\n\t\treturn (\n\t\t\tthis.endpoint.virtual\n\t\t\t&& (this.endpoint.nodeId === NODE_ID_BROADCAST\n\t\t\t\t|| this.endpoint.nodeId === NODE_ID_BROADCAST_LR)\n\t\t);\n\t}\n\n\t/** Returns the value DB for this CC API's node (if it can be safely accessed) */\n\tprotected tryGetValueDB(): ValueDB | undefined {\n\t\tif (!this.isSinglecast()) return;\n\t\ttry {\n\t\t\treturn this.host.getValueDB(this.endpoint.nodeId);\n\t\t} catch {\n\t\t\treturn;\n\t\t}\n\t}\n\n\t/** Returns the value DB for this CC's node (or throws if it cannot be accessed) */\n\tprotected getValueDB(): ValueDB {\n\t\tif (this.isSinglecast()) {\n\t\t\ttry {\n\t\t\t\treturn this.host.getValueDB(this.endpoint.nodeId);\n\t\t\t} catch {\n\t\t\t\tthrow new ZWaveError(\n\t\t\t\t\t\"The node for this CC does not exist or the driver is not ready yet\",\n\t\t\t\t\tZWaveErrorCodes.Driver_NotReady,\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t\tthrow new ZWaveError(\n\t\t\t\"Cannot retrieve the value DB for non-singlecast CCs\",\n\t\t\tZWaveErrorCodes.CC_NoNodeID,\n\t\t);\n\t}\n}\n\nfunction overrideQueriesWrapper(\n\tctx: GetValueDB & LogNode,\n\tendpoint: PhysicalCCAPIEndpoint,\n\tccId: CommandClasses,\n\tmethod: string,\n\toverrides: CompatOverrideQueries,\n\tfallback: (...args: any[]) => any,\n): (...args: any[]) => any {\n\t// We must not capture the `this` context here, because the API methods are bound on use\n\treturn function (this: any, ...args: any[]) {\n\t\tconst match = overrides.matchOverride(\n\t\t\tccId,\n\t\t\tendpoint.index,\n\t\t\tmethod,\n\t\t\targs,\n\t\t);\n\t\tif (!match) return fallback.call(this, ...args);\n\n\t\tctx.logNode(endpoint.nodeId, {\n\t\t\tmessage: `API call ${method} for ${getCCName(\n\t\t\t\tccId,\n\t\t\t)} CC overridden by a compat flag.`,\n\t\t\tlevel: \"debug\",\n\t\t\tdirection: \"none\",\n\t\t});\n\n\t\tconst ccValues = getCCValues(ccId);\n\t\tif (ccValues) {\n\t\t\tconst valueDB = ctx.getValueDB(endpoint.nodeId);\n\n\t\t\tconst prop2value = (prop: string): CCValue | undefined => {\n\t\t\t\t// We use a simplistic parser to support dynamic value IDs:\n\t\t\t\t// If end with round brackets with something inside, they are considered dynamic\n\t\t\t\t// Otherwise static\n\t\t\t\tconst argsMatch = prop.match(/^(.*)\\((.*)\\)$/);\n\t\t\t\tif (argsMatch) {\n\t\t\t\t\tconst methodName = argsMatch[1];\n\t\t\t\t\tconst methodArgs = JSON.parse(`[${argsMatch[2]}]`);\n\n\t\t\t\t\tconst dynValue = ccValues[methodName];\n\t\t\t\t\tif (typeof dynValue === \"function\") {\n\t\t\t\t\t\treturn dynValue(...methodArgs);\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tconst staticValue = ccValues[prop] as\n\t\t\t\t\t\t| StaticCCValue\n\t\t\t\t\t\t| undefined;\n\t\t\t\t\tif (typeof staticValue?.endpoint === \"function\") {\n\t\t\t\t\t\treturn staticValue;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t};\n\n\t\t\t// Persist values if necessary\n\t\t\tif (match.persistValues) {\n\t\t\t\tfor (const [prop, value] of Object.entries(\n\t\t\t\t\tmatch.persistValues,\n\t\t\t\t)) {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tconst ccValue = prop2value(prop);\n\t\t\t\t\t\tif (ccValue) {\n\t\t\t\t\t\t\tvalueDB.setValue(\n\t\t\t\t\t\t\t\tccValue.endpoint(endpoint.index),\n\t\t\t\t\t\t\t\tvalue,\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tctx.logNode(endpoint.nodeId, {\n\t\t\t\t\t\t\t\tmessage: `Failed to persist value ${prop} during overridden API call: value does not exist`,\n\t\t\t\t\t\t\t\tlevel: \"error\",\n\t\t\t\t\t\t\t\tdirection: \"none\",\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t}\n\t\t\t\t\t} catch (e) {\n\t\t\t\t\t\tctx.logNode(endpoint.nodeId, {\n\t\t\t\t\t\t\tmessage: `Failed to persist value ${prop} during overridden API call: ${getErrorMessage(\n\t\t\t\t\t\t\t\te,\n\t\t\t\t\t\t\t)}`,\n\t\t\t\t\t\t\tlevel: \"error\",\n\t\t\t\t\t\t\tdirection: \"none\",\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// As well as metadata\n\t\t\tif (match.extendMetadata) {\n\t\t\t\tfor (const [prop, meta] of Object.entries(\n\t\t\t\t\tmatch.extendMetadata,\n\t\t\t\t)) {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tconst ccValue = prop2value(prop);\n\t\t\t\t\t\tif (ccValue) {\n\t\t\t\t\t\t\tvalueDB.setMetadata(\n\t\t\t\t\t\t\t\tccValue.endpoint(endpoint.index),\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t...ccValue.meta,\n\t\t\t\t\t\t\t\t\t...meta,\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tctx.logNode(endpoint.nodeId, {\n\t\t\t\t\t\t\t\tmessage: `Failed to extend value metadata ${prop} during overridden API call: value does not exist`,\n\t\t\t\t\t\t\t\tlevel: \"error\",\n\t\t\t\t\t\t\t\tdirection: \"none\",\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t}\n\t\t\t\t\t} catch (e) {\n\t\t\t\t\t\tctx.logNode(endpoint.nodeId, {\n\t\t\t\t\t\t\tmessage: `Failed to extend value metadata ${prop} during overridden API call: ${getErrorMessage(\n\t\t\t\t\t\t\t\te,\n\t\t\t\t\t\t\t)}`,\n\t\t\t\t\t\t\tlevel: \"error\",\n\t\t\t\t\t\t\tdirection: \"none\",\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// API methods are always async\n\t\treturn Promise.resolve(match.result);\n\t};\n}\n\n/** A CC API that is only available for physical endpoints */\nexport class PhysicalCCAPI extends CCAPI {\n\tpublic constructor(host: CCAPIHost, endpoint: CCAPIEndpoint) {\n\t\tsuper(host, endpoint);\n\t\tthis.assertPhysicalEndpoint(endpoint);\n\t}\n\n\tdeclare protected readonly endpoint: PhysicalCCAPIEndpoint;\n}\n\nexport type APIConstructor<T extends CCAPI = CCAPI> = new (\n\thost: CCAPIHost,\n\tendpoint: CCAPIEndpoint,\n) => T;\n\nexport type CCToName<CC extends CommandClasses> = {\n\t[K in keyof CCNameMap]: CCNameMap[K] extends CC ? K : never;\n}[keyof CCNameMap];\n\nexport type CCNameOrId = CommandClasses | Extract<keyof CCAPIs, string>;\n\nexport type CCToAPI<CC extends CCNameOrId> = CC extends CommandClasses\n\t? CCToName<CC> extends keyof CCAPIs\n\t\t? CCAPIs[CCToName<CC>]\n\t\t: never\n\t: CC extends keyof CCAPIs\n\t\t? CCAPIs[CC]\n\t\t: never;\n\nexport type APIMethodsOf<CC extends CCNameOrId> = Omit<\n\tOnlyMethods<CCToAPI<CC>>,\n\t| \"ccId\"\n\t| \"getNode\"\n\t| \"tryGetNode\"\n\t| \"isSetValueOptimistic\"\n\t| \"isSupported\"\n\t| \"pollValue\"\n\t| \"setValue\"\n\t| \"version\"\n\t| \"supportsCommand\"\n\t| \"withOptions\"\n\t| \"withTXReport\"\n>;\n\nexport type OwnMethodsOf<API extends CCAPI> = Omit<\n\tOnlyMethods<API>,\n\tkeyof OnlyMethods<CCAPI>\n>;\n\n// Wraps the given type in an object that contains a TX report\nexport type WrapWithTXReport<T> = [T] extends [Promise<infer U>]\n\t? Promise<WrapWithTXReport<U>>\n\t: [T] extends [void]\n\t\t? { txReport: TXReport | undefined }\n\t\t: { result: T; txReport: TXReport | undefined };\n\nexport type ReturnWithTXReport<T> = T extends (...args: any[]) => any\n\t? (...args: Parameters<T>) => WrapWithTXReport<ReturnType<T>>\n\t: undefined;\n\n// Converts the type of the given API implementation so the API methods return an object including the TX report\nexport type WithTXReport<API extends CCAPI> = Omit<\n\tAPI,\n\tkeyof OwnMethodsOf<API> | \"withOptions\" | \"withTXReport\" | \"setValue\"\n> & {\n\t[\n\t\tK in keyof OwnMethodsOf<API> | \"setValue\" | \"pollValue\"\n\t]: ReturnWithTXReport<API[K]>;\n};\n\nexport function normalizeCCNameOrId(\n\tccNameOrId: number | string,\n): CommandClasses | undefined {\n\tif (!(ccNameOrId in CommandClasses)) return undefined;\n\n\tlet ret: CommandClasses | undefined;\n\tif (typeof ccNameOrId === \"string\") {\n\t\tif (/^\\d+$/.test(ccNameOrId)) {\n\t\t\t// This can happen on property access\n\t\t\tret = +ccNameOrId;\n\t\t} else if (typeof (CommandClasses as any)[ccNameOrId] === \"number\") {\n\t\t\tret = (CommandClasses as any)[ccNameOrId];\n\t\t}\n\t} else {\n\t\tret = ccNameOrId;\n\t}\n\n\treturn ret;\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;AACA;;;;;;;;;;;;;;AAAA,kBAkCO;AACP,oBAMO;AACP,wBAAwB;AAExB,oCAKO;AAeA,MAAM,YAA2B,OAAO,IAAI,iBAAiB;AAQ7D,MAAM,kBAAiC,OAAO,IACpD,uBAAuB;AAsCj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;cACP,WAAW;aACX;UACF;QACD;MACD;IACD;AAGA,WAAO,QAAQ,QAAQ,MAAM,MAAM;EACpC;AACD;AA1HS;AA6HH,MAAO,sBAAsB,MAAK;EA9vBxC,OA8vBwC;;;EACvC,YAAmB,MAAiB,UAAuB;AAC1D,UAAM,MAAM,QAAQ;AACpB,SAAK,uBAAuB,QAAQ;EACrC;;AAiEK,SAAU,oBACf,YAA2B;AAE3B,MAAI,EAAE,cAAc;AAAiB,WAAO;AAE5C,MAAI;AACJ,MAAI,OAAO,eAAe,UAAU;AACnC,QAAI,QAAQ,KAAK,UAAU,GAAG;AAE7B,YAAM,CAAC;IACR,WAAW,OAAQ,2BAAuB,UAAU,MAAM,UAAU;AACnE,YAAO,2BAAuB,UAAU;IACzC;EACD,OAAO;AACN,UAAM;EACP;AAEA,SAAO;AACR;AAlBgB;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -11,6 +11,17 @@ export interface CommandClassOptions extends CCAddress {
|
|
|
11
11
|
ccCommand?: number;
|
|
12
12
|
payload?: BytesView;
|
|
13
13
|
}
|
|
14
|
+
export declare enum CommandRelation {
|
|
15
|
+
Unrelated = 0,
|
|
16
|
+
Redundant = 1,
|
|
17
|
+
Supersedes = 2
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Compares command destinations. Single targets must match exactly.
|
|
21
|
+
* Multi-targets must contain the same IDs regardless of order.
|
|
22
|
+
*/
|
|
23
|
+
export declare function haveSameDestination(first: number | readonly number[], second: number | readonly number[]): boolean;
|
|
24
|
+
export declare function getCommandRelation(newer: CommandClass, older: CommandClass): CommandRelation;
|
|
14
25
|
export type CCEndpoint = EndpointId & SupportsCC & ControlsCC & GetCCs & ModifyCCs;
|
|
15
26
|
export type CCNode = NodeId & SupportsCC & ControlsCC & GetCCs & GetEndpoint<CCEndpoint> & GetAllEndpoints<CCEndpoint> & QuerySecurityClasses & SetSecurityClass & ListenBehavior & QueryNodeStatus;
|
|
16
27
|
export type InterviewContext = CCAPIHost<CCAPINode & GetCCs & SupportsCC & ControlsCC & QuerySecurityClasses & SetSecurityClass & ReportInterviewProgress & GetEndpoint<EndpointId & GetCCs & SupportsCC & ControlsCC & ModifyCCs> & GetAllEndpoints<EndpointId & SupportsCC & ControlsCC>> & GetInterviewOptions & LookupManufacturer;
|
|
@@ -38,6 +49,7 @@ export declare class CCRaw {
|
|
|
38
49
|
export declare class CommandClass implements CCId {
|
|
39
50
|
constructor(options: CommandClassOptions);
|
|
40
51
|
static parse(data: BytesView, ctx: CCParsingContext): Promise<CommandClass>;
|
|
52
|
+
private static withFrameType;
|
|
41
53
|
static from(raw: CCRaw, ctx: CCParsingContext): CommandClass | Promise<CommandClass>;
|
|
42
54
|
/** This CC's identifier */
|
|
43
55
|
ccId: CommandClasses;
|
|
@@ -58,8 +70,9 @@ export declare class CommandClass implements CCId {
|
|
|
58
70
|
toggleEncapsulationFlag(flag: EncapsulationFlags, active: boolean): void;
|
|
59
71
|
/** Contains a reference to the encapsulating CC if this CC is encapsulated */
|
|
60
72
|
encapsulatingCC?: EncapsulatingCommandClass;
|
|
73
|
+
private _frameType?;
|
|
61
74
|
/** The type of Z-Wave frame this CC was sent with */
|
|
62
|
-
|
|
75
|
+
get frameType(): FrameType | undefined;
|
|
63
76
|
/** Returns true if this CC is an extended CC (0xF100..0xFFFF) */
|
|
64
77
|
isExtended(): boolean;
|
|
65
78
|
/** Whether the interview for this CC was previously completed */
|
|
@@ -71,6 +84,15 @@ export declare class CommandClass implements CCId {
|
|
|
71
84
|
*/
|
|
72
85
|
serialize(ctx: CCEncodingContext): Promise<Bytes>;
|
|
73
86
|
prepareRetransmission(): void;
|
|
87
|
+
/**
|
|
88
|
+
* Determines this command's relation to an older command. Shared command
|
|
89
|
+
* context must match before command-specific relation logic runs.
|
|
90
|
+
*/
|
|
91
|
+
getRelationTo(other: CommandClass): CommandRelation;
|
|
92
|
+
/**
|
|
93
|
+
* Subclasses override this to determine additional command-specific relations.
|
|
94
|
+
*/
|
|
95
|
+
protected determineRelation(_other: CommandClass): CommandRelation;
|
|
74
96
|
/**
|
|
75
97
|
* Create an instance of the given CC without checking whether it is supported.
|
|
76
98
|
* If the CC is implemented, this returns an instance of the given CC which is linked to the given endpoint.
|
|
@@ -21,9 +21,12 @@ var CommandClass_exports = {};
|
|
|
21
21
|
__export(CommandClass_exports, {
|
|
22
22
|
CCRaw: () => CCRaw,
|
|
23
23
|
CommandClass: () => CommandClass,
|
|
24
|
+
CommandRelation: () => CommandRelation,
|
|
24
25
|
InvalidCC: () => InvalidCC,
|
|
25
26
|
ccToLogPayload: () => ccToLogPayload,
|
|
26
|
-
|
|
27
|
+
getCommandRelation: () => getCommandRelation,
|
|
28
|
+
getEffectiveCCVersion: () => getEffectiveCCVersion,
|
|
29
|
+
haveSameDestination: () => haveSameDestination
|
|
27
30
|
});
|
|
28
31
|
module.exports = __toCommonJS(CommandClass_exports);
|
|
29
32
|
var import_core = require("@zwave-js/core");
|
|
@@ -32,6 +35,25 @@ var import_typeguards = require("alcalzone-shared/typeguards");
|
|
|
32
35
|
var import_CommandClassDecorators = require("./CommandClassDecorators.js");
|
|
33
36
|
var import_EncapsulatingCommandClass = require("./EncapsulatingCommandClass.js");
|
|
34
37
|
var import_Values = require("./Values.js");
|
|
38
|
+
var CommandRelation;
|
|
39
|
+
(function(CommandRelation2) {
|
|
40
|
+
CommandRelation2[CommandRelation2["Unrelated"] = 0] = "Unrelated";
|
|
41
|
+
CommandRelation2[CommandRelation2["Redundant"] = 1] = "Redundant";
|
|
42
|
+
CommandRelation2[CommandRelation2["Supersedes"] = 2] = "Supersedes";
|
|
43
|
+
})(CommandRelation || (CommandRelation = {}));
|
|
44
|
+
function haveSameDestination(first, second) {
|
|
45
|
+
if (typeof first === "number" || typeof second === "number") {
|
|
46
|
+
return first === second;
|
|
47
|
+
}
|
|
48
|
+
const firstTargets = new Set(first);
|
|
49
|
+
const secondTargets = new Set(second);
|
|
50
|
+
return firstTargets.size === secondTargets.size && [...firstTargets].every((target) => secondTargets.has(target));
|
|
51
|
+
}
|
|
52
|
+
__name(haveSameDestination, "haveSameDestination");
|
|
53
|
+
function getCommandRelation(newer, older) {
|
|
54
|
+
return newer.getRelationTo(older);
|
|
55
|
+
}
|
|
56
|
+
__name(getCommandRelation, "getCommandRelation");
|
|
35
57
|
function getEffectiveCCVersion(ctx, cc, defaultVersion) {
|
|
36
58
|
if (typeof cc.nodeId !== "number" || cc.nodeId === import_core.NODE_ID_BROADCAST || cc.nodeId === import_core.NODE_ID_BROADCAST_LR) {
|
|
37
59
|
return (0, import_CommandClassDecorators.getImplementedVersion)(cc.ccId);
|
|
@@ -59,16 +81,10 @@ class CCRaw {
|
|
|
59
81
|
let ccCommand = data[ccIdLength];
|
|
60
82
|
let payload = import_shared.Bytes.view(data.subarray(ccIdLength + 1));
|
|
61
83
|
if (ccId === import_core.CommandClasses["Transport Service"]) {
|
|
62
|
-
payload = import_shared.Bytes.concat([
|
|
63
|
-
[ccCommand & 7],
|
|
64
|
-
payload
|
|
65
|
-
]);
|
|
84
|
+
payload = import_shared.Bytes.concat([[ccCommand & 7], payload]);
|
|
66
85
|
ccCommand = ccCommand & 248;
|
|
67
86
|
} else if (ccId === import_core.CommandClasses["Manufacturer Proprietary"]) {
|
|
68
|
-
payload = import_shared.Bytes.concat([
|
|
69
|
-
[ccCommand],
|
|
70
|
-
payload
|
|
71
|
-
]);
|
|
87
|
+
payload = import_shared.Bytes.concat([[ccCommand], payload]);
|
|
72
88
|
ccCommand = void 0;
|
|
73
89
|
}
|
|
74
90
|
return new CCRaw(ccId, ccCommand, payload);
|
|
@@ -94,14 +110,14 @@ class CommandClass {
|
|
|
94
110
|
const raw = CCRaw.parse(data);
|
|
95
111
|
const CCConstructor = (0, import_CommandClassDecorators.getCCConstructor)(raw.ccId);
|
|
96
112
|
if (!CCConstructor) {
|
|
97
|
-
return await CommandClass.from(raw, ctx);
|
|
113
|
+
return CommandClass.withFrameType(await CommandClass.from(raw, ctx), ctx.frameType);
|
|
98
114
|
}
|
|
99
115
|
let CommandConstructor;
|
|
100
116
|
if (raw.ccCommand != void 0) {
|
|
101
117
|
CommandConstructor = (0, import_CommandClassDecorators.getCCCommandConstructor)(raw.ccId, raw.ccCommand);
|
|
102
118
|
}
|
|
103
119
|
try {
|
|
104
|
-
return await (CommandConstructor ?? CCConstructor).from(raw, ctx);
|
|
120
|
+
return CommandClass.withFrameType(await (CommandConstructor ?? CCConstructor).from(raw, ctx), ctx.frameType);
|
|
105
121
|
} catch (e) {
|
|
106
122
|
if ((0, import_core.isZWaveError)(e) && e.code === import_core.ZWaveErrorCodes.PacketFormat_InvalidPayload) {
|
|
107
123
|
const ccName = CommandConstructor?.name ?? `${(0, import_core.getCCName)(raw.ccId)} CC`;
|
|
@@ -116,11 +132,15 @@ class CommandClass {
|
|
|
116
132
|
ccName,
|
|
117
133
|
reason
|
|
118
134
|
});
|
|
119
|
-
return ret;
|
|
135
|
+
return CommandClass.withFrameType(ret, ctx.frameType);
|
|
120
136
|
}
|
|
121
137
|
throw e;
|
|
122
138
|
}
|
|
123
139
|
}
|
|
140
|
+
static withFrameType(cc, frameType) {
|
|
141
|
+
cc._frameType = frameType;
|
|
142
|
+
return cc;
|
|
143
|
+
}
|
|
124
144
|
static from(raw, ctx) {
|
|
125
145
|
return new this({
|
|
126
146
|
nodeId: ctx.sourceNodeId,
|
|
@@ -156,8 +176,11 @@ class CommandClass {
|
|
|
156
176
|
}
|
|
157
177
|
/** Contains a reference to the encapsulating CC if this CC is encapsulated */
|
|
158
178
|
encapsulatingCC;
|
|
179
|
+
_frameType;
|
|
159
180
|
/** The type of Z-Wave frame this CC was sent with */
|
|
160
|
-
frameType
|
|
181
|
+
get frameType() {
|
|
182
|
+
return this._frameType;
|
|
183
|
+
}
|
|
161
184
|
/** Returns true if this CC is an extended CC (0xF100..0xFFFF) */
|
|
162
185
|
isExtended() {
|
|
163
186
|
return this.ccId >= 61696;
|
|
@@ -200,6 +223,22 @@ class CommandClass {
|
|
|
200
223
|
}
|
|
201
224
|
prepareRetransmission() {
|
|
202
225
|
}
|
|
226
|
+
/**
|
|
227
|
+
* Determines this command's relation to an older command. Shared command
|
|
228
|
+
* context must match before command-specific relation logic runs.
|
|
229
|
+
*/
|
|
230
|
+
getRelationTo(other) {
|
|
231
|
+
if (this.ccId !== other.ccId || !haveSameDestination(this.nodeId, other.nodeId) || this.endpointIndex !== other.endpointIndex || this.encapsulationFlags !== other.encapsulationFlags) {
|
|
232
|
+
return CommandRelation.Unrelated;
|
|
233
|
+
}
|
|
234
|
+
return this.determineRelation(other);
|
|
235
|
+
}
|
|
236
|
+
/**
|
|
237
|
+
* Subclasses override this to determine additional command-specific relations.
|
|
238
|
+
*/
|
|
239
|
+
determineRelation(_other) {
|
|
240
|
+
return CommandRelation.Unrelated;
|
|
241
|
+
}
|
|
203
242
|
/**
|
|
204
243
|
* Create an instance of the given CC without checking whether it is supported.
|
|
205
244
|
* If the CC is implemented, this returns an instance of the given CC which is linked to the given endpoint.
|
|
@@ -461,7 +500,13 @@ class CommandClass {
|
|
|
461
500
|
...valueDB.getValues(this.ccId),
|
|
462
501
|
...valueDB.getAllMetadata(this.ccId)
|
|
463
502
|
];
|
|
464
|
-
const supportedVersion = typeof this.nodeId === "number" && this.nodeId !== import_core.NODE_ID_BROADCAST && this.nodeId !== import_core.NODE_ID_BROADCAST_LR ?
|
|
503
|
+
const supportedVersion = typeof this.nodeId === "number" && this.nodeId !== import_core.NODE_ID_BROADCAST && this.nodeId !== import_core.NODE_ID_BROADCAST_LR ? (
|
|
504
|
+
// On singlecast CCs, use the version the node reported support for,
|
|
505
|
+
ctx.getSupportedCCVersion(this.ccId, this.nodeId, this.endpointIndex)
|
|
506
|
+
) : (
|
|
507
|
+
// on multicast/broadcast, use the highest version we implement
|
|
508
|
+
(0, import_CommandClassDecorators.getImplementedVersion)(this.ccId)
|
|
509
|
+
);
|
|
465
510
|
for (const value of Object.values((0, import_CommandClassDecorators.getCCValues)(this) ?? {})) {
|
|
466
511
|
if (!value || typeof value === "function")
|
|
467
512
|
continue;
|
|
@@ -723,8 +768,11 @@ __name(ccToLogPayload, "ccToLogPayload");
|
|
|
723
768
|
0 && (module.exports = {
|
|
724
769
|
CCRaw,
|
|
725
770
|
CommandClass,
|
|
771
|
+
CommandRelation,
|
|
726
772
|
InvalidCC,
|
|
727
773
|
ccToLogPayload,
|
|
728
|
-
|
|
774
|
+
getCommandRelation,
|
|
775
|
+
getEffectiveCCVersion,
|
|
776
|
+
haveSameDestination
|
|
729
777
|
});
|
|
730
778
|
//# sourceMappingURL=CommandClass.js.map
|