@zwave-js/cc 13.10.1 → 14.0.0-beta.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 (293) hide show
  1. package/build/cc/AlarmSensorCC.d.ts +31 -20
  2. package/build/cc/AlarmSensorCC.d.ts.map +1 -1
  3. package/build/cc/AlarmSensorCC.js +106 -87
  4. package/build/cc/AlarmSensorCC.js.map +1 -1
  5. package/build/cc/AssociationCC.d.ts +38 -32
  6. package/build/cc/AssociationCC.d.ts.map +1 -1
  7. package/build/cc/AssociationCC.js +193 -176
  8. package/build/cc/AssociationCC.js.map +1 -1
  9. package/build/cc/AssociationGroupInfoCC.d.ts +42 -36
  10. package/build/cc/AssociationGroupInfoCC.d.ts.map +1 -1
  11. package/build/cc/AssociationGroupInfoCC.js +218 -200
  12. package/build/cc/AssociationGroupInfoCC.js.map +1 -1
  13. package/build/cc/BarrierOperatorCC.d.ts +41 -24
  14. package/build/cc/BarrierOperatorCC.d.ts.map +1 -1
  15. package/build/cc/BarrierOperatorCC.js +143 -109
  16. package/build/cc/BarrierOperatorCC.js.map +1 -1
  17. package/build/cc/BasicCC.d.ts +22 -23
  18. package/build/cc/BasicCC.d.ts.map +1 -1
  19. package/build/cc/BasicCC.js +83 -77
  20. package/build/cc/BasicCC.js.map +1 -1
  21. package/build/cc/BatteryCC.d.ts +22 -14
  22. package/build/cc/BatteryCC.d.ts.map +1 -1
  23. package/build/cc/BatteryCC.js +116 -87
  24. package/build/cc/BatteryCC.js.map +1 -1
  25. package/build/cc/BinarySensorCC.d.ts +22 -19
  26. package/build/cc/BinarySensorCC.d.ts.map +1 -1
  27. package/build/cc/BinarySensorCC.js +103 -93
  28. package/build/cc/BinarySensorCC.js.map +1 -1
  29. package/build/cc/BinarySwitchCC.d.ts +20 -20
  30. package/build/cc/BinarySwitchCC.d.ts.map +1 -1
  31. package/build/cc/BinarySwitchCC.js +71 -59
  32. package/build/cc/BinarySwitchCC.js.map +1 -1
  33. package/build/cc/CRC16CC.d.ts +9 -9
  34. package/build/cc/CRC16CC.d.ts.map +1 -1
  35. package/build/cc/CRC16CC.js +36 -36
  36. package/build/cc/CRC16CC.js.map +1 -1
  37. package/build/cc/CentralSceneCC.d.ts +34 -16
  38. package/build/cc/CentralSceneCC.d.ts.map +1 -1
  39. package/build/cc/CentralSceneCC.js +116 -79
  40. package/build/cc/CentralSceneCC.js.map +1 -1
  41. package/build/cc/ClimateControlScheduleCC.d.ts +38 -21
  42. package/build/cc/ClimateControlScheduleCC.d.ts.map +1 -1
  43. package/build/cc/ClimateControlScheduleCC.js +113 -81
  44. package/build/cc/ClimateControlScheduleCC.js.map +1 -1
  45. package/build/cc/ClockCC.d.ts +18 -11
  46. package/build/cc/ClockCC.d.ts.map +1 -1
  47. package/build/cc/ClockCC.js +57 -43
  48. package/build/cc/ClockCC.js.map +1 -1
  49. package/build/cc/ColorSwitchCC.d.ts +37 -33
  50. package/build/cc/ColorSwitchCC.d.ts.map +1 -1
  51. package/build/cc/ColorSwitchCC.js +216 -189
  52. package/build/cc/ColorSwitchCC.js.map +1 -1
  53. package/build/cc/ConfigurationCC.d.ts +89 -74
  54. package/build/cc/ConfigurationCC.d.ts.map +1 -1
  55. package/build/cc/ConfigurationCC.js +541 -485
  56. package/build/cc/ConfigurationCC.js.map +1 -1
  57. package/build/cc/DeviceResetLocallyCC.d.ts +3 -3
  58. package/build/cc/DeviceResetLocallyCC.d.ts.map +1 -1
  59. package/build/cc/DeviceResetLocallyCC.js +14 -14
  60. package/build/cc/DeviceResetLocallyCC.js.map +1 -1
  61. package/build/cc/DoorLockCC.d.ts +66 -27
  62. package/build/cc/DoorLockCC.d.ts.map +1 -1
  63. package/build/cc/DoorLockCC.js +288 -197
  64. package/build/cc/DoorLockCC.js.map +1 -1
  65. package/build/cc/DoorLockLoggingCC.d.ts +23 -13
  66. package/build/cc/DoorLockLoggingCC.d.ts.map +1 -1
  67. package/build/cc/DoorLockLoggingCC.js +81 -63
  68. package/build/cc/DoorLockLoggingCC.js.map +1 -1
  69. package/build/cc/EnergyProductionCC.d.ts +16 -14
  70. package/build/cc/EnergyProductionCC.d.ts.map +1 -1
  71. package/build/cc/EnergyProductionCC.js +58 -52
  72. package/build/cc/EnergyProductionCC.js.map +1 -1
  73. package/build/cc/EntryControlCC.d.ts +44 -18
  74. package/build/cc/EntryControlCC.d.ts.map +1 -1
  75. package/build/cc/EntryControlCC.js +163 -112
  76. package/build/cc/EntryControlCC.js.map +1 -1
  77. package/build/cc/FirmwareUpdateMetaDataCC.d.ts +69 -34
  78. package/build/cc/FirmwareUpdateMetaDataCC.d.ts.map +1 -1
  79. package/build/cc/FirmwareUpdateMetaDataCC.js +311 -245
  80. package/build/cc/FirmwareUpdateMetaDataCC.js.map +1 -1
  81. package/build/cc/HumidityControlModeCC.d.ts +24 -16
  82. package/build/cc/HumidityControlModeCC.d.ts.map +1 -1
  83. package/build/cc/HumidityControlModeCC.js +80 -65
  84. package/build/cc/HumidityControlModeCC.js.map +1 -1
  85. package/build/cc/HumidityControlOperatingStateCC.d.ts +11 -7
  86. package/build/cc/HumidityControlOperatingStateCC.d.ts.map +1 -1
  87. package/build/cc/HumidityControlOperatingStateCC.js +31 -22
  88. package/build/cc/HumidityControlOperatingStateCC.js.map +1 -1
  89. package/build/cc/HumidityControlSetpointCC.d.ts +68 -49
  90. package/build/cc/HumidityControlSetpointCC.d.ts.map +1 -1
  91. package/build/cc/HumidityControlSetpointCC.js +203 -181
  92. package/build/cc/HumidityControlSetpointCC.js.map +1 -1
  93. package/build/cc/InclusionControllerCC.d.ts +13 -11
  94. package/build/cc/InclusionControllerCC.d.ts.map +1 -1
  95. package/build/cc/InclusionControllerCC.js +49 -42
  96. package/build/cc/InclusionControllerCC.js.map +1 -1
  97. package/build/cc/IndicatorCC.d.ts +46 -39
  98. package/build/cc/IndicatorCC.d.ts.map +1 -1
  99. package/build/cc/IndicatorCC.js +298 -277
  100. package/build/cc/IndicatorCC.js.map +1 -1
  101. package/build/cc/IrrigationCC.d.ts +127 -57
  102. package/build/cc/IrrigationCC.d.ts.map +1 -1
  103. package/build/cc/IrrigationCC.js +496 -352
  104. package/build/cc/IrrigationCC.js.map +1 -1
  105. package/build/cc/LanguageCC.d.ts +17 -11
  106. package/build/cc/LanguageCC.d.ts.map +1 -1
  107. package/build/cc/LanguageCC.js +54 -44
  108. package/build/cc/LanguageCC.js.map +1 -1
  109. package/build/cc/LockCC.d.ts +16 -11
  110. package/build/cc/LockCC.d.ts.map +1 -1
  111. package/build/cc/LockCC.js +48 -38
  112. package/build/cc/LockCC.js.map +1 -1
  113. package/build/cc/ManufacturerProprietaryCC.d.ts +12 -11
  114. package/build/cc/ManufacturerProprietaryCC.d.ts.map +1 -1
  115. package/build/cc/ManufacturerProprietaryCC.js +45 -50
  116. package/build/cc/ManufacturerProprietaryCC.js.map +1 -1
  117. package/build/cc/ManufacturerSpecificCC.d.ts +20 -13
  118. package/build/cc/ManufacturerSpecificCC.d.ts.map +1 -1
  119. package/build/cc/ManufacturerSpecificCC.js +79 -63
  120. package/build/cc/ManufacturerSpecificCC.js.map +1 -1
  121. package/build/cc/MeterCC.d.ts +30 -26
  122. package/build/cc/MeterCC.d.ts.map +1 -1
  123. package/build/cc/MeterCC.js +236 -204
  124. package/build/cc/MeterCC.js.map +1 -1
  125. package/build/cc/MultiChannelAssociationCC.d.ts +31 -26
  126. package/build/cc/MultiChannelAssociationCC.d.ts.map +1 -1
  127. package/build/cc/MultiChannelAssociationCC.js +177 -168
  128. package/build/cc/MultiChannelAssociationCC.js.map +1 -1
  129. package/build/cc/MultiChannelCC.d.ts +70 -49
  130. package/build/cc/MultiChannelCC.d.ts.map +1 -1
  131. package/build/cc/MultiChannelCC.js +377 -318
  132. package/build/cc/MultiChannelCC.js.map +1 -1
  133. package/build/cc/MultiCommandCC.d.ts +9 -9
  134. package/build/cc/MultiCommandCC.d.ts.map +1 -1
  135. package/build/cc/MultiCommandCC.js +35 -36
  136. package/build/cc/MultiCommandCC.js.map +1 -1
  137. package/build/cc/MultilevelSensorCC.d.ts +38 -33
  138. package/build/cc/MultilevelSensorCC.d.ts.map +1 -1
  139. package/build/cc/MultilevelSensorCC.js +172 -152
  140. package/build/cc/MultilevelSensorCC.js.map +1 -1
  141. package/build/cc/MultilevelSwitchCC.d.ts +29 -25
  142. package/build/cc/MultilevelSwitchCC.d.ts.map +1 -1
  143. package/build/cc/MultilevelSwitchCC.js +147 -127
  144. package/build/cc/MultilevelSwitchCC.js.map +1 -1
  145. package/build/cc/NoOperationCC.d.ts +0 -8
  146. package/build/cc/NoOperationCC.d.ts.map +1 -1
  147. package/build/cc/NoOperationCC.js +2 -11
  148. package/build/cc/NoOperationCC.js.map +1 -1
  149. package/build/cc/NodeNamingCC.d.ts +27 -17
  150. package/build/cc/NodeNamingCC.d.ts.map +1 -1
  151. package/build/cc/NodeNamingCC.js +86 -69
  152. package/build/cc/NodeNamingCC.js.map +1 -1
  153. package/build/cc/NotificationCC.d.ts +46 -43
  154. package/build/cc/NotificationCC.d.ts.map +1 -1
  155. package/build/cc/NotificationCC.js +317 -303
  156. package/build/cc/NotificationCC.js.map +1 -1
  157. package/build/cc/PowerlevelCC.d.ts +22 -18
  158. package/build/cc/PowerlevelCC.d.ts.map +1 -1
  159. package/build/cc/PowerlevelCC.js +125 -95
  160. package/build/cc/PowerlevelCC.js.map +1 -1
  161. package/build/cc/ProtectionCC.d.ts +49 -26
  162. package/build/cc/ProtectionCC.d.ts.map +1 -1
  163. package/build/cc/ProtectionCC.js +172 -126
  164. package/build/cc/ProtectionCC.js.map +1 -1
  165. package/build/cc/SceneActivationCC.d.ts +8 -7
  166. package/build/cc/SceneActivationCC.d.ts.map +1 -1
  167. package/build/cc/SceneActivationCC.js +28 -23
  168. package/build/cc/SceneActivationCC.js.map +1 -1
  169. package/build/cc/SceneActuatorConfigurationCC.d.ts +23 -15
  170. package/build/cc/SceneActuatorConfigurationCC.d.ts.map +1 -1
  171. package/build/cc/SceneActuatorConfigurationCC.js +79 -62
  172. package/build/cc/SceneActuatorConfigurationCC.js.map +1 -1
  173. package/build/cc/SceneControllerConfigurationCC.d.ts +25 -17
  174. package/build/cc/SceneControllerConfigurationCC.d.ts.map +1 -1
  175. package/build/cc/SceneControllerConfigurationCC.js +92 -78
  176. package/build/cc/SceneControllerConfigurationCC.js.map +1 -1
  177. package/build/cc/ScheduleEntryLockCC.d.ts +86 -72
  178. package/build/cc/ScheduleEntryLockCC.d.ts.map +1 -1
  179. package/build/cc/ScheduleEntryLockCC.js +607 -455
  180. package/build/cc/ScheduleEntryLockCC.js.map +1 -1
  181. package/build/cc/Security2CC.d.ts +78 -87
  182. package/build/cc/Security2CC.d.ts.map +1 -1
  183. package/build/cc/Security2CC.js +798 -765
  184. package/build/cc/Security2CC.js.map +1 -1
  185. package/build/cc/SecurityCC.d.ts +47 -42
  186. package/build/cc/SecurityCC.d.ts.map +1 -1
  187. package/build/cc/SecurityCC.js +240 -218
  188. package/build/cc/SecurityCC.js.map +1 -1
  189. package/build/cc/SoundSwitchCC.d.ts +36 -29
  190. package/build/cc/SoundSwitchCC.d.ts.map +1 -1
  191. package/build/cc/SoundSwitchCC.js +180 -157
  192. package/build/cc/SoundSwitchCC.js.map +1 -1
  193. package/build/cc/SupervisionCC.d.ts +17 -14
  194. package/build/cc/SupervisionCC.d.ts.map +1 -1
  195. package/build/cc/SupervisionCC.js +86 -66
  196. package/build/cc/SupervisionCC.js.map +1 -1
  197. package/build/cc/ThermostatFanModeCC.d.ts +25 -15
  198. package/build/cc/ThermostatFanModeCC.d.ts.map +1 -1
  199. package/build/cc/ThermostatFanModeCC.js +79 -60
  200. package/build/cc/ThermostatFanModeCC.js.map +1 -1
  201. package/build/cc/ThermostatFanStateCC.d.ts +11 -7
  202. package/build/cc/ThermostatFanStateCC.d.ts.map +1 -1
  203. package/build/cc/ThermostatFanStateCC.js +31 -22
  204. package/build/cc/ThermostatFanStateCC.js.map +1 -1
  205. package/build/cc/ThermostatModeCC.d.ts +24 -21
  206. package/build/cc/ThermostatModeCC.d.ts.map +1 -1
  207. package/build/cc/ThermostatModeCC.js +106 -90
  208. package/build/cc/ThermostatModeCC.js.map +1 -1
  209. package/build/cc/ThermostatOperatingStateCC.d.ts +11 -7
  210. package/build/cc/ThermostatOperatingStateCC.d.ts.map +1 -1
  211. package/build/cc/ThermostatOperatingStateCC.js +31 -22
  212. package/build/cc/ThermostatOperatingStateCC.js.map +1 -1
  213. package/build/cc/ThermostatSetbackCC.d.ts +14 -13
  214. package/build/cc/ThermostatSetbackCC.d.ts.map +1 -1
  215. package/build/cc/ThermostatSetbackCC.js +64 -57
  216. package/build/cc/ThermostatSetbackCC.js.map +1 -1
  217. package/build/cc/ThermostatSetpointCC.d.ts +38 -57
  218. package/build/cc/ThermostatSetpointCC.d.ts.map +1 -1
  219. package/build/cc/ThermostatSetpointCC.js +200 -264
  220. package/build/cc/ThermostatSetpointCC.js.map +1 -1
  221. package/build/cc/TimeCC.d.ts +24 -20
  222. package/build/cc/TimeCC.d.ts.map +1 -1
  223. package/build/cc/TimeCC.js +119 -108
  224. package/build/cc/TimeCC.js.map +1 -1
  225. package/build/cc/TimeParametersCC.d.ts +18 -14
  226. package/build/cc/TimeParametersCC.d.ts.map +1 -1
  227. package/build/cc/TimeParametersCC.js +77 -69
  228. package/build/cc/TimeParametersCC.js.map +1 -1
  229. package/build/cc/TransportServiceCC.d.ts +29 -32
  230. package/build/cc/TransportServiceCC.d.ts.map +1 -1
  231. package/build/cc/TransportServiceCC.js +159 -161
  232. package/build/cc/TransportServiceCC.js.map +1 -1
  233. package/build/cc/UserCodeCC.d.ts +83 -66
  234. package/build/cc/UserCodeCC.d.ts.map +1 -1
  235. package/build/cc/UserCodeCC.js +449 -402
  236. package/build/cc/UserCodeCC.js.map +1 -1
  237. package/build/cc/VersionCC.d.ts +36 -20
  238. package/build/cc/VersionCC.d.ts.map +1 -1
  239. package/build/cc/VersionCC.js +190 -149
  240. package/build/cc/VersionCC.js.map +1 -1
  241. package/build/cc/WakeUpCC.d.ts +27 -13
  242. package/build/cc/WakeUpCC.d.ts.map +1 -1
  243. package/build/cc/WakeUpCC.js +105 -77
  244. package/build/cc/WakeUpCC.js.map +1 -1
  245. package/build/cc/WindowCoveringCC.d.ts +39 -27
  246. package/build/cc/WindowCoveringCC.d.ts.map +1 -1
  247. package/build/cc/WindowCoveringCC.js +169 -137
  248. package/build/cc/WindowCoveringCC.js.map +1 -1
  249. package/build/cc/ZWavePlusCC.d.ts +8 -7
  250. package/build/cc/ZWavePlusCC.d.ts.map +1 -1
  251. package/build/cc/ZWavePlusCC.js +44 -37
  252. package/build/cc/ZWavePlusCC.js.map +1 -1
  253. package/build/cc/ZWaveProtocolCC.d.ts +111 -84
  254. package/build/cc/ZWaveProtocolCC.d.ts.map +1 -1
  255. package/build/cc/ZWaveProtocolCC.js +583 -508
  256. package/build/cc/ZWaveProtocolCC.js.map +1 -1
  257. package/build/cc/index.d.ts +37 -34
  258. package/build/cc/index.d.ts.map +1 -1
  259. package/build/cc/index.js +6 -7
  260. package/build/cc/index.js.map +1 -1
  261. package/build/cc/manufacturerProprietary/FibaroCC.d.ts +29 -24
  262. package/build/cc/manufacturerProprietary/FibaroCC.d.ts.map +1 -1
  263. package/build/cc/manufacturerProprietary/FibaroCC.js +109 -112
  264. package/build/cc/manufacturerProprietary/FibaroCC.js.map +1 -1
  265. package/build/index.d.ts +0 -1
  266. package/build/index.d.ts.map +1 -1
  267. package/build/index.js +0 -1
  268. package/build/index.js.map +1 -1
  269. package/build/lib/API.d.ts +21 -18
  270. package/build/lib/API.d.ts.map +1 -1
  271. package/build/lib/API.js +25 -49
  272. package/build/lib/API.js.map +1 -1
  273. package/build/lib/CommandClass.d.ts +51 -89
  274. package/build/lib/CommandClass.d.ts.map +1 -1
  275. package/build/lib/CommandClass.js +177 -249
  276. package/build/lib/CommandClass.js.map +1 -1
  277. package/build/lib/EncapsulatingCommandClass.d.ts +1 -15
  278. package/build/lib/EncapsulatingCommandClass.d.ts.map +1 -1
  279. package/build/lib/EncapsulatingCommandClass.js.map +1 -1
  280. package/build/lib/ICommandClassContainer.d.ts +1 -8
  281. package/build/lib/ICommandClassContainer.d.ts.map +1 -1
  282. package/build/lib/ICommandClassContainer.js +0 -8
  283. package/build/lib/ICommandClassContainer.js.map +1 -1
  284. package/build/lib/Values.d.ts +3 -3
  285. package/build/lib/Values.d.ts.map +1 -1
  286. package/build/lib/_Types.d.ts.map +1 -1
  287. package/build/lib/_Types.js +1 -0
  288. package/build/lib/_Types.js.map +1 -1
  289. package/build/lib/utils.d.ts +14 -13
  290. package/build/lib/utils.d.ts.map +1 -1
  291. package/build/lib/utils.js +94 -92
  292. package/build/lib/utils.js.map +1 -1
  293. package/package.json +4 -5
@@ -5,6 +5,7 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
5
5
  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;
6
6
  return c > 3 && r && Object.defineProperty(target, key, r), r;
7
7
  };
8
+ var MultilevelSensorCCReport_1, MultilevelSensorCCGet_1, MultilevelSensorCCSupportedSensorReport_1, MultilevelSensorCCSupportedScaleReport_1, MultilevelSensorCCGetSupportedScale_1;
8
9
  Object.defineProperty(exports, "__esModule", { value: true });
9
10
  exports.MultilevelSensorCCGetSupportedScale = exports.MultilevelSensorCCSupportedScaleReport = exports.MultilevelSensorCCGetSupportedSensor = exports.MultilevelSensorCCSupportedSensorReport = exports.MultilevelSensorCCGet = exports.MultilevelSensorCCReport = exports.MultilevelSensorCC = exports.MultilevelSensorCCAPI = exports.MultilevelSensorCCValues = void 0;
10
11
  function __assertType(argName, typeName, boundHasError) {
@@ -114,11 +115,12 @@ exports.MultilevelSensorCCValues = Object.freeze({
114
115
  * Determine the scale to use to query a sensor reading. Uses the user-preferred scale if given,
115
116
  * followed by the most recently used scale, otherwile falls back to the first supported one.
116
117
  */
117
- function getPreferredSensorScale(applHost, nodeId, endpointIndex, sensorType, supportedScales) {
118
+ function getPreferredSensorScale(ctx, nodeId, endpointIndex, sensorType, supportedScales) {
119
+ const preferences = ctx.getUserPreferences();
118
120
  const sensor = (0, core_1.getSensor)(sensorType);
119
121
  // If the sensor type is unknown, we have no default. Use the user-provided scale or 0
120
122
  if (!sensor) {
121
- const preferred = applHost.options.preferences?.scales[sensorType];
123
+ const preferred = preferences?.scales[sensorType];
122
124
  // We cannot look up strings for unknown sensor types, so this must be a number or we use the fallback
123
125
  if (typeof preferred !== "number")
124
126
  return 0;
@@ -128,23 +130,23 @@ function getPreferredSensorScale(applHost, nodeId, endpointIndex, sensorType, su
128
130
  let preferred;
129
131
  // Named scales apply to multiple sensor types. To be able to override the scale for single types
130
132
  // we need to look at the preferences by sensor type first
131
- preferred = applHost.options.preferences?.scales[sensorType];
133
+ preferred = preferences?.scales[sensorType];
132
134
  // If the scale is named, we can then try to use the named preference
133
135
  const scaleGroupName = sensor.scaleGroupName;
134
136
  if (preferred == undefined && scaleGroupName) {
135
- preferred = applHost.options.preferences?.scales[scaleGroupName];
137
+ preferred = preferences?.scales[scaleGroupName];
136
138
  }
137
139
  // Then attempt reading the scale from the corresponding value
138
140
  if (preferred == undefined) {
139
141
  const sensorName = (0, core_1.getSensorName)(sensorType);
140
142
  const sensorValue = exports.MultilevelSensorCCValues.value(sensorName);
141
- const metadata = applHost
143
+ const metadata = ctx
142
144
  .tryGetValueDB(nodeId)
143
145
  ?.getMetadata(sensorValue.endpoint(endpointIndex));
144
146
  const scale = metadata?.ccSpecific?.scale;
145
147
  if (typeof scale === "number" && supportedScales.includes(scale)) {
146
148
  preferred = scale;
147
- applHost.controllerLog.logNode(nodeId, {
149
+ ctx.logNode(nodeId, {
148
150
  endpoint: endpointIndex,
149
151
  message: `No scale preference for sensor type ${sensorType}, using the last-used scale ${preferred}`,
150
152
  });
@@ -153,7 +155,7 @@ function getPreferredSensorScale(applHost, nodeId, endpointIndex, sensorType, su
153
155
  // Then fall back to the first supported scale
154
156
  if (preferred == undefined) {
155
157
  preferred = supportedScales[0] ?? 0;
156
- applHost.controllerLog.logNode(nodeId, {
158
+ ctx.logNode(nodeId, {
157
159
  endpoint: endpointIndex,
158
160
  message: `No scale preference for sensor type ${sensorType}, using the first supported scale ${preferred}`,
159
161
  });
@@ -170,7 +172,7 @@ function getPreferredSensorScale(applHost, nodeId, endpointIndex, sensorType, su
170
172
  }
171
173
  if (typeof preferred === "string") {
172
174
  // Looking up failed
173
- applHost.controllerLog.logNode(nodeId, {
175
+ ctx.logNode(nodeId, {
174
176
  endpoint: endpointIndex,
175
177
  message: `Preferred scale "${preferred}" for sensor type ${sensorType} not found, using the first supported scale ${supportedScales[0] ?? 0}`,
176
178
  });
@@ -182,7 +184,7 @@ function getPreferredSensorScale(applHost, nodeId, endpointIndex, sensorType, su
182
184
  return preferred;
183
185
  }
184
186
  else if (!supportedScales.includes(preferred)) {
185
- applHost.controllerLog.logNode(nodeId, {
187
+ ctx.logNode(nodeId, {
186
188
  endpoint: endpointIndex,
187
189
  message: `Preferred scale ${preferred} not supported for sensor type ${sensorType}, using the first supported scale`,
188
190
  });
@@ -235,15 +237,15 @@ let MultilevelSensorCCAPI = class MultilevelSensorCCAPI extends API_1.PhysicalCC
235
237
  property: "supportedScales",
236
238
  propertyKey: sensorType,
237
239
  }) ?? [];
238
- preferredScale = getPreferredSensorScale(this.applHost, this.endpoint.nodeId, this.endpoint.index, sensorType, supportedScales);
240
+ preferredScale = getPreferredSensorScale(this.host, this.endpoint.nodeId, this.endpoint.index, sensorType, supportedScales);
239
241
  }
240
- const cc = new MultilevelSensorCCGet(this.applHost, {
242
+ const cc = new MultilevelSensorCCGet({
241
243
  nodeId: this.endpoint.nodeId,
242
- endpoint: this.endpoint.index,
243
- sensorType,
244
- scale: scale ?? preferredScale,
244
+ endpointIndex: this.endpoint.index,
245
+ sensorType: sensorType,
246
+ scale: (scale ?? preferredScale),
245
247
  });
246
- const response = await this.applHost.sendCommand(cc, this.commandOptions);
248
+ const response = await this.host.sendCommand(cc, this.commandOptions);
247
249
  if (!response)
248
250
  return;
249
251
  const responseScale = (0, core_1.getSensorScale)(response.type, response.scale);
@@ -269,22 +271,22 @@ let MultilevelSensorCCAPI = class MultilevelSensorCCAPI extends API_1.PhysicalCC
269
271
  }
270
272
  async getSupportedSensorTypes() {
271
273
  this.assertSupportsCommand(_Types_1.MultilevelSensorCommand, _Types_1.MultilevelSensorCommand.GetSupportedSensor);
272
- const cc = new MultilevelSensorCCGetSupportedSensor(this.applHost, {
274
+ const cc = new MultilevelSensorCCGetSupportedSensor({
273
275
  nodeId: this.endpoint.nodeId,
274
- endpoint: this.endpoint.index,
276
+ endpointIndex: this.endpoint.index,
275
277
  });
276
- const response = await this.applHost.sendCommand(cc, this.commandOptions);
278
+ const response = await this.host.sendCommand(cc, this.commandOptions);
277
279
  return response?.supportedSensorTypes;
278
280
  }
279
281
  async getSupportedScales(sensorType) {
280
282
  __assertType("sensorType", "number", __assertType__number.bind(void 0, sensorType));
281
283
  this.assertSupportsCommand(_Types_1.MultilevelSensorCommand, _Types_1.MultilevelSensorCommand.GetSupportedScale);
282
- const cc = new MultilevelSensorCCGetSupportedScale(this.applHost, {
284
+ const cc = new MultilevelSensorCCGetSupportedScale({
283
285
  nodeId: this.endpoint.nodeId,
284
- endpoint: this.endpoint.index,
286
+ endpointIndex: this.endpoint.index,
285
287
  sensorType,
286
288
  });
287
- const response = await this.applHost.sendCommand(cc, this.commandOptions);
289
+ const response = await this.host.sendCommand(cc, this.commandOptions);
288
290
  return response?.supportedScales;
289
291
  }
290
292
  async sendReport(sensorType, scale, value) {
@@ -292,14 +294,14 @@ let MultilevelSensorCCAPI = class MultilevelSensorCCAPI extends API_1.PhysicalCC
292
294
  __assertType("scale", undefined, __assertType__su__number__2_eu.bind(void 0, scale));
293
295
  __assertType("value", "number", __assertType__number.bind(void 0, value));
294
296
  this.assertSupportsCommand(_Types_1.MultilevelSensorCommand, _Types_1.MultilevelSensorCommand.Report);
295
- const cc = new MultilevelSensorCCReport(this.applHost, {
297
+ const cc = new MultilevelSensorCCReport({
296
298
  nodeId: this.endpoint.nodeId,
297
- endpoint: this.endpoint.index,
299
+ endpointIndex: this.endpoint.index,
298
300
  type: sensorType,
299
301
  scale,
300
302
  value,
301
303
  });
302
- return this.applHost.sendCommand(cc, this.commandOptions);
304
+ return this.host.sendCommand(cc, this.commandOptions);
303
305
  }
304
306
  };
305
307
  exports.MultilevelSensorCCAPI = MultilevelSensorCCAPI;
@@ -307,20 +309,20 @@ exports.MultilevelSensorCCAPI = MultilevelSensorCCAPI = __decorate([
307
309
  (0, CommandClassDecorators_1.API)(safe_1.CommandClasses["Multilevel Sensor"])
308
310
  ], MultilevelSensorCCAPI);
309
311
  let MultilevelSensorCC = class MultilevelSensorCC extends CommandClass_1.CommandClass {
310
- async interview(applHost) {
311
- const node = this.getNode(applHost);
312
- const endpoint = this.getEndpoint(applHost);
313
- const api = API_1.CCAPI.create(safe_1.CommandClasses["Multilevel Sensor"], applHost, endpoint).withOptions({
312
+ async interview(ctx) {
313
+ const node = this.getNode(ctx);
314
+ const endpoint = this.getEndpoint(ctx);
315
+ const api = API_1.CCAPI.create(safe_1.CommandClasses["Multilevel Sensor"], ctx, endpoint).withOptions({
314
316
  priority: safe_1.MessagePriority.NodeQuery,
315
317
  });
316
- applHost.controllerLog.logNode(node.id, {
318
+ ctx.logNode(node.id, {
317
319
  endpoint: this.endpointIndex,
318
320
  message: `Interviewing ${this.ccName}...`,
319
321
  direction: "none",
320
322
  });
321
- if (this.version >= 5) {
323
+ if (api.version >= 5) {
322
324
  // Query the supported sensor types
323
- applHost.controllerLog.logNode(node.id, {
325
+ ctx.logNode(node.id, {
324
326
  endpoint: this.endpointIndex,
325
327
  message: "retrieving supported sensor types...",
326
328
  direction: "outbound",
@@ -332,14 +334,14 @@ let MultilevelSensorCC = class MultilevelSensorCC extends CommandClass_1.Command
332
334
  .map((t) => (0, core_1.getSensorName)(t))
333
335
  .map((name) => `· ${name}`)
334
336
  .join("\n");
335
- applHost.controllerLog.logNode(node.id, {
337
+ ctx.logNode(node.id, {
336
338
  endpoint: this.endpointIndex,
337
339
  message: logMessage,
338
340
  direction: "inbound",
339
341
  });
340
342
  }
341
343
  else {
342
- applHost.controllerLog.logNode(node.id, {
344
+ ctx.logNode(node.id, {
343
345
  endpoint: this.endpointIndex,
344
346
  message: "Querying supported sensor types timed out, skipping interview...",
345
347
  level: "warn",
@@ -348,7 +350,7 @@ let MultilevelSensorCC = class MultilevelSensorCC extends CommandClass_1.Command
348
350
  }
349
351
  // As well as the supported scales for each sensor
350
352
  for (const type of sensorTypes) {
351
- applHost.controllerLog.logNode(node.id, {
353
+ ctx.logNode(node.id, {
352
354
  endpoint: this.endpointIndex,
353
355
  message: `querying supported scales for ${(0, core_1.getSensorName)(type)} sensor`,
354
356
  direction: "outbound",
@@ -361,14 +363,14 @@ let MultilevelSensorCC = class MultilevelSensorCC extends CommandClass_1.Command
361
363
  ?? (0, core_1.getUnknownScale)(s)).label)
362
364
  .map((name) => `· ${name}`)
363
365
  .join("\n");
364
- applHost.controllerLog.logNode(node.id, {
366
+ ctx.logNode(node.id, {
365
367
  endpoint: this.endpointIndex,
366
368
  message: logMessage,
367
369
  direction: "inbound",
368
370
  });
369
371
  }
370
372
  else {
371
- applHost.controllerLog.logNode(node.id, {
373
+ ctx.logNode(node.id, {
372
374
  endpoint: this.endpointIndex,
373
375
  message: "Querying supported scales timed out, skipping interview...",
374
376
  level: "warn",
@@ -377,20 +379,20 @@ let MultilevelSensorCC = class MultilevelSensorCC extends CommandClass_1.Command
377
379
  }
378
380
  }
379
381
  }
380
- await this.refreshValues(applHost);
382
+ await this.refreshValues(ctx);
381
383
  // Remember that the interview is complete
382
- this.setInterviewComplete(applHost, true);
384
+ this.setInterviewComplete(ctx, true);
383
385
  }
384
- async refreshValues(applHost) {
385
- const node = this.getNode(applHost);
386
- const endpoint = this.getEndpoint(applHost);
387
- const api = API_1.CCAPI.create(safe_1.CommandClasses["Multilevel Sensor"], applHost, endpoint).withOptions({
386
+ async refreshValues(ctx) {
387
+ const node = this.getNode(ctx);
388
+ const endpoint = this.getEndpoint(ctx);
389
+ const api = API_1.CCAPI.create(safe_1.CommandClasses["Multilevel Sensor"], ctx, endpoint).withOptions({
388
390
  priority: safe_1.MessagePriority.NodeQuery,
389
391
  });
390
- const valueDB = this.getValueDB(applHost);
391
- if (this.version <= 4) {
392
+ const valueDB = this.getValueDB(ctx);
393
+ if (api.version <= 4) {
392
394
  // Sensors up to V4 only support a single value
393
- applHost.controllerLog.logNode(node.id, {
395
+ ctx.logNode(node.id, {
394
396
  endpoint: this.endpointIndex,
395
397
  message: "querying current sensor reading...",
396
398
  direction: "outbound",
@@ -401,7 +403,7 @@ let MultilevelSensorCC = class MultilevelSensorCC extends CommandClass_1.Command
401
403
  const logMessage = `received current sensor reading:
402
404
  sensor type: ${(0, core_1.getSensorName)(mlsResponse.type)}
403
405
  value: ${mlsResponse.value}${sensorScale?.unit ? ` ${sensorScale.unit}` : ""}`;
404
- applHost.controllerLog.logNode(node.id, {
406
+ ctx.logNode(node.id, {
405
407
  endpoint: this.endpointIndex,
406
408
  message: logMessage,
407
409
  direction: "inbound",
@@ -416,7 +418,7 @@ value: ${mlsResponse.value}${sensorScale?.unit ? ` ${sensorScale.unit}` :
416
418
  endpoint: this.endpointIndex,
417
419
  }) || [];
418
420
  for (const type of sensorTypes) {
419
- applHost.controllerLog.logNode(node.id, {
421
+ ctx.logNode(node.id, {
420
422
  endpoint: this.endpointIndex,
421
423
  message: `querying ${(0, core_1.getSensorName)(type)} sensor reading...`,
422
424
  direction: "outbound",
@@ -424,7 +426,7 @@ value: ${mlsResponse.value}${sensorScale?.unit ? ` ${sensorScale.unit}` :
424
426
  const value = await api.get(type);
425
427
  if (value) {
426
428
  const logMessage = `received current ${(0, core_1.getSensorName)(type)} sensor reading: ${value.value} ${value.scale.unit || ""}`;
427
- applHost.controllerLog.logNode(node.id, {
429
+ ctx.logNode(node.id, {
428
430
  endpoint: this.endpointIndex,
429
431
  message: logMessage,
430
432
  direction: "inbound",
@@ -433,14 +435,14 @@ value: ${mlsResponse.value}${sensorScale?.unit ? ` ${sensorScale.unit}` :
433
435
  }
434
436
  }
435
437
  }
436
- shouldRefreshValues(applHost) {
438
+ shouldRefreshValues(ctx) {
437
439
  // Poll the device when all of the supported values were last updated longer than 6 hours ago.
438
440
  // This may lead to some values not being updated, but the user may have disabled some unnecessary
439
441
  // reports to reduce traffic.
440
- const valueDB = applHost.tryGetValueDB(this.nodeId);
442
+ const valueDB = ctx.tryGetValueDB(this.nodeId);
441
443
  if (!valueDB)
442
444
  return true;
443
- const values = this.getDefinedValueIDs(applHost).filter((v) => exports.MultilevelSensorCCValues.value.is(v));
445
+ const values = this.getDefinedValueIDs(ctx).filter((v) => exports.MultilevelSensorCCValues.value.is(v));
444
446
  return values.every((v) => {
445
447
  const lastUpdated = valueDB.getTimestamp(v);
446
448
  return (lastUpdated == undefined
@@ -451,8 +453,8 @@ value: ${mlsResponse.value}${sensorScale?.unit ? ` ${sensorScale.unit}` :
451
453
  * Returns which sensor types are supported.
452
454
  * This only works AFTER the interview process
453
455
  */
454
- static getSupportedSensorTypesCached(applHost, endpoint) {
455
- return applHost
456
+ static getSupportedSensorTypesCached(ctx, endpoint) {
457
+ return ctx
456
458
  .getValueDB(endpoint.nodeId)
457
459
  .getValue(exports.MultilevelSensorCCValues.supportedSensorTypes.endpoint(endpoint.index));
458
460
  }
@@ -460,19 +462,19 @@ value: ${mlsResponse.value}${sensorScale?.unit ? ` ${sensorScale.unit}` :
460
462
  * Returns which scales are supported for a given sensor type.
461
463
  * This only works AFTER the interview process
462
464
  */
463
- static getSupportedScalesCached(applHost, endpoint, sensorType) {
464
- return applHost
465
+ static getSupportedScalesCached(ctx, endpoint, sensorType) {
466
+ return ctx
465
467
  .getValueDB(endpoint.nodeId)
466
468
  .getValue(exports.MultilevelSensorCCValues.supportedScales(sensorType).endpoint(endpoint.index));
467
469
  }
468
- translatePropertyKey(applHost, property, propertyKey) {
470
+ translatePropertyKey(ctx, property, propertyKey) {
469
471
  // TODO: check this
470
472
  if (property === "values" && typeof propertyKey === "number") {
471
473
  const sensor = (0, core_1.getSensor)(propertyKey);
472
474
  if (sensor)
473
475
  return sensor.label;
474
476
  }
475
- return super.translatePropertyKey(applHost, property, propertyKey);
477
+ return super.translatePropertyKey(ctx, property, propertyKey);
476
478
  }
477
479
  };
478
480
  exports.MultilevelSensorCC = MultilevelSensorCC;
@@ -481,40 +483,43 @@ exports.MultilevelSensorCC = MultilevelSensorCC = __decorate([
481
483
  (0, CommandClassDecorators_1.implementedVersion)(11),
482
484
  (0, CommandClassDecorators_1.ccValues)(exports.MultilevelSensorCCValues)
483
485
  ], MultilevelSensorCC);
484
- let MultilevelSensorCCReport = class MultilevelSensorCCReport extends MultilevelSensorCC {
485
- constructor(host, options) {
486
- super(host, options);
487
- if ((0, CommandClass_1.gotDeserializationOptions)(options)) {
488
- (0, safe_1.validatePayload)(this.payload.length >= 1);
489
- this.type = this.payload[0];
490
- // parseFloatWithScale does its own validation
491
- const { value, scale } = (0, safe_1.parseFloatWithScale)(this.payload.subarray(1));
492
- this.value = value;
493
- this.scale = scale;
494
- }
495
- else {
496
- this.type = options.type;
497
- this.value = options.value;
498
- this.scale = typeof options.scale === "number"
499
- ? options.scale
500
- : options.scale.key;
501
- }
486
+ let MultilevelSensorCCReport = MultilevelSensorCCReport_1 = class MultilevelSensorCCReport extends MultilevelSensorCC {
487
+ constructor(options) {
488
+ super(options);
489
+ this.type = options.type;
490
+ this.value = options.value;
491
+ this.scale = typeof options.scale === "number"
492
+ ? options.scale
493
+ : options.scale.key;
494
+ }
495
+ static from(raw, ctx) {
496
+ (0, safe_1.validatePayload)(raw.payload.length >= 1);
497
+ const type = raw.payload[0];
498
+ // parseFloatWithScale does its own validation
499
+ const { value, scale } = (0, safe_1.parseFloatWithScale)(raw.payload.subarray(1));
500
+ return new MultilevelSensorCCReport_1({
501
+ nodeId: ctx.sourceNodeId,
502
+ type,
503
+ value,
504
+ scale,
505
+ });
502
506
  }
503
- persistValues(applHost) {
504
- if (!super.persistValues(applHost))
507
+ persistValues(ctx) {
508
+ if (!super.persistValues(ctx))
505
509
  return false;
506
510
  const sensor = (0, core_1.getSensor)(this.type);
507
511
  const scale = (0, core_1.getSensorScale)(this.type, this.scale) ?? (0, core_1.getUnknownScale)(this.scale);
508
512
  // Filter out unknown sensor types and scales, unless the strict validation is disabled
509
- const measurementValidation = !this.host.getDeviceConfig?.(this.nodeId)?.compat?.disableStrictMeasurementValidation;
513
+ const measurementValidation = !ctx.getDeviceConfig?.(this.nodeId)?.compat?.disableStrictMeasurementValidation;
514
+ const ccVersion = (0, CommandClass_1.getEffectiveCCVersion)(ctx, this);
510
515
  if (measurementValidation) {
511
516
  // Filter out unsupported sensor types and scales if possible
512
- if (this.version >= 5) {
513
- const supportedSensorTypes = this.getValue(applHost, exports.MultilevelSensorCCValues.supportedSensorTypes);
517
+ if (ccVersion >= 5) {
518
+ const supportedSensorTypes = this.getValue(ctx, exports.MultilevelSensorCCValues.supportedSensorTypes);
514
519
  if (supportedSensorTypes?.length) {
515
520
  safe_1.validatePayload.withReason(`Unsupported sensor type ${(0, core_1.getSensorName)(this.type)} or corrupted data`)(supportedSensorTypes.includes(this.type));
516
521
  }
517
- const supportedScales = this.getValue(applHost, exports.MultilevelSensorCCValues.supportedScales(this.type));
522
+ const supportedScales = this.getValue(ctx, exports.MultilevelSensorCCValues.supportedScales(this.type));
518
523
  if (supportedScales?.length) {
519
524
  safe_1.validatePayload.withReason(`Unsupported scale ${scale.label} or corrupted data`)(supportedScales.includes(scale.key));
520
525
  }
@@ -528,7 +533,7 @@ let MultilevelSensorCCReport = class MultilevelSensorCCReport extends Multilevel
528
533
  }
529
534
  const sensorName = (0, core_1.getSensorName)(this.type);
530
535
  const sensorValue = exports.MultilevelSensorCCValues.value(sensorName);
531
- this.setMetadata(applHost, sensorValue, {
536
+ this.setMetadata(ctx, sensorValue, {
532
537
  ...sensorValue.meta,
533
538
  unit: scale.unit,
534
539
  ccSpecific: {
@@ -536,22 +541,22 @@ let MultilevelSensorCCReport = class MultilevelSensorCCReport extends Multilevel
536
541
  scale: scale.key,
537
542
  },
538
543
  });
539
- this.setValue(applHost, sensorValue, this.value);
544
+ this.setValue(ctx, sensorValue, this.value);
540
545
  return true;
541
546
  }
542
547
  type;
543
548
  scale;
544
549
  value;
545
- serialize() {
550
+ serialize(ctx) {
546
551
  this.payload = Buffer.concat([
547
552
  Buffer.from([this.type]),
548
553
  (0, safe_1.encodeFloatWithScale)(this.value, this.scale),
549
554
  ]);
550
- return super.serialize();
555
+ return super.serialize(ctx);
551
556
  }
552
- toLogEntry(host) {
557
+ toLogEntry(ctx) {
553
558
  return {
554
- ...super.toLogEntry(host),
559
+ ...super.toLogEntry(ctx),
555
560
  message: {
556
561
  "sensor type": (0, core_1.getSensorName)(this.type),
557
562
  scale: ((0, core_1.getSensorScale)(this.type, this.scale)
@@ -562,7 +567,7 @@ let MultilevelSensorCCReport = class MultilevelSensorCCReport extends Multilevel
562
567
  }
563
568
  };
564
569
  exports.MultilevelSensorCCReport = MultilevelSensorCCReport;
565
- exports.MultilevelSensorCCReport = MultilevelSensorCCReport = __decorate([
570
+ exports.MultilevelSensorCCReport = MultilevelSensorCCReport = MultilevelSensorCCReport_1 = __decorate([
566
571
  (0, CommandClassDecorators_1.CCCommand)(_Types_1.MultilevelSensorCommand.Report),
567
572
  (0, CommandClassDecorators_1.useSupervision)()
568
573
  ], MultilevelSensorCCReport);
@@ -570,25 +575,33 @@ const testResponseForMultilevelSensorGet = (sent, received) => {
570
575
  // We expect a Multilevel Sensor Report that matches the requested sensor type (if a type was requested)
571
576
  return sent.sensorType == undefined || received.type === sent.sensorType;
572
577
  };
573
- let MultilevelSensorCCGet = class MultilevelSensorCCGet extends MultilevelSensorCC {
574
- constructor(host, options) {
575
- super(host, options);
576
- if ((0, CommandClass_1.gotDeserializationOptions)(options)) {
577
- if (this.payload.length >= 2) {
578
- this.sensorType = this.payload[0];
579
- this.scale = (this.payload[1] >> 3) & 0b11;
580
- }
578
+ let MultilevelSensorCCGet = MultilevelSensorCCGet_1 = class MultilevelSensorCCGet extends MultilevelSensorCC {
579
+ constructor(options) {
580
+ super(options);
581
+ if ("sensorType" in options) {
582
+ this.sensorType = options.sensorType;
583
+ this.scale = options.scale;
584
+ }
585
+ }
586
+ static from(raw, ctx) {
587
+ if (raw.payload.length >= 2) {
588
+ const sensorType = raw.payload[0];
589
+ const scale = (raw.payload[1] >> 3) & 0b11;
590
+ return new MultilevelSensorCCGet_1({
591
+ nodeId: ctx.sourceNodeId,
592
+ sensorType,
593
+ scale,
594
+ });
581
595
  }
582
596
  else {
583
- if ("sensorType" in options) {
584
- this.sensorType = options.sensorType;
585
- this.scale = options.scale;
586
- }
597
+ return new MultilevelSensorCCGet_1({
598
+ nodeId: ctx.sourceNodeId,
599
+ });
587
600
  }
588
601
  }
589
602
  sensorType;
590
603
  scale;
591
- serialize() {
604
+ serialize(ctx) {
592
605
  if (this.sensorType != undefined
593
606
  && this.scale != undefined) {
594
607
  this.payload = Buffer.from([
@@ -596,9 +609,9 @@ let MultilevelSensorCCGet = class MultilevelSensorCCGet extends MultilevelSensor
596
609
  (this.scale & 0b11) << 3,
597
610
  ]);
598
611
  }
599
- return super.serialize();
612
+ return super.serialize(ctx);
600
613
  }
601
- toLogEntry(host) {
614
+ toLogEntry(ctx) {
602
615
  let message = {};
603
616
  if (this.sensorType != undefined
604
617
  && this.scale != undefined) {
@@ -608,36 +621,38 @@ let MultilevelSensorCCGet = class MultilevelSensorCCGet extends MultilevelSensor
608
621
  };
609
622
  }
610
623
  return {
611
- ...super.toLogEntry(host),
624
+ ...super.toLogEntry(ctx),
612
625
  message,
613
626
  };
614
627
  }
615
628
  };
616
629
  exports.MultilevelSensorCCGet = MultilevelSensorCCGet;
617
- exports.MultilevelSensorCCGet = MultilevelSensorCCGet = __decorate([
630
+ exports.MultilevelSensorCCGet = MultilevelSensorCCGet = MultilevelSensorCCGet_1 = __decorate([
618
631
  (0, CommandClassDecorators_1.CCCommand)(_Types_1.MultilevelSensorCommand.Get),
619
632
  (0, CommandClassDecorators_1.expectedCCResponse)(MultilevelSensorCCReport, testResponseForMultilevelSensorGet)
620
633
  ], MultilevelSensorCCGet);
621
- let MultilevelSensorCCSupportedSensorReport = class MultilevelSensorCCSupportedSensorReport extends MultilevelSensorCC {
622
- constructor(host, options) {
623
- super(host, options);
624
- if ((0, CommandClass_1.gotDeserializationOptions)(options)) {
625
- (0, safe_1.validatePayload)(this.payload.length >= 1);
626
- this.supportedSensorTypes = (0, safe_1.parseBitMask)(this.payload);
627
- }
628
- else {
629
- this.supportedSensorTypes = options.supportedSensorTypes;
630
- }
634
+ let MultilevelSensorCCSupportedSensorReport = MultilevelSensorCCSupportedSensorReport_1 = class MultilevelSensorCCSupportedSensorReport extends MultilevelSensorCC {
635
+ constructor(options) {
636
+ super(options);
637
+ this.supportedSensorTypes = options.supportedSensorTypes;
638
+ }
639
+ static from(raw, ctx) {
640
+ (0, safe_1.validatePayload)(raw.payload.length >= 1);
641
+ const supportedSensorTypes = (0, safe_1.parseBitMask)(raw.payload);
642
+ return new MultilevelSensorCCSupportedSensorReport_1({
643
+ nodeId: ctx.sourceNodeId,
644
+ supportedSensorTypes,
645
+ });
631
646
  }
632
647
  // TODO: Use this during interview to precreate values
633
648
  supportedSensorTypes;
634
- serialize() {
649
+ serialize(ctx) {
635
650
  this.payload = (0, core_1.encodeBitMask)(this.supportedSensorTypes);
636
- return super.serialize();
651
+ return super.serialize(ctx);
637
652
  }
638
- toLogEntry(host) {
653
+ toLogEntry(ctx) {
639
654
  return {
640
- ...super.toLogEntry(host),
655
+ ...super.toLogEntry(ctx),
641
656
  message: {
642
657
  "supported sensor types": this.supportedSensorTypes
643
658
  .map((t) => `\n· ${(0, core_1.getSensorName)(t)}`)
@@ -650,7 +665,7 @@ exports.MultilevelSensorCCSupportedSensorReport = MultilevelSensorCCSupportedSen
650
665
  __decorate([
651
666
  (0, CommandClassDecorators_1.ccValue)(exports.MultilevelSensorCCValues.supportedSensorTypes)
652
667
  ], MultilevelSensorCCSupportedSensorReport.prototype, "supportedSensorTypes", void 0);
653
- exports.MultilevelSensorCCSupportedSensorReport = MultilevelSensorCCSupportedSensorReport = __decorate([
668
+ exports.MultilevelSensorCCSupportedSensorReport = MultilevelSensorCCSupportedSensorReport = MultilevelSensorCCSupportedSensorReport_1 = __decorate([
654
669
  (0, CommandClassDecorators_1.CCCommand)(_Types_1.MultilevelSensorCommand.SupportedSensorReport)
655
670
  ], MultilevelSensorCCSupportedSensorReport);
656
671
  let MultilevelSensorCCGetSupportedSensor = class MultilevelSensorCCGetSupportedSensor extends MultilevelSensorCC {
@@ -660,31 +675,34 @@ exports.MultilevelSensorCCGetSupportedSensor = MultilevelSensorCCGetSupportedSen
660
675
  (0, CommandClassDecorators_1.CCCommand)(_Types_1.MultilevelSensorCommand.GetSupportedSensor),
661
676
  (0, CommandClassDecorators_1.expectedCCResponse)(MultilevelSensorCCSupportedSensorReport)
662
677
  ], MultilevelSensorCCGetSupportedSensor);
663
- let MultilevelSensorCCSupportedScaleReport = class MultilevelSensorCCSupportedScaleReport extends MultilevelSensorCC {
664
- constructor(host, options) {
665
- super(host, options);
666
- if ((0, CommandClass_1.gotDeserializationOptions)(options)) {
667
- (0, safe_1.validatePayload)(this.payload.length >= 2);
668
- this.sensorType = this.payload[0];
669
- this.supportedScales = (0, safe_1.parseBitMask)(Buffer.from([this.payload[1] & 0b1111]), 0);
670
- }
671
- else {
672
- this.sensorType = options.sensorType;
673
- this.supportedScales = options.supportedScales;
674
- }
678
+ let MultilevelSensorCCSupportedScaleReport = MultilevelSensorCCSupportedScaleReport_1 = class MultilevelSensorCCSupportedScaleReport extends MultilevelSensorCC {
679
+ constructor(options) {
680
+ super(options);
681
+ this.sensorType = options.sensorType;
682
+ this.supportedScales = options.supportedScales;
683
+ }
684
+ static from(raw, ctx) {
685
+ (0, safe_1.validatePayload)(raw.payload.length >= 2);
686
+ const sensorType = raw.payload[0];
687
+ const supportedScales = (0, safe_1.parseBitMask)(Buffer.from([raw.payload[1] & 0b1111]), 0);
688
+ return new MultilevelSensorCCSupportedScaleReport_1({
689
+ nodeId: ctx.sourceNodeId,
690
+ sensorType,
691
+ supportedScales,
692
+ });
675
693
  }
676
694
  sensorType;
677
695
  supportedScales;
678
- serialize() {
696
+ serialize(ctx) {
679
697
  this.payload = Buffer.concat([
680
698
  Buffer.from([this.sensorType]),
681
699
  (0, core_1.encodeBitMask)(this.supportedScales, 4, 0),
682
700
  ]);
683
- return super.serialize();
701
+ return super.serialize(ctx);
684
702
  }
685
- toLogEntry(host) {
703
+ toLogEntry(ctx) {
686
704
  return {
687
- ...super.toLogEntry(host),
705
+ ...super.toLogEntry(ctx),
688
706
  message: {
689
707
  "sensor type": (0, core_1.getSensorName)(this.sensorType),
690
708
  "supported scales": this.supportedScales
@@ -699,28 +717,30 @@ exports.MultilevelSensorCCSupportedScaleReport = MultilevelSensorCCSupportedScal
699
717
  __decorate([
700
718
  (0, CommandClassDecorators_1.ccValue)(exports.MultilevelSensorCCValues.supportedScales, (self) => [self.sensorType])
701
719
  ], MultilevelSensorCCSupportedScaleReport.prototype, "supportedScales", void 0);
702
- exports.MultilevelSensorCCSupportedScaleReport = MultilevelSensorCCSupportedScaleReport = __decorate([
720
+ exports.MultilevelSensorCCSupportedScaleReport = MultilevelSensorCCSupportedScaleReport = MultilevelSensorCCSupportedScaleReport_1 = __decorate([
703
721
  (0, CommandClassDecorators_1.CCCommand)(_Types_1.MultilevelSensorCommand.SupportedScaleReport)
704
722
  ], MultilevelSensorCCSupportedScaleReport);
705
- let MultilevelSensorCCGetSupportedScale = class MultilevelSensorCCGetSupportedScale extends MultilevelSensorCC {
706
- constructor(host, options) {
707
- super(host, options);
708
- if ((0, CommandClass_1.gotDeserializationOptions)(options)) {
709
- (0, safe_1.validatePayload)(this.payload.length >= 1);
710
- this.sensorType = this.payload[0];
711
- }
712
- else {
713
- this.sensorType = options.sensorType;
714
- }
723
+ let MultilevelSensorCCGetSupportedScale = MultilevelSensorCCGetSupportedScale_1 = class MultilevelSensorCCGetSupportedScale extends MultilevelSensorCC {
724
+ constructor(options) {
725
+ super(options);
726
+ this.sensorType = options.sensorType;
727
+ }
728
+ static from(raw, ctx) {
729
+ (0, safe_1.validatePayload)(raw.payload.length >= 1);
730
+ const sensorType = raw.payload[0];
731
+ return new MultilevelSensorCCGetSupportedScale_1({
732
+ nodeId: ctx.sourceNodeId,
733
+ sensorType,
734
+ });
715
735
  }
716
736
  sensorType;
717
- serialize() {
737
+ serialize(ctx) {
718
738
  this.payload = Buffer.from([this.sensorType]);
719
- return super.serialize();
739
+ return super.serialize(ctx);
720
740
  }
721
- toLogEntry(host) {
741
+ toLogEntry(ctx) {
722
742
  return {
723
- ...super.toLogEntry(host),
743
+ ...super.toLogEntry(ctx),
724
744
  message: {
725
745
  "sensor type": (0, core_1.getSensorName)(this.sensorType),
726
746
  },
@@ -728,7 +748,7 @@ let MultilevelSensorCCGetSupportedScale = class MultilevelSensorCCGetSupportedSc
728
748
  }
729
749
  };
730
750
  exports.MultilevelSensorCCGetSupportedScale = MultilevelSensorCCGetSupportedScale;
731
- exports.MultilevelSensorCCGetSupportedScale = MultilevelSensorCCGetSupportedScale = __decorate([
751
+ exports.MultilevelSensorCCGetSupportedScale = MultilevelSensorCCGetSupportedScale = MultilevelSensorCCGetSupportedScale_1 = __decorate([
732
752
  (0, CommandClassDecorators_1.CCCommand)(_Types_1.MultilevelSensorCommand.GetSupportedScale),
733
753
  (0, CommandClassDecorators_1.expectedCCResponse)(MultilevelSensorCCSupportedScaleReport)
734
754
  ], MultilevelSensorCCGetSupportedScale);