@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 ColorSwitchCCSupportedReport_1, ColorSwitchCCReport_1, ColorSwitchCCGet_1, ColorSwitchCCSet_1, ColorSwitchCCStartLevelChange_1, ColorSwitchCCStopLevelChange_1;
8
9
  Object.defineProperty(exports, "__esModule", { value: true });
9
10
  exports.ColorSwitchCCStopLevelChange = exports.ColorSwitchCCStartLevelChange = exports.ColorSwitchCCSet = exports.ColorSwitchCCGet = exports.ColorSwitchCCReport = exports.ColorSwitchCCSupportedGet = exports.ColorSwitchCCSupportedReport = exports.ColorSwitchCC = exports.ColorSwitchCCAPI = exports.ColorSwitchCCValues = void 0;
10
11
  function __assertType(argName, typeName, boundHasError) {
@@ -447,22 +448,22 @@ let ColorSwitchCCAPI = class ColorSwitchCCAPI extends API_1.CCAPI {
447
448
  }
448
449
  async getSupported() {
449
450
  this.assertSupportsCommand(_Types_1.ColorSwitchCommand, _Types_1.ColorSwitchCommand.SupportedGet);
450
- const cc = new ColorSwitchCCSupportedGet(this.applHost, {
451
+ const cc = new ColorSwitchCCSupportedGet({
451
452
  nodeId: this.endpoint.nodeId,
452
- endpoint: this.endpoint.index,
453
+ endpointIndex: this.endpoint.index,
453
454
  });
454
- const response = await this.applHost.sendCommand(cc, this.commandOptions);
455
+ const response = await this.host.sendCommand(cc, this.commandOptions);
455
456
  return response?.supportedColorComponents;
456
457
  }
457
458
  async get(component) {
458
459
  __assertType("component", "ColorComponent", __assertType__ColorComponent.bind(void 0, component));
459
460
  this.assertSupportsCommand(_Types_1.ColorSwitchCommand, _Types_1.ColorSwitchCommand.Get);
460
- const cc = new ColorSwitchCCGet(this.applHost, {
461
+ const cc = new ColorSwitchCCGet({
461
462
  nodeId: this.endpoint.nodeId,
462
- endpoint: this.endpoint.index,
463
+ endpointIndex: this.endpoint.index,
463
464
  colorComponent: component,
464
465
  });
465
- const response = await this.applHost.sendCommand(cc, this.commandOptions);
466
+ const response = await this.host.sendCommand(cc, this.commandOptions);
466
467
  if (response) {
467
468
  return (0, safe_2.pick)(response, ["currentValue", "targetValue", "duration"]);
468
469
  }
@@ -470,12 +471,12 @@ let ColorSwitchCCAPI = class ColorSwitchCCAPI extends API_1.CCAPI {
470
471
  async set(options) {
471
472
  __assertType("options", "ColorSwitchCCSetOptions", __assertType__ColorSwitchCCSetOptions.bind(void 0, options));
472
473
  this.assertSupportsCommand(_Types_1.ColorSwitchCommand, _Types_1.ColorSwitchCommand.Set);
473
- const cc = new ColorSwitchCCSet(this.applHost, {
474
+ const cc = new ColorSwitchCCSet({
474
475
  nodeId: this.endpoint.nodeId,
475
- endpoint: this.endpoint.index,
476
+ endpointIndex: this.endpoint.index,
476
477
  ...options,
477
478
  });
478
- const result = await this.applHost.sendCommand(cc, this.commandOptions);
479
+ const result = await this.host.sendCommand(cc, this.commandOptions);
479
480
  if ((0, core_1.isUnsupervisedOrSucceeded)(result)) {
480
481
  // If the command did not fail, assume that it succeeded and update the values accordingly
481
482
  // TODO: The API methods should not modify the value DB directly, but to do so
@@ -491,7 +492,7 @@ let ColorSwitchCCAPI = class ColorSwitchCCAPI extends API_1.CCAPI {
491
492
  ?.supportsCC(this.ccId));
492
493
  // and optimistically update the currentColor
493
494
  for (const node of affectedNodes) {
494
- const valueDB = this.applHost.tryGetValueDB(node.id);
495
+ const valueDB = this.host.tryGetValueDB(node.id);
495
496
  if (valueDB) {
496
497
  this.updateCurrentColor(valueDB, cc.colorTable);
497
498
  }
@@ -540,22 +541,22 @@ let ColorSwitchCCAPI = class ColorSwitchCCAPI extends API_1.CCAPI {
540
541
  async startLevelChange(options) {
541
542
  __assertType("options", "ColorSwitchCCStartLevelChangeOptions", __assertType__ColorSwitchCCStartLevelChangeOptions.bind(void 0, options));
542
543
  this.assertSupportsCommand(_Types_1.ColorSwitchCommand, _Types_1.ColorSwitchCommand.StartLevelChange);
543
- const cc = new ColorSwitchCCStartLevelChange(this.applHost, {
544
+ const cc = new ColorSwitchCCStartLevelChange({
544
545
  nodeId: this.endpoint.nodeId,
545
- endpoint: this.endpoint.index,
546
+ endpointIndex: this.endpoint.index,
546
547
  ...options,
547
548
  });
548
- return this.applHost.sendCommand(cc, this.commandOptions);
549
+ return this.host.sendCommand(cc, this.commandOptions);
549
550
  }
550
551
  async stopLevelChange(colorComponent) {
551
552
  __assertType("colorComponent", "ColorComponent", __assertType__ColorComponent.bind(void 0, colorComponent));
552
553
  this.assertSupportsCommand(_Types_1.ColorSwitchCommand, _Types_1.ColorSwitchCommand.StopLevelChange);
553
- const cc = new ColorSwitchCCStopLevelChange(this.applHost, {
554
+ const cc = new ColorSwitchCCStopLevelChange({
554
555
  nodeId: this.endpoint.nodeId,
555
- endpoint: this.endpoint.index,
556
+ endpointIndex: this.endpoint.index,
556
557
  colorComponent,
557
558
  });
558
- return this.applHost.sendCommand(cc, this.commandOptions);
559
+ return this.host.sendCommand(cc, this.commandOptions);
559
560
  }
560
561
  get [API_1.SET_VALUE]() {
561
562
  return async function ({ property, propertyKey }, value, options) {
@@ -655,32 +656,32 @@ exports.ColorSwitchCCAPI = ColorSwitchCCAPI = __decorate([
655
656
  (0, CommandClassDecorators_1.API)(core_1.CommandClasses["Color Switch"])
656
657
  ], ColorSwitchCCAPI);
657
658
  let ColorSwitchCC = class ColorSwitchCC extends CommandClass_1.CommandClass {
658
- async interview(applHost) {
659
- const node = this.getNode(applHost);
660
- const endpoint = this.getEndpoint(applHost);
661
- const api = API_1.CCAPI.create(core_1.CommandClasses["Color Switch"], applHost, endpoint).withOptions({
659
+ async interview(ctx) {
660
+ const node = this.getNode(ctx);
661
+ const endpoint = this.getEndpoint(ctx);
662
+ const api = API_1.CCAPI.create(core_1.CommandClasses["Color Switch"], ctx, endpoint).withOptions({
662
663
  priority: core_1.MessagePriority.NodeQuery,
663
664
  });
664
- applHost.controllerLog.logNode(node.id, {
665
+ ctx.logNode(node.id, {
665
666
  endpoint: this.endpointIndex,
666
667
  message: `Interviewing ${this.ccName}...`,
667
668
  direction: "none",
668
669
  });
669
- applHost.controllerLog.logNode(node.id, {
670
+ ctx.logNode(node.id, {
670
671
  endpoint: this.endpointIndex,
671
672
  message: "querying supported colors...",
672
673
  direction: "outbound",
673
674
  });
674
675
  const supportedColors = await api.getSupported();
675
676
  if (!supportedColors) {
676
- applHost.controllerLog.logNode(node.id, {
677
+ ctx.logNode(node.id, {
677
678
  endpoint: this.endpointIndex,
678
679
  message: "Querying supported colors timed out, skipping interview...",
679
680
  level: "warn",
680
681
  });
681
682
  return;
682
683
  }
683
- applHost.controllerLog.logNode(node.id, {
684
+ ctx.logNode(node.id, {
684
685
  endpoint: this.endpointIndex,
685
686
  message: `received supported colors:${supportedColors
686
687
  .map((c) => `\n· ${(0, safe_2.getEnumMemberName)(_Types_1.ColorComponent, c)}`)
@@ -691,46 +692,46 @@ let ColorSwitchCC = class ColorSwitchCC extends CommandClass_1.CommandClass {
691
692
  for (const color of supportedColors) {
692
693
  const currentColorChannelValue = exports.ColorSwitchCCValues
693
694
  .currentColorChannel(color);
694
- this.setMetadata(applHost, currentColorChannelValue);
695
+ this.setMetadata(ctx, currentColorChannelValue);
695
696
  const targetColorChannelValue = exports.ColorSwitchCCValues
696
697
  .targetColorChannel(color);
697
- this.setMetadata(applHost, targetColorChannelValue);
698
+ this.setMetadata(ctx, targetColorChannelValue);
698
699
  }
699
700
  // And the compound one
700
701
  const currentColorValue = exports.ColorSwitchCCValues.currentColor;
701
- this.setMetadata(applHost, currentColorValue);
702
+ this.setMetadata(ctx, currentColorValue);
702
703
  const targetColorValue = exports.ColorSwitchCCValues.targetColor;
703
- this.setMetadata(applHost, targetColorValue);
704
+ this.setMetadata(ctx, targetColorValue);
704
705
  // Create the collective HEX color values
705
706
  const supportsHex = [
706
707
  _Types_1.ColorComponent.Red,
707
708
  _Types_1.ColorComponent.Green,
708
709
  _Types_1.ColorComponent.Blue,
709
710
  ].every((c) => supportedColors.includes(c));
710
- this.setValue(applHost, exports.ColorSwitchCCValues.supportsHexColor, supportsHex);
711
+ this.setValue(ctx, exports.ColorSwitchCCValues.supportsHexColor, supportsHex);
711
712
  if (supportsHex) {
712
713
  const hexColorValue = exports.ColorSwitchCCValues.hexColor;
713
- this.setMetadata(applHost, hexColorValue);
714
+ this.setMetadata(ctx, hexColorValue);
714
715
  }
715
716
  // Query all color components
716
- await this.refreshValues(applHost);
717
+ await this.refreshValues(ctx);
717
718
  // Remember that the interview is complete
718
- this.setInterviewComplete(applHost, true);
719
+ this.setInterviewComplete(ctx, true);
719
720
  }
720
- async refreshValues(applHost) {
721
- const node = this.getNode(applHost);
722
- const endpoint = this.getEndpoint(applHost);
723
- const api = API_1.CCAPI.create(core_1.CommandClasses["Color Switch"], applHost, endpoint).withOptions({
721
+ async refreshValues(ctx) {
722
+ const node = this.getNode(ctx);
723
+ const endpoint = this.getEndpoint(ctx);
724
+ const api = API_1.CCAPI.create(core_1.CommandClasses["Color Switch"], ctx, endpoint).withOptions({
724
725
  priority: core_1.MessagePriority.NodeQuery,
725
726
  });
726
- const supportedColors = this.getValue(applHost, exports.ColorSwitchCCValues.supportedColorComponents) ?? [];
727
+ const supportedColors = this.getValue(ctx, exports.ColorSwitchCCValues.supportedColorComponents) ?? [];
727
728
  for (const color of supportedColors) {
728
729
  // Some devices report invalid colors, but the CC API checks
729
730
  // for valid values and throws otherwise.
730
731
  if (!(0, safe_2.isEnumMember)(_Types_1.ColorComponent, color))
731
732
  continue;
732
733
  const colorName = (0, safe_2.getEnumMemberName)(_Types_1.ColorComponent, color);
733
- applHost.controllerLog.logNode(node.id, {
734
+ ctx.logNode(node.id, {
734
735
  endpoint: this.endpointIndex,
735
736
  message: `querying current color state (${colorName})`,
736
737
  direction: "outbound",
@@ -738,14 +739,14 @@ let ColorSwitchCC = class ColorSwitchCC extends CommandClass_1.CommandClass {
738
739
  await api.get(color);
739
740
  }
740
741
  }
741
- translatePropertyKey(applHost, property, propertyKey) {
742
+ translatePropertyKey(ctx, property, propertyKey) {
742
743
  if ((property === "currentColor" || property === "targetColor")
743
744
  && typeof propertyKey === "number") {
744
745
  const translated = _Types_1.ColorComponent[propertyKey];
745
746
  if (translated)
746
747
  return translated;
747
748
  }
748
- return super.translatePropertyKey(applHost, property, propertyKey);
749
+ return super.translatePropertyKey(ctx, property, propertyKey);
749
750
  }
750
751
  };
751
752
  exports.ColorSwitchCC = ColorSwitchCC;
@@ -754,27 +755,29 @@ exports.ColorSwitchCC = ColorSwitchCC = __decorate([
754
755
  (0, CommandClassDecorators_1.implementedVersion)(3),
755
756
  (0, CommandClassDecorators_1.ccValues)(exports.ColorSwitchCCValues)
756
757
  ], ColorSwitchCC);
757
- let ColorSwitchCCSupportedReport = class ColorSwitchCCSupportedReport extends ColorSwitchCC {
758
- constructor(host, options) {
759
- super(host, options);
760
- if ((0, CommandClass_1.gotDeserializationOptions)(options)) {
761
- // Docs say 'variable length', but the table shows 2 bytes.
762
- (0, core_1.validatePayload)(this.payload.length >= 2);
763
- this.supportedColorComponents = (0, core_1.parseBitMask)(this.payload.subarray(0, 2), _Types_1.ColorComponent["Warm White"]);
764
- }
765
- else {
766
- this.supportedColorComponents = options.supportedColorComponents;
767
- }
758
+ let ColorSwitchCCSupportedReport = ColorSwitchCCSupportedReport_1 = class ColorSwitchCCSupportedReport extends ColorSwitchCC {
759
+ constructor(options) {
760
+ super(options);
761
+ this.supportedColorComponents = options.supportedColorComponents;
762
+ }
763
+ static from(raw, ctx) {
764
+ // Docs say 'variable length', but the table shows 2 bytes.
765
+ (0, core_1.validatePayload)(raw.payload.length >= 2);
766
+ const supportedColorComponents = (0, core_1.parseBitMask)(raw.payload.subarray(0, 2), _Types_1.ColorComponent["Warm White"]);
767
+ return new ColorSwitchCCSupportedReport_1({
768
+ nodeId: ctx.sourceNodeId,
769
+ supportedColorComponents,
770
+ });
768
771
  }
769
772
  supportedColorComponents;
770
- serialize() {
773
+ serialize(ctx) {
771
774
  this.payload = (0, safe_1.encodeBitMask)(this.supportedColorComponents, 15, // fixed 2 bytes
772
775
  _Types_1.ColorComponent["Warm White"]);
773
- return super.serialize();
776
+ return super.serialize(ctx);
774
777
  }
775
- toLogEntry(host) {
778
+ toLogEntry(ctx) {
776
779
  return {
777
- ...super.toLogEntry(host),
780
+ ...super.toLogEntry(ctx),
778
781
  message: {
779
782
  "supported color components": this.supportedColorComponents
780
783
  .map((c) => `\n· ${(0, safe_2.getEnumMemberName)(_Types_1.ColorComponent, c)}`)
@@ -787,7 +790,7 @@ exports.ColorSwitchCCSupportedReport = ColorSwitchCCSupportedReport;
787
790
  __decorate([
788
791
  (0, CommandClassDecorators_1.ccValue)(exports.ColorSwitchCCValues.supportedColorComponents)
789
792
  ], ColorSwitchCCSupportedReport.prototype, "supportedColorComponents", void 0);
790
- exports.ColorSwitchCCSupportedReport = ColorSwitchCCSupportedReport = __decorate([
793
+ exports.ColorSwitchCCSupportedReport = ColorSwitchCCSupportedReport = ColorSwitchCCSupportedReport_1 = __decorate([
791
794
  (0, CommandClassDecorators_1.CCCommand)(_Types_1.ColorSwitchCommand.SupportedReport)
792
795
  ], ColorSwitchCCSupportedReport);
793
796
  let ColorSwitchCCSupportedGet = class ColorSwitchCCSupportedGet extends ColorSwitchCC {
@@ -797,59 +800,66 @@ exports.ColorSwitchCCSupportedGet = ColorSwitchCCSupportedGet = __decorate([
797
800
  (0, CommandClassDecorators_1.CCCommand)(_Types_1.ColorSwitchCommand.SupportedGet),
798
801
  (0, CommandClassDecorators_1.expectedCCResponse)(ColorSwitchCCSupportedReport)
799
802
  ], ColorSwitchCCSupportedGet);
800
- let ColorSwitchCCReport = class ColorSwitchCCReport extends ColorSwitchCC {
801
- constructor(host, options) {
802
- super(host, options);
803
- if ((0, CommandClass_1.gotDeserializationOptions)(options)) {
804
- (0, core_1.validatePayload)(this.payload.length >= 2);
805
- this.colorComponent = this.payload[0];
806
- this.currentValue = this.payload[1];
807
- if (this.version >= 3 && this.payload.length >= 4) {
808
- this.targetValue = this.payload[2];
809
- this.duration = core_1.Duration.parseReport(this.payload[3]);
810
- }
811
- }
812
- else {
813
- this.colorComponent = options.colorComponent;
814
- this.currentValue = options.currentValue;
815
- this.targetValue = options.targetValue;
816
- this.duration = core_1.Duration.from(options.duration);
817
- }
803
+ let ColorSwitchCCReport = ColorSwitchCCReport_1 = class ColorSwitchCCReport extends ColorSwitchCC {
804
+ constructor(options) {
805
+ super(options);
806
+ this.colorComponent = options.colorComponent;
807
+ this.currentValue = options.currentValue;
808
+ this.targetValue = options.targetValue;
809
+ this.duration = core_1.Duration.from(options.duration);
810
+ }
811
+ static from(raw, ctx) {
812
+ (0, core_1.validatePayload)(raw.payload.length >= 2);
813
+ const colorComponent = raw.payload[0];
814
+ const currentValue = raw.payload[1];
815
+ let targetValue;
816
+ let duration;
817
+ if (raw.payload.length >= 4) {
818
+ targetValue = raw.payload[2];
819
+ duration = core_1.Duration.parseReport(raw.payload[3]);
820
+ }
821
+ return new ColorSwitchCCReport_1({
822
+ nodeId: ctx.sourceNodeId,
823
+ colorComponent,
824
+ currentValue,
825
+ targetValue,
826
+ duration,
827
+ });
818
828
  }
819
- persistValues(applHost) {
829
+ persistValues(ctx) {
820
830
  // Duration is stored globally instead of per component
821
- if (!super.persistValues(applHost))
831
+ if (!super.persistValues(ctx))
822
832
  return false;
823
833
  // Update compound current value
824
834
  const colorTableKey = colorComponentToTableKey(this.colorComponent);
825
835
  if (colorTableKey) {
826
836
  const compoundCurrentColorValue = exports.ColorSwitchCCValues.currentColor;
827
- const compoundCurrentColor = this.getValue(applHost, compoundCurrentColorValue) ?? {};
837
+ const compoundCurrentColor = this.getValue(ctx, compoundCurrentColorValue) ?? {};
828
838
  compoundCurrentColor[colorTableKey] = this.currentValue;
829
- this.setValue(applHost, compoundCurrentColorValue, compoundCurrentColor);
839
+ this.setValue(ctx, compoundCurrentColorValue, compoundCurrentColor);
830
840
  // and target value
831
841
  if (this.targetValue != undefined) {
832
842
  const compoundTargetColorValue = exports.ColorSwitchCCValues.targetColor;
833
- const compoundTargetColor = this.getValue(applHost, compoundTargetColorValue) ?? {};
843
+ const compoundTargetColor = this.getValue(ctx, compoundTargetColorValue) ?? {};
834
844
  compoundTargetColor[colorTableKey] = this.targetValue;
835
- this.setValue(applHost, compoundTargetColorValue, compoundTargetColor);
845
+ this.setValue(ctx, compoundTargetColorValue, compoundTargetColor);
836
846
  }
837
847
  }
838
848
  // Update collective hex value if required
839
- const supportsHex = !!this.getValue(applHost, exports.ColorSwitchCCValues.supportsHexColor);
849
+ const supportsHex = !!this.getValue(ctx, exports.ColorSwitchCCValues.supportsHexColor);
840
850
  if (supportsHex
841
851
  && (this.colorComponent === _Types_1.ColorComponent.Red
842
852
  || this.colorComponent === _Types_1.ColorComponent.Green
843
853
  || this.colorComponent === _Types_1.ColorComponent.Blue)) {
844
854
  const hexColorValue = exports.ColorSwitchCCValues.hexColor;
845
- const hexValue = this.getValue(applHost, hexColorValue)
855
+ const hexValue = this.getValue(ctx, hexColorValue)
846
856
  ?? "000000";
847
857
  const byteOffset = _Types_1.ColorComponent.Blue - this.colorComponent;
848
858
  const byteMask = 0xff << (byteOffset * 8);
849
859
  let hexValueNumeric = parseInt(hexValue, 16);
850
860
  hexValueNumeric = (hexValueNumeric & ~byteMask)
851
861
  | (this.currentValue << (byteOffset * 8));
852
- this.setValue(applHost, hexColorValue, hexValueNumeric.toString(16).padStart(6, "0"));
862
+ this.setValue(ctx, hexColorValue, hexValueNumeric.toString(16).padStart(6, "0"));
853
863
  }
854
864
  return true;
855
865
  }
@@ -857,7 +867,7 @@ let ColorSwitchCCReport = class ColorSwitchCCReport extends ColorSwitchCC {
857
867
  currentValue;
858
868
  targetValue;
859
869
  duration;
860
- serialize() {
870
+ serialize(ctx) {
861
871
  this.payload = Buffer.from([
862
872
  this.colorComponent,
863
873
  this.currentValue,
@@ -871,9 +881,9 @@ let ColorSwitchCCReport = class ColorSwitchCCReport extends ColorSwitchCC {
871
881
  ]),
872
882
  ]);
873
883
  }
874
- return super.serialize();
884
+ return super.serialize(ctx);
875
885
  }
876
- toLogEntry(host) {
886
+ toLogEntry(ctx) {
877
887
  const message = {
878
888
  "color component": (0, safe_2.getEnumMemberName)(_Types_1.ColorComponent, this.colorComponent),
879
889
  "current value": this.currentValue,
@@ -885,7 +895,7 @@ let ColorSwitchCCReport = class ColorSwitchCCReport extends ColorSwitchCC {
885
895
  message.duration = this.duration.toString();
886
896
  }
887
897
  return {
888
- ...super.toLogEntry(host),
898
+ ...super.toLogEntry(ctx),
889
899
  message,
890
900
  };
891
901
  }
@@ -900,22 +910,24 @@ __decorate([
900
910
  __decorate([
901
911
  (0, CommandClassDecorators_1.ccValue)(exports.ColorSwitchCCValues.duration)
902
912
  ], ColorSwitchCCReport.prototype, "duration", void 0);
903
- exports.ColorSwitchCCReport = ColorSwitchCCReport = __decorate([
913
+ exports.ColorSwitchCCReport = ColorSwitchCCReport = ColorSwitchCCReport_1 = __decorate([
904
914
  (0, CommandClassDecorators_1.CCCommand)(_Types_1.ColorSwitchCommand.Report)
905
915
  ], ColorSwitchCCReport);
906
916
  function testResponseForColorSwitchGet(sent, received) {
907
917
  return sent.colorComponent === received.colorComponent;
908
918
  }
909
- let ColorSwitchCCGet = class ColorSwitchCCGet extends ColorSwitchCC {
910
- constructor(host, options) {
911
- super(host, options);
912
- if ((0, CommandClass_1.gotDeserializationOptions)(options)) {
913
- (0, core_1.validatePayload)(this.payload.length >= 1);
914
- this._colorComponent = this.payload[0];
915
- }
916
- else {
917
- this._colorComponent = options.colorComponent;
918
- }
919
+ let ColorSwitchCCGet = ColorSwitchCCGet_1 = class ColorSwitchCCGet extends ColorSwitchCC {
920
+ constructor(options) {
921
+ super(options);
922
+ this._colorComponent = options.colorComponent;
923
+ }
924
+ static from(raw, ctx) {
925
+ (0, core_1.validatePayload)(raw.payload.length >= 1);
926
+ const colorComponent = raw.payload[0];
927
+ return new ColorSwitchCCGet_1({
928
+ nodeId: ctx.sourceNodeId,
929
+ colorComponent,
930
+ });
919
931
  }
920
932
  _colorComponent;
921
933
  get colorComponent() {
@@ -927,13 +939,13 @@ let ColorSwitchCCGet = class ColorSwitchCCGet extends ColorSwitchCC {
927
939
  }
928
940
  this._colorComponent = value;
929
941
  }
930
- serialize() {
942
+ serialize(ctx) {
931
943
  this.payload = Buffer.from([this._colorComponent]);
932
- return super.serialize();
944
+ return super.serialize(ctx);
933
945
  }
934
- toLogEntry(host) {
946
+ toLogEntry(ctx) {
935
947
  return {
936
- ...super.toLogEntry(host),
948
+ ...super.toLogEntry(ctx),
937
949
  message: {
938
950
  "color component": (0, safe_2.getEnumMemberName)(_Types_1.ColorComponent, this.colorComponent),
939
951
  },
@@ -941,54 +953,58 @@ let ColorSwitchCCGet = class ColorSwitchCCGet extends ColorSwitchCC {
941
953
  }
942
954
  };
943
955
  exports.ColorSwitchCCGet = ColorSwitchCCGet;
944
- exports.ColorSwitchCCGet = ColorSwitchCCGet = __decorate([
956
+ exports.ColorSwitchCCGet = ColorSwitchCCGet = ColorSwitchCCGet_1 = __decorate([
945
957
  (0, CommandClassDecorators_1.CCCommand)(_Types_1.ColorSwitchCommand.Get),
946
958
  (0, CommandClassDecorators_1.expectedCCResponse)(ColorSwitchCCReport, testResponseForColorSwitchGet)
947
959
  ], ColorSwitchCCGet);
948
- let ColorSwitchCCSet = class ColorSwitchCCSet extends ColorSwitchCC {
949
- constructor(host, options) {
950
- super(host, options);
951
- if ((0, CommandClass_1.gotDeserializationOptions)(options)) {
952
- (0, core_1.validatePayload)(this.payload.length >= 1);
953
- const populatedColorCount = this.payload[0] & 0b11111;
954
- (0, core_1.validatePayload)(this.payload.length >= 1 + populatedColorCount * 2);
955
- this.colorTable = {};
956
- let offset = 1;
957
- for (let color = 0; color < populatedColorCount; color++) {
958
- const component = this.payload[offset];
959
- const value = this.payload[offset + 1];
960
- const key = colorComponentToTableKey(component);
961
- // @ts-expect-error
962
- if (key)
963
- this.colorTable[key] = value;
964
- offset += 2;
965
- }
966
- if (this.payload.length > offset) {
967
- this.duration = core_1.Duration.parseSet(this.payload[offset]);
960
+ let ColorSwitchCCSet = ColorSwitchCCSet_1 = class ColorSwitchCCSet extends ColorSwitchCC {
961
+ constructor(options) {
962
+ super(options);
963
+ // Populate properties from options object
964
+ if ("hexColor" in options) {
965
+ const match = hexColorRegex.exec(options.hexColor);
966
+ if (!match) {
967
+ throw new core_1.ZWaveError(`${options.hexColor} is not a valid HEX color string`, core_1.ZWaveErrorCodes.Argument_Invalid);
968
968
  }
969
+ this.colorTable = {
970
+ red: parseInt(match.groups.red, 16),
971
+ green: parseInt(match.groups.green, 16),
972
+ blue: parseInt(match.groups.blue, 16),
973
+ };
969
974
  }
970
975
  else {
971
- // Populate properties from options object
972
- if ("hexColor" in options) {
973
- const match = hexColorRegex.exec(options.hexColor);
974
- if (!match) {
975
- throw new core_1.ZWaveError(`${options.hexColor} is not a valid HEX color string`, core_1.ZWaveErrorCodes.Argument_Invalid);
976
- }
977
- this.colorTable = {
978
- red: parseInt(match.groups.red, 16),
979
- green: parseInt(match.groups.green, 16),
980
- blue: parseInt(match.groups.blue, 16),
981
- };
982
- }
983
- else {
984
- this.colorTable = (0, safe_2.pick)(options, colorTableKeys);
985
- }
986
- this.duration = core_1.Duration.from(options.duration);
987
- }
976
+ this.colorTable = (0, safe_2.pick)(options, colorTableKeys);
977
+ }
978
+ this.duration = core_1.Duration.from(options.duration);
979
+ }
980
+ static from(raw, ctx) {
981
+ (0, core_1.validatePayload)(raw.payload.length >= 1);
982
+ const populatedColorCount = raw.payload[0] & 0b11111;
983
+ (0, core_1.validatePayload)(raw.payload.length >= 1 + populatedColorCount * 2);
984
+ const colorTable = {};
985
+ let offset = 1;
986
+ for (let color = 0; color < populatedColorCount; color++) {
987
+ const component = raw.payload[offset];
988
+ const value = raw.payload[offset + 1];
989
+ const key = colorComponentToTableKey(component);
990
+ // @ts-expect-error
991
+ if (key)
992
+ this.colorTable[key] = value;
993
+ offset += 2;
994
+ }
995
+ let duration;
996
+ if (raw.payload.length > offset) {
997
+ duration = core_1.Duration.parseSet(raw.payload[offset]);
998
+ }
999
+ return new ColorSwitchCCSet_1({
1000
+ nodeId: ctx.sourceNodeId,
1001
+ ...colorTable,
1002
+ duration,
1003
+ });
988
1004
  }
989
1005
  colorTable;
990
1006
  duration;
991
- serialize() {
1007
+ serialize(ctx) {
992
1008
  const populatedColorCount = Object.keys(this.colorTable).length;
993
1009
  this.payload = Buffer.allocUnsafe(1 + populatedColorCount * 2 + 1);
994
1010
  this.payload[0] = populatedColorCount & 0b11111;
@@ -1000,13 +1016,14 @@ let ColorSwitchCCSet = class ColorSwitchCCSet extends ColorSwitchCC {
1000
1016
  i += 2;
1001
1017
  }
1002
1018
  this.payload[i] = (this.duration ?? core_1.Duration.default()).serializeSet();
1003
- if (this.version < 2 && this.host.getDeviceConfig?.(this.nodeId)?.compat?.encodeCCsUsingTargetVersion) {
1019
+ const ccVersion = (0, CommandClass_1.getEffectiveCCVersion)(ctx, this);
1020
+ if (ccVersion < 2 && ctx.getDeviceConfig?.(this.nodeId)?.compat?.encodeCCsUsingTargetVersion) {
1004
1021
  // When forcing CC version 1, omit the duration byte
1005
1022
  this.payload = this.payload.subarray(0, -1);
1006
1023
  }
1007
- return super.serialize();
1024
+ return super.serialize(ctx);
1008
1025
  }
1009
- toLogEntry(host) {
1026
+ toLogEntry(ctx) {
1010
1027
  const message = {};
1011
1028
  for (const [key, value] of Object.entries(this.colorTable)) {
1012
1029
  const realKey = key in _Types_1.ColorComponentMap
@@ -1018,45 +1035,52 @@ let ColorSwitchCCSet = class ColorSwitchCCSet extends ColorSwitchCC {
1018
1035
  message.duration = this.duration.toString();
1019
1036
  }
1020
1037
  return {
1021
- ...super.toLogEntry(host),
1038
+ ...super.toLogEntry(ctx),
1022
1039
  message,
1023
1040
  };
1024
1041
  }
1025
1042
  };
1026
1043
  exports.ColorSwitchCCSet = ColorSwitchCCSet;
1027
- exports.ColorSwitchCCSet = ColorSwitchCCSet = __decorate([
1044
+ exports.ColorSwitchCCSet = ColorSwitchCCSet = ColorSwitchCCSet_1 = __decorate([
1028
1045
  (0, CommandClassDecorators_1.CCCommand)(_Types_1.ColorSwitchCommand.Set),
1029
1046
  (0, CommandClassDecorators_1.useSupervision)()
1030
1047
  ], ColorSwitchCCSet);
1031
- let ColorSwitchCCStartLevelChange = class ColorSwitchCCStartLevelChange extends ColorSwitchCC {
1032
- constructor(host, options) {
1033
- super(host, options);
1034
- if ((0, CommandClass_1.gotDeserializationOptions)(options)) {
1035
- (0, core_1.validatePayload)(this.payload.length >= 3);
1036
- const ignoreStartLevel = (this.payload[0] & 0b0_0_1_00000) >>> 5;
1037
- this.ignoreStartLevel = !!ignoreStartLevel;
1038
- const direction = (this.payload[0] & 0b0_1_0_00000) >>> 6;
1039
- this.direction = direction ? "down" : "up";
1040
- this.colorComponent = this.payload[1];
1041
- this.startLevel = this.payload[2];
1042
- if (this.payload.length >= 4) {
1043
- this.duration = core_1.Duration.parseSet(this.payload[3]);
1044
- }
1045
- }
1046
- else {
1047
- this.duration = core_1.Duration.from(options.duration);
1048
- this.ignoreStartLevel = options.ignoreStartLevel;
1049
- this.startLevel = options.startLevel ?? 0;
1050
- this.direction = options.direction;
1051
- this.colorComponent = options.colorComponent;
1052
- }
1048
+ let ColorSwitchCCStartLevelChange = ColorSwitchCCStartLevelChange_1 = class ColorSwitchCCStartLevelChange extends ColorSwitchCC {
1049
+ constructor(options) {
1050
+ super(options);
1051
+ this.duration = core_1.Duration.from(options.duration);
1052
+ this.ignoreStartLevel = options.ignoreStartLevel;
1053
+ this.startLevel = options.startLevel ?? 0;
1054
+ this.direction = options.direction;
1055
+ this.colorComponent = options.colorComponent;
1056
+ }
1057
+ static from(raw, ctx) {
1058
+ (0, core_1.validatePayload)(raw.payload.length >= 3);
1059
+ const ignoreStartLevel = !!((raw.payload[0] & 0b0_0_1_00000) >>> 5);
1060
+ const direction = ((raw.payload[0] & 0b0_1_0_00000) >>> 6)
1061
+ ? "down"
1062
+ : "up";
1063
+ const colorComponent = raw.payload[1];
1064
+ const startLevel = raw.payload[2];
1065
+ let duration;
1066
+ if (raw.payload.length >= 4) {
1067
+ duration = core_1.Duration.parseSet(raw.payload[3]);
1068
+ }
1069
+ return new ColorSwitchCCStartLevelChange_1({
1070
+ nodeId: ctx.sourceNodeId,
1071
+ ignoreStartLevel,
1072
+ direction,
1073
+ colorComponent,
1074
+ startLevel,
1075
+ duration,
1076
+ });
1053
1077
  }
1054
1078
  duration;
1055
1079
  startLevel;
1056
1080
  ignoreStartLevel;
1057
1081
  direction;
1058
1082
  colorComponent;
1059
- serialize() {
1083
+ serialize(ctx) {
1060
1084
  const controlByte = (_Types_1.LevelChangeDirection[this.direction] << 6)
1061
1085
  | (this.ignoreStartLevel ? 0b0010_0000 : 0);
1062
1086
  this.payload = Buffer.from([
@@ -1065,13 +1089,14 @@ let ColorSwitchCCStartLevelChange = class ColorSwitchCCStartLevelChange extends
1065
1089
  this.startLevel,
1066
1090
  (this.duration ?? core_1.Duration.default()).serializeSet(),
1067
1091
  ]);
1068
- if (this.version < 3 && this.host.getDeviceConfig?.(this.nodeId)?.compat?.encodeCCsUsingTargetVersion) {
1092
+ const ccVersion = (0, CommandClass_1.getEffectiveCCVersion)(ctx, this);
1093
+ if (ccVersion < 3 && ctx.getDeviceConfig?.(this.nodeId)?.compat?.encodeCCsUsingTargetVersion) {
1069
1094
  // When forcing CC version 1 or 2, omit the duration byte
1070
1095
  this.payload = this.payload.subarray(0, -1);
1071
1096
  }
1072
- return super.serialize();
1097
+ return super.serialize(ctx);
1073
1098
  }
1074
- toLogEntry(host) {
1099
+ toLogEntry(ctx) {
1075
1100
  const message = {
1076
1101
  "color component": (0, safe_2.getEnumMemberName)(_Types_1.ColorComponent, this.colorComponent),
1077
1102
  "start level": `${this.startLevel}${this.ignoreStartLevel ? " (ignored)" : ""}`,
@@ -1081,35 +1106,37 @@ let ColorSwitchCCStartLevelChange = class ColorSwitchCCStartLevelChange extends
1081
1106
  message.duration = this.duration.toString();
1082
1107
  }
1083
1108
  return {
1084
- ...super.toLogEntry(host),
1109
+ ...super.toLogEntry(ctx),
1085
1110
  message,
1086
1111
  };
1087
1112
  }
1088
1113
  };
1089
1114
  exports.ColorSwitchCCStartLevelChange = ColorSwitchCCStartLevelChange;
1090
- exports.ColorSwitchCCStartLevelChange = ColorSwitchCCStartLevelChange = __decorate([
1115
+ exports.ColorSwitchCCStartLevelChange = ColorSwitchCCStartLevelChange = ColorSwitchCCStartLevelChange_1 = __decorate([
1091
1116
  (0, CommandClassDecorators_1.CCCommand)(_Types_1.ColorSwitchCommand.StartLevelChange),
1092
1117
  (0, CommandClassDecorators_1.useSupervision)()
1093
1118
  ], ColorSwitchCCStartLevelChange);
1094
- let ColorSwitchCCStopLevelChange = class ColorSwitchCCStopLevelChange extends ColorSwitchCC {
1095
- constructor(host, options) {
1096
- super(host, options);
1097
- if ((0, CommandClass_1.gotDeserializationOptions)(options)) {
1098
- (0, core_1.validatePayload)(this.payload.length >= 1);
1099
- this.colorComponent = this.payload[0];
1100
- }
1101
- else {
1102
- this.colorComponent = options.colorComponent;
1103
- }
1119
+ let ColorSwitchCCStopLevelChange = ColorSwitchCCStopLevelChange_1 = class ColorSwitchCCStopLevelChange extends ColorSwitchCC {
1120
+ constructor(options) {
1121
+ super(options);
1122
+ this.colorComponent = options.colorComponent;
1123
+ }
1124
+ static from(raw, ctx) {
1125
+ (0, core_1.validatePayload)(raw.payload.length >= 1);
1126
+ const colorComponent = raw.payload[0];
1127
+ return new ColorSwitchCCStopLevelChange_1({
1128
+ nodeId: ctx.sourceNodeId,
1129
+ colorComponent,
1130
+ });
1104
1131
  }
1105
1132
  colorComponent;
1106
- serialize() {
1133
+ serialize(ctx) {
1107
1134
  this.payload = Buffer.from([this.colorComponent]);
1108
- return super.serialize();
1135
+ return super.serialize(ctx);
1109
1136
  }
1110
- toLogEntry(host) {
1137
+ toLogEntry(ctx) {
1111
1138
  return {
1112
- ...super.toLogEntry(host),
1139
+ ...super.toLogEntry(ctx),
1113
1140
  message: {
1114
1141
  "color component": (0, safe_2.getEnumMemberName)(_Types_1.ColorComponent, this.colorComponent),
1115
1142
  },
@@ -1117,7 +1144,7 @@ let ColorSwitchCCStopLevelChange = class ColorSwitchCCStopLevelChange extends Co
1117
1144
  }
1118
1145
  };
1119
1146
  exports.ColorSwitchCCStopLevelChange = ColorSwitchCCStopLevelChange;
1120
- exports.ColorSwitchCCStopLevelChange = ColorSwitchCCStopLevelChange = __decorate([
1147
+ exports.ColorSwitchCCStopLevelChange = ColorSwitchCCStopLevelChange = ColorSwitchCCStopLevelChange_1 = __decorate([
1121
1148
  (0, CommandClassDecorators_1.CCCommand)(_Types_1.ColorSwitchCommand.StopLevelChange),
1122
1149
  (0, CommandClassDecorators_1.useSupervision)()
1123
1150
  ], ColorSwitchCCStopLevelChange);