@zwave-js/cc 14.0.0-beta.4 → 14.0.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.
Files changed (331) hide show
  1. package/build/cjs/cc/AlarmSensorCC.js +381 -266
  2. package/build/cjs/cc/AlarmSensorCC.js.map +3 -3
  3. package/build/cjs/cc/AssociationCC.js +669 -503
  4. package/build/cjs/cc/AssociationCC.js.map +3 -3
  5. package/build/cjs/cc/AssociationGroupInfoCC.js +633 -492
  6. package/build/cjs/cc/AssociationGroupInfoCC.js.map +3 -3
  7. package/build/cjs/cc/BarrierOperatorCC.js +595 -429
  8. package/build/cjs/cc/BarrierOperatorCC.js.map +3 -3
  9. package/build/cjs/cc/BasicCC.js +354 -260
  10. package/build/cjs/cc/BasicCC.js.map +3 -3
  11. package/build/cjs/cc/BatteryCC.js +427 -345
  12. package/build/cjs/cc/BatteryCC.js.map +3 -3
  13. package/build/cjs/cc/BinarySensorCC.js +391 -276
  14. package/build/cjs/cc/BinarySensorCC.js.map +3 -3
  15. package/build/cjs/cc/BinarySwitchCC.js +347 -253
  16. package/build/cjs/cc/BinarySwitchCC.js.map +3 -3
  17. package/build/cjs/cc/CRC16CC.js +160 -85
  18. package/build/cjs/cc/CRC16CC.js.map +3 -3
  19. package/build/cjs/cc/CentralSceneCC.js +459 -324
  20. package/build/cjs/cc/CentralSceneCC.js.map +3 -3
  21. package/build/cjs/cc/ClimateControlScheduleCC.js +459 -293
  22. package/build/cjs/cc/ClimateControlScheduleCC.js.map +3 -3
  23. package/build/cjs/cc/ClockCC.js +254 -150
  24. package/build/cjs/cc/ClockCC.js.map +3 -3
  25. package/build/cjs/cc/ColorSwitchCC.js +758 -610
  26. package/build/cjs/cc/ColorSwitchCC.js.map +3 -3
  27. package/build/cjs/cc/ConfigurationCC.js +1700 -1453
  28. package/build/cjs/cc/ConfigurationCC.js.map +3 -3
  29. package/build/cjs/cc/DeviceResetLocallyCC.js +125 -49
  30. package/build/cjs/cc/DeviceResetLocallyCC.js.map +3 -3
  31. package/build/cjs/cc/DoorLockCC.js +904 -777
  32. package/build/cjs/cc/DoorLockCC.js.map +3 -3
  33. package/build/cjs/cc/DoorLockLoggingCC.js +321 -206
  34. package/build/cjs/cc/DoorLockLoggingCC.js.map +3 -3
  35. package/build/cjs/cc/EnergyProductionCC.js +249 -160
  36. package/build/cjs/cc/EnergyProductionCC.js.map +3 -3
  37. package/build/cjs/cc/EntryControlCC.js +619 -458
  38. package/build/cjs/cc/EntryControlCC.js.map +3 -3
  39. package/build/cjs/cc/FirmwareUpdateMetaDataCC.js +898 -698
  40. package/build/cjs/cc/FirmwareUpdateMetaDataCC.js.map +3 -3
  41. package/build/cjs/cc/HailCC.js +57 -11
  42. package/build/cjs/cc/HailCC.js.map +2 -2
  43. package/build/cjs/cc/HumidityControlModeCC.js +359 -233
  44. package/build/cjs/cc/HumidityControlModeCC.js.map +3 -3
  45. package/build/cjs/cc/HumidityControlOperatingStateCC.js +189 -103
  46. package/build/cjs/cc/HumidityControlOperatingStateCC.js.map +3 -3
  47. package/build/cjs/cc/HumidityControlSetpointCC.js +682 -495
  48. package/build/cjs/cc/HumidityControlSetpointCC.js.map +3 -3
  49. package/build/cjs/cc/InclusionControllerCC.js +205 -114
  50. package/build/cjs/cc/InclusionControllerCC.js.map +3 -3
  51. package/build/cjs/cc/IndicatorCC.js +897 -736
  52. package/build/cjs/cc/IndicatorCC.js.map +3 -3
  53. package/build/cjs/cc/IrrigationCC.js +1651 -1405
  54. package/build/cjs/cc/IrrigationCC.js.map +3 -3
  55. package/build/cjs/cc/LanguageCC.js +268 -171
  56. package/build/cjs/cc/LanguageCC.js.map +3 -3
  57. package/build/cjs/cc/LockCC.js +254 -154
  58. package/build/cjs/cc/LockCC.js.map +3 -3
  59. package/build/cjs/cc/ManufacturerProprietaryCC.js +189 -129
  60. package/build/cjs/cc/ManufacturerProprietaryCC.js.map +2 -2
  61. package/build/cjs/cc/ManufacturerSpecificCC.js +319 -213
  62. package/build/cjs/cc/ManufacturerSpecificCC.js.map +3 -3
  63. package/build/cjs/cc/MeterCC.js +827 -707
  64. package/build/cjs/cc/MeterCC.js.map +3 -3
  65. package/build/cjs/cc/MultiChannelAssociationCC.js +612 -478
  66. package/build/cjs/cc/MultiChannelAssociationCC.js.map +3 -3
  67. package/build/cjs/cc/MultiChannelCC.js +1037 -819
  68. package/build/cjs/cc/MultiChannelCC.js.map +3 -3
  69. package/build/cjs/cc/MultiCommandCC.js +172 -97
  70. package/build/cjs/cc/MultiCommandCC.js.map +3 -3
  71. package/build/cjs/cc/MultilevelSensorCC.js +589 -449
  72. package/build/cjs/cc/MultilevelSensorCC.js.map +3 -3
  73. package/build/cjs/cc/MultilevelSwitchCC.js +587 -439
  74. package/build/cjs/cc/MultilevelSwitchCC.js.map +3 -3
  75. package/build/cjs/cc/NoOperationCC.js +89 -27
  76. package/build/cjs/cc/NoOperationCC.js.map +2 -2
  77. package/build/cjs/cc/NodeNamingCC.js +417 -277
  78. package/build/cjs/cc/NodeNamingCC.js.map +3 -3
  79. package/build/cjs/cc/NotificationCC.js +972 -818
  80. package/build/cjs/cc/NotificationCC.js.map +3 -3
  81. package/build/cjs/cc/PowerlevelCC.js +450 -303
  82. package/build/cjs/cc/PowerlevelCC.js.map +3 -3
  83. package/build/cjs/cc/ProtectionCC.js +686 -494
  84. package/build/cjs/cc/ProtectionCC.js.map +3 -3
  85. package/build/cjs/cc/SceneActivationCC.js +165 -97
  86. package/build/cjs/cc/SceneActivationCC.js.map +3 -3
  87. package/build/cjs/cc/SceneActuatorConfigurationCC.js +346 -243
  88. package/build/cjs/cc/SceneActuatorConfigurationCC.js.map +3 -3
  89. package/build/cjs/cc/SceneControllerConfigurationCC.js +401 -298
  90. package/build/cjs/cc/SceneControllerConfigurationCC.js.map +3 -3
  91. package/build/cjs/cc/ScheduleEntryLockCC.js +1552 -1272
  92. package/build/cjs/cc/ScheduleEntryLockCC.js.map +3 -3
  93. package/build/cjs/cc/Security2CC.js +1483 -1219
  94. package/build/cjs/cc/Security2CC.js.map +3 -3
  95. package/build/cjs/cc/SecurityCC.js +839 -619
  96. package/build/cjs/cc/SecurityCC.js.map +3 -3
  97. package/build/cjs/cc/SoundSwitchCC.js +707 -515
  98. package/build/cjs/cc/SoundSwitchCC.js.map +3 -3
  99. package/build/cjs/cc/SupervisionCC.js +327 -237
  100. package/build/cjs/cc/SupervisionCC.js.map +3 -3
  101. package/build/cjs/cc/ThermostatFanModeCC.js +386 -263
  102. package/build/cjs/cc/ThermostatFanModeCC.js.map +3 -3
  103. package/build/cjs/cc/ThermostatFanStateCC.js +192 -106
  104. package/build/cjs/cc/ThermostatFanStateCC.js.map +3 -3
  105. package/build/cjs/cc/ThermostatModeCC.js +425 -302
  106. package/build/cjs/cc/ThermostatModeCC.js.map +3 -3
  107. package/build/cjs/cc/ThermostatOperatingStateCC.js +188 -102
  108. package/build/cjs/cc/ThermostatOperatingStateCC.js.map +3 -3
  109. package/build/cjs/cc/ThermostatSetbackCC.js +277 -173
  110. package/build/cjs/cc/ThermostatSetbackCC.js.map +3 -3
  111. package/build/cjs/cc/ThermostatSetpointCC.js +645 -491
  112. package/build/cjs/cc/ThermostatSetpointCC.js.map +3 -3
  113. package/build/cjs/cc/TimeCC.js +515 -353
  114. package/build/cjs/cc/TimeCC.js.map +3 -3
  115. package/build/cjs/cc/TimeParametersCC.js +302 -202
  116. package/build/cjs/cc/TimeParametersCC.js.map +3 -3
  117. package/build/cjs/cc/TransportServiceCC.js +433 -315
  118. package/build/cjs/cc/TransportServiceCC.js.map +3 -3
  119. package/build/cjs/cc/UserCodeCC.js +1385 -1102
  120. package/build/cjs/cc/UserCodeCC.js.map +3 -3
  121. package/build/cjs/cc/VersionCC.js +696 -562
  122. package/build/cjs/cc/VersionCC.js.map +3 -3
  123. package/build/cjs/cc/WakeUpCC.js +499 -346
  124. package/build/cjs/cc/WakeUpCC.js.map +3 -3
  125. package/build/cjs/cc/WindowCoveringCC.js +626 -478
  126. package/build/cjs/cc/WindowCoveringCC.js.map +3 -3
  127. package/build/cjs/cc/ZWaveLongRangeCC.js +57 -10
  128. package/build/cjs/cc/ZWaveLongRangeCC.js.map +2 -2
  129. package/build/cjs/cc/ZWavePlusCC.js +233 -159
  130. package/build/cjs/cc/ZWavePlusCC.js.map +3 -3
  131. package/build/cjs/cc/ZWaveProtocolCC.js +1515 -948
  132. package/build/cjs/cc/ZWaveProtocolCC.js.map +3 -3
  133. package/build/cjs/cc/manufacturerProprietary/Decorators.d.ts +4 -4
  134. package/build/cjs/cc/manufacturerProprietary/Decorators.js.map +1 -1
  135. package/build/cjs/cc/manufacturerProprietary/FibaroCC.js +395 -274
  136. package/build/cjs/cc/manufacturerProprietary/FibaroCC.js.map +3 -3
  137. package/build/cjs/lib/CommandClassDecorators.d.ts +11 -15
  138. package/build/cjs/lib/CommandClassDecorators.js +19 -20
  139. package/build/cjs/lib/CommandClassDecorators.js.map +2 -2
  140. package/build/cjs/lib/Security2/Extension.d.ts +1 -1
  141. package/build/cjs/lib/Security2/Extension.js +217 -126
  142. package/build/cjs/lib/Security2/Extension.js.map +3 -3
  143. package/build/esm/cc/AlarmSensorCC.d.ts.map +1 -1
  144. package/build/esm/cc/AlarmSensorCC.js +389 -291
  145. package/build/esm/cc/AlarmSensorCC.js.map +1 -1
  146. package/build/esm/cc/AssociationCC.d.ts.map +1 -1
  147. package/build/esm/cc/AssociationCC.js +678 -537
  148. package/build/esm/cc/AssociationCC.js.map +1 -1
  149. package/build/esm/cc/AssociationGroupInfoCC.d.ts.map +1 -1
  150. package/build/esm/cc/AssociationGroupInfoCC.js +659 -539
  151. package/build/esm/cc/AssociationGroupInfoCC.js.map +1 -1
  152. package/build/esm/cc/BarrierOperatorCC.d.ts.map +1 -1
  153. package/build/esm/cc/BarrierOperatorCC.js +634 -493
  154. package/build/esm/cc/BarrierOperatorCC.js.map +1 -1
  155. package/build/esm/cc/BasicCC.d.ts.map +1 -1
  156. package/build/esm/cc/BasicCC.js +380 -302
  157. package/build/esm/cc/BasicCC.js.map +1 -1
  158. package/build/esm/cc/BatteryCC.d.ts.map +1 -1
  159. package/build/esm/cc/BatteryCC.js +449 -384
  160. package/build/esm/cc/BatteryCC.js.map +1 -1
  161. package/build/esm/cc/BinarySensorCC.d.ts.map +1 -1
  162. package/build/esm/cc/BinarySensorCC.js +395 -297
  163. package/build/esm/cc/BinarySensorCC.js.map +1 -1
  164. package/build/esm/cc/BinarySwitchCC.d.ts.map +1 -1
  165. package/build/esm/cc/BinarySwitchCC.js +353 -274
  166. package/build/esm/cc/BinarySwitchCC.js.map +1 -1
  167. package/build/esm/cc/CRC16CC.js +162 -98
  168. package/build/esm/cc/CRC16CC.js.map +1 -1
  169. package/build/esm/cc/CentralSceneCC.d.ts.map +1 -1
  170. package/build/esm/cc/CentralSceneCC.js +465 -351
  171. package/build/esm/cc/CentralSceneCC.js.map +1 -1
  172. package/build/esm/cc/ClimateControlScheduleCC.d.ts.map +1 -1
  173. package/build/esm/cc/ClimateControlScheduleCC.js +454 -313
  174. package/build/esm/cc/ClimateControlScheduleCC.js.map +1 -1
  175. package/build/esm/cc/ClockCC.js +248 -159
  176. package/build/esm/cc/ClockCC.js.map +1 -1
  177. package/build/esm/cc/ColorSwitchCC.d.ts.map +1 -1
  178. package/build/esm/cc/ColorSwitchCC.js +802 -677
  179. package/build/esm/cc/ColorSwitchCC.js.map +1 -1
  180. package/build/esm/cc/ConfigurationCC.js +1899 -1687
  181. package/build/esm/cc/ConfigurationCC.js.map +1 -1
  182. package/build/esm/cc/DeviceResetLocallyCC.js +124 -59
  183. package/build/esm/cc/DeviceResetLocallyCC.js.map +1 -1
  184. package/build/esm/cc/DoorLockCC.d.ts.map +1 -1
  185. package/build/esm/cc/DoorLockCC.js +951 -849
  186. package/build/esm/cc/DoorLockCC.js.map +1 -1
  187. package/build/esm/cc/DoorLockLoggingCC.d.ts.map +1 -1
  188. package/build/esm/cc/DoorLockLoggingCC.js +316 -218
  189. package/build/esm/cc/DoorLockLoggingCC.js.map +1 -1
  190. package/build/esm/cc/EnergyProductionCC.js +240 -164
  191. package/build/esm/cc/EnergyProductionCC.js.map +1 -1
  192. package/build/esm/cc/EntryControlCC.d.ts.map +1 -1
  193. package/build/esm/cc/EntryControlCC.js +629 -493
  194. package/build/esm/cc/EntryControlCC.js.map +1 -1
  195. package/build/esm/cc/FirmwareUpdateMetaDataCC.d.ts.map +1 -1
  196. package/build/esm/cc/FirmwareUpdateMetaDataCC.js +938 -769
  197. package/build/esm/cc/FirmwareUpdateMetaDataCC.js.map +1 -1
  198. package/build/esm/cc/HailCC.js +51 -12
  199. package/build/esm/cc/HailCC.js.map +1 -1
  200. package/build/esm/cc/HumidityControlModeCC.d.ts.map +1 -1
  201. package/build/esm/cc/HumidityControlModeCC.js +357 -250
  202. package/build/esm/cc/HumidityControlModeCC.js.map +1 -1
  203. package/build/esm/cc/HumidityControlOperatingStateCC.d.ts.map +1 -1
  204. package/build/esm/cc/HumidityControlOperatingStateCC.js +182 -109
  205. package/build/esm/cc/HumidityControlOperatingStateCC.js.map +1 -1
  206. package/build/esm/cc/HumidityControlSetpointCC.d.ts.map +1 -1
  207. package/build/esm/cc/HumidityControlSetpointCC.js +706 -546
  208. package/build/esm/cc/HumidityControlSetpointCC.js.map +1 -1
  209. package/build/esm/cc/InclusionControllerCC.js +197 -119
  210. package/build/esm/cc/InclusionControllerCC.js.map +1 -1
  211. package/build/esm/cc/IndicatorCC.js +973 -835
  212. package/build/esm/cc/IndicatorCC.js.map +1 -1
  213. package/build/esm/cc/IrrigationCC.d.ts.map +1 -1
  214. package/build/esm/cc/IrrigationCC.js +1697 -1496
  215. package/build/esm/cc/IrrigationCC.js.map +1 -1
  216. package/build/esm/cc/LanguageCC.d.ts.map +1 -1
  217. package/build/esm/cc/LanguageCC.js +266 -184
  218. package/build/esm/cc/LanguageCC.js.map +1 -1
  219. package/build/esm/cc/LockCC.d.ts.map +1 -1
  220. package/build/esm/cc/LockCC.js +247 -162
  221. package/build/esm/cc/LockCC.js.map +1 -1
  222. package/build/esm/cc/ManufacturerProprietaryCC.js +192 -141
  223. package/build/esm/cc/ManufacturerProprietaryCC.js.map +1 -1
  224. package/build/esm/cc/ManufacturerSpecificCC.d.ts.map +1 -1
  225. package/build/esm/cc/ManufacturerSpecificCC.js +312 -223
  226. package/build/esm/cc/ManufacturerSpecificCC.js.map +1 -1
  227. package/build/esm/cc/MeterCC.d.ts.map +1 -1
  228. package/build/esm/cc/MeterCC.js +896 -795
  229. package/build/esm/cc/MeterCC.js.map +1 -1
  230. package/build/esm/cc/MultiChannelAssociationCC.d.ts.map +1 -1
  231. package/build/esm/cc/MultiChannelAssociationCC.js +631 -518
  232. package/build/esm/cc/MultiChannelAssociationCC.js.map +1 -1
  233. package/build/esm/cc/MultiChannelCC.d.ts.map +1 -1
  234. package/build/esm/cc/MultiChannelCC.js +1106 -921
  235. package/build/esm/cc/MultiChannelCC.js.map +1 -1
  236. package/build/esm/cc/MultiCommandCC.js +166 -102
  237. package/build/esm/cc/MultiCommandCC.js.map +1 -1
  238. package/build/esm/cc/MultilevelSensorCC.d.ts.map +1 -1
  239. package/build/esm/cc/MultilevelSensorCC.js +616 -497
  240. package/build/esm/cc/MultilevelSensorCC.js.map +1 -1
  241. package/build/esm/cc/MultilevelSwitchCC.d.ts.map +1 -1
  242. package/build/esm/cc/MultilevelSwitchCC.js +621 -496
  243. package/build/esm/cc/MultilevelSwitchCC.js.map +1 -1
  244. package/build/esm/cc/NoOperationCC.js +82 -29
  245. package/build/esm/cc/NoOperationCC.js.map +1 -1
  246. package/build/esm/cc/NodeNamingCC.d.ts.map +1 -1
  247. package/build/esm/cc/NodeNamingCC.js +413 -294
  248. package/build/esm/cc/NodeNamingCC.js.map +1 -1
  249. package/build/esm/cc/NotificationCC.d.ts.map +1 -1
  250. package/build/esm/cc/NotificationCC.js +1097 -966
  251. package/build/esm/cc/NotificationCC.js.map +1 -1
  252. package/build/esm/cc/PowerlevelCC.js +437 -311
  253. package/build/esm/cc/PowerlevelCC.js.map +1 -1
  254. package/build/esm/cc/ProtectionCC.d.ts.map +1 -1
  255. package/build/esm/cc/ProtectionCC.js +704 -543
  256. package/build/esm/cc/ProtectionCC.js.map +1 -1
  257. package/build/esm/cc/SceneActivationCC.d.ts.map +1 -1
  258. package/build/esm/cc/SceneActivationCC.js +157 -100
  259. package/build/esm/cc/SceneActivationCC.js.map +1 -1
  260. package/build/esm/cc/SceneActuatorConfigurationCC.js +357 -269
  261. package/build/esm/cc/SceneActuatorConfigurationCC.js.map +1 -1
  262. package/build/esm/cc/SceneControllerConfigurationCC.js +434 -346
  263. package/build/esm/cc/SceneControllerConfigurationCC.js.map +1 -1
  264. package/build/esm/cc/ScheduleEntryLockCC.d.ts.map +1 -1
  265. package/build/esm/cc/ScheduleEntryLockCC.js +1596 -1357
  266. package/build/esm/cc/ScheduleEntryLockCC.js.map +1 -1
  267. package/build/esm/cc/Security2CC.js +1633 -1406
  268. package/build/esm/cc/Security2CC.js.map +1 -1
  269. package/build/esm/cc/SecurityCC.js +876 -687
  270. package/build/esm/cc/SecurityCC.js.map +1 -1
  271. package/build/esm/cc/SoundSwitchCC.d.ts.map +1 -1
  272. package/build/esm/cc/SoundSwitchCC.js +689 -526
  273. package/build/esm/cc/SoundSwitchCC.js.map +1 -1
  274. package/build/esm/cc/SupervisionCC.js +349 -272
  275. package/build/esm/cc/SupervisionCC.js.map +1 -1
  276. package/build/esm/cc/ThermostatFanModeCC.d.ts.map +1 -1
  277. package/build/esm/cc/ThermostatFanModeCC.js +388 -284
  278. package/build/esm/cc/ThermostatFanModeCC.js.map +1 -1
  279. package/build/esm/cc/ThermostatFanStateCC.d.ts.map +1 -1
  280. package/build/esm/cc/ThermostatFanStateCC.js +184 -111
  281. package/build/esm/cc/ThermostatFanStateCC.js.map +1 -1
  282. package/build/esm/cc/ThermostatModeCC.d.ts.map +1 -1
  283. package/build/esm/cc/ThermostatModeCC.js +435 -331
  284. package/build/esm/cc/ThermostatModeCC.js.map +1 -1
  285. package/build/esm/cc/ThermostatOperatingStateCC.d.ts.map +1 -1
  286. package/build/esm/cc/ThermostatOperatingStateCC.js +180 -107
  287. package/build/esm/cc/ThermostatOperatingStateCC.js.map +1 -1
  288. package/build/esm/cc/ThermostatSetbackCC.js +274 -185
  289. package/build/esm/cc/ThermostatSetbackCC.js.map +1 -1
  290. package/build/esm/cc/ThermostatSetpointCC.d.ts.map +1 -1
  291. package/build/esm/cc/ThermostatSetpointCC.js +674 -543
  292. package/build/esm/cc/ThermostatSetpointCC.js.map +1 -1
  293. package/build/esm/cc/TimeCC.js +499 -360
  294. package/build/esm/cc/TimeCC.js.map +1 -1
  295. package/build/esm/cc/TimeParametersCC.d.ts.map +1 -1
  296. package/build/esm/cc/TimeParametersCC.js +296 -211
  297. package/build/esm/cc/TimeParametersCC.js.map +1 -1
  298. package/build/esm/cc/TransportServiceCC.js +464 -363
  299. package/build/esm/cc/TransportServiceCC.js.map +1 -1
  300. package/build/esm/cc/UserCodeCC.d.ts.map +1 -1
  301. package/build/esm/cc/UserCodeCC.js +1443 -1205
  302. package/build/esm/cc/UserCodeCC.js.map +1 -1
  303. package/build/esm/cc/VersionCC.d.ts.map +1 -1
  304. package/build/esm/cc/VersionCC.js +744 -635
  305. package/build/esm/cc/VersionCC.js.map +1 -1
  306. package/build/esm/cc/WakeUpCC.d.ts.map +1 -1
  307. package/build/esm/cc/WakeUpCC.js +494 -364
  308. package/build/esm/cc/WakeUpCC.js.map +1 -1
  309. package/build/esm/cc/WindowCoveringCC.d.ts.map +1 -1
  310. package/build/esm/cc/WindowCoveringCC.js +655 -530
  311. package/build/esm/cc/WindowCoveringCC.js.map +1 -1
  312. package/build/esm/cc/ZWaveLongRangeCC.js +51 -11
  313. package/build/esm/cc/ZWaveLongRangeCC.js.map +1 -1
  314. package/build/esm/cc/ZWavePlusCC.d.ts.map +1 -1
  315. package/build/esm/cc/ZWavePlusCC.js +223 -162
  316. package/build/esm/cc/ZWavePlusCC.js.map +1 -1
  317. package/build/esm/cc/ZWaveProtocolCC.js +1443 -953
  318. package/build/esm/cc/ZWaveProtocolCC.js.map +1 -1
  319. package/build/esm/cc/manufacturerProprietary/Decorators.d.ts +4 -4
  320. package/build/esm/cc/manufacturerProprietary/Decorators.d.ts.map +1 -1
  321. package/build/esm/cc/manufacturerProprietary/FibaroCC.js +390 -286
  322. package/build/esm/cc/manufacturerProprietary/FibaroCC.js.map +1 -1
  323. package/build/esm/lib/CommandClassDecorators.d.ts +11 -15
  324. package/build/esm/lib/CommandClassDecorators.d.ts.map +1 -1
  325. package/build/esm/lib/CommandClassDecorators.js +24 -24
  326. package/build/esm/lib/CommandClassDecorators.js.map +1 -1
  327. package/build/esm/lib/Security2/Extension.d.ts +1 -1
  328. package/build/esm/lib/Security2/Extension.d.ts.map +1 -1
  329. package/build/esm/lib/Security2/Extension.js +207 -123
  330. package/build/esm/lib/Security2/Extension.js.map +1 -1
  331. package/package.json +6 -6
@@ -1,10 +1,37 @@
1
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
- return c > 3 && r && Object.defineProperty(target, key, r), r;
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, ccValue, ccValues, commandClass, expectedCCResponse, getCommandClass, implementedVersion, useSupervision, } from "../lib/CommandClassDecorators.js";
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 = class MeterCCAPI extends PhysicalCCAPI {
446
- supportsCommand(cmd) {
447
- switch (cmd) {
448
- case MeterCommand.Get:
449
- case MeterCommand.Report:
450
- return true; // This is mandatory
451
- case MeterCommand.SupportedGet:
452
- case MeterCommand.SupportedReport:
453
- return this.version >= 2;
454
- case MeterCommand.Reset: {
455
- const ret = this.tryGetValueDB()?.getValue({
456
- commandClass: getCommandClass(this),
457
- endpoint: this.endpoint.index,
458
- property: "supportsReset",
459
- });
460
- return ret === true;
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
- return super.supportsCommand(cmd);
464
- }
465
- get [POLL_VALUE]() {
466
- return async function ({ property, propertyKey }) {
467
- switch (property) {
468
- case "value":
469
- case "previousValue":
470
- case "deltaTime": {
471
- if (propertyKey == undefined) {
472
- throwMissingPropertyKey(this.ccId, property);
473
- }
474
- else if (typeof propertyKey !== "number") {
475
- throwUnsupportedPropertyKey(this.ccId, property, propertyKey);
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
- const { rateType, scale } = splitPropertyKey(propertyKey);
478
- return (await this.get({
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
- async sendReport(options) {
512
- __assertType("options", "MeterCCReportOptions", __assertType__MeterCCReportOptions.bind(void 0, options));
513
- this.assertSupportsCommand(MeterCommand, MeterCommand.Report);
514
- const cc = new MeterCCReport({
515
- nodeId: this.endpoint.nodeId,
516
- endpointIndex: this.endpoint.index,
517
- ...options,
518
- });
519
- return this.host.sendCommand(cc, this.commandOptions);
520
- }
521
- async getAll(accumulatedOnly = false) {
522
- __assertType("accumulatedOnly", "(optional) boolean", __assertType__optional_boolean.bind(void 0, accumulatedOnly));
523
- const valueDB = this.tryGetValueDB();
524
- if (this.version >= 2) {
525
- const meterType = valueDB?.getValue(MeterCCValues.type.endpoint(this.endpoint.index));
526
- const supportedScales = valueDB?.getValue(MeterCCValues.supportedScales.endpoint(this.endpoint.index)) ?? [];
527
- const supportedRateTypes = valueDB?.getValue(MeterCCValues.supportedRateTypes.endpoint(this.endpoint.index)) ?? [];
528
- const rateTypes = supportedRateTypes.length
529
- ? supportedRateTypes
530
- : [undefined];
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
- else {
551
- const response = await this.get();
552
- return response ? [response] : [];
553
- }
554
- }
555
- // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
556
- async getSupported() {
557
- this.assertSupportsCommand(MeterCommand, MeterCommand.SupportedGet);
558
- const cc = new MeterCCSupportedGet({
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
- async sendSupportedReport(options) {
573
- __assertType("options", "MeterCCSupportedReportOptions", __assertType__MeterCCSupportedReportOptions.bind(void 0, options));
574
- this.assertSupportsCommand(MeterCommand, MeterCommand.SupportedReport);
575
- const cc = new MeterCCSupportedReport({
576
- nodeId: this.endpoint.nodeId,
577
- endpointIndex: this.endpoint.index,
578
- ...options,
579
- });
580
- await this.host.sendCommand(cc, this.commandOptions);
581
- }
582
- async reset(options) {
583
- __assertType("options", "(optional) MeterCCResetOptions", __assertType__optional_MeterCCResetOptions.bind(void 0, options));
584
- this.assertSupportsCommand(MeterCommand, MeterCommand.Reset);
585
- const cc = new MeterCCReset({
586
- nodeId: this.endpoint.nodeId,
587
- endpointIndex: this.endpoint.index,
588
- ...options,
589
- });
590
- return this.host.sendCommand(cc, this.commandOptions);
591
- }
592
- get [SET_VALUE]() {
593
- return async function ({ property, propertyKey }, value) {
594
- if (property !== "reset") {
595
- throwUnsupportedProperty(this.ccId, property);
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 if (propertyKey != undefined
598
- && typeof propertyKey !== "number") {
599
- throwUnsupportedPropertyKey(this.ccId, property, propertyKey);
591
+ else {
592
+ const response = await this.get();
593
+ return response ? [response] : [];
600
594
  }
601
- else if (value !== true) {
602
- throwWrongValueType(this.ccId, property, "true", value === false ? "false" : typeof value);
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
- const { meterType, scale, rateType } = splitPropertyKey(propertyKey);
606
- return this.reset({
607
- type: meterType,
608
- scale,
609
- rateType,
610
- targetValue: 0,
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
- return this.reset();
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
- MeterCCAPI = __decorate([
683
- API(CommandClasses.Meter)
684
- ], MeterCCAPI);
723
+ return MeterCCAPI = _classThis;
724
+ })();
685
725
  export { MeterCCAPI };
686
- let MeterCC = class MeterCC extends CommandClass {
687
- async interview(ctx) {
688
- const node = this.getNode(ctx);
689
- const endpoint = this.getEndpoint(ctx);
690
- const api = CCAPI.create(CommandClasses.Meter, ctx, endpoint).withOptions({
691
- priority: MessagePriority.NodeQuery,
692
- });
693
- ctx.logNode(node.id, {
694
- endpoint: this.endpointIndex,
695
- message: `Interviewing ${this.ccName}...`,
696
- direction: "none",
697
- });
698
- if (api.version >= 2) {
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: "querying meter support...",
702
- direction: "outbound",
749
+ message: `Interviewing ${this.ccName}...`,
750
+ direction: "none",
703
751
  });
704
- const suppResp = await api.getSupported();
705
- if (suppResp) {
706
- const logMessage = `received meter support:
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
- .map((s) => (getMeterScale(suppResp.type, s)
710
- ?? getUnknownMeterScale(s)).label)
711
- .map((label) => `\n· ${label}`)
712
- .join("")}
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
- .map((rt) => getEnumMemberName(RateType, rt))
715
- .map((label) => `\n· ${label}`)
716
- .join("")}
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: logMessage,
721
- direction: "inbound",
801
+ message: `querying default meter value...`,
802
+ direction: "outbound",
722
803
  });
804
+ await api.get();
723
805
  }
724
806
  else {
725
- ctx.logNode(node.id, {
726
- endpoint: this.endpointIndex,
727
- message: "Querying meter support timed out, skipping interview...",
728
- level: "warn",
729
- });
730
- return;
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
- // Query current meter values
734
- await this.refreshValues(ctx);
735
- // Remember that the interview is complete
736
- this.setInterviewComplete(ctx, true);
737
- }
738
- async refreshValues(ctx) {
739
- const node = this.getNode(ctx);
740
- const endpoint = this.getEndpoint(ctx);
741
- const api = CCAPI.create(CommandClasses.Meter, ctx, endpoint).withOptions({
742
- priority: MessagePriority.NodeQuery,
743
- });
744
- if (api.version === 1) {
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
- shouldRefreshValues(ctx) {
776
- // Poll the device when all of the supported values were last updated longer than 6 hours ago.
777
- // This may lead to some values not being updated, but the user may have disabled some unnecessary
778
- // reports to reduce traffic.
779
- const valueDB = ctx.tryGetValueDB(this.nodeId);
780
- if (!valueDB)
781
- return true;
782
- const values = this.getDefinedValueIDs(ctx).filter((v) => MeterCCValues.value.is(v));
783
- return values.every((v) => {
784
- const lastUpdated = valueDB.getTimestamp(v);
785
- return (lastUpdated == undefined
786
- || Date.now() - lastUpdated > timespan.hours(6));
787
- });
788
- }
789
- /**
790
- * Returns which type this meter has.
791
- * This only works AFTER the interview process
792
- */
793
- static getMeterTypeCached(ctx, endpoint) {
794
- return ctx
795
- .getValueDB(endpoint.nodeId)
796
- .getValue(MeterCCValues.type.endpoint(endpoint.index));
797
- }
798
- /**
799
- * Returns which scales are supported by this meter.
800
- * This only works AFTER the interview process
801
- */
802
- static getSupportedScalesCached(ctx, endpoint) {
803
- return ctx
804
- .getValueDB(endpoint.nodeId)
805
- .getValue(MeterCCValues.supportedScales.endpoint(endpoint.index));
806
- }
807
- /**
808
- * Returns whether reset is supported by this meter.
809
- * This only works AFTER the interview process
810
- */
811
- static supportsResetCached(ctx, endpoint) {
812
- return ctx
813
- .getValueDB(endpoint.nodeId)
814
- .getValue(MeterCCValues.supportsReset.endpoint(endpoint.index));
815
- }
816
- /**
817
- * Returns which rate types are supported by this meter.
818
- * This only works AFTER the interview process
819
- */
820
- static getSupportedRateTypesCached(ctx, endpoint) {
821
- return ctx
822
- .getValueDB(endpoint.nodeId)
823
- .getValue(MeterCCValues.supportedRateTypes.endpoint(endpoint.index));
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 (rateType !== RateType.Unspecified) {
837
- ret += "_" + getEnumMemberName(RateType, rateType);
895
+ else if (property === "reset" && typeof propertyKey === "number") {
896
+ return getMeterName(propertyKey);
838
897
  }
839
- return ret;
840
- }
841
- else if (property === "reset" && typeof propertyKey === "number") {
842
- return getMeterName(propertyKey);
898
+ return super.translatePropertyKey(ctx, property, propertyKey);
843
899
  }
844
- return super.translatePropertyKey(ctx, property, propertyKey);
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 = MeterCCReport_1 = class MeterCCReport extends MeterCC {
854
- constructor(options) {
855
- super(options);
856
- this.type = options.type;
857
- this.scale = options.scale;
858
- this.value = options.value;
859
- this.previousValue = options.previousValue;
860
- this.rateType = options.rateType ?? RateType.Unspecified;
861
- this.deltaTime = options.deltaTime ?? UNKNOWN_STATE;
862
- }
863
- static from(raw, ctx) {
864
- const { type, rateType, scale1, value, bytesRead } = parseMeterValueAndInfo(raw.payload, 0);
865
- let offset = bytesRead;
866
- const floatSize = bytesRead - 2;
867
- let deltaTime;
868
- let previousValue;
869
- if (raw.payload.length >= offset + 2) {
870
- deltaTime = raw.payload.readUInt16BE(offset);
871
- offset += 2;
872
- if (deltaTime === 0xffff) {
873
- deltaTime = UNKNOWN_STATE;
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
- if (
876
- // Previous value is included only if delta time is not 0
877
- deltaTime !== 0
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
- else {
890
- // 0 means that no previous value is included
891
- deltaTime = 0;
892
- }
893
- const scale = parseScale(scale1, raw.payload, offset);
894
- return new MeterCCReport_1({
895
- nodeId: ctx.sourceNodeId,
896
- type,
897
- rateType,
898
- value,
899
- deltaTime,
900
- previousValue,
901
- scale,
902
- });
903
- }
904
- persistValues(ctx) {
905
- if (!super.persistValues(ctx))
906
- return false;
907
- const ccVersion = getEffectiveCCVersion(ctx, this);
908
- const meter = getMeter(this.type);
909
- const scale = getMeterScale(this.type, this.scale)
910
- ?? getUnknownMeterScale(this.scale);
911
- // Filter out unknown meter types and scales, unless the strict validation is disabled
912
- const measurementValidation = !ctx.getDeviceConfig?.(this.nodeId)?.compat?.disableStrictMeasurementValidation;
913
- if (measurementValidation) {
914
- validatePayload.withReason(`Unknown meter type ${num2hex(this.type)} or corrupted data`)(!!meter);
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
- const valueValue = MeterCCValues.value(this.type, this.rateType, this.scale);
933
- this.setMetadata(ctx, valueValue, {
934
- ...valueValue.meta,
935
- label: getValueLabel(this.type, this.scale, this.rateType),
936
- unit: scale.unit,
937
- ccSpecific: {
938
- meterType: this.type,
939
- scale: this.scale,
940
- rateType: this.rateType,
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
- this.payload,
973
- Bytes.from([scale2]),
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
- return super.serialize(ctx);
977
- }
978
- toLogEntry(ctx) {
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 = MeterCCGet_1 = class MeterCCGet extends MeterCC {
1010
- constructor(options) {
1011
- super(options);
1012
- this.rateType = options.rateType;
1013
- this.scale = options.scale;
1014
- }
1015
- static from(raw, ctx) {
1016
- let rateType;
1017
- let scale;
1018
- if (raw.payload.length >= 1) {
1019
- rateType = (raw.payload[0] & 0b11_000_000) >>> 6;
1020
- scale = (raw.payload[0] & 0b00_111_000) >>> 3;
1021
- if (scale === 7) {
1022
- validatePayload(raw.payload.length >= 2);
1023
- scale += raw.payload[1];
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
- return new MeterCCGet_1({
1027
- nodeId: ctx.sourceNodeId,
1028
- rateType,
1029
- scale,
1030
- });
1031
- }
1032
- rateType;
1033
- scale;
1034
- serialize(ctx) {
1035
- let scale1;
1036
- let scale2;
1037
- let bufferLength = 0;
1038
- const ccVersion = getEffectiveCCVersion(ctx, this);
1039
- if (this.scale == undefined) {
1040
- scale1 = 0;
1041
- }
1042
- else if (ccVersion >= 4 && this.scale >= 7) {
1043
- scale1 = 7;
1044
- scale2 = this.scale >>> 3;
1045
- bufferLength = 2;
1046
- }
1047
- else if (ccVersion >= 3) {
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
- message.scale = this.scale;
1134
+ scale1 = 0;
1085
1135
  }
1086
- }
1087
- return {
1088
- ...super.toLogEntry(ctx),
1089
- message,
1090
- };
1091
- }
1092
- };
1093
- MeterCCGet = MeterCCGet_1 = __decorate([
1094
- CCCommand(MeterCommand.Get),
1095
- expectedCCResponse(MeterCCReport, testResponseForMeterGet)
1096
- ], MeterCCGet);
1097
- export { MeterCCGet };
1098
- let MeterCCSupportedReport = MeterCCSupportedReport_1 = class MeterCCSupportedReport extends MeterCC {
1099
- constructor(options) {
1100
- super(options);
1101
- this.type = options.type;
1102
- this.supportsReset = options.supportsReset;
1103
- this.supportedScales = options.supportedScales;
1104
- this.supportedRateTypes = options.supportedRateTypes;
1105
- }
1106
- static from(raw, ctx) {
1107
- validatePayload(raw.payload.length >= 2);
1108
- const type = raw.payload[0] & 0b0_00_11111;
1109
- const supportsReset = !!(raw.payload[0] & 0b1_00_00000);
1110
- const hasMoreScales = !!(raw.payload[1] & 0b1_0000000);
1111
- let supportedScales;
1112
- if (hasMoreScales) {
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
- return true;
1167
- }
1168
- serialize(ctx) {
1169
- const typeByte = (this.type & 0b0_00_11111)
1170
- | (this.supportedRateTypes.includes(RateType.Consumed)
1171
- ? 0b0_01_00000
1172
- : 0)
1173
- | (this.supportedRateTypes.includes(RateType.Produced)
1174
- ? 0b0_10_00000
1175
- : 0)
1176
- | (this.supportsReset ? 0b1_00_00000 : 0);
1177
- const supportedScales = encodeBitMask(this.supportedScales, undefined,
1178
- // The first byte only has 7 bits for the bitmask,
1179
- // so we add a fake bit for the value -1 and later shift
1180
- // the first byte one to the right
1181
- -1);
1182
- const scalesByte1 = (supportedScales[0] >>> 1)
1183
- | (supportedScales.length > 1 ? 0b1000_0000 : 0);
1184
- this.payload = Bytes.from([
1185
- typeByte,
1186
- scalesByte1,
1187
- ]);
1188
- if (supportedScales.length > 1) {
1189
- this.payload = Bytes.concat([
1190
- this.payload,
1191
- Bytes.from([supportedScales.length - 1]),
1192
- Bytes.from(supportedScales.subarray(1)),
1193
- ]);
1194
- }
1195
- return super.serialize(ctx);
1196
- }
1197
- toLogEntry(ctx) {
1198
- const message = {
1199
- "meter type": getMeterName(this.type),
1200
- "supports reset": this.supportsReset,
1201
- "supported scales": `${this.supportedScales
1202
- .map((scale) => `
1203
- · ${(getMeterScale(this.type, scale) ?? getUnknownMeterScale(scale)).label}`)
1204
- .join("")}`,
1205
- "supported rate types": this.supportedRateTypes
1206
- .map((rt) => getEnumMemberName(RateType, rt))
1207
- .join(", "),
1208
- };
1209
- return {
1210
- ...super.toLogEntry(ctx),
1211
- message,
1212
- };
1213
- }
1214
- };
1215
- __decorate([
1216
- ccValue(MeterCCValues.type)
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
- const { type, rateType, scale1, value: targetValue, bytesRead: scale2Offset, } = parseMeterValueAndInfo(raw.payload, 0);
1253
- const scale = parseScale(scale1, raw.payload, scale2Offset);
1254
- return new MeterCCReset_1({
1255
- nodeId: ctx.sourceNodeId,
1256
- type,
1257
- rateType,
1258
- targetValue,
1259
- scale,
1260
- });
1261
- }
1262
- type;
1263
- scale;
1264
- rateType;
1265
- targetValue;
1266
- serialize(ctx) {
1267
- if (this.type != undefined
1268
- && this.scale != undefined
1269
- && this.rateType != undefined
1270
- && this.targetValue != undefined) {
1271
- const { data: typeAndValue, scale2 } = encodeMeterValueAndInfo(this.type, this.rateType, this.scale, this.targetValue);
1272
- this.payload = typeAndValue;
1273
- if (scale2 != undefined) {
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([scale2]),
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
- return super.serialize(ctx);
1281
- }
1282
- toLogEntry(ctx) {
1283
- const message = {};
1284
- if (this.type != undefined) {
1285
- message.type = getMeterName(this.type);
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
- if (this.rateType != undefined) {
1288
- message["rate type"] = getEnumMemberName(RateType, this.rateType);
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
- if (this.type != undefined && this.scale != undefined) {
1291
- message.scale = (getMeterScale(this.type, this.scale)
1292
- ?? getUnknownMeterScale(this.scale)).label;
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
- if (this.targetValue != undefined) {
1295
- message["target value"] = this.targetValue;
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
- return {
1298
- ...super.toLogEntry(ctx),
1299
- message,
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