@zwave-js/cc 14.0.0-beta.4 → 14.0.0-beta.5
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 +381 -266
- package/build/cjs/cc/AlarmSensorCC.js.map +3 -3
- package/build/cjs/cc/AssociationCC.js +669 -503
- package/build/cjs/cc/AssociationCC.js.map +3 -3
- package/build/cjs/cc/AssociationGroupInfoCC.js +633 -492
- package/build/cjs/cc/AssociationGroupInfoCC.js.map +3 -3
- package/build/cjs/cc/BarrierOperatorCC.js +595 -429
- package/build/cjs/cc/BarrierOperatorCC.js.map +3 -3
- package/build/cjs/cc/BasicCC.js +354 -260
- package/build/cjs/cc/BasicCC.js.map +3 -3
- package/build/cjs/cc/BatteryCC.js +427 -345
- package/build/cjs/cc/BatteryCC.js.map +3 -3
- package/build/cjs/cc/BinarySensorCC.js +391 -276
- package/build/cjs/cc/BinarySensorCC.js.map +3 -3
- package/build/cjs/cc/BinarySwitchCC.js +347 -253
- package/build/cjs/cc/BinarySwitchCC.js.map +3 -3
- package/build/cjs/cc/CRC16CC.js +160 -85
- package/build/cjs/cc/CRC16CC.js.map +3 -3
- package/build/cjs/cc/CentralSceneCC.js +459 -324
- package/build/cjs/cc/CentralSceneCC.js.map +3 -3
- package/build/cjs/cc/ClimateControlScheduleCC.js +459 -293
- package/build/cjs/cc/ClimateControlScheduleCC.js.map +3 -3
- package/build/cjs/cc/ClockCC.js +254 -150
- package/build/cjs/cc/ClockCC.js.map +3 -3
- package/build/cjs/cc/ColorSwitchCC.js +758 -610
- package/build/cjs/cc/ColorSwitchCC.js.map +3 -3
- package/build/cjs/cc/ConfigurationCC.js +1700 -1453
- package/build/cjs/cc/ConfigurationCC.js.map +3 -3
- package/build/cjs/cc/DeviceResetLocallyCC.js +125 -49
- package/build/cjs/cc/DeviceResetLocallyCC.js.map +3 -3
- package/build/cjs/cc/DoorLockCC.js +904 -777
- package/build/cjs/cc/DoorLockCC.js.map +3 -3
- package/build/cjs/cc/DoorLockLoggingCC.js +321 -206
- package/build/cjs/cc/DoorLockLoggingCC.js.map +3 -3
- package/build/cjs/cc/EnergyProductionCC.js +249 -160
- package/build/cjs/cc/EnergyProductionCC.js.map +3 -3
- package/build/cjs/cc/EntryControlCC.js +619 -458
- package/build/cjs/cc/EntryControlCC.js.map +3 -3
- package/build/cjs/cc/FirmwareUpdateMetaDataCC.js +898 -698
- package/build/cjs/cc/FirmwareUpdateMetaDataCC.js.map +3 -3
- package/build/cjs/cc/HailCC.js +57 -11
- package/build/cjs/cc/HailCC.js.map +2 -2
- package/build/cjs/cc/HumidityControlModeCC.js +359 -233
- package/build/cjs/cc/HumidityControlModeCC.js.map +3 -3
- package/build/cjs/cc/HumidityControlOperatingStateCC.js +189 -103
- package/build/cjs/cc/HumidityControlOperatingStateCC.js.map +3 -3
- package/build/cjs/cc/HumidityControlSetpointCC.js +682 -495
- package/build/cjs/cc/HumidityControlSetpointCC.js.map +3 -3
- package/build/cjs/cc/InclusionControllerCC.js +205 -114
- package/build/cjs/cc/InclusionControllerCC.js.map +3 -3
- package/build/cjs/cc/IndicatorCC.js +897 -736
- package/build/cjs/cc/IndicatorCC.js.map +3 -3
- package/build/cjs/cc/IrrigationCC.js +1651 -1405
- package/build/cjs/cc/IrrigationCC.js.map +3 -3
- package/build/cjs/cc/LanguageCC.js +268 -171
- package/build/cjs/cc/LanguageCC.js.map +3 -3
- package/build/cjs/cc/LockCC.js +254 -154
- package/build/cjs/cc/LockCC.js.map +3 -3
- package/build/cjs/cc/ManufacturerProprietaryCC.js +189 -129
- package/build/cjs/cc/ManufacturerProprietaryCC.js.map +2 -2
- package/build/cjs/cc/ManufacturerSpecificCC.js +319 -213
- package/build/cjs/cc/ManufacturerSpecificCC.js.map +3 -3
- package/build/cjs/cc/MeterCC.js +827 -707
- package/build/cjs/cc/MeterCC.js.map +3 -3
- package/build/cjs/cc/MultiChannelAssociationCC.js +612 -478
- package/build/cjs/cc/MultiChannelAssociationCC.js.map +3 -3
- package/build/cjs/cc/MultiChannelCC.js +1037 -819
- package/build/cjs/cc/MultiChannelCC.js.map +3 -3
- package/build/cjs/cc/MultiCommandCC.js +172 -97
- package/build/cjs/cc/MultiCommandCC.js.map +3 -3
- package/build/cjs/cc/MultilevelSensorCC.js +589 -449
- package/build/cjs/cc/MultilevelSensorCC.js.map +3 -3
- package/build/cjs/cc/MultilevelSwitchCC.js +587 -439
- package/build/cjs/cc/MultilevelSwitchCC.js.map +3 -3
- package/build/cjs/cc/NoOperationCC.js +89 -27
- package/build/cjs/cc/NoOperationCC.js.map +2 -2
- package/build/cjs/cc/NodeNamingCC.js +417 -277
- package/build/cjs/cc/NodeNamingCC.js.map +3 -3
- package/build/cjs/cc/NotificationCC.js +972 -818
- package/build/cjs/cc/NotificationCC.js.map +3 -3
- package/build/cjs/cc/PowerlevelCC.js +450 -303
- package/build/cjs/cc/PowerlevelCC.js.map +3 -3
- package/build/cjs/cc/ProtectionCC.js +686 -494
- package/build/cjs/cc/ProtectionCC.js.map +3 -3
- package/build/cjs/cc/SceneActivationCC.js +165 -97
- package/build/cjs/cc/SceneActivationCC.js.map +3 -3
- package/build/cjs/cc/SceneActuatorConfigurationCC.js +346 -243
- package/build/cjs/cc/SceneActuatorConfigurationCC.js.map +3 -3
- package/build/cjs/cc/SceneControllerConfigurationCC.js +401 -298
- package/build/cjs/cc/SceneControllerConfigurationCC.js.map +3 -3
- package/build/cjs/cc/ScheduleEntryLockCC.js +1552 -1272
- package/build/cjs/cc/ScheduleEntryLockCC.js.map +3 -3
- package/build/cjs/cc/Security2CC.js +1483 -1219
- package/build/cjs/cc/Security2CC.js.map +3 -3
- package/build/cjs/cc/SecurityCC.js +839 -619
- package/build/cjs/cc/SecurityCC.js.map +3 -3
- package/build/cjs/cc/SoundSwitchCC.js +707 -515
- package/build/cjs/cc/SoundSwitchCC.js.map +3 -3
- package/build/cjs/cc/SupervisionCC.js +327 -237
- package/build/cjs/cc/SupervisionCC.js.map +3 -3
- package/build/cjs/cc/ThermostatFanModeCC.js +386 -263
- package/build/cjs/cc/ThermostatFanModeCC.js.map +3 -3
- package/build/cjs/cc/ThermostatFanStateCC.js +192 -106
- package/build/cjs/cc/ThermostatFanStateCC.js.map +3 -3
- package/build/cjs/cc/ThermostatModeCC.js +425 -302
- package/build/cjs/cc/ThermostatModeCC.js.map +3 -3
- package/build/cjs/cc/ThermostatOperatingStateCC.js +188 -102
- package/build/cjs/cc/ThermostatOperatingStateCC.js.map +3 -3
- package/build/cjs/cc/ThermostatSetbackCC.js +277 -173
- package/build/cjs/cc/ThermostatSetbackCC.js.map +3 -3
- package/build/cjs/cc/ThermostatSetpointCC.js +645 -491
- package/build/cjs/cc/ThermostatSetpointCC.js.map +3 -3
- package/build/cjs/cc/TimeCC.js +515 -353
- package/build/cjs/cc/TimeCC.js.map +3 -3
- package/build/cjs/cc/TimeParametersCC.js +302 -202
- package/build/cjs/cc/TimeParametersCC.js.map +3 -3
- package/build/cjs/cc/TransportServiceCC.js +433 -315
- package/build/cjs/cc/TransportServiceCC.js.map +3 -3
- package/build/cjs/cc/UserCodeCC.js +1385 -1102
- package/build/cjs/cc/UserCodeCC.js.map +3 -3
- package/build/cjs/cc/VersionCC.js +696 -562
- package/build/cjs/cc/VersionCC.js.map +3 -3
- package/build/cjs/cc/WakeUpCC.js +499 -346
- package/build/cjs/cc/WakeUpCC.js.map +3 -3
- package/build/cjs/cc/WindowCoveringCC.js +626 -478
- package/build/cjs/cc/WindowCoveringCC.js.map +3 -3
- package/build/cjs/cc/ZWaveLongRangeCC.js +57 -10
- package/build/cjs/cc/ZWaveLongRangeCC.js.map +2 -2
- package/build/cjs/cc/ZWavePlusCC.js +233 -159
- package/build/cjs/cc/ZWavePlusCC.js.map +3 -3
- package/build/cjs/cc/ZWaveProtocolCC.js +1515 -948
- package/build/cjs/cc/ZWaveProtocolCC.js.map +3 -3
- package/build/cjs/cc/manufacturerProprietary/Decorators.d.ts +4 -4
- package/build/cjs/cc/manufacturerProprietary/Decorators.js.map +1 -1
- package/build/cjs/cc/manufacturerProprietary/FibaroCC.js +395 -274
- package/build/cjs/cc/manufacturerProprietary/FibaroCC.js.map +3 -3
- package/build/cjs/lib/CommandClassDecorators.d.ts +11 -15
- package/build/cjs/lib/CommandClassDecorators.js +19 -20
- package/build/cjs/lib/CommandClassDecorators.js.map +2 -2
- package/build/cjs/lib/Security2/Extension.d.ts +1 -1
- package/build/cjs/lib/Security2/Extension.js +217 -126
- package/build/cjs/lib/Security2/Extension.js.map +3 -3
- package/build/esm/cc/AlarmSensorCC.d.ts.map +1 -1
- package/build/esm/cc/AlarmSensorCC.js +389 -291
- 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 +678 -537
- 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 +659 -539
- 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 +634 -493
- package/build/esm/cc/BarrierOperatorCC.js.map +1 -1
- package/build/esm/cc/BasicCC.d.ts.map +1 -1
- package/build/esm/cc/BasicCC.js +380 -302
- package/build/esm/cc/BasicCC.js.map +1 -1
- package/build/esm/cc/BatteryCC.d.ts.map +1 -1
- package/build/esm/cc/BatteryCC.js +449 -384
- 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 +395 -297
- package/build/esm/cc/BinarySensorCC.js.map +1 -1
- package/build/esm/cc/BinarySwitchCC.d.ts.map +1 -1
- package/build/esm/cc/BinarySwitchCC.js +353 -274
- package/build/esm/cc/BinarySwitchCC.js.map +1 -1
- package/build/esm/cc/CRC16CC.js +162 -98
- 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 +465 -351
- 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 +454 -313
- package/build/esm/cc/ClimateControlScheduleCC.js.map +1 -1
- package/build/esm/cc/ClockCC.js +248 -159
- 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 +802 -677
- package/build/esm/cc/ColorSwitchCC.js.map +1 -1
- package/build/esm/cc/ConfigurationCC.js +1899 -1687
- package/build/esm/cc/ConfigurationCC.js.map +1 -1
- package/build/esm/cc/DeviceResetLocallyCC.js +124 -59
- 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 +951 -849
- package/build/esm/cc/DoorLockCC.js.map +1 -1
- package/build/esm/cc/DoorLockLoggingCC.d.ts.map +1 -1
- package/build/esm/cc/DoorLockLoggingCC.js +316 -218
- package/build/esm/cc/DoorLockLoggingCC.js.map +1 -1
- package/build/esm/cc/EnergyProductionCC.js +240 -164
- package/build/esm/cc/EnergyProductionCC.js.map +1 -1
- package/build/esm/cc/EntryControlCC.d.ts.map +1 -1
- package/build/esm/cc/EntryControlCC.js +629 -493
- 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 +938 -769
- package/build/esm/cc/FirmwareUpdateMetaDataCC.js.map +1 -1
- package/build/esm/cc/HailCC.js +51 -12
- package/build/esm/cc/HailCC.js.map +1 -1
- package/build/esm/cc/HumidityControlModeCC.d.ts.map +1 -1
- package/build/esm/cc/HumidityControlModeCC.js +357 -250
- package/build/esm/cc/HumidityControlModeCC.js.map +1 -1
- package/build/esm/cc/HumidityControlOperatingStateCC.d.ts.map +1 -1
- package/build/esm/cc/HumidityControlOperatingStateCC.js +182 -109
- package/build/esm/cc/HumidityControlOperatingStateCC.js.map +1 -1
- package/build/esm/cc/HumidityControlSetpointCC.d.ts.map +1 -1
- package/build/esm/cc/HumidityControlSetpointCC.js +706 -546
- package/build/esm/cc/HumidityControlSetpointCC.js.map +1 -1
- package/build/esm/cc/InclusionControllerCC.js +197 -119
- package/build/esm/cc/InclusionControllerCC.js.map +1 -1
- package/build/esm/cc/IndicatorCC.js +973 -835
- 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 +1697 -1496
- package/build/esm/cc/IrrigationCC.js.map +1 -1
- package/build/esm/cc/LanguageCC.d.ts.map +1 -1
- package/build/esm/cc/LanguageCC.js +266 -184
- package/build/esm/cc/LanguageCC.js.map +1 -1
- package/build/esm/cc/LockCC.d.ts.map +1 -1
- package/build/esm/cc/LockCC.js +247 -162
- package/build/esm/cc/LockCC.js.map +1 -1
- package/build/esm/cc/ManufacturerProprietaryCC.js +192 -141
- package/build/esm/cc/ManufacturerProprietaryCC.js.map +1 -1
- package/build/esm/cc/ManufacturerSpecificCC.d.ts.map +1 -1
- package/build/esm/cc/ManufacturerSpecificCC.js +312 -223
- 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 +896 -795
- 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 +631 -518
- package/build/esm/cc/MultiChannelAssociationCC.js.map +1 -1
- package/build/esm/cc/MultiChannelCC.d.ts.map +1 -1
- package/build/esm/cc/MultiChannelCC.js +1106 -921
- package/build/esm/cc/MultiChannelCC.js.map +1 -1
- package/build/esm/cc/MultiCommandCC.js +166 -102
- package/build/esm/cc/MultiCommandCC.js.map +1 -1
- package/build/esm/cc/MultilevelSensorCC.d.ts.map +1 -1
- package/build/esm/cc/MultilevelSensorCC.js +616 -497
- package/build/esm/cc/MultilevelSensorCC.js.map +1 -1
- package/build/esm/cc/MultilevelSwitchCC.d.ts.map +1 -1
- package/build/esm/cc/MultilevelSwitchCC.js +621 -496
- package/build/esm/cc/MultilevelSwitchCC.js.map +1 -1
- package/build/esm/cc/NoOperationCC.js +82 -29
- package/build/esm/cc/NoOperationCC.js.map +1 -1
- package/build/esm/cc/NodeNamingCC.d.ts.map +1 -1
- package/build/esm/cc/NodeNamingCC.js +413 -294
- package/build/esm/cc/NodeNamingCC.js.map +1 -1
- package/build/esm/cc/NotificationCC.d.ts.map +1 -1
- package/build/esm/cc/NotificationCC.js +1097 -966
- package/build/esm/cc/NotificationCC.js.map +1 -1
- package/build/esm/cc/PowerlevelCC.js +437 -311
- package/build/esm/cc/PowerlevelCC.js.map +1 -1
- package/build/esm/cc/ProtectionCC.d.ts.map +1 -1
- package/build/esm/cc/ProtectionCC.js +704 -543
- package/build/esm/cc/ProtectionCC.js.map +1 -1
- package/build/esm/cc/SceneActivationCC.d.ts.map +1 -1
- package/build/esm/cc/SceneActivationCC.js +157 -100
- package/build/esm/cc/SceneActivationCC.js.map +1 -1
- package/build/esm/cc/SceneActuatorConfigurationCC.js +357 -269
- package/build/esm/cc/SceneActuatorConfigurationCC.js.map +1 -1
- package/build/esm/cc/SceneControllerConfigurationCC.js +434 -346
- 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 +1596 -1357
- package/build/esm/cc/ScheduleEntryLockCC.js.map +1 -1
- package/build/esm/cc/Security2CC.js +1633 -1406
- package/build/esm/cc/Security2CC.js.map +1 -1
- package/build/esm/cc/SecurityCC.js +876 -687
- package/build/esm/cc/SecurityCC.js.map +1 -1
- package/build/esm/cc/SoundSwitchCC.d.ts.map +1 -1
- package/build/esm/cc/SoundSwitchCC.js +689 -526
- package/build/esm/cc/SoundSwitchCC.js.map +1 -1
- package/build/esm/cc/SupervisionCC.js +349 -272
- 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 +388 -284
- package/build/esm/cc/ThermostatFanModeCC.js.map +1 -1
- package/build/esm/cc/ThermostatFanStateCC.d.ts.map +1 -1
- package/build/esm/cc/ThermostatFanStateCC.js +184 -111
- package/build/esm/cc/ThermostatFanStateCC.js.map +1 -1
- package/build/esm/cc/ThermostatModeCC.d.ts.map +1 -1
- package/build/esm/cc/ThermostatModeCC.js +435 -331
- 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 +180 -107
- package/build/esm/cc/ThermostatOperatingStateCC.js.map +1 -1
- package/build/esm/cc/ThermostatSetbackCC.js +274 -185
- package/build/esm/cc/ThermostatSetbackCC.js.map +1 -1
- package/build/esm/cc/ThermostatSetpointCC.d.ts.map +1 -1
- package/build/esm/cc/ThermostatSetpointCC.js +674 -543
- package/build/esm/cc/ThermostatSetpointCC.js.map +1 -1
- package/build/esm/cc/TimeCC.js +499 -360
- package/build/esm/cc/TimeCC.js.map +1 -1
- package/build/esm/cc/TimeParametersCC.d.ts.map +1 -1
- package/build/esm/cc/TimeParametersCC.js +296 -211
- package/build/esm/cc/TimeParametersCC.js.map +1 -1
- package/build/esm/cc/TransportServiceCC.js +464 -363
- 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 +1443 -1205
- package/build/esm/cc/UserCodeCC.js.map +1 -1
- package/build/esm/cc/VersionCC.d.ts.map +1 -1
- package/build/esm/cc/VersionCC.js +744 -635
- package/build/esm/cc/VersionCC.js.map +1 -1
- package/build/esm/cc/WakeUpCC.d.ts.map +1 -1
- package/build/esm/cc/WakeUpCC.js +494 -364
- package/build/esm/cc/WakeUpCC.js.map +1 -1
- package/build/esm/cc/WindowCoveringCC.d.ts.map +1 -1
- package/build/esm/cc/WindowCoveringCC.js +655 -530
- package/build/esm/cc/WindowCoveringCC.js.map +1 -1
- package/build/esm/cc/ZWaveLongRangeCC.js +51 -11
- package/build/esm/cc/ZWaveLongRangeCC.js.map +1 -1
- package/build/esm/cc/ZWavePlusCC.d.ts.map +1 -1
- package/build/esm/cc/ZWavePlusCC.js +223 -162
- package/build/esm/cc/ZWavePlusCC.js.map +1 -1
- package/build/esm/cc/ZWaveProtocolCC.js +1443 -953
- package/build/esm/cc/ZWaveProtocolCC.js.map +1 -1
- package/build/esm/cc/manufacturerProprietary/Decorators.d.ts +4 -4
- package/build/esm/cc/manufacturerProprietary/Decorators.d.ts.map +1 -1
- package/build/esm/cc/manufacturerProprietary/FibaroCC.js +390 -286
- package/build/esm/cc/manufacturerProprietary/FibaroCC.js.map +1 -1
- package/build/esm/lib/CommandClassDecorators.d.ts +11 -15
- package/build/esm/lib/CommandClassDecorators.d.ts.map +1 -1
- package/build/esm/lib/CommandClassDecorators.js +24 -24
- package/build/esm/lib/CommandClassDecorators.js.map +1 -1
- package/build/esm/lib/Security2/Extension.d.ts +1 -1
- package/build/esm/lib/Security2/Extension.d.ts.map +1 -1
- package/build/esm/lib/Security2/Extension.js +207 -123
- package/build/esm/lib/Security2/Extension.js.map +1 -1
- package/package.json +6 -6
package/build/esm/cc/MeterCC.js
CHANGED
|
@@ -1,10 +1,37 @@
|
|
|
1
|
-
var
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
var __esDecorate = (this && this.__esDecorate) || function (ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
|
|
2
|
+
function accept(f) { if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected"); return f; }
|
|
3
|
+
var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value";
|
|
4
|
+
var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null;
|
|
5
|
+
var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});
|
|
6
|
+
var _, done = false;
|
|
7
|
+
for (var i = decorators.length - 1; i >= 0; i--) {
|
|
8
|
+
var context = {};
|
|
9
|
+
for (var p in contextIn) context[p] = p === "access" ? {} : contextIn[p];
|
|
10
|
+
for (var p in contextIn.access) context.access[p] = contextIn.access[p];
|
|
11
|
+
context.addInitializer = function (f) { if (done) throw new TypeError("Cannot add initializers after decoration has completed"); extraInitializers.push(accept(f || null)); };
|
|
12
|
+
var result = (0, decorators[i])(kind === "accessor" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);
|
|
13
|
+
if (kind === "accessor") {
|
|
14
|
+
if (result === void 0) continue;
|
|
15
|
+
if (result === null || typeof result !== "object") throw new TypeError("Object expected");
|
|
16
|
+
if (_ = accept(result.get)) descriptor.get = _;
|
|
17
|
+
if (_ = accept(result.set)) descriptor.set = _;
|
|
18
|
+
if (_ = accept(result.init)) initializers.unshift(_);
|
|
19
|
+
}
|
|
20
|
+
else if (_ = accept(result)) {
|
|
21
|
+
if (kind === "field") initializers.unshift(_);
|
|
22
|
+
else descriptor[key] = _;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
if (target) Object.defineProperty(target, contextIn.name, descriptor);
|
|
26
|
+
done = true;
|
|
27
|
+
};
|
|
28
|
+
var __runInitializers = (this && this.__runInitializers) || function (thisArg, initializers, value) {
|
|
29
|
+
var useValue = arguments.length > 2;
|
|
30
|
+
for (var i = 0; i < initializers.length; i++) {
|
|
31
|
+
value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);
|
|
32
|
+
}
|
|
33
|
+
return useValue ? value : void 0;
|
|
6
34
|
};
|
|
7
|
-
var MeterCCReport_1, MeterCCGet_1, MeterCCSupportedReport_1, MeterCCReset_1;
|
|
8
35
|
function __assertType(argName, typeName, boundHasError) {
|
|
9
36
|
const { ZWaveError, ZWaveErrorCodes } = require("@zwave-js/core");
|
|
10
37
|
if (boundHasError()) {
|
|
@@ -289,7 +316,7 @@ import { Bytes } from "@zwave-js/shared/safe";
|
|
|
289
316
|
import { getEnumMemberName, num2hex, pick, } from "@zwave-js/shared/safe";
|
|
290
317
|
import { CCAPI, POLL_VALUE, PhysicalCCAPI, SET_VALUE, SET_VALUE_HOOKS, throwMissingPropertyKey, throwUnsupportedProperty, throwUnsupportedPropertyKey, throwWrongValueType, } from "../lib/API.js";
|
|
291
318
|
import { CommandClass, getEffectiveCCVersion, } from "../lib/CommandClass.js";
|
|
292
|
-
import { API, CCCommand,
|
|
319
|
+
import { API, CCCommand, ccValueProperty, ccValues, commandClass, expectedCCResponse, getCommandClass, implementedVersion, useSupervision, } from "../lib/CommandClassDecorators.js";
|
|
293
320
|
import { V } from "../lib/Values.js";
|
|
294
321
|
import { MeterCommand, RateType } from "../lib/_Types.js";
|
|
295
322
|
export const MeterCCValues = Object.freeze({
|
|
@@ -442,563 +469,600 @@ export function isAccumulatedValue(meterType, scale) {
|
|
|
442
469
|
}
|
|
443
470
|
return false;
|
|
444
471
|
}
|
|
445
|
-
let MeterCCAPI =
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
472
|
+
let MeterCCAPI = (() => {
|
|
473
|
+
let _classDecorators = [API(CommandClasses.Meter)];
|
|
474
|
+
let _classDescriptor;
|
|
475
|
+
let _classExtraInitializers = [];
|
|
476
|
+
let _classThis;
|
|
477
|
+
let _classSuper = PhysicalCCAPI;
|
|
478
|
+
var MeterCCAPI = class extends _classSuper {
|
|
479
|
+
static { _classThis = this; }
|
|
480
|
+
static {
|
|
481
|
+
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
|
|
482
|
+
__esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
|
|
483
|
+
MeterCCAPI = _classThis = _classDescriptor.value;
|
|
484
|
+
if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
485
|
+
__runInitializers(_classThis, _classExtraInitializers);
|
|
486
|
+
}
|
|
487
|
+
supportsCommand(cmd) {
|
|
488
|
+
switch (cmd) {
|
|
489
|
+
case MeterCommand.Get:
|
|
490
|
+
case MeterCommand.Report:
|
|
491
|
+
return true; // This is mandatory
|
|
492
|
+
case MeterCommand.SupportedGet:
|
|
493
|
+
case MeterCommand.SupportedReport:
|
|
494
|
+
return this.version >= 2;
|
|
495
|
+
case MeterCommand.Reset: {
|
|
496
|
+
const ret = this.tryGetValueDB()?.getValue({
|
|
497
|
+
commandClass: getCommandClass(this),
|
|
498
|
+
endpoint: this.endpoint.index,
|
|
499
|
+
property: "supportsReset",
|
|
500
|
+
});
|
|
501
|
+
return ret === true;
|
|
502
|
+
}
|
|
461
503
|
}
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
504
|
+
return super.supportsCommand(cmd);
|
|
505
|
+
}
|
|
506
|
+
get [POLL_VALUE]() {
|
|
507
|
+
return async function ({ property, propertyKey }) {
|
|
508
|
+
switch (property) {
|
|
509
|
+
case "value":
|
|
510
|
+
case "previousValue":
|
|
511
|
+
case "deltaTime": {
|
|
512
|
+
if (propertyKey == undefined) {
|
|
513
|
+
throwMissingPropertyKey(this.ccId, property);
|
|
514
|
+
}
|
|
515
|
+
else if (typeof propertyKey !== "number") {
|
|
516
|
+
throwUnsupportedPropertyKey(this.ccId, property, propertyKey);
|
|
517
|
+
}
|
|
518
|
+
const { rateType, scale } = splitPropertyKey(propertyKey);
|
|
519
|
+
return (await this.get({
|
|
520
|
+
rateType,
|
|
521
|
+
scale,
|
|
522
|
+
}))?.[property];
|
|
476
523
|
}
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
rateType,
|
|
480
|
-
scale,
|
|
481
|
-
}))?.[property];
|
|
524
|
+
default:
|
|
525
|
+
throwUnsupportedProperty(this.ccId, property);
|
|
482
526
|
}
|
|
483
|
-
default:
|
|
484
|
-
throwUnsupportedProperty(this.ccId, property);
|
|
485
|
-
}
|
|
486
|
-
};
|
|
487
|
-
}
|
|
488
|
-
async get(options) {
|
|
489
|
-
__assertType("options", "(optional) MeterCCGetOptions", __assertType__optional_MeterCCGetOptions.bind(void 0, options));
|
|
490
|
-
this.assertSupportsCommand(MeterCommand, MeterCommand.Get);
|
|
491
|
-
const cc = new MeterCCGet({
|
|
492
|
-
nodeId: this.endpoint.nodeId,
|
|
493
|
-
endpointIndex: this.endpoint.index,
|
|
494
|
-
...options,
|
|
495
|
-
});
|
|
496
|
-
const response = await this.host.sendCommand(cc, this.commandOptions);
|
|
497
|
-
if (response) {
|
|
498
|
-
return {
|
|
499
|
-
type: response.type,
|
|
500
|
-
scale: getMeterScale(response.type, response.scale)
|
|
501
|
-
?? getUnknownMeterScale(response.scale),
|
|
502
|
-
...pick(response, [
|
|
503
|
-
"value",
|
|
504
|
-
"previousValue",
|
|
505
|
-
"rateType",
|
|
506
|
-
"deltaTime",
|
|
507
|
-
]),
|
|
508
527
|
};
|
|
509
528
|
}
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
const ret = [];
|
|
532
|
-
for (const rateType of rateTypes) {
|
|
533
|
-
for (const scale of supportedScales) {
|
|
534
|
-
// Skip non-accumulated values if requested
|
|
535
|
-
if (accumulatedOnly
|
|
536
|
-
&& meterType != undefined
|
|
537
|
-
&& !isAccumulatedValue(meterType, scale)) {
|
|
538
|
-
continue;
|
|
539
|
-
}
|
|
540
|
-
const response = await this.get({
|
|
541
|
-
scale,
|
|
542
|
-
rateType,
|
|
543
|
-
});
|
|
544
|
-
if (response)
|
|
545
|
-
ret.push(response);
|
|
546
|
-
}
|
|
529
|
+
async get(options) {
|
|
530
|
+
__assertType("options", "(optional) MeterCCGetOptions", __assertType__optional_MeterCCGetOptions.bind(void 0, options));
|
|
531
|
+
this.assertSupportsCommand(MeterCommand, MeterCommand.Get);
|
|
532
|
+
const cc = new MeterCCGet({
|
|
533
|
+
nodeId: this.endpoint.nodeId,
|
|
534
|
+
endpointIndex: this.endpoint.index,
|
|
535
|
+
...options,
|
|
536
|
+
});
|
|
537
|
+
const response = await this.host.sendCommand(cc, this.commandOptions);
|
|
538
|
+
if (response) {
|
|
539
|
+
return {
|
|
540
|
+
type: response.type,
|
|
541
|
+
scale: getMeterScale(response.type, response.scale)
|
|
542
|
+
?? getUnknownMeterScale(response.scale),
|
|
543
|
+
...pick(response, [
|
|
544
|
+
"value",
|
|
545
|
+
"previousValue",
|
|
546
|
+
"rateType",
|
|
547
|
+
"deltaTime",
|
|
548
|
+
]),
|
|
549
|
+
};
|
|
547
550
|
}
|
|
548
|
-
return ret;
|
|
549
551
|
}
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
nodeId: this.endpoint.nodeId,
|
|
560
|
-
endpointIndex: this.endpoint.index,
|
|
561
|
-
});
|
|
562
|
-
const response = await this.host.sendCommand(cc, this.commandOptions);
|
|
563
|
-
if (response) {
|
|
564
|
-
return pick(response, [
|
|
565
|
-
"type",
|
|
566
|
-
"supportsReset",
|
|
567
|
-
"supportedScales",
|
|
568
|
-
"supportedRateTypes",
|
|
569
|
-
]);
|
|
552
|
+
async sendReport(options) {
|
|
553
|
+
__assertType("options", "MeterCCReportOptions", __assertType__MeterCCReportOptions.bind(void 0, options));
|
|
554
|
+
this.assertSupportsCommand(MeterCommand, MeterCommand.Report);
|
|
555
|
+
const cc = new MeterCCReport({
|
|
556
|
+
nodeId: this.endpoint.nodeId,
|
|
557
|
+
endpointIndex: this.endpoint.index,
|
|
558
|
+
...options,
|
|
559
|
+
});
|
|
560
|
+
return this.host.sendCommand(cc, this.commandOptions);
|
|
570
561
|
}
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
562
|
+
async getAll(accumulatedOnly = false) {
|
|
563
|
+
__assertType("accumulatedOnly", "(optional) boolean", __assertType__optional_boolean.bind(void 0, accumulatedOnly));
|
|
564
|
+
const valueDB = this.tryGetValueDB();
|
|
565
|
+
if (this.version >= 2) {
|
|
566
|
+
const meterType = valueDB?.getValue(MeterCCValues.type.endpoint(this.endpoint.index));
|
|
567
|
+
const supportedScales = valueDB?.getValue(MeterCCValues.supportedScales.endpoint(this.endpoint.index)) ?? [];
|
|
568
|
+
const supportedRateTypes = valueDB?.getValue(MeterCCValues.supportedRateTypes.endpoint(this.endpoint.index)) ?? [];
|
|
569
|
+
const rateTypes = supportedRateTypes.length
|
|
570
|
+
? supportedRateTypes
|
|
571
|
+
: [undefined];
|
|
572
|
+
const ret = [];
|
|
573
|
+
for (const rateType of rateTypes) {
|
|
574
|
+
for (const scale of supportedScales) {
|
|
575
|
+
// Skip non-accumulated values if requested
|
|
576
|
+
if (accumulatedOnly
|
|
577
|
+
&& meterType != undefined
|
|
578
|
+
&& !isAccumulatedValue(meterType, scale)) {
|
|
579
|
+
continue;
|
|
580
|
+
}
|
|
581
|
+
const response = await this.get({
|
|
582
|
+
scale,
|
|
583
|
+
rateType,
|
|
584
|
+
});
|
|
585
|
+
if (response)
|
|
586
|
+
ret.push(response);
|
|
587
|
+
}
|
|
588
|
+
}
|
|
589
|
+
return ret;
|
|
596
590
|
}
|
|
597
|
-
else
|
|
598
|
-
|
|
599
|
-
|
|
591
|
+
else {
|
|
592
|
+
const response = await this.get();
|
|
593
|
+
return response ? [response] : [];
|
|
600
594
|
}
|
|
601
|
-
|
|
602
|
-
|
|
595
|
+
}
|
|
596
|
+
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
|
|
597
|
+
async getSupported() {
|
|
598
|
+
this.assertSupportsCommand(MeterCommand, MeterCommand.SupportedGet);
|
|
599
|
+
const cc = new MeterCCSupportedGet({
|
|
600
|
+
nodeId: this.endpoint.nodeId,
|
|
601
|
+
endpointIndex: this.endpoint.index,
|
|
602
|
+
});
|
|
603
|
+
const response = await this.host.sendCommand(cc, this.commandOptions);
|
|
604
|
+
if (response) {
|
|
605
|
+
return pick(response, [
|
|
606
|
+
"type",
|
|
607
|
+
"supportsReset",
|
|
608
|
+
"supportedScales",
|
|
609
|
+
"supportedRateTypes",
|
|
610
|
+
]);
|
|
603
611
|
}
|
|
612
|
+
}
|
|
613
|
+
async sendSupportedReport(options) {
|
|
614
|
+
__assertType("options", "MeterCCSupportedReportOptions", __assertType__MeterCCSupportedReportOptions.bind(void 0, options));
|
|
615
|
+
this.assertSupportsCommand(MeterCommand, MeterCommand.SupportedReport);
|
|
616
|
+
const cc = new MeterCCSupportedReport({
|
|
617
|
+
nodeId: this.endpoint.nodeId,
|
|
618
|
+
endpointIndex: this.endpoint.index,
|
|
619
|
+
...options,
|
|
620
|
+
});
|
|
621
|
+
await this.host.sendCommand(cc, this.commandOptions);
|
|
622
|
+
}
|
|
623
|
+
async reset(options) {
|
|
624
|
+
__assertType("options", "(optional) MeterCCResetOptions", __assertType__optional_MeterCCResetOptions.bind(void 0, options));
|
|
625
|
+
this.assertSupportsCommand(MeterCommand, MeterCommand.Reset);
|
|
626
|
+
const cc = new MeterCCReset({
|
|
627
|
+
nodeId: this.endpoint.nodeId,
|
|
628
|
+
endpointIndex: this.endpoint.index,
|
|
629
|
+
...options,
|
|
630
|
+
});
|
|
631
|
+
return this.host.sendCommand(cc, this.commandOptions);
|
|
632
|
+
}
|
|
633
|
+
get [SET_VALUE]() {
|
|
634
|
+
return async function ({ property, propertyKey }, value) {
|
|
635
|
+
if (property !== "reset") {
|
|
636
|
+
throwUnsupportedProperty(this.ccId, property);
|
|
637
|
+
}
|
|
638
|
+
else if (propertyKey != undefined
|
|
639
|
+
&& typeof propertyKey !== "number") {
|
|
640
|
+
throwUnsupportedPropertyKey(this.ccId, property, propertyKey);
|
|
641
|
+
}
|
|
642
|
+
else if (value !== true) {
|
|
643
|
+
throwWrongValueType(this.ccId, property, "true", value === false ? "false" : typeof value);
|
|
644
|
+
}
|
|
645
|
+
if (typeof propertyKey === "number") {
|
|
646
|
+
const { meterType, scale, rateType } = splitPropertyKey(propertyKey);
|
|
647
|
+
return this.reset({
|
|
648
|
+
type: meterType,
|
|
649
|
+
scale,
|
|
650
|
+
rateType,
|
|
651
|
+
targetValue: 0,
|
|
652
|
+
});
|
|
653
|
+
}
|
|
654
|
+
else {
|
|
655
|
+
return this.reset();
|
|
656
|
+
}
|
|
657
|
+
return undefined;
|
|
658
|
+
};
|
|
659
|
+
}
|
|
660
|
+
[SET_VALUE_HOOKS] = ({ property, propertyKey }, _value, _options) => {
|
|
661
|
+
if (property !== "reset")
|
|
662
|
+
return;
|
|
604
663
|
if (typeof propertyKey === "number") {
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
664
|
+
// Reset single
|
|
665
|
+
const { meterType, rateType, scale } = splitPropertyKey(propertyKey);
|
|
666
|
+
const readingValueId = MeterCCValues.value(meterType, rateType, scale).endpoint(this.endpoint.index);
|
|
667
|
+
return {
|
|
668
|
+
optimisticallyUpdateRelatedValues: (supervisedAndSuccessful) => {
|
|
669
|
+
if (!supervisedAndSuccessful)
|
|
670
|
+
return;
|
|
671
|
+
// After resetting a single reading with supervision, store zero
|
|
672
|
+
// in the corresponding value
|
|
673
|
+
const valueDB = this.tryGetValueDB();
|
|
674
|
+
if (!valueDB)
|
|
675
|
+
return;
|
|
676
|
+
if (isAccumulatedValue(meterType, scale)) {
|
|
677
|
+
valueDB.setValue({
|
|
678
|
+
commandClass: this.ccId,
|
|
679
|
+
endpoint: this.endpoint.index,
|
|
680
|
+
property,
|
|
681
|
+
propertyKey,
|
|
682
|
+
}, 0);
|
|
683
|
+
}
|
|
684
|
+
},
|
|
685
|
+
verifyChanges: () => {
|
|
686
|
+
this.schedulePoll(readingValueId, 0, { transition: "fast" });
|
|
687
|
+
},
|
|
688
|
+
};
|
|
612
689
|
}
|
|
613
690
|
else {
|
|
614
|
-
|
|
691
|
+
// Reset all
|
|
692
|
+
const valueDB = this.tryGetValueDB();
|
|
693
|
+
if (!valueDB)
|
|
694
|
+
return;
|
|
695
|
+
const accumulatedValues = valueDB.findValues((vid) => vid.commandClass === this.ccId
|
|
696
|
+
&& vid.endpoint === this.endpoint.index
|
|
697
|
+
&& MeterCCValues.value.is(vid)).filter(({ propertyKey }) => {
|
|
698
|
+
if (typeof propertyKey !== "number")
|
|
699
|
+
return false;
|
|
700
|
+
const { meterType, scale } = splitPropertyKey(propertyKey);
|
|
701
|
+
return isAccumulatedValue(meterType, scale);
|
|
702
|
+
});
|
|
703
|
+
return {
|
|
704
|
+
optimisticallyUpdateRelatedValues: (supervisedAndSuccessful) => {
|
|
705
|
+
if (!supervisedAndSuccessful)
|
|
706
|
+
return;
|
|
707
|
+
// After setting the reset all value with supervision,
|
|
708
|
+
// reset all accumulated values, since we know they are now zero.
|
|
709
|
+
for (const value of accumulatedValues) {
|
|
710
|
+
valueDB.setValue(value, 0);
|
|
711
|
+
}
|
|
712
|
+
},
|
|
713
|
+
verifyChanges: () => {
|
|
714
|
+
// Poll all accumulated values, unless they were updated by the device
|
|
715
|
+
for (const valueID of accumulatedValues) {
|
|
716
|
+
this.schedulePoll(valueID, 0, { transition: "fast" });
|
|
717
|
+
}
|
|
718
|
+
},
|
|
719
|
+
};
|
|
615
720
|
}
|
|
616
|
-
return undefined;
|
|
617
721
|
};
|
|
618
|
-
}
|
|
619
|
-
[SET_VALUE_HOOKS] = ({ property, propertyKey }, _value, _options) => {
|
|
620
|
-
if (property !== "reset")
|
|
621
|
-
return;
|
|
622
|
-
if (typeof propertyKey === "number") {
|
|
623
|
-
// Reset single
|
|
624
|
-
const { meterType, rateType, scale } = splitPropertyKey(propertyKey);
|
|
625
|
-
const readingValueId = MeterCCValues.value(meterType, rateType, scale).endpoint(this.endpoint.index);
|
|
626
|
-
return {
|
|
627
|
-
optimisticallyUpdateRelatedValues: (supervisedAndSuccessful) => {
|
|
628
|
-
if (!supervisedAndSuccessful)
|
|
629
|
-
return;
|
|
630
|
-
// After resetting a single reading with supervision, store zero
|
|
631
|
-
// in the corresponding value
|
|
632
|
-
const valueDB = this.tryGetValueDB();
|
|
633
|
-
if (!valueDB)
|
|
634
|
-
return;
|
|
635
|
-
if (isAccumulatedValue(meterType, scale)) {
|
|
636
|
-
valueDB.setValue({
|
|
637
|
-
commandClass: this.ccId,
|
|
638
|
-
endpoint: this.endpoint.index,
|
|
639
|
-
property,
|
|
640
|
-
propertyKey,
|
|
641
|
-
}, 0);
|
|
642
|
-
}
|
|
643
|
-
},
|
|
644
|
-
verifyChanges: () => {
|
|
645
|
-
this.schedulePoll(readingValueId, 0, { transition: "fast" });
|
|
646
|
-
},
|
|
647
|
-
};
|
|
648
|
-
}
|
|
649
|
-
else {
|
|
650
|
-
// Reset all
|
|
651
|
-
const valueDB = this.tryGetValueDB();
|
|
652
|
-
if (!valueDB)
|
|
653
|
-
return;
|
|
654
|
-
const accumulatedValues = valueDB.findValues((vid) => vid.commandClass === this.ccId
|
|
655
|
-
&& vid.endpoint === this.endpoint.index
|
|
656
|
-
&& MeterCCValues.value.is(vid)).filter(({ propertyKey }) => {
|
|
657
|
-
if (typeof propertyKey !== "number")
|
|
658
|
-
return false;
|
|
659
|
-
const { meterType, scale } = splitPropertyKey(propertyKey);
|
|
660
|
-
return isAccumulatedValue(meterType, scale);
|
|
661
|
-
});
|
|
662
|
-
return {
|
|
663
|
-
optimisticallyUpdateRelatedValues: (supervisedAndSuccessful) => {
|
|
664
|
-
if (!supervisedAndSuccessful)
|
|
665
|
-
return;
|
|
666
|
-
// After setting the reset all value with supervision,
|
|
667
|
-
// reset all accumulated values, since we know they are now zero.
|
|
668
|
-
for (const value of accumulatedValues) {
|
|
669
|
-
valueDB.setValue(value, 0);
|
|
670
|
-
}
|
|
671
|
-
},
|
|
672
|
-
verifyChanges: () => {
|
|
673
|
-
// Poll all accumulated values, unless they were updated by the device
|
|
674
|
-
for (const valueID of accumulatedValues) {
|
|
675
|
-
this.schedulePoll(valueID, 0, { transition: "fast" });
|
|
676
|
-
}
|
|
677
|
-
},
|
|
678
|
-
};
|
|
679
|
-
}
|
|
680
722
|
};
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
API(CommandClasses.Meter)
|
|
684
|
-
], MeterCCAPI);
|
|
723
|
+
return MeterCCAPI = _classThis;
|
|
724
|
+
})();
|
|
685
725
|
export { MeterCCAPI };
|
|
686
|
-
let MeterCC =
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
726
|
+
let MeterCC = (() => {
|
|
727
|
+
let _classDecorators = [commandClass(CommandClasses.Meter), implementedVersion(6), ccValues(MeterCCValues)];
|
|
728
|
+
let _classDescriptor;
|
|
729
|
+
let _classExtraInitializers = [];
|
|
730
|
+
let _classThis;
|
|
731
|
+
let _classSuper = CommandClass;
|
|
732
|
+
var MeterCC = class extends _classSuper {
|
|
733
|
+
static { _classThis = this; }
|
|
734
|
+
static {
|
|
735
|
+
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
|
|
736
|
+
__esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
|
|
737
|
+
MeterCC = _classThis = _classDescriptor.value;
|
|
738
|
+
if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
739
|
+
__runInitializers(_classThis, _classExtraInitializers);
|
|
740
|
+
}
|
|
741
|
+
async interview(ctx) {
|
|
742
|
+
const node = this.getNode(ctx);
|
|
743
|
+
const endpoint = this.getEndpoint(ctx);
|
|
744
|
+
const api = CCAPI.create(CommandClasses.Meter, ctx, endpoint).withOptions({
|
|
745
|
+
priority: MessagePriority.NodeQuery,
|
|
746
|
+
});
|
|
699
747
|
ctx.logNode(node.id, {
|
|
700
748
|
endpoint: this.endpointIndex,
|
|
701
|
-
message:
|
|
702
|
-
direction: "
|
|
749
|
+
message: `Interviewing ${this.ccName}...`,
|
|
750
|
+
direction: "none",
|
|
703
751
|
});
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
752
|
+
if (api.version >= 2) {
|
|
753
|
+
ctx.logNode(node.id, {
|
|
754
|
+
endpoint: this.endpointIndex,
|
|
755
|
+
message: "querying meter support...",
|
|
756
|
+
direction: "outbound",
|
|
757
|
+
});
|
|
758
|
+
const suppResp = await api.getSupported();
|
|
759
|
+
if (suppResp) {
|
|
760
|
+
const logMessage = `received meter support:
|
|
707
761
|
type: ${getMeterName(suppResp.type)}
|
|
708
762
|
supported scales: ${suppResp.supportedScales
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
763
|
+
.map((s) => (getMeterScale(suppResp.type, s)
|
|
764
|
+
?? getUnknownMeterScale(s)).label)
|
|
765
|
+
.map((label) => `\n· ${label}`)
|
|
766
|
+
.join("")}
|
|
713
767
|
supported rate types: ${suppResp.supportedRateTypes
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
768
|
+
.map((rt) => getEnumMemberName(RateType, rt))
|
|
769
|
+
.map((label) => `\n· ${label}`)
|
|
770
|
+
.join("")}
|
|
717
771
|
supports reset: ${suppResp.supportsReset}`;
|
|
772
|
+
ctx.logNode(node.id, {
|
|
773
|
+
endpoint: this.endpointIndex,
|
|
774
|
+
message: logMessage,
|
|
775
|
+
direction: "inbound",
|
|
776
|
+
});
|
|
777
|
+
}
|
|
778
|
+
else {
|
|
779
|
+
ctx.logNode(node.id, {
|
|
780
|
+
endpoint: this.endpointIndex,
|
|
781
|
+
message: "Querying meter support timed out, skipping interview...",
|
|
782
|
+
level: "warn",
|
|
783
|
+
});
|
|
784
|
+
return;
|
|
785
|
+
}
|
|
786
|
+
}
|
|
787
|
+
// Query current meter values
|
|
788
|
+
await this.refreshValues(ctx);
|
|
789
|
+
// Remember that the interview is complete
|
|
790
|
+
this.setInterviewComplete(ctx, true);
|
|
791
|
+
}
|
|
792
|
+
async refreshValues(ctx) {
|
|
793
|
+
const node = this.getNode(ctx);
|
|
794
|
+
const endpoint = this.getEndpoint(ctx);
|
|
795
|
+
const api = CCAPI.create(CommandClasses.Meter, ctx, endpoint).withOptions({
|
|
796
|
+
priority: MessagePriority.NodeQuery,
|
|
797
|
+
});
|
|
798
|
+
if (api.version === 1) {
|
|
718
799
|
ctx.logNode(node.id, {
|
|
719
800
|
endpoint: this.endpointIndex,
|
|
720
|
-
message:
|
|
721
|
-
direction: "
|
|
801
|
+
message: `querying default meter value...`,
|
|
802
|
+
direction: "outbound",
|
|
722
803
|
});
|
|
804
|
+
await api.get();
|
|
723
805
|
}
|
|
724
806
|
else {
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
807
|
+
const type = this.getValue(ctx, MeterCCValues.type)
|
|
808
|
+
?? 0;
|
|
809
|
+
const supportedScales = this.getValue(ctx, MeterCCValues.supportedScales) ?? [];
|
|
810
|
+
const supportedRateTypes = this.getValue(ctx, MeterCCValues.supportedRateTypes) ?? [];
|
|
811
|
+
const rateTypes = supportedRateTypes.length
|
|
812
|
+
? supportedRateTypes
|
|
813
|
+
: [undefined];
|
|
814
|
+
for (const rateType of rateTypes) {
|
|
815
|
+
for (const scale of supportedScales) {
|
|
816
|
+
ctx.logNode(node.id, {
|
|
817
|
+
endpoint: this.endpointIndex,
|
|
818
|
+
message: `querying meter value (type = ${getMeterName(type)}, scale = ${(getMeterScale(type, scale)
|
|
819
|
+
?? getUnknownMeterScale(scale)).label}${rateType != undefined
|
|
820
|
+
? `, rate type = ${getEnumMemberName(RateType, rateType)}`
|
|
821
|
+
: ""})...`,
|
|
822
|
+
direction: "outbound",
|
|
823
|
+
});
|
|
824
|
+
await api.get({ scale, rateType });
|
|
825
|
+
}
|
|
826
|
+
}
|
|
731
827
|
}
|
|
732
828
|
}
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
ctx.logNode(node.id, {
|
|
746
|
-
endpoint: this.endpointIndex,
|
|
747
|
-
message: `querying default meter value...`,
|
|
748
|
-
direction: "outbound",
|
|
829
|
+
shouldRefreshValues(ctx) {
|
|
830
|
+
// Poll the device when all of the supported values were last updated longer than 6 hours ago.
|
|
831
|
+
// This may lead to some values not being updated, but the user may have disabled some unnecessary
|
|
832
|
+
// reports to reduce traffic.
|
|
833
|
+
const valueDB = ctx.tryGetValueDB(this.nodeId);
|
|
834
|
+
if (!valueDB)
|
|
835
|
+
return true;
|
|
836
|
+
const values = this.getDefinedValueIDs(ctx).filter((v) => MeterCCValues.value.is(v));
|
|
837
|
+
return values.every((v) => {
|
|
838
|
+
const lastUpdated = valueDB.getTimestamp(v);
|
|
839
|
+
return (lastUpdated == undefined
|
|
840
|
+
|| Date.now() - lastUpdated > timespan.hours(6));
|
|
749
841
|
});
|
|
750
|
-
await api.get();
|
|
751
|
-
}
|
|
752
|
-
else {
|
|
753
|
-
const type = this.getValue(ctx, MeterCCValues.type)
|
|
754
|
-
?? 0;
|
|
755
|
-
const supportedScales = this.getValue(ctx, MeterCCValues.supportedScales) ?? [];
|
|
756
|
-
const supportedRateTypes = this.getValue(ctx, MeterCCValues.supportedRateTypes) ?? [];
|
|
757
|
-
const rateTypes = supportedRateTypes.length
|
|
758
|
-
? supportedRateTypes
|
|
759
|
-
: [undefined];
|
|
760
|
-
for (const rateType of rateTypes) {
|
|
761
|
-
for (const scale of supportedScales) {
|
|
762
|
-
ctx.logNode(node.id, {
|
|
763
|
-
endpoint: this.endpointIndex,
|
|
764
|
-
message: `querying meter value (type = ${getMeterName(type)}, scale = ${(getMeterScale(type, scale)
|
|
765
|
-
?? getUnknownMeterScale(scale)).label}${rateType != undefined
|
|
766
|
-
? `, rate type = ${getEnumMemberName(RateType, rateType)}`
|
|
767
|
-
: ""})...`,
|
|
768
|
-
direction: "outbound",
|
|
769
|
-
});
|
|
770
|
-
await api.get({ scale, rateType });
|
|
771
|
-
}
|
|
772
|
-
}
|
|
773
842
|
}
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
translatePropertyKey(ctx, property, propertyKey) {
|
|
826
|
-
if (property === "value" && typeof propertyKey === "number") {
|
|
827
|
-
const { meterType, rateType, scale } = splitPropertyKey(propertyKey);
|
|
828
|
-
let ret;
|
|
829
|
-
if (meterType !== 0) {
|
|
830
|
-
ret = `${getMeterName(meterType)}_${(getMeterScale(meterType, scale)
|
|
831
|
-
?? getUnknownMeterScale(scale)).label}`;
|
|
832
|
-
}
|
|
833
|
-
else {
|
|
834
|
-
ret = "default";
|
|
843
|
+
/**
|
|
844
|
+
* Returns which type this meter has.
|
|
845
|
+
* This only works AFTER the interview process
|
|
846
|
+
*/
|
|
847
|
+
static getMeterTypeCached(ctx, endpoint) {
|
|
848
|
+
return ctx
|
|
849
|
+
.getValueDB(endpoint.nodeId)
|
|
850
|
+
.getValue(MeterCCValues.type.endpoint(endpoint.index));
|
|
851
|
+
}
|
|
852
|
+
/**
|
|
853
|
+
* Returns which scales are supported by this meter.
|
|
854
|
+
* This only works AFTER the interview process
|
|
855
|
+
*/
|
|
856
|
+
static getSupportedScalesCached(ctx, endpoint) {
|
|
857
|
+
return ctx
|
|
858
|
+
.getValueDB(endpoint.nodeId)
|
|
859
|
+
.getValue(MeterCCValues.supportedScales.endpoint(endpoint.index));
|
|
860
|
+
}
|
|
861
|
+
/**
|
|
862
|
+
* Returns whether reset is supported by this meter.
|
|
863
|
+
* This only works AFTER the interview process
|
|
864
|
+
*/
|
|
865
|
+
static supportsResetCached(ctx, endpoint) {
|
|
866
|
+
return ctx
|
|
867
|
+
.getValueDB(endpoint.nodeId)
|
|
868
|
+
.getValue(MeterCCValues.supportsReset.endpoint(endpoint.index));
|
|
869
|
+
}
|
|
870
|
+
/**
|
|
871
|
+
* Returns which rate types are supported by this meter.
|
|
872
|
+
* This only works AFTER the interview process
|
|
873
|
+
*/
|
|
874
|
+
static getSupportedRateTypesCached(ctx, endpoint) {
|
|
875
|
+
return ctx
|
|
876
|
+
.getValueDB(endpoint.nodeId)
|
|
877
|
+
.getValue(MeterCCValues.supportedRateTypes.endpoint(endpoint.index));
|
|
878
|
+
}
|
|
879
|
+
translatePropertyKey(ctx, property, propertyKey) {
|
|
880
|
+
if (property === "value" && typeof propertyKey === "number") {
|
|
881
|
+
const { meterType, rateType, scale } = splitPropertyKey(propertyKey);
|
|
882
|
+
let ret;
|
|
883
|
+
if (meterType !== 0) {
|
|
884
|
+
ret = `${getMeterName(meterType)}_${(getMeterScale(meterType, scale)
|
|
885
|
+
?? getUnknownMeterScale(scale)).label}`;
|
|
886
|
+
}
|
|
887
|
+
else {
|
|
888
|
+
ret = "default";
|
|
889
|
+
}
|
|
890
|
+
if (rateType !== RateType.Unspecified) {
|
|
891
|
+
ret += "_" + getEnumMemberName(RateType, rateType);
|
|
892
|
+
}
|
|
893
|
+
return ret;
|
|
835
894
|
}
|
|
836
|
-
if (
|
|
837
|
-
|
|
895
|
+
else if (property === "reset" && typeof propertyKey === "number") {
|
|
896
|
+
return getMeterName(propertyKey);
|
|
838
897
|
}
|
|
839
|
-
return
|
|
840
|
-
}
|
|
841
|
-
else if (property === "reset" && typeof propertyKey === "number") {
|
|
842
|
-
return getMeterName(propertyKey);
|
|
898
|
+
return super.translatePropertyKey(ctx, property, propertyKey);
|
|
843
899
|
}
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
};
|
|
847
|
-
MeterCC = __decorate([
|
|
848
|
-
commandClass(CommandClasses.Meter),
|
|
849
|
-
implementedVersion(6),
|
|
850
|
-
ccValues(MeterCCValues)
|
|
851
|
-
], MeterCC);
|
|
900
|
+
};
|
|
901
|
+
return MeterCC = _classThis;
|
|
902
|
+
})();
|
|
852
903
|
export { MeterCC };
|
|
853
|
-
let MeterCCReport =
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
904
|
+
let MeterCCReport = (() => {
|
|
905
|
+
let _classDecorators = [CCCommand(MeterCommand.Report)];
|
|
906
|
+
let _classDescriptor;
|
|
907
|
+
let _classExtraInitializers = [];
|
|
908
|
+
let _classThis;
|
|
909
|
+
let _classSuper = MeterCC;
|
|
910
|
+
var MeterCCReport = class extends _classSuper {
|
|
911
|
+
static { _classThis = this; }
|
|
912
|
+
static {
|
|
913
|
+
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
|
|
914
|
+
__esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
|
|
915
|
+
MeterCCReport = _classThis = _classDescriptor.value;
|
|
916
|
+
if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
917
|
+
__runInitializers(_classThis, _classExtraInitializers);
|
|
918
|
+
}
|
|
919
|
+
constructor(options) {
|
|
920
|
+
super(options);
|
|
921
|
+
this.type = options.type;
|
|
922
|
+
this.scale = options.scale;
|
|
923
|
+
this.value = options.value;
|
|
924
|
+
this.previousValue = options.previousValue;
|
|
925
|
+
this.rateType = options.rateType ?? RateType.Unspecified;
|
|
926
|
+
this.deltaTime = options.deltaTime ?? UNKNOWN_STATE;
|
|
927
|
+
}
|
|
928
|
+
static from(raw, ctx) {
|
|
929
|
+
const { type, rateType, scale1, value, bytesRead } = parseMeterValueAndInfo(raw.payload, 0);
|
|
930
|
+
let offset = bytesRead;
|
|
931
|
+
const floatSize = bytesRead - 2;
|
|
932
|
+
let deltaTime;
|
|
933
|
+
let previousValue;
|
|
934
|
+
if (raw.payload.length >= offset + 2) {
|
|
935
|
+
deltaTime = raw.payload.readUInt16BE(offset);
|
|
936
|
+
offset += 2;
|
|
937
|
+
if (deltaTime === 0xffff) {
|
|
938
|
+
deltaTime = UNKNOWN_STATE;
|
|
939
|
+
}
|
|
940
|
+
if (
|
|
941
|
+
// Previous value is included only if delta time is not 0
|
|
942
|
+
deltaTime !== 0
|
|
943
|
+
&& raw.payload.length >= offset + floatSize) {
|
|
944
|
+
const { value: prevValue } = parseFloatWithScale(
|
|
945
|
+
// This float is split in the payload
|
|
946
|
+
Bytes.concat([
|
|
947
|
+
Bytes.from([raw.payload[1]]),
|
|
948
|
+
raw.payload.subarray(offset),
|
|
949
|
+
]));
|
|
950
|
+
offset += floatSize;
|
|
951
|
+
previousValue = prevValue;
|
|
952
|
+
}
|
|
874
953
|
}
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
&& raw.payload.length >= offset + floatSize) {
|
|
879
|
-
const { value: prevValue } = parseFloatWithScale(
|
|
880
|
-
// This float is split in the payload
|
|
881
|
-
Bytes.concat([
|
|
882
|
-
Bytes.from([raw.payload[1]]),
|
|
883
|
-
raw.payload.subarray(offset),
|
|
884
|
-
]));
|
|
885
|
-
offset += floatSize;
|
|
886
|
-
previousValue = prevValue;
|
|
954
|
+
else {
|
|
955
|
+
// 0 means that no previous value is included
|
|
956
|
+
deltaTime = 0;
|
|
887
957
|
}
|
|
958
|
+
const scale = parseScale(scale1, raw.payload, offset);
|
|
959
|
+
return new this({
|
|
960
|
+
nodeId: ctx.sourceNodeId,
|
|
961
|
+
type,
|
|
962
|
+
rateType,
|
|
963
|
+
value,
|
|
964
|
+
deltaTime,
|
|
965
|
+
previousValue,
|
|
966
|
+
scale,
|
|
967
|
+
});
|
|
888
968
|
}
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
validatePayload.withReason(`Unknown meter scale ${num2hex(this.scale)} or corrupted data`)(scale.label !== getUnknownMeterScale(this.scale).label);
|
|
916
|
-
// Filter out unsupported meter types, scales and rate types if possible
|
|
917
|
-
if (ccVersion >= 2) {
|
|
918
|
-
const expectedType = this.getValue(ctx, MeterCCValues.type);
|
|
919
|
-
if (expectedType != undefined) {
|
|
920
|
-
validatePayload.withReason("Unexpected meter type or corrupted data")(this.type === expectedType);
|
|
921
|
-
}
|
|
922
|
-
const supportedScales = this.getValue(ctx, MeterCCValues.supportedScales);
|
|
923
|
-
if (supportedScales?.length) {
|
|
924
|
-
validatePayload.withReason(`Unsupported meter scale ${scale.label} or corrupted data`)(supportedScales.includes(this.scale));
|
|
925
|
-
}
|
|
926
|
-
const supportedRateTypes = this.getValue(ctx, MeterCCValues.supportedRateTypes);
|
|
927
|
-
if (supportedRateTypes?.length) {
|
|
928
|
-
validatePayload.withReason(`Unsupported rate type ${getEnumMemberName(RateType, this.rateType)} or corrupted data`)(supportedRateTypes.includes(this.rateType));
|
|
969
|
+
persistValues(ctx) {
|
|
970
|
+
if (!super.persistValues(ctx))
|
|
971
|
+
return false;
|
|
972
|
+
const ccVersion = getEffectiveCCVersion(ctx, this);
|
|
973
|
+
const meter = getMeter(this.type);
|
|
974
|
+
const scale = getMeterScale(this.type, this.scale)
|
|
975
|
+
?? getUnknownMeterScale(this.scale);
|
|
976
|
+
// Filter out unknown meter types and scales, unless the strict validation is disabled
|
|
977
|
+
const measurementValidation = !ctx.getDeviceConfig?.(this.nodeId)?.compat?.disableStrictMeasurementValidation;
|
|
978
|
+
if (measurementValidation) {
|
|
979
|
+
validatePayload.withReason(`Unknown meter type ${num2hex(this.type)} or corrupted data`)(!!meter);
|
|
980
|
+
validatePayload.withReason(`Unknown meter scale ${num2hex(this.scale)} or corrupted data`)(scale.label !== getUnknownMeterScale(this.scale).label);
|
|
981
|
+
// Filter out unsupported meter types, scales and rate types if possible
|
|
982
|
+
if (ccVersion >= 2) {
|
|
983
|
+
const expectedType = this.getValue(ctx, MeterCCValues.type);
|
|
984
|
+
if (expectedType != undefined) {
|
|
985
|
+
validatePayload.withReason("Unexpected meter type or corrupted data")(this.type === expectedType);
|
|
986
|
+
}
|
|
987
|
+
const supportedScales = this.getValue(ctx, MeterCCValues.supportedScales);
|
|
988
|
+
if (supportedScales?.length) {
|
|
989
|
+
validatePayload.withReason(`Unsupported meter scale ${scale.label} or corrupted data`)(supportedScales.includes(this.scale));
|
|
990
|
+
}
|
|
991
|
+
const supportedRateTypes = this.getValue(ctx, MeterCCValues.supportedRateTypes);
|
|
992
|
+
if (supportedRateTypes?.length) {
|
|
993
|
+
validatePayload.withReason(`Unsupported rate type ${getEnumMemberName(RateType, this.rateType)} or corrupted data`)(supportedRateTypes.includes(this.rateType));
|
|
994
|
+
}
|
|
929
995
|
}
|
|
930
996
|
}
|
|
997
|
+
const valueValue = MeterCCValues.value(this.type, this.rateType, this.scale);
|
|
998
|
+
this.setMetadata(ctx, valueValue, {
|
|
999
|
+
...valueValue.meta,
|
|
1000
|
+
label: getValueLabel(this.type, this.scale, this.rateType),
|
|
1001
|
+
unit: scale.unit,
|
|
1002
|
+
ccSpecific: {
|
|
1003
|
+
meterType: this.type,
|
|
1004
|
+
scale: this.scale,
|
|
1005
|
+
rateType: this.rateType,
|
|
1006
|
+
},
|
|
1007
|
+
});
|
|
1008
|
+
this.setValue(ctx, valueValue, this.value);
|
|
1009
|
+
return true;
|
|
931
1010
|
}
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
this.setValue(ctx, valueValue, this.value);
|
|
944
|
-
return true;
|
|
945
|
-
}
|
|
946
|
-
type;
|
|
947
|
-
scale;
|
|
948
|
-
value;
|
|
949
|
-
previousValue;
|
|
950
|
-
rateType;
|
|
951
|
-
deltaTime;
|
|
952
|
-
serialize(ctx) {
|
|
953
|
-
const { data: typeAndValue, floatParams, scale2 } = encodeMeterValueAndInfo(this.type, this.rateType, this.scale, this.value);
|
|
954
|
-
const deltaTime = this.deltaTime ?? 0xffff;
|
|
955
|
-
const deltaTimeBytes = new Bytes(2);
|
|
956
|
-
deltaTimeBytes.writeUInt16BE(deltaTime, 0);
|
|
957
|
-
this.payload = Bytes.concat([
|
|
958
|
-
typeAndValue,
|
|
959
|
-
deltaTimeBytes,
|
|
960
|
-
]);
|
|
961
|
-
if (this.deltaTime !== 0 && this.previousValue != undefined) {
|
|
962
|
-
// Encode the float, but only keep the value bytes
|
|
963
|
-
const prevValueBytes = encodeFloatWithScale(this.previousValue, 0, // we discard the scale anyways
|
|
964
|
-
floatParams).subarray(1);
|
|
965
|
-
this.payload = Bytes.concat([
|
|
966
|
-
this.payload,
|
|
967
|
-
prevValueBytes,
|
|
968
|
-
]);
|
|
969
|
-
}
|
|
970
|
-
if (scale2 != undefined) {
|
|
1011
|
+
type;
|
|
1012
|
+
scale;
|
|
1013
|
+
value;
|
|
1014
|
+
previousValue;
|
|
1015
|
+
rateType;
|
|
1016
|
+
deltaTime;
|
|
1017
|
+
serialize(ctx) {
|
|
1018
|
+
const { data: typeAndValue, floatParams, scale2 } = encodeMeterValueAndInfo(this.type, this.rateType, this.scale, this.value);
|
|
1019
|
+
const deltaTime = this.deltaTime ?? 0xffff;
|
|
1020
|
+
const deltaTimeBytes = new Bytes(2);
|
|
1021
|
+
deltaTimeBytes.writeUInt16BE(deltaTime, 0);
|
|
971
1022
|
this.payload = Bytes.concat([
|
|
972
|
-
|
|
973
|
-
|
|
1023
|
+
typeAndValue,
|
|
1024
|
+
deltaTimeBytes,
|
|
974
1025
|
]);
|
|
1026
|
+
if (this.deltaTime !== 0 && this.previousValue != undefined) {
|
|
1027
|
+
// Encode the float, but only keep the value bytes
|
|
1028
|
+
const prevValueBytes = encodeFloatWithScale(this.previousValue, 0, // we discard the scale anyways
|
|
1029
|
+
floatParams).subarray(1);
|
|
1030
|
+
this.payload = Bytes.concat([
|
|
1031
|
+
this.payload,
|
|
1032
|
+
prevValueBytes,
|
|
1033
|
+
]);
|
|
1034
|
+
}
|
|
1035
|
+
if (scale2 != undefined) {
|
|
1036
|
+
this.payload = Bytes.concat([
|
|
1037
|
+
this.payload,
|
|
1038
|
+
Bytes.from([scale2]),
|
|
1039
|
+
]);
|
|
1040
|
+
}
|
|
1041
|
+
return super.serialize(ctx);
|
|
1042
|
+
}
|
|
1043
|
+
toLogEntry(ctx) {
|
|
1044
|
+
const scale = getMeterScale(this.type, this.scale)
|
|
1045
|
+
?? getUnknownMeterScale(this.scale);
|
|
1046
|
+
const message = {
|
|
1047
|
+
"meter type": getMeterName(this.type),
|
|
1048
|
+
scale: scale.label,
|
|
1049
|
+
"rate type": getEnumMemberName(RateType, this.rateType),
|
|
1050
|
+
value: this.value,
|
|
1051
|
+
};
|
|
1052
|
+
if (this.deltaTime !== UNKNOWN_STATE) {
|
|
1053
|
+
message["time delta"] = `${this.deltaTime} seconds`;
|
|
1054
|
+
}
|
|
1055
|
+
if (this.previousValue != undefined) {
|
|
1056
|
+
message["prev. value"] = this.previousValue;
|
|
1057
|
+
}
|
|
1058
|
+
return {
|
|
1059
|
+
...super.toLogEntry(ctx),
|
|
1060
|
+
message,
|
|
1061
|
+
};
|
|
975
1062
|
}
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
const scale = getMeterScale(this.type, this.scale)
|
|
980
|
-
?? getUnknownMeterScale(this.scale);
|
|
981
|
-
const message = {
|
|
982
|
-
"meter type": getMeterName(this.type),
|
|
983
|
-
scale: scale.label,
|
|
984
|
-
"rate type": getEnumMemberName(RateType, this.rateType),
|
|
985
|
-
value: this.value,
|
|
986
|
-
};
|
|
987
|
-
if (this.deltaTime !== UNKNOWN_STATE) {
|
|
988
|
-
message["time delta"] = `${this.deltaTime} seconds`;
|
|
989
|
-
}
|
|
990
|
-
if (this.previousValue != undefined) {
|
|
991
|
-
message["prev. value"] = this.previousValue;
|
|
992
|
-
}
|
|
993
|
-
return {
|
|
994
|
-
...super.toLogEntry(ctx),
|
|
995
|
-
message,
|
|
996
|
-
};
|
|
997
|
-
}
|
|
998
|
-
};
|
|
999
|
-
MeterCCReport = MeterCCReport_1 = __decorate([
|
|
1000
|
-
CCCommand(MeterCommand.Report)
|
|
1001
|
-
], MeterCCReport);
|
|
1063
|
+
};
|
|
1064
|
+
return MeterCCReport = _classThis;
|
|
1065
|
+
})();
|
|
1002
1066
|
export { MeterCCReport };
|
|
1003
1067
|
function testResponseForMeterGet(sent, received) {
|
|
1004
1068
|
// We expect a Meter Report that matches the requested scale and rate type
|
|
@@ -1006,303 +1070,340 @@ function testResponseForMeterGet(sent, received) {
|
|
|
1006
1070
|
return ((sent.scale == undefined || sent.scale === received.scale)
|
|
1007
1071
|
&& (sent.rateType == undefined || sent.rateType == received.rateType));
|
|
1008
1072
|
}
|
|
1009
|
-
let MeterCCGet =
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
if (
|
|
1022
|
-
|
|
1023
|
-
|
|
1073
|
+
let MeterCCGet = (() => {
|
|
1074
|
+
let _classDecorators = [CCCommand(MeterCommand.Get), expectedCCResponse(MeterCCReport, testResponseForMeterGet)];
|
|
1075
|
+
let _classDescriptor;
|
|
1076
|
+
let _classExtraInitializers = [];
|
|
1077
|
+
let _classThis;
|
|
1078
|
+
let _classSuper = MeterCC;
|
|
1079
|
+
var MeterCCGet = class extends _classSuper {
|
|
1080
|
+
static { _classThis = this; }
|
|
1081
|
+
static {
|
|
1082
|
+
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
|
|
1083
|
+
__esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
|
|
1084
|
+
MeterCCGet = _classThis = _classDescriptor.value;
|
|
1085
|
+
if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
1086
|
+
__runInitializers(_classThis, _classExtraInitializers);
|
|
1087
|
+
}
|
|
1088
|
+
constructor(options) {
|
|
1089
|
+
super(options);
|
|
1090
|
+
this.rateType = options.rateType;
|
|
1091
|
+
this.scale = options.scale;
|
|
1092
|
+
}
|
|
1093
|
+
static from(raw, ctx) {
|
|
1094
|
+
let rateType;
|
|
1095
|
+
let scale;
|
|
1096
|
+
if (raw.payload.length >= 1) {
|
|
1097
|
+
rateType = (raw.payload[0] & 0b11_000_000) >>> 6;
|
|
1098
|
+
scale = (raw.payload[0] & 0b00_111_000) >>> 3;
|
|
1099
|
+
if (scale === 7) {
|
|
1100
|
+
validatePayload(raw.payload.length >= 2);
|
|
1101
|
+
scale += raw.payload[1];
|
|
1102
|
+
}
|
|
1024
1103
|
}
|
|
1104
|
+
return new this({
|
|
1105
|
+
nodeId: ctx.sourceNodeId,
|
|
1106
|
+
rateType,
|
|
1107
|
+
scale,
|
|
1108
|
+
});
|
|
1025
1109
|
}
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
scale1 = this.scale & 0b111;
|
|
1049
|
-
bufferLength = 1;
|
|
1050
|
-
}
|
|
1051
|
-
else if (ccVersion >= 2) {
|
|
1052
|
-
scale1 = this.scale & 0b11;
|
|
1053
|
-
bufferLength = 1;
|
|
1054
|
-
}
|
|
1055
|
-
else {
|
|
1056
|
-
scale1 = 0;
|
|
1057
|
-
}
|
|
1058
|
-
let rateTypeFlags = 0;
|
|
1059
|
-
if (ccVersion >= 4 && this.rateType != undefined) {
|
|
1060
|
-
rateTypeFlags = this.rateType & 0b11;
|
|
1061
|
-
bufferLength = Math.max(bufferLength, 1);
|
|
1062
|
-
}
|
|
1063
|
-
this.payload = Bytes.alloc(bufferLength, 0);
|
|
1064
|
-
this.payload[0] = (rateTypeFlags << 6) | (scale1 << 3);
|
|
1065
|
-
if (scale2)
|
|
1066
|
-
this.payload[1] = scale2;
|
|
1067
|
-
return super.serialize(ctx);
|
|
1068
|
-
}
|
|
1069
|
-
toLogEntry(ctx) {
|
|
1070
|
-
const message = {};
|
|
1071
|
-
if (this.rateType != undefined) {
|
|
1072
|
-
message["rate type"] = getEnumMemberName(RateType, this.rateType);
|
|
1073
|
-
}
|
|
1074
|
-
if (this.scale != undefined) {
|
|
1075
|
-
if (ctx) {
|
|
1076
|
-
// Try to lookup the meter type to translate the scale
|
|
1077
|
-
const type = this.getValue(ctx, MeterCCValues.type);
|
|
1078
|
-
if (type != undefined) {
|
|
1079
|
-
message.scale = (getMeterScale(type, this.scale)
|
|
1080
|
-
?? getUnknownMeterScale(this.scale)).label;
|
|
1081
|
-
}
|
|
1110
|
+
rateType;
|
|
1111
|
+
scale;
|
|
1112
|
+
serialize(ctx) {
|
|
1113
|
+
let scale1;
|
|
1114
|
+
let scale2;
|
|
1115
|
+
let bufferLength = 0;
|
|
1116
|
+
const ccVersion = getEffectiveCCVersion(ctx, this);
|
|
1117
|
+
if (this.scale == undefined) {
|
|
1118
|
+
scale1 = 0;
|
|
1119
|
+
}
|
|
1120
|
+
else if (ccVersion >= 4 && this.scale >= 7) {
|
|
1121
|
+
scale1 = 7;
|
|
1122
|
+
scale2 = this.scale >>> 3;
|
|
1123
|
+
bufferLength = 2;
|
|
1124
|
+
}
|
|
1125
|
+
else if (ccVersion >= 3) {
|
|
1126
|
+
scale1 = this.scale & 0b111;
|
|
1127
|
+
bufferLength = 1;
|
|
1128
|
+
}
|
|
1129
|
+
else if (ccVersion >= 2) {
|
|
1130
|
+
scale1 = this.scale & 0b11;
|
|
1131
|
+
bufferLength = 1;
|
|
1082
1132
|
}
|
|
1083
1133
|
else {
|
|
1084
|
-
|
|
1134
|
+
scale1 = 0;
|
|
1085
1135
|
}
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
// The bitmask is spread out
|
|
1114
|
-
validatePayload(raw.payload.length >= 3);
|
|
1115
|
-
const extraBytes = raw.payload[2];
|
|
1116
|
-
validatePayload(raw.payload.length >= 3 + extraBytes);
|
|
1117
|
-
// The bitmask is the original payload byte plus all following bytes
|
|
1118
|
-
// Since the first byte only has 7 bits, we need to reduce all following bits by 1
|
|
1119
|
-
supportedScales = parseBitMask(Bytes.concat([
|
|
1120
|
-
Bytes.from([raw.payload[1] & 0b0_1111111]),
|
|
1121
|
-
raw.payload.subarray(3, 3 + extraBytes),
|
|
1122
|
-
]), 0).map((scale) => (scale >= 8 ? scale - 1 : scale));
|
|
1123
|
-
}
|
|
1124
|
-
else {
|
|
1125
|
-
// only 7 bits in the bitmask. Bit 7 is 0, so no need to mask it out
|
|
1126
|
-
supportedScales = parseBitMask(Bytes.from([raw.payload[1]]), 0);
|
|
1127
|
-
}
|
|
1128
|
-
// This is only present in V4+
|
|
1129
|
-
const supportedRateTypes = parseBitMask(Bytes.from([(raw.payload[0] & 0b0_11_00000) >>> 5]), 1);
|
|
1130
|
-
return new MeterCCSupportedReport_1({
|
|
1131
|
-
nodeId: ctx.sourceNodeId,
|
|
1132
|
-
type,
|
|
1133
|
-
supportsReset,
|
|
1134
|
-
supportedScales,
|
|
1135
|
-
supportedRateTypes,
|
|
1136
|
-
});
|
|
1137
|
-
}
|
|
1138
|
-
type;
|
|
1139
|
-
supportsReset;
|
|
1140
|
-
supportedScales;
|
|
1141
|
-
supportedRateTypes;
|
|
1142
|
-
persistValues(ctx) {
|
|
1143
|
-
if (!super.persistValues(ctx))
|
|
1144
|
-
return false;
|
|
1145
|
-
if (!this.supportsReset)
|
|
1146
|
-
return true;
|
|
1147
|
-
const ccVersion = getEffectiveCCVersion(ctx, this);
|
|
1148
|
-
// Create reset values
|
|
1149
|
-
if (ccVersion < 6) {
|
|
1150
|
-
this.ensureMetadata(ctx, MeterCCValues.resetAll);
|
|
1151
|
-
}
|
|
1152
|
-
else {
|
|
1153
|
-
for (const scale of this.supportedScales) {
|
|
1154
|
-
// Only accumulated values can be reset
|
|
1155
|
-
if (!isAccumulatedValue(this.type, scale))
|
|
1156
|
-
continue;
|
|
1157
|
-
for (const rateType of this.supportedRateTypes) {
|
|
1158
|
-
const resetSingleValue = MeterCCValues.resetSingle(this.type, rateType, scale);
|
|
1159
|
-
this.ensureMetadata(ctx, resetSingleValue, {
|
|
1160
|
-
...resetSingleValue.meta,
|
|
1161
|
-
label: `Reset ${getValueLabel(this.type, scale, rateType)}`,
|
|
1162
|
-
});
|
|
1136
|
+
let rateTypeFlags = 0;
|
|
1137
|
+
if (ccVersion >= 4 && this.rateType != undefined) {
|
|
1138
|
+
rateTypeFlags = this.rateType & 0b11;
|
|
1139
|
+
bufferLength = Math.max(bufferLength, 1);
|
|
1140
|
+
}
|
|
1141
|
+
this.payload = Bytes.alloc(bufferLength, 0);
|
|
1142
|
+
this.payload[0] = (rateTypeFlags << 6) | (scale1 << 3);
|
|
1143
|
+
if (scale2)
|
|
1144
|
+
this.payload[1] = scale2;
|
|
1145
|
+
return super.serialize(ctx);
|
|
1146
|
+
}
|
|
1147
|
+
toLogEntry(ctx) {
|
|
1148
|
+
const message = {};
|
|
1149
|
+
if (this.rateType != undefined) {
|
|
1150
|
+
message["rate type"] = getEnumMemberName(RateType, this.rateType);
|
|
1151
|
+
}
|
|
1152
|
+
if (this.scale != undefined) {
|
|
1153
|
+
if (ctx) {
|
|
1154
|
+
// Try to lookup the meter type to translate the scale
|
|
1155
|
+
const type = this.getValue(ctx, MeterCCValues.type);
|
|
1156
|
+
if (type != undefined) {
|
|
1157
|
+
message.scale = (getMeterScale(type, this.scale)
|
|
1158
|
+
?? getUnknownMeterScale(this.scale)).label;
|
|
1159
|
+
}
|
|
1160
|
+
}
|
|
1161
|
+
else {
|
|
1162
|
+
message.scale = this.scale;
|
|
1163
1163
|
}
|
|
1164
1164
|
}
|
|
1165
|
+
return {
|
|
1166
|
+
...super.toLogEntry(ctx),
|
|
1167
|
+
message,
|
|
1168
|
+
};
|
|
1165
1169
|
}
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
this.
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
.
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
], MeterCCSupportedReport.prototype, "type", void 0);
|
|
1218
|
-
__decorate([
|
|
1219
|
-
ccValue(MeterCCValues.supportsReset)
|
|
1220
|
-
], MeterCCSupportedReport.prototype, "supportsReset", void 0);
|
|
1221
|
-
__decorate([
|
|
1222
|
-
ccValue(MeterCCValues.supportedScales)
|
|
1223
|
-
], MeterCCSupportedReport.prototype, "supportedScales", void 0);
|
|
1224
|
-
__decorate([
|
|
1225
|
-
ccValue(MeterCCValues.supportedRateTypes)
|
|
1226
|
-
], MeterCCSupportedReport.prototype, "supportedRateTypes", void 0);
|
|
1227
|
-
MeterCCSupportedReport = MeterCCSupportedReport_1 = __decorate([
|
|
1228
|
-
CCCommand(MeterCommand.SupportedReport)
|
|
1229
|
-
], MeterCCSupportedReport);
|
|
1230
|
-
export { MeterCCSupportedReport };
|
|
1231
|
-
let MeterCCSupportedGet = class MeterCCSupportedGet extends MeterCC {
|
|
1232
|
-
};
|
|
1233
|
-
MeterCCSupportedGet = __decorate([
|
|
1234
|
-
CCCommand(MeterCommand.SupportedGet),
|
|
1235
|
-
expectedCCResponse(MeterCCSupportedReport)
|
|
1236
|
-
], MeterCCSupportedGet);
|
|
1237
|
-
export { MeterCCSupportedGet };
|
|
1238
|
-
let MeterCCReset = MeterCCReset_1 = class MeterCCReset extends MeterCC {
|
|
1239
|
-
constructor(options) {
|
|
1240
|
-
super(options);
|
|
1241
|
-
this.type = options.type;
|
|
1242
|
-
this.scale = options.scale;
|
|
1243
|
-
this.rateType = options.rateType;
|
|
1244
|
-
this.targetValue = options.targetValue;
|
|
1245
|
-
}
|
|
1246
|
-
static from(raw, ctx) {
|
|
1247
|
-
if (raw.payload.length === 0) {
|
|
1248
|
-
return new MeterCCReset_1({
|
|
1170
|
+
};
|
|
1171
|
+
return MeterCCGet = _classThis;
|
|
1172
|
+
})();
|
|
1173
|
+
export { MeterCCGet };
|
|
1174
|
+
let MeterCCSupportedReport = (() => {
|
|
1175
|
+
let _classDecorators = [CCCommand(MeterCommand.SupportedReport), ccValueProperty("type", MeterCCValues.type), ccValueProperty("supportsReset", MeterCCValues.supportsReset), ccValueProperty("supportedScales", MeterCCValues.supportedScales), ccValueProperty("supportedRateTypes", MeterCCValues.supportedRateTypes)];
|
|
1176
|
+
let _classDescriptor;
|
|
1177
|
+
let _classExtraInitializers = [];
|
|
1178
|
+
let _classThis;
|
|
1179
|
+
let _classSuper = MeterCC;
|
|
1180
|
+
var MeterCCSupportedReport = class extends _classSuper {
|
|
1181
|
+
static { _classThis = this; }
|
|
1182
|
+
static {
|
|
1183
|
+
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
|
|
1184
|
+
__esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
|
|
1185
|
+
MeterCCSupportedReport = _classThis = _classDescriptor.value;
|
|
1186
|
+
if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
1187
|
+
__runInitializers(_classThis, _classExtraInitializers);
|
|
1188
|
+
}
|
|
1189
|
+
constructor(options) {
|
|
1190
|
+
super(options);
|
|
1191
|
+
this.type = options.type;
|
|
1192
|
+
this.supportsReset = options.supportsReset;
|
|
1193
|
+
this.supportedScales = options.supportedScales;
|
|
1194
|
+
this.supportedRateTypes = options.supportedRateTypes;
|
|
1195
|
+
}
|
|
1196
|
+
static from(raw, ctx) {
|
|
1197
|
+
validatePayload(raw.payload.length >= 2);
|
|
1198
|
+
const type = raw.payload[0] & 0b0_00_11111;
|
|
1199
|
+
const supportsReset = !!(raw.payload[0] & 0b1_00_00000);
|
|
1200
|
+
const hasMoreScales = !!(raw.payload[1] & 0b1_0000000);
|
|
1201
|
+
let supportedScales;
|
|
1202
|
+
if (hasMoreScales) {
|
|
1203
|
+
// The bitmask is spread out
|
|
1204
|
+
validatePayload(raw.payload.length >= 3);
|
|
1205
|
+
const extraBytes = raw.payload[2];
|
|
1206
|
+
validatePayload(raw.payload.length >= 3 + extraBytes);
|
|
1207
|
+
// The bitmask is the original payload byte plus all following bytes
|
|
1208
|
+
// Since the first byte only has 7 bits, we need to reduce all following bits by 1
|
|
1209
|
+
supportedScales = parseBitMask(Bytes.concat([
|
|
1210
|
+
Bytes.from([raw.payload[1] & 0b0_1111111]),
|
|
1211
|
+
raw.payload.subarray(3, 3 + extraBytes),
|
|
1212
|
+
]), 0).map((scale) => (scale >= 8 ? scale - 1 : scale));
|
|
1213
|
+
}
|
|
1214
|
+
else {
|
|
1215
|
+
// only 7 bits in the bitmask. Bit 7 is 0, so no need to mask it out
|
|
1216
|
+
supportedScales = parseBitMask(Bytes.from([raw.payload[1]]), 0);
|
|
1217
|
+
}
|
|
1218
|
+
// This is only present in V4+
|
|
1219
|
+
const supportedRateTypes = parseBitMask(Bytes.from([(raw.payload[0] & 0b0_11_00000) >>> 5]), 1);
|
|
1220
|
+
return new this({
|
|
1249
1221
|
nodeId: ctx.sourceNodeId,
|
|
1222
|
+
type,
|
|
1223
|
+
supportsReset,
|
|
1224
|
+
supportedScales,
|
|
1225
|
+
supportedRateTypes,
|
|
1250
1226
|
});
|
|
1251
1227
|
}
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1228
|
+
type;
|
|
1229
|
+
supportsReset;
|
|
1230
|
+
supportedScales;
|
|
1231
|
+
supportedRateTypes;
|
|
1232
|
+
persistValues(ctx) {
|
|
1233
|
+
if (!super.persistValues(ctx))
|
|
1234
|
+
return false;
|
|
1235
|
+
if (!this.supportsReset)
|
|
1236
|
+
return true;
|
|
1237
|
+
const ccVersion = getEffectiveCCVersion(ctx, this);
|
|
1238
|
+
// Create reset values
|
|
1239
|
+
if (ccVersion < 6) {
|
|
1240
|
+
this.ensureMetadata(ctx, MeterCCValues.resetAll);
|
|
1241
|
+
}
|
|
1242
|
+
else {
|
|
1243
|
+
for (const scale of this.supportedScales) {
|
|
1244
|
+
// Only accumulated values can be reset
|
|
1245
|
+
if (!isAccumulatedValue(this.type, scale))
|
|
1246
|
+
continue;
|
|
1247
|
+
for (const rateType of this.supportedRateTypes) {
|
|
1248
|
+
const resetSingleValue = MeterCCValues.resetSingle(this.type, rateType, scale);
|
|
1249
|
+
this.ensureMetadata(ctx, resetSingleValue, {
|
|
1250
|
+
...resetSingleValue.meta,
|
|
1251
|
+
label: `Reset ${getValueLabel(this.type, scale, rateType)}`,
|
|
1252
|
+
});
|
|
1253
|
+
}
|
|
1254
|
+
}
|
|
1255
|
+
}
|
|
1256
|
+
return true;
|
|
1257
|
+
}
|
|
1258
|
+
serialize(ctx) {
|
|
1259
|
+
const typeByte = (this.type & 0b0_00_11111)
|
|
1260
|
+
| (this.supportedRateTypes.includes(RateType.Consumed)
|
|
1261
|
+
? 0b0_01_00000
|
|
1262
|
+
: 0)
|
|
1263
|
+
| (this.supportedRateTypes.includes(RateType.Produced)
|
|
1264
|
+
? 0b0_10_00000
|
|
1265
|
+
: 0)
|
|
1266
|
+
| (this.supportsReset ? 0b1_00_00000 : 0);
|
|
1267
|
+
const supportedScales = encodeBitMask(this.supportedScales, undefined,
|
|
1268
|
+
// The first byte only has 7 bits for the bitmask,
|
|
1269
|
+
// so we add a fake bit for the value -1 and later shift
|
|
1270
|
+
// the first byte one to the right
|
|
1271
|
+
-1);
|
|
1272
|
+
const scalesByte1 = (supportedScales[0] >>> 1)
|
|
1273
|
+
| (supportedScales.length > 1 ? 0b1000_0000 : 0);
|
|
1274
|
+
this.payload = Bytes.from([
|
|
1275
|
+
typeByte,
|
|
1276
|
+
scalesByte1,
|
|
1277
|
+
]);
|
|
1278
|
+
if (supportedScales.length > 1) {
|
|
1274
1279
|
this.payload = Bytes.concat([
|
|
1275
1280
|
this.payload,
|
|
1276
|
-
Bytes.from([
|
|
1281
|
+
Bytes.from([supportedScales.length - 1]),
|
|
1282
|
+
Bytes.from(supportedScales.subarray(1)),
|
|
1277
1283
|
]);
|
|
1278
1284
|
}
|
|
1285
|
+
return super.serialize(ctx);
|
|
1286
|
+
}
|
|
1287
|
+
toLogEntry(ctx) {
|
|
1288
|
+
const message = {
|
|
1289
|
+
"meter type": getMeterName(this.type),
|
|
1290
|
+
"supports reset": this.supportsReset,
|
|
1291
|
+
"supported scales": `${this.supportedScales
|
|
1292
|
+
.map((scale) => `
|
|
1293
|
+
· ${(getMeterScale(this.type, scale) ?? getUnknownMeterScale(scale)).label}`)
|
|
1294
|
+
.join("")}`,
|
|
1295
|
+
"supported rate types": this.supportedRateTypes
|
|
1296
|
+
.map((rt) => getEnumMemberName(RateType, rt))
|
|
1297
|
+
.join(", "),
|
|
1298
|
+
};
|
|
1299
|
+
return {
|
|
1300
|
+
...super.toLogEntry(ctx),
|
|
1301
|
+
message,
|
|
1302
|
+
};
|
|
1279
1303
|
}
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1304
|
+
};
|
|
1305
|
+
return MeterCCSupportedReport = _classThis;
|
|
1306
|
+
})();
|
|
1307
|
+
export { MeterCCSupportedReport };
|
|
1308
|
+
let MeterCCSupportedGet = (() => {
|
|
1309
|
+
let _classDecorators = [CCCommand(MeterCommand.SupportedGet), expectedCCResponse(MeterCCSupportedReport)];
|
|
1310
|
+
let _classDescriptor;
|
|
1311
|
+
let _classExtraInitializers = [];
|
|
1312
|
+
let _classThis;
|
|
1313
|
+
let _classSuper = MeterCC;
|
|
1314
|
+
var MeterCCSupportedGet = class extends _classSuper {
|
|
1315
|
+
static { _classThis = this; }
|
|
1316
|
+
static {
|
|
1317
|
+
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
|
|
1318
|
+
__esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
|
|
1319
|
+
MeterCCSupportedGet = _classThis = _classDescriptor.value;
|
|
1320
|
+
if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
1321
|
+
__runInitializers(_classThis, _classExtraInitializers);
|
|
1286
1322
|
}
|
|
1287
|
-
|
|
1288
|
-
|
|
1323
|
+
};
|
|
1324
|
+
return MeterCCSupportedGet = _classThis;
|
|
1325
|
+
})();
|
|
1326
|
+
export { MeterCCSupportedGet };
|
|
1327
|
+
let MeterCCReset = (() => {
|
|
1328
|
+
let _classDecorators = [CCCommand(MeterCommand.Reset), useSupervision()];
|
|
1329
|
+
let _classDescriptor;
|
|
1330
|
+
let _classExtraInitializers = [];
|
|
1331
|
+
let _classThis;
|
|
1332
|
+
let _classSuper = MeterCC;
|
|
1333
|
+
var MeterCCReset = class extends _classSuper {
|
|
1334
|
+
static { _classThis = this; }
|
|
1335
|
+
static {
|
|
1336
|
+
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
|
|
1337
|
+
__esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
|
|
1338
|
+
MeterCCReset = _classThis = _classDescriptor.value;
|
|
1339
|
+
if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
1340
|
+
__runInitializers(_classThis, _classExtraInitializers);
|
|
1341
|
+
}
|
|
1342
|
+
constructor(options) {
|
|
1343
|
+
super(options);
|
|
1344
|
+
this.type = options.type;
|
|
1345
|
+
this.scale = options.scale;
|
|
1346
|
+
this.rateType = options.rateType;
|
|
1347
|
+
this.targetValue = options.targetValue;
|
|
1348
|
+
}
|
|
1349
|
+
static from(raw, ctx) {
|
|
1350
|
+
if (raw.payload.length === 0) {
|
|
1351
|
+
return new this({
|
|
1352
|
+
nodeId: ctx.sourceNodeId,
|
|
1353
|
+
});
|
|
1354
|
+
}
|
|
1355
|
+
const { type, rateType, scale1, value: targetValue, bytesRead: scale2Offset, } = parseMeterValueAndInfo(raw.payload, 0);
|
|
1356
|
+
const scale = parseScale(scale1, raw.payload, scale2Offset);
|
|
1357
|
+
return new this({
|
|
1358
|
+
nodeId: ctx.sourceNodeId,
|
|
1359
|
+
type,
|
|
1360
|
+
rateType,
|
|
1361
|
+
targetValue,
|
|
1362
|
+
scale,
|
|
1363
|
+
});
|
|
1289
1364
|
}
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1365
|
+
type;
|
|
1366
|
+
scale;
|
|
1367
|
+
rateType;
|
|
1368
|
+
targetValue;
|
|
1369
|
+
serialize(ctx) {
|
|
1370
|
+
if (this.type != undefined
|
|
1371
|
+
&& this.scale != undefined
|
|
1372
|
+
&& this.rateType != undefined
|
|
1373
|
+
&& this.targetValue != undefined) {
|
|
1374
|
+
const { data: typeAndValue, scale2 } = encodeMeterValueAndInfo(this.type, this.rateType, this.scale, this.targetValue);
|
|
1375
|
+
this.payload = typeAndValue;
|
|
1376
|
+
if (scale2 != undefined) {
|
|
1377
|
+
this.payload = Bytes.concat([
|
|
1378
|
+
this.payload,
|
|
1379
|
+
Bytes.from([scale2]),
|
|
1380
|
+
]);
|
|
1381
|
+
}
|
|
1382
|
+
}
|
|
1383
|
+
return super.serialize(ctx);
|
|
1293
1384
|
}
|
|
1294
|
-
|
|
1295
|
-
message
|
|
1385
|
+
toLogEntry(ctx) {
|
|
1386
|
+
const message = {};
|
|
1387
|
+
if (this.type != undefined) {
|
|
1388
|
+
message.type = getMeterName(this.type);
|
|
1389
|
+
}
|
|
1390
|
+
if (this.rateType != undefined) {
|
|
1391
|
+
message["rate type"] = getEnumMemberName(RateType, this.rateType);
|
|
1392
|
+
}
|
|
1393
|
+
if (this.type != undefined && this.scale != undefined) {
|
|
1394
|
+
message.scale = (getMeterScale(this.type, this.scale)
|
|
1395
|
+
?? getUnknownMeterScale(this.scale)).label;
|
|
1396
|
+
}
|
|
1397
|
+
if (this.targetValue != undefined) {
|
|
1398
|
+
message["target value"] = this.targetValue;
|
|
1399
|
+
}
|
|
1400
|
+
return {
|
|
1401
|
+
...super.toLogEntry(ctx),
|
|
1402
|
+
message,
|
|
1403
|
+
};
|
|
1296
1404
|
}
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
};
|
|
1301
|
-
}
|
|
1302
|
-
};
|
|
1303
|
-
MeterCCReset = MeterCCReset_1 = __decorate([
|
|
1304
|
-
CCCommand(MeterCommand.Reset),
|
|
1305
|
-
useSupervision()
|
|
1306
|
-
], MeterCCReset);
|
|
1405
|
+
};
|
|
1406
|
+
return MeterCCReset = _classThis;
|
|
1407
|
+
})();
|
|
1307
1408
|
export { MeterCCReset };
|
|
1308
1409
|
//# sourceMappingURL=MeterCC.js.map
|