@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 MultiChannelCCEndPointReport_1, MultiChannelCCCapabilityReport_1, MultiChannelCCCapabilityGet_1, MultiChannelCCEndPointFindReport_1, MultiChannelCCEndPointFind_1, MultiChannelCCAggregatedMembersReport_1, MultiChannelCCCommandEncapsulation_1, MultiChannelCCV1Report_1, MultiChannelCCV1CommandEncapsulation_1;
8
9
  Object.defineProperty(exports, "__esModule", { value: true });
9
10
  exports.MultiChannelCCV1CommandEncapsulation = exports.MultiChannelCCV1Get = exports.MultiChannelCCV1Report = exports.MultiChannelCCCommandEncapsulation = exports.MultiChannelCCAggregatedMembersGet = exports.MultiChannelCCAggregatedMembersReport = exports.MultiChannelCCEndPointFind = exports.MultiChannelCCEndPointFindReport = exports.MultiChannelCCCapabilityGet = exports.MultiChannelCCCapabilityReport = exports.MultiChannelCCEndPointGet = exports.MultiChannelCCEndPointReport = exports.MultiChannelCC = exports.MultiChannelCCAPI = exports.MultiChannelCCValues = void 0;
10
11
  function __assertType(argName, typeName, boundHasError) {
@@ -24,6 +25,7 @@ const arrays_1 = require("alcalzone-shared/arrays");
24
25
  const API_1 = require("../lib/API");
25
26
  const CommandClass_1 = require("../lib/CommandClass");
26
27
  const CommandClassDecorators_1 = require("../lib/CommandClassDecorators");
28
+ const EncapsulatingCommandClass_1 = require("../lib/EncapsulatingCommandClass");
27
29
  const Values_1 = require("../lib/Values");
28
30
  const _Types_1 = require("../lib/_Types");
29
31
  // TODO: Handle removal reports of dynamic endpoints
@@ -61,13 +63,13 @@ exports.MultiChannelCCValues = Object.freeze({
61
63
  * Many devices unnecessarily use endpoints when they could (or do) provide all functionality via the root device.
62
64
  * This function gives an estimate if this is the case (i.e. all endpoints have a different device class)
63
65
  */
64
- function areEndpointsUnnecessary(applHost, node, endpointIndizes) {
66
+ function areEndpointsUnnecessary(ctx, nodeId, endpointIndizes) {
65
67
  // Gather all device classes
66
68
  const deviceClasses = new Map();
67
69
  for (const endpoint of endpointIndizes) {
68
70
  const devClassValueId = exports.MultiChannelCCValues.endpointDeviceClass
69
71
  .endpoint(endpoint);
70
- const deviceClass = applHost.getValueDB(node.id).getValue(devClassValueId);
72
+ const deviceClass = ctx.getValueDB(nodeId).getValue(devClassValueId);
71
73
  if (deviceClass) {
72
74
  deviceClasses.set(endpoint, {
73
75
  generic: deviceClass.generic,
@@ -118,11 +120,11 @@ let MultiChannelCCAPI = class MultiChannelCCAPI extends API_1.CCAPI {
118
120
  // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
119
121
  async getEndpoints() {
120
122
  this.assertSupportsCommand(_Types_1.MultiChannelCommand, _Types_1.MultiChannelCommand.EndPointGet);
121
- const cc = new MultiChannelCCEndPointGet(this.applHost, {
123
+ const cc = new MultiChannelCCEndPointGet({
122
124
  nodeId: this.endpoint.nodeId,
123
- endpoint: this.endpoint.index,
125
+ endpointIndex: this.endpoint.index,
124
126
  });
125
- const response = await this.applHost.sendCommand(cc, this.commandOptions);
127
+ const response = await this.host.sendCommand(cc, this.commandOptions);
126
128
  if (response) {
127
129
  return {
128
130
  isDynamicEndpointCount: response.countIsDynamic,
@@ -135,12 +137,12 @@ let MultiChannelCCAPI = class MultiChannelCCAPI extends API_1.CCAPI {
135
137
  async getEndpointCapabilities(endpoint) {
136
138
  __assertType("endpoint", "number", __assertType__number.bind(void 0, endpoint));
137
139
  this.assertSupportsCommand(_Types_1.MultiChannelCommand, _Types_1.MultiChannelCommand.CapabilityGet);
138
- const cc = new MultiChannelCCCapabilityGet(this.applHost, {
140
+ const cc = new MultiChannelCCCapabilityGet({
139
141
  nodeId: this.endpoint.nodeId,
140
- endpoint: this.endpoint.index,
142
+ endpointIndex: this.endpoint.index,
141
143
  requestedEndpoint: endpoint,
142
144
  });
143
- const response = await this.applHost.sendCommand(cc, this.commandOptions);
145
+ const response = await this.host.sendCommand(cc, this.commandOptions);
144
146
  if (response) {
145
147
  const generic = (0, safe_1.getGenericDeviceClass)(response.genericDeviceClass);
146
148
  const specific = (0, safe_1.getSpecificDeviceClass)(response.genericDeviceClass, response.specificDeviceClass);
@@ -157,24 +159,24 @@ let MultiChannelCCAPI = class MultiChannelCCAPI extends API_1.CCAPI {
157
159
  __assertType("genericClass", "number", __assertType__number.bind(void 0, genericClass));
158
160
  __assertType("specificClass", "number", __assertType__number.bind(void 0, specificClass));
159
161
  this.assertSupportsCommand(_Types_1.MultiChannelCommand, _Types_1.MultiChannelCommand.EndPointFind);
160
- const cc = new MultiChannelCCEndPointFind(this.applHost, {
162
+ const cc = new MultiChannelCCEndPointFind({
161
163
  nodeId: this.endpoint.nodeId,
162
- endpoint: this.endpoint.index,
164
+ endpointIndex: this.endpoint.index,
163
165
  genericClass,
164
166
  specificClass,
165
167
  });
166
- const response = await this.applHost.sendCommand(cc, this.commandOptions);
168
+ const response = await this.host.sendCommand(cc, this.commandOptions);
167
169
  return response?.foundEndpoints;
168
170
  }
169
171
  async getAggregatedMembers(endpoint) {
170
172
  __assertType("endpoint", "number", __assertType__number.bind(void 0, endpoint));
171
173
  this.assertSupportsCommand(_Types_1.MultiChannelCommand, _Types_1.MultiChannelCommand.AggregatedMembersGet);
172
- const cc = new MultiChannelCCAggregatedMembersGet(this.applHost, {
174
+ const cc = new MultiChannelCCAggregatedMembersGet({
173
175
  nodeId: this.endpoint.nodeId,
174
- endpoint: this.endpoint.index,
176
+ endpointIndex: this.endpoint.index,
175
177
  requestedEndpoint: endpoint,
176
178
  });
177
- const response = await this.applHost.sendCommand(cc, this.commandOptions);
179
+ const response = await this.host.sendCommand(cc, this.commandOptions);
178
180
  return response?.members;
179
181
  }
180
182
  // Encapsulation is used internally and too frequently that we
@@ -182,20 +184,20 @@ let MultiChannelCCAPI = class MultiChannelCCAPI extends API_1.CCAPI {
182
184
  // eslint-disable-next-line @zwave-js/ccapi-validate-args
183
185
  async sendEncapsulated(options) {
184
186
  this.assertSupportsCommand(_Types_1.MultiChannelCommand, _Types_1.MultiChannelCommand.CommandEncapsulation);
185
- const cc = new MultiChannelCCCommandEncapsulation(this.applHost, {
187
+ const cc = new MultiChannelCCCommandEncapsulation({
186
188
  nodeId: this.endpoint.nodeId,
187
189
  ...options,
188
190
  });
189
- await this.applHost.sendCommand(cc, this.commandOptions);
191
+ await this.host.sendCommand(cc, this.commandOptions);
190
192
  }
191
193
  async getEndpointCountV1(ccId) {
192
194
  __assertType("ccId", "CommandClasses", __assertType__number.bind(void 0, ccId));
193
195
  this.assertSupportsCommand(_Types_1.MultiChannelCommand, _Types_1.MultiChannelCommand.GetV1);
194
- const cc = new MultiChannelCCV1Get(this.applHost, {
196
+ const cc = new MultiChannelCCV1Get({
195
197
  nodeId: this.endpoint.nodeId,
196
198
  requestedCC: ccId,
197
199
  });
198
- const response = await this.applHost.sendCommand(cc, this.commandOptions);
200
+ const response = await this.host.sendCommand(cc, this.commandOptions);
199
201
  return response?.endpointCount;
200
202
  }
201
203
  // Encapsulation is used internally and too frequently that we
@@ -203,11 +205,11 @@ let MultiChannelCCAPI = class MultiChannelCCAPI extends API_1.CCAPI {
203
205
  // eslint-disable-next-line @zwave-js/ccapi-validate-args
204
206
  async sendEncapsulatedV1(encapsulated) {
205
207
  this.assertSupportsCommand(_Types_1.MultiChannelCommand, _Types_1.MultiChannelCommand.CommandEncapsulationV1);
206
- const cc = new MultiChannelCCV1CommandEncapsulation(this.applHost, {
208
+ const cc = new MultiChannelCCV1CommandEncapsulation({
207
209
  nodeId: this.endpoint.nodeId,
208
210
  encapsulated,
209
211
  });
210
- await this.applHost.sendCommand(cc, this.commandOptions);
212
+ await this.host.sendCommand(cc, this.commandOptions);
211
213
  }
212
214
  };
213
215
  exports.MultiChannelCCAPI = MultiChannelCCAPI;
@@ -221,23 +223,23 @@ let MultiChannelCC = class MultiChannelCC extends CommandClass_1.CommandClass {
221
223
  && !(cc instanceof MultiChannelCCCommandEncapsulation)
222
224
  && !(cc instanceof MultiChannelCCV1CommandEncapsulation));
223
225
  }
224
- /** Encapsulates a command that targets a specific endpoint */
225
- static encapsulate(host, cc) {
226
- const ccVersion = host.getSafeCCVersion(safe_1.CommandClasses["Multi Channel"], cc.nodeId);
227
- let ret;
228
- if (ccVersion === 1) {
229
- ret = new MultiChannelCCV1CommandEncapsulation(host, {
230
- nodeId: cc.nodeId,
231
- encapsulated: cc,
232
- });
233
- }
234
- else {
235
- ret = new MultiChannelCCCommandEncapsulation(host, {
236
- nodeId: cc.nodeId,
237
- encapsulated: cc,
238
- destination: cc.endpointIndex,
239
- });
240
- }
226
+ /** Encapsulates a command that targets a specific endpoint, with version 2+ of the Multi Channel CC */
227
+ static encapsulate(cc) {
228
+ const ret = new MultiChannelCCCommandEncapsulation({
229
+ nodeId: cc.nodeId,
230
+ encapsulated: cc,
231
+ destination: cc.endpointIndex,
232
+ });
233
+ // Copy the encapsulation flags from the encapsulated command
234
+ ret.encapsulationFlags = cc.encapsulationFlags;
235
+ return ret;
236
+ }
237
+ /** Encapsulates a command that targets a specific endpoint, with version 1 of the Multi Channel CC */
238
+ static encapsulateV1(cc) {
239
+ const ret = new MultiChannelCCV1CommandEncapsulation({
240
+ nodeId: cc.nodeId,
241
+ encapsulated: cc,
242
+ });
241
243
  // Copy the encapsulation flags from the encapsulated command
242
244
  ret.encapsulationFlags = cc.encapsulationFlags;
243
245
  return ret;
@@ -246,40 +248,41 @@ let MultiChannelCC = class MultiChannelCC extends CommandClass_1.CommandClass {
246
248
  // The endpoints are discovered by querying the root device
247
249
  return true;
248
250
  }
249
- async interview(applHost) {
250
- const node = this.getNode(applHost);
251
- const removeEndpoints = applHost.getDeviceConfig?.(node.id)?.compat
251
+ async interview(ctx) {
252
+ const node = this.getNode(ctx);
253
+ const removeEndpoints = ctx.getDeviceConfig?.(node.id)?.compat
252
254
  ?.removeEndpoints;
253
255
  if (removeEndpoints === "*") {
254
- applHost.controllerLog.logNode(node.id, {
256
+ ctx.logNode(node.id, {
255
257
  endpoint: this.endpointIndex,
256
258
  message: `Skipping ${this.ccName} interview b/c all endpoints are ignored by the device config file...`,
257
259
  direction: "none",
258
260
  });
259
261
  return;
260
262
  }
261
- applHost.controllerLog.logNode(node.id, {
263
+ ctx.logNode(node.id, {
262
264
  endpoint: this.endpointIndex,
263
265
  message: `Interviewing ${this.ccName}...`,
264
266
  direction: "none",
265
267
  });
266
268
  // Special interview procedure for legacy nodes
267
- if (this.version === 1)
268
- return this.interviewV1(applHost);
269
+ const ccVersion = (0, CommandClass_1.getEffectiveCCVersion)(ctx, this);
270
+ if (ccVersion === 1)
271
+ return this.interviewV1(ctx);
269
272
  const endpoint = node.getEndpoint(this.endpointIndex);
270
- const api = API_1.CCAPI.create(safe_1.CommandClasses["Multi Channel"], applHost, endpoint).withOptions({
273
+ const api = API_1.CCAPI.create(safe_1.CommandClasses["Multi Channel"], ctx, endpoint).withOptions({
271
274
  priority: safe_1.MessagePriority.NodeQuery,
272
275
  });
273
- const valueDB = this.getValueDB(applHost);
276
+ const valueDB = this.getValueDB(ctx);
274
277
  // Step 1: Retrieve general information about end points
275
- applHost.controllerLog.logNode(node.id, {
278
+ ctx.logNode(node.id, {
276
279
  endpoint: this.endpointIndex,
277
280
  message: "querying device endpoint information...",
278
281
  direction: "outbound",
279
282
  });
280
283
  const multiResponse = await api.getEndpoints();
281
284
  if (!multiResponse) {
282
- applHost.controllerLog.logNode(node.id, {
285
+ ctx.logNode(node.id, {
283
286
  endpoint: this.endpointIndex,
284
287
  message: "Querying device endpoint information timed out, aborting interview...",
285
288
  level: "warn",
@@ -294,7 +297,7 @@ identical capabilities: ${multiResponse.identicalCapabilities}`;
294
297
  logMessage +=
295
298
  `\nendpoint count (aggregated): ${multiResponse.aggregatedEndpointCount}`;
296
299
  }
297
- applHost.controllerLog.logNode(node.id, {
300
+ ctx.logNode(node.id, {
298
301
  endpoint: this.endpointIndex,
299
302
  message: logMessage,
300
303
  direction: "inbound",
@@ -309,7 +312,7 @@ identical capabilities: ${multiResponse.identicalCapabilities}`;
309
312
  };
310
313
  if (api.supportsCommand(_Types_1.MultiChannelCommand.EndPointFind)) {
311
314
  // Step 2a: Find all endpoints
312
- applHost.controllerLog.logNode(node.id, {
315
+ ctx.logNode(node.id, {
313
316
  endpoint: this.endpointIndex,
314
317
  message: "querying all endpoints...",
315
318
  direction: "outbound",
@@ -319,7 +322,7 @@ identical capabilities: ${multiResponse.identicalCapabilities}`;
319
322
  allEndpoints.push(...foundEndpoints);
320
323
  if (!allEndpoints.length) {
321
324
  // Create a sequential list of endpoints
322
- applHost.controllerLog.logNode(node.id, {
325
+ ctx.logNode(node.id, {
323
326
  endpoint: this.endpointIndex,
324
327
  message: `Endpoint query returned no results, assuming that endpoints are sequential`,
325
328
  direction: "inbound",
@@ -327,7 +330,7 @@ identical capabilities: ${multiResponse.identicalCapabilities}`;
327
330
  addSequentialEndpoints();
328
331
  }
329
332
  else {
330
- applHost.controllerLog.logNode(node.id, {
333
+ ctx.logNode(node.id, {
331
334
  endpoint: this.endpointIndex,
332
335
  message: `received endpoints: ${allEndpoints
333
336
  .map(String)
@@ -338,7 +341,7 @@ identical capabilities: ${multiResponse.identicalCapabilities}`;
338
341
  }
339
342
  else {
340
343
  // Step 2b: Assume that the endpoints are in sequential order
341
- applHost.controllerLog.logNode(node.id, {
344
+ ctx.logNode(node.id, {
342
345
  endpoint: this.endpointIndex,
343
346
  message: `does not support EndPointFind, assuming that endpoints are sequential`,
344
347
  direction: "none",
@@ -347,7 +350,7 @@ identical capabilities: ${multiResponse.identicalCapabilities}`;
347
350
  }
348
351
  // Step 2.5: remove ignored endpoints
349
352
  if (removeEndpoints?.length) {
350
- applHost.controllerLog.logNode(node.id, {
353
+ ctx.logNode(node.id, {
351
354
  endpoint: this.endpointIndex,
352
355
  message: `The following endpoints are ignored through the config file: ${removeEndpoints.join(", ")}`,
353
356
  direction: "none",
@@ -358,16 +361,16 @@ identical capabilities: ${multiResponse.identicalCapabilities}`;
358
361
  let hasQueriedCapabilities = false;
359
362
  for (const endpoint of allEndpoints) {
360
363
  if (endpoint > multiResponse.individualEndpointCount
361
- && this.version >= 4) {
364
+ && ccVersion >= 4) {
362
365
  // Find members of aggregated end point
363
- applHost.controllerLog.logNode(node.id, {
366
+ ctx.logNode(node.id, {
364
367
  endpoint: this.endpointIndex,
365
368
  message: `querying members of aggregated endpoint #${endpoint}...`,
366
369
  direction: "outbound",
367
370
  });
368
371
  const members = await api.getAggregatedMembers(endpoint);
369
372
  if (members) {
370
- applHost.controllerLog.logNode(node.id, {
373
+ ctx.logNode(node.id, {
371
374
  endpoint: this.endpointIndex,
372
375
  message: `aggregated endpoint #${endpoint} has members ${members
373
376
  .map(String)
@@ -379,7 +382,7 @@ identical capabilities: ${multiResponse.identicalCapabilities}`;
379
382
  // When the device reports identical capabilities for all endpoints,
380
383
  // we don't need to query them all
381
384
  if (multiResponse.identicalCapabilities && hasQueriedCapabilities) {
382
- applHost.controllerLog.logNode(node.id, {
385
+ ctx.logNode(node.id, {
383
386
  endpoint: this.endpointIndex,
384
387
  message: `all endpoints identical, skipping capability query for endpoint #${endpoint}...`,
385
388
  direction: "none",
@@ -391,7 +394,7 @@ identical capabilities: ${multiResponse.identicalCapabilities}`;
391
394
  valueDB.setValue(exports.MultiChannelCCValues.endpointCCs.endpoint(endpoint), [...ep1Caps]);
392
395
  continue;
393
396
  }
394
- applHost.controllerLog.logNode(node.id, {
397
+ ctx.logNode(node.id, {
395
398
  endpoint: this.endpointIndex,
396
399
  message: `querying capabilities for endpoint #${endpoint}...`,
397
400
  direction: "outbound",
@@ -408,14 +411,14 @@ supported CCs:`;
408
411
  for (const cc of caps.supportedCCs) {
409
412
  logMessage += `\n · ${(0, safe_1.getCCName)(cc)}`;
410
413
  }
411
- applHost.controllerLog.logNode(node.id, {
414
+ ctx.logNode(node.id, {
412
415
  endpoint: this.endpointIndex,
413
416
  message: logMessage,
414
417
  direction: "inbound",
415
418
  });
416
419
  }
417
420
  else {
418
- applHost.controllerLog.logNode(node.id, {
421
+ ctx.logNode(node.id, {
419
422
  endpoint: this.endpointIndex,
420
423
  message: `Querying endpoint #${endpoint} capabilities timed out, aborting interview...`,
421
424
  level: "warn",
@@ -426,37 +429,37 @@ supported CCs:`;
426
429
  // Now that all endpoints have been interviewed, remember which ones are there
427
430
  // But first figure out if they seem unnecessary and if they do, which ones should be preserved
428
431
  if (!multiResponse.identicalCapabilities
429
- && areEndpointsUnnecessary(applHost, node, allEndpoints)) {
430
- const preserve = applHost.getDeviceConfig?.(node.id)?.compat
432
+ && areEndpointsUnnecessary(ctx, node.id, allEndpoints)) {
433
+ const preserve = ctx.getDeviceConfig?.(node.id)?.compat
431
434
  ?.preserveEndpoints;
432
435
  if (!preserve) {
433
436
  allEndpoints = [];
434
- applHost.controllerLog.logNode(node.id, {
437
+ ctx.logNode(node.id, {
435
438
  message: `Endpoints seem unnecessary b/c they have different device classes, ignoring all...`,
436
439
  });
437
440
  }
438
441
  else if (preserve === "*") {
439
442
  // preserve all endpoints, do nothing
440
- applHost.controllerLog.logNode(node.id, {
443
+ ctx.logNode(node.id, {
441
444
  message: `Endpoints seem unnecessary, but are configured to be preserved.`,
442
445
  });
443
446
  }
444
447
  else {
445
448
  allEndpoints = allEndpoints.filter((ep) => preserve.includes(ep));
446
- applHost.controllerLog.logNode(node.id, {
449
+ ctx.logNode(node.id, {
447
450
  message: `Endpoints seem unnecessary, but endpoints ${allEndpoints.join(", ")} are configured to be preserved.`,
448
451
  });
449
452
  }
450
453
  }
451
- this.setValue(applHost, exports.MultiChannelCCValues.endpointIndizes, allEndpoints);
454
+ this.setValue(ctx, exports.MultiChannelCCValues.endpointIndizes, allEndpoints);
452
455
  // Remember that the interview is complete
453
- this.setInterviewComplete(applHost, true);
456
+ this.setInterviewComplete(ctx, true);
454
457
  }
455
- async interviewV1(applHost) {
456
- const node = this.getNode(applHost);
457
- const endpoint = this.getEndpoint(applHost);
458
- const api = API_1.CCAPI.create(safe_1.CommandClasses["Multi Channel"], applHost, endpoint);
459
- const valueDB = this.getValueDB(applHost);
458
+ async interviewV1(ctx) {
459
+ const node = this.getNode(ctx);
460
+ const endpoint = this.getEndpoint(ctx);
461
+ const api = API_1.CCAPI.create(safe_1.CommandClasses["Multi Channel"], ctx, endpoint);
462
+ const valueDB = this.getValueDB(ctx);
460
463
  // V1 works the opposite way - we scan all CCs and remember how many
461
464
  // endpoints they have
462
465
  const supportedCCs = [...node.getCCs()]
@@ -464,17 +467,17 @@ supported CCs:`;
464
467
  .filter(([, info]) => info.isSupported)
465
468
  .map(([cc]) => cc)
466
469
  // Don't query CCs that want to skip the endpoint interview
467
- .filter((cc) => !CommandClass_1.CommandClass.createInstanceUnchecked(applHost, node, cc)?.skipEndpointInterview());
470
+ .filter((cc) => !CommandClass_1.CommandClass.createInstanceUnchecked(node, cc)?.skipEndpointInterview());
468
471
  const endpointCounts = new Map();
469
472
  for (const ccId of supportedCCs) {
470
- applHost.controllerLog.logNode(node.id, {
473
+ ctx.logNode(node.id, {
471
474
  message: `Querying endpoint count for CommandClass ${(0, safe_1.getCCName)(ccId)}...`,
472
475
  direction: "outbound",
473
476
  });
474
477
  const endpointCount = await api.getEndpointCountV1(ccId);
475
478
  if (endpointCount != undefined) {
476
479
  endpointCounts.set(ccId, endpointCount);
477
- applHost.controllerLog.logNode(node.id, {
480
+ ctx.logNode(node.id, {
478
481
  message: `CommandClass ${(0, safe_1.getCCName)(ccId)} has ${endpointCount} endpoints`,
479
482
  direction: "inbound",
480
483
  });
@@ -483,12 +486,12 @@ supported CCs:`;
483
486
  // Store the collected information
484
487
  // We have only individual and no dynamic and no aggregated endpoints
485
488
  const numEndpoints = Math.max(...endpointCounts.values());
486
- this.setValue(applHost, exports.MultiChannelCCValues.endpointCountIsDynamic, false);
487
- this.setValue(applHost, exports.MultiChannelCCValues.aggregatedEndpointCount, 0);
488
- this.setValue(applHost, exports.MultiChannelCCValues.individualEndpointCount, numEndpoints);
489
+ this.setValue(ctx, exports.MultiChannelCCValues.endpointCountIsDynamic, false);
490
+ this.setValue(ctx, exports.MultiChannelCCValues.aggregatedEndpointCount, 0);
491
+ this.setValue(ctx, exports.MultiChannelCCValues.individualEndpointCount, numEndpoints);
489
492
  // Since we queried all CCs separately, we can assume that all
490
493
  // endpoints have different capabilities
491
- this.setValue(applHost, exports.MultiChannelCCValues.endpointsHaveIdenticalCapabilities, false);
494
+ this.setValue(ctx, exports.MultiChannelCCValues.endpointsHaveIdenticalCapabilities, false);
492
495
  for (let endpoint = 1; endpoint <= numEndpoints; endpoint++) {
493
496
  // Check which CCs exist on this endpoint
494
497
  const endpointCCs = [...endpointCounts.entries()]
@@ -498,7 +501,7 @@ supported CCs:`;
498
501
  valueDB.setValue(exports.MultiChannelCCValues.endpointCCs.endpoint(endpoint), endpointCCs);
499
502
  }
500
503
  // Remember that the interview is complete
501
- this.setInterviewComplete(applHost, true);
504
+ this.setInterviewComplete(ctx, true);
502
505
  }
503
506
  };
504
507
  exports.MultiChannelCC = MultiChannelCC;
@@ -507,39 +510,45 @@ exports.MultiChannelCC = MultiChannelCC = __decorate([
507
510
  (0, CommandClassDecorators_1.implementedVersion)(4),
508
511
  (0, CommandClassDecorators_1.ccValues)(exports.MultiChannelCCValues)
509
512
  ], MultiChannelCC);
510
- let MultiChannelCCEndPointReport = class MultiChannelCCEndPointReport extends MultiChannelCC {
511
- constructor(host, options) {
512
- super(host, options);
513
- if ((0, CommandClass_1.gotDeserializationOptions)(options)) {
514
- (0, safe_1.validatePayload)(this.payload.length >= 2);
515
- this.countIsDynamic = !!(this.payload[0] & 0b10000000);
516
- this.identicalCapabilities = !!(this.payload[0] & 0b01000000);
517
- this.individualCount = this.payload[1] & 0b01111111;
518
- if (this.version >= 4 && this.payload.length >= 3) {
519
- this.aggregatedCount = this.payload[2] & 0b01111111;
520
- }
521
- }
522
- else {
523
- this.countIsDynamic = options.countIsDynamic;
524
- this.identicalCapabilities = options.identicalCapabilities;
525
- this.individualCount = options.individualCount;
526
- this.aggregatedCount = options.aggregatedCount;
513
+ let MultiChannelCCEndPointReport = MultiChannelCCEndPointReport_1 = class MultiChannelCCEndPointReport extends MultiChannelCC {
514
+ constructor(options) {
515
+ super(options);
516
+ this.countIsDynamic = options.countIsDynamic;
517
+ this.identicalCapabilities = options.identicalCapabilities;
518
+ this.individualCount = options.individualCount;
519
+ this.aggregatedCount = options.aggregatedCount;
520
+ }
521
+ static from(raw, ctx) {
522
+ (0, safe_1.validatePayload)(raw.payload.length >= 2);
523
+ const countIsDynamic = !!(raw.payload[0] & 0b10000000);
524
+ const identicalCapabilities = !!(raw.payload[0] & 0b01000000);
525
+ const individualCount = raw.payload[1] & 0b01111111;
526
+ let aggregatedCount;
527
+ if (raw.payload.length >= 3) {
528
+ aggregatedCount = raw.payload[2] & 0b01111111;
527
529
  }
530
+ return new MultiChannelCCEndPointReport_1({
531
+ nodeId: ctx.sourceNodeId,
532
+ countIsDynamic,
533
+ identicalCapabilities,
534
+ individualCount,
535
+ aggregatedCount,
536
+ });
528
537
  }
529
538
  countIsDynamic;
530
539
  identicalCapabilities;
531
540
  individualCount;
532
541
  aggregatedCount;
533
- serialize() {
542
+ serialize(ctx) {
534
543
  this.payload = Buffer.from([
535
544
  (this.countIsDynamic ? 0b10000000 : 0)
536
545
  | (this.identicalCapabilities ? 0b01000000 : 0),
537
546
  this.individualCount & 0b01111111,
538
547
  this.aggregatedCount ?? 0,
539
548
  ]);
540
- return super.serialize();
549
+ return super.serialize(ctx);
541
550
  }
542
- toLogEntry(host) {
551
+ toLogEntry(ctx) {
543
552
  const message = {
544
553
  "endpoint count (individual)": this.individualCount,
545
554
  "count is dynamic": this.countIsDynamic,
@@ -549,7 +558,7 @@ let MultiChannelCCEndPointReport = class MultiChannelCCEndPointReport extends Mu
549
558
  message["endpoint count (aggregated)"] = this.aggregatedCount;
550
559
  }
551
560
  const ret = {
552
- ...super.toLogEntry(host),
561
+ ...super.toLogEntry(ctx),
553
562
  message,
554
563
  };
555
564
  return ret;
@@ -568,7 +577,7 @@ __decorate([
568
577
  __decorate([
569
578
  (0, CommandClassDecorators_1.ccValue)(exports.MultiChannelCCValues.aggregatedEndpointCount)
570
579
  ], MultiChannelCCEndPointReport.prototype, "aggregatedCount", void 0);
571
- exports.MultiChannelCCEndPointReport = MultiChannelCCEndPointReport = __decorate([
580
+ exports.MultiChannelCCEndPointReport = MultiChannelCCEndPointReport = MultiChannelCCEndPointReport_1 = __decorate([
572
581
  (0, CommandClassDecorators_1.CCCommand)(_Types_1.MultiChannelCommand.EndPointReport)
573
582
  ], MultiChannelCCEndPointReport);
574
583
  let MultiChannelCCEndPointGet = class MultiChannelCCEndPointGet extends MultiChannelCC {
@@ -578,48 +587,55 @@ exports.MultiChannelCCEndPointGet = MultiChannelCCEndPointGet = __decorate([
578
587
  (0, CommandClassDecorators_1.CCCommand)(_Types_1.MultiChannelCommand.EndPointGet),
579
588
  (0, CommandClassDecorators_1.expectedCCResponse)(MultiChannelCCEndPointReport)
580
589
  ], MultiChannelCCEndPointGet);
581
- let MultiChannelCCCapabilityReport = class MultiChannelCCCapabilityReport extends MultiChannelCC {
582
- constructor(host, options) {
583
- super(host, options);
584
- if ((0, CommandClass_1.gotDeserializationOptions)(options)) {
585
- // Only validate the bytes we expect to see here
586
- // parseApplicationNodeInformation does its own validation
587
- (0, safe_1.validatePayload)(this.payload.length >= 1);
588
- this.endpointIndex = this.payload[0] & 0b01111111;
589
- this.isDynamic = !!(this.payload[0] & 0b10000000);
590
- const NIF = (0, safe_1.parseApplicationNodeInformation)(this.payload.subarray(1));
591
- this.genericDeviceClass = NIF.genericDeviceClass;
592
- this.specificDeviceClass = NIF.specificDeviceClass;
593
- this.supportedCCs = NIF.supportedCCs;
594
- // Removal reports have very specific information
595
- this.wasRemoved = this.isDynamic
596
- && this.genericDeviceClass === 0xff // "Non-Interoperable"
597
- && this.specificDeviceClass === 0x00;
598
- }
599
- else {
600
- this.endpointIndex = options.endpointIndex;
601
- this.genericDeviceClass = options.genericDeviceClass;
602
- this.specificDeviceClass = options.specificDeviceClass;
603
- this.supportedCCs = options.supportedCCs;
604
- this.isDynamic = options.isDynamic;
605
- this.wasRemoved = options.wasRemoved;
606
- }
590
+ let MultiChannelCCCapabilityReport = MultiChannelCCCapabilityReport_1 = class MultiChannelCCCapabilityReport extends MultiChannelCC {
591
+ constructor(options) {
592
+ super(options);
593
+ this.endpointIndex = options.endpointIndex;
594
+ this.genericDeviceClass = options.genericDeviceClass;
595
+ this.specificDeviceClass = options.specificDeviceClass;
596
+ this.supportedCCs = options.supportedCCs;
597
+ this.isDynamic = options.isDynamic;
598
+ this.wasRemoved = options.wasRemoved;
599
+ }
600
+ static from(raw, ctx) {
601
+ // Only validate the bytes we expect to see here
602
+ // parseApplicationNodeInformation does its own validation
603
+ (0, safe_1.validatePayload)(raw.payload.length >= 1);
604
+ const endpointIndex = raw.payload[0] & 0b01111111;
605
+ const isDynamic = !!(raw.payload[0] & 0b10000000);
606
+ const NIF = (0, safe_1.parseApplicationNodeInformation)(raw.payload.subarray(1));
607
+ const genericDeviceClass = NIF.genericDeviceClass;
608
+ const specificDeviceClass = NIF.specificDeviceClass;
609
+ const supportedCCs = NIF.supportedCCs;
610
+ // Removal reports have very specific information
611
+ const wasRemoved = isDynamic
612
+ && genericDeviceClass === 0xff // "Non-Interoperable"
613
+ && specificDeviceClass === 0x00;
614
+ return new MultiChannelCCCapabilityReport_1({
615
+ nodeId: ctx.sourceNodeId,
616
+ endpointIndex,
617
+ isDynamic,
618
+ genericDeviceClass,
619
+ specificDeviceClass,
620
+ supportedCCs,
621
+ wasRemoved,
622
+ });
607
623
  }
608
- persistValues(applHost) {
609
- if (!super.persistValues(applHost))
624
+ persistValues(ctx) {
625
+ if (!super.persistValues(ctx))
610
626
  return false;
611
627
  const deviceClassValue = exports.MultiChannelCCValues.endpointDeviceClass;
612
628
  const ccsValue = exports.MultiChannelCCValues.endpointCCs;
613
629
  if (this.wasRemoved) {
614
- this.removeValue(applHost, deviceClassValue);
615
- this.removeValue(applHost, ccsValue);
630
+ this.removeValue(ctx, deviceClassValue);
631
+ this.removeValue(ctx, ccsValue);
616
632
  }
617
633
  else {
618
- this.setValue(applHost, deviceClassValue, {
634
+ this.setValue(ctx, deviceClassValue, {
619
635
  generic: this.genericDeviceClass,
620
636
  specific: this.specificDeviceClass,
621
637
  });
622
- this.setValue(applHost, ccsValue, this.supportedCCs);
638
+ this.setValue(ctx, ccsValue, this.supportedCCs);
623
639
  }
624
640
  return true;
625
641
  }
@@ -629,7 +645,7 @@ let MultiChannelCCCapabilityReport = class MultiChannelCCCapabilityReport extend
629
645
  supportedCCs;
630
646
  isDynamic;
631
647
  wasRemoved;
632
- serialize() {
648
+ serialize(ctx) {
633
649
  this.payload = Buffer.concat([
634
650
  Buffer.from([
635
651
  (this.endpointIndex & 0b01111111)
@@ -637,11 +653,11 @@ let MultiChannelCCCapabilityReport = class MultiChannelCCCapabilityReport extend
637
653
  ]),
638
654
  (0, safe_1.encodeApplicationNodeInformation)(this),
639
655
  ]);
640
- return super.serialize();
656
+ return super.serialize(ctx);
641
657
  }
642
- toLogEntry(host) {
658
+ toLogEntry(ctx) {
643
659
  return {
644
- ...super.toLogEntry(host),
660
+ ...super.toLogEntry(ctx),
645
661
  message: {
646
662
  "endpoint index": this.endpointIndex,
647
663
  "generic device class": (0, safe_1.getGenericDeviceClass)(this.genericDeviceClass).label,
@@ -655,66 +671,73 @@ let MultiChannelCCCapabilityReport = class MultiChannelCCCapabilityReport extend
655
671
  }
656
672
  };
657
673
  exports.MultiChannelCCCapabilityReport = MultiChannelCCCapabilityReport;
658
- exports.MultiChannelCCCapabilityReport = MultiChannelCCCapabilityReport = __decorate([
674
+ exports.MultiChannelCCCapabilityReport = MultiChannelCCCapabilityReport = MultiChannelCCCapabilityReport_1 = __decorate([
659
675
  (0, CommandClassDecorators_1.CCCommand)(_Types_1.MultiChannelCommand.CapabilityReport)
660
676
  ], MultiChannelCCCapabilityReport);
661
677
  function testResponseForMultiChannelCapabilityGet(sent, received) {
662
678
  return received.endpointIndex === sent.requestedEndpoint;
663
679
  }
664
- let MultiChannelCCCapabilityGet = class MultiChannelCCCapabilityGet extends MultiChannelCC {
665
- constructor(host, options) {
666
- super(host, options);
667
- if ((0, CommandClass_1.gotDeserializationOptions)(options)) {
668
- (0, safe_1.validatePayload)(this.payload.length >= 1);
669
- this.requestedEndpoint = this.payload[0] & 0b01111111;
670
- }
671
- else {
672
- this.requestedEndpoint = options.requestedEndpoint;
673
- }
680
+ let MultiChannelCCCapabilityGet = MultiChannelCCCapabilityGet_1 = class MultiChannelCCCapabilityGet extends MultiChannelCC {
681
+ constructor(options) {
682
+ super(options);
683
+ this.requestedEndpoint = options.requestedEndpoint;
684
+ }
685
+ static from(raw, ctx) {
686
+ (0, safe_1.validatePayload)(raw.payload.length >= 1);
687
+ const requestedEndpoint = raw.payload[0] & 0b01111111;
688
+ return new MultiChannelCCCapabilityGet_1({
689
+ nodeId: ctx.sourceNodeId,
690
+ requestedEndpoint,
691
+ });
674
692
  }
675
693
  requestedEndpoint;
676
- serialize() {
694
+ serialize(ctx) {
677
695
  this.payload = Buffer.from([this.requestedEndpoint & 0b01111111]);
678
- return super.serialize();
696
+ return super.serialize(ctx);
679
697
  }
680
- toLogEntry(host) {
698
+ toLogEntry(ctx) {
681
699
  return {
682
- ...super.toLogEntry(host),
700
+ ...super.toLogEntry(ctx),
683
701
  message: { endpoint: this.requestedEndpoint },
684
702
  };
685
703
  }
686
704
  };
687
705
  exports.MultiChannelCCCapabilityGet = MultiChannelCCCapabilityGet;
688
- exports.MultiChannelCCCapabilityGet = MultiChannelCCCapabilityGet = __decorate([
706
+ exports.MultiChannelCCCapabilityGet = MultiChannelCCCapabilityGet = MultiChannelCCCapabilityGet_1 = __decorate([
689
707
  (0, CommandClassDecorators_1.CCCommand)(_Types_1.MultiChannelCommand.CapabilityGet),
690
708
  (0, CommandClassDecorators_1.expectedCCResponse)(MultiChannelCCCapabilityReport, testResponseForMultiChannelCapabilityGet)
691
709
  ], MultiChannelCCCapabilityGet);
692
- let MultiChannelCCEndPointFindReport = class MultiChannelCCEndPointFindReport extends MultiChannelCC {
693
- constructor(host, options) {
694
- super(host, options);
695
- if ((0, CommandClass_1.gotDeserializationOptions)(options)) {
696
- (0, safe_1.validatePayload)(this.payload.length >= 3);
697
- this.reportsToFollow = this.payload[0];
698
- this.genericClass = this.payload[1];
699
- this.specificClass = this.payload[2];
700
- // Some devices omit the endpoint list although that is not allowed in the specs
701
- // therefore don't validatePayload here.
702
- this.foundEndpoints = [...this.payload.subarray(3)]
703
- .map((e) => e & 0b01111111)
704
- .filter((e) => e !== 0);
705
- }
706
- else {
707
- this.genericClass = options.genericClass;
708
- this.specificClass = options.specificClass;
709
- this.foundEndpoints = options.foundEndpoints;
710
- this.reportsToFollow = options.reportsToFollow;
711
- }
710
+ let MultiChannelCCEndPointFindReport = MultiChannelCCEndPointFindReport_1 = class MultiChannelCCEndPointFindReport extends MultiChannelCC {
711
+ constructor(options) {
712
+ super(options);
713
+ this.genericClass = options.genericClass;
714
+ this.specificClass = options.specificClass;
715
+ this.foundEndpoints = options.foundEndpoints;
716
+ this.reportsToFollow = options.reportsToFollow;
717
+ }
718
+ static from(raw, ctx) {
719
+ (0, safe_1.validatePayload)(raw.payload.length >= 3);
720
+ const reportsToFollow = raw.payload[0];
721
+ const genericClass = raw.payload[1];
722
+ const specificClass = raw.payload[2];
723
+ // Some devices omit the endpoint list although that is not allowed in the specs
724
+ // therefore don't validatePayload here.
725
+ const foundEndpoints = [...raw.payload.subarray(3)]
726
+ .map((e) => e & 0b01111111)
727
+ .filter((e) => e !== 0);
728
+ return new MultiChannelCCEndPointFindReport_1({
729
+ nodeId: ctx.sourceNodeId,
730
+ reportsToFollow,
731
+ genericClass,
732
+ specificClass,
733
+ foundEndpoints,
734
+ });
712
735
  }
713
736
  genericClass;
714
737
  specificClass;
715
738
  foundEndpoints;
716
739
  reportsToFollow;
717
- serialize() {
740
+ serialize(ctx) {
718
741
  this.payload = Buffer.concat([
719
742
  Buffer.from([
720
743
  this.reportsToFollow,
@@ -723,7 +746,7 @@ let MultiChannelCCEndPointFindReport = class MultiChannelCCEndPointFindReport ex
723
746
  ]),
724
747
  Buffer.from(this.foundEndpoints.map((e) => e & 0b01111111)),
725
748
  ]);
726
- return super.serialize();
749
+ return super.serialize(ctx);
727
750
  }
728
751
  getPartialCCSessionId() {
729
752
  // Distinguish sessions by the requested device classes
@@ -735,15 +758,15 @@ let MultiChannelCCEndPointFindReport = class MultiChannelCCEndPointFindReport ex
735
758
  expectMoreMessages() {
736
759
  return this.reportsToFollow > 0;
737
760
  }
738
- mergePartialCCs(applHost, partials) {
761
+ mergePartialCCs(partials, _ctx) {
739
762
  // Concat the list of end points
740
763
  this.foundEndpoints = [...partials, this]
741
764
  .map((report) => report.foundEndpoints)
742
765
  .reduce((prev, cur) => prev.concat(...cur), []);
743
766
  }
744
- toLogEntry(host) {
767
+ toLogEntry(ctx) {
745
768
  return {
746
- ...super.toLogEntry(host),
769
+ ...super.toLogEntry(ctx),
747
770
  message: {
748
771
  "generic device class": (0, safe_1.getGenericDeviceClass)(this.genericClass).label,
749
772
  "specific device class": (0, safe_1.getSpecificDeviceClass)(this.genericClass, this.specificClass).label,
@@ -754,31 +777,34 @@ let MultiChannelCCEndPointFindReport = class MultiChannelCCEndPointFindReport ex
754
777
  }
755
778
  };
756
779
  exports.MultiChannelCCEndPointFindReport = MultiChannelCCEndPointFindReport;
757
- exports.MultiChannelCCEndPointFindReport = MultiChannelCCEndPointFindReport = __decorate([
780
+ exports.MultiChannelCCEndPointFindReport = MultiChannelCCEndPointFindReport = MultiChannelCCEndPointFindReport_1 = __decorate([
758
781
  (0, CommandClassDecorators_1.CCCommand)(_Types_1.MultiChannelCommand.EndPointFindReport)
759
782
  ], MultiChannelCCEndPointFindReport);
760
- let MultiChannelCCEndPointFind = class MultiChannelCCEndPointFind extends MultiChannelCC {
761
- constructor(host, options) {
762
- super(host, options);
763
- if ((0, CommandClass_1.gotDeserializationOptions)(options)) {
764
- (0, safe_1.validatePayload)(this.payload.length >= 2);
765
- this.genericClass = this.payload[0];
766
- this.specificClass = this.payload[1];
767
- }
768
- else {
769
- this.genericClass = options.genericClass;
770
- this.specificClass = options.specificClass;
771
- }
783
+ let MultiChannelCCEndPointFind = MultiChannelCCEndPointFind_1 = class MultiChannelCCEndPointFind extends MultiChannelCC {
784
+ constructor(options) {
785
+ super(options);
786
+ this.genericClass = options.genericClass;
787
+ this.specificClass = options.specificClass;
788
+ }
789
+ static from(raw, ctx) {
790
+ (0, safe_1.validatePayload)(raw.payload.length >= 2);
791
+ const genericClass = raw.payload[0];
792
+ const specificClass = raw.payload[1];
793
+ return new MultiChannelCCEndPointFind_1({
794
+ nodeId: ctx.sourceNodeId,
795
+ genericClass,
796
+ specificClass,
797
+ });
772
798
  }
773
799
  genericClass;
774
800
  specificClass;
775
- serialize() {
801
+ serialize(ctx) {
776
802
  this.payload = Buffer.from([this.genericClass, this.specificClass]);
777
- return super.serialize();
803
+ return super.serialize(ctx);
778
804
  }
779
- toLogEntry(host) {
805
+ toLogEntry(ctx) {
780
806
  return {
781
- ...super.toLogEntry(host),
807
+ ...super.toLogEntry(ctx),
782
808
  message: {
783
809
  "generic device class": (0, safe_1.getGenericDeviceClass)(this.genericClass).label,
784
810
  "specific device class": (0, safe_1.getSpecificDeviceClass)(this.genericClass, this.specificClass).label,
@@ -787,25 +813,35 @@ let MultiChannelCCEndPointFind = class MultiChannelCCEndPointFind extends MultiC
787
813
  }
788
814
  };
789
815
  exports.MultiChannelCCEndPointFind = MultiChannelCCEndPointFind;
790
- exports.MultiChannelCCEndPointFind = MultiChannelCCEndPointFind = __decorate([
816
+ exports.MultiChannelCCEndPointFind = MultiChannelCCEndPointFind = MultiChannelCCEndPointFind_1 = __decorate([
791
817
  (0, CommandClassDecorators_1.CCCommand)(_Types_1.MultiChannelCommand.EndPointFind),
792
818
  (0, CommandClassDecorators_1.expectedCCResponse)(MultiChannelCCEndPointFindReport)
793
819
  ], MultiChannelCCEndPointFind);
794
- let MultiChannelCCAggregatedMembersReport = class MultiChannelCCAggregatedMembersReport extends MultiChannelCC {
795
- constructor(host, options) {
796
- super(host, options);
797
- (0, safe_1.validatePayload)(this.payload.length >= 2);
798
- this.aggregatedEndpointIndex = this.payload[0] & 0b0111_1111;
799
- const bitMaskLength = this.payload[1];
800
- (0, safe_1.validatePayload)(this.payload.length >= 2 + bitMaskLength);
801
- const bitMask = this.payload.subarray(2, 2 + bitMaskLength);
802
- this.members = (0, safe_1.parseBitMask)(bitMask);
820
+ let MultiChannelCCAggregatedMembersReport = MultiChannelCCAggregatedMembersReport_1 = class MultiChannelCCAggregatedMembersReport extends MultiChannelCC {
821
+ constructor(options) {
822
+ super(options);
823
+ // TODO: Check implementation:
824
+ this.aggregatedEndpointIndex = options.aggregatedEndpointIndex;
825
+ this.members = options.members;
826
+ }
827
+ static from(raw, ctx) {
828
+ (0, safe_1.validatePayload)(raw.payload.length >= 2);
829
+ const aggregatedEndpointIndex = raw.payload[0] & 0b0111_1111;
830
+ const bitMaskLength = raw.payload[1];
831
+ (0, safe_1.validatePayload)(raw.payload.length >= 2 + bitMaskLength);
832
+ const bitMask = raw.payload.subarray(2, 2 + bitMaskLength);
833
+ const members = (0, safe_1.parseBitMask)(bitMask);
834
+ return new MultiChannelCCAggregatedMembersReport_1({
835
+ nodeId: ctx.sourceNodeId,
836
+ aggregatedEndpointIndex,
837
+ members,
838
+ });
803
839
  }
804
840
  aggregatedEndpointIndex;
805
841
  members;
806
- toLogEntry(host) {
842
+ toLogEntry(ctx) {
807
843
  return {
808
- ...super.toLogEntry(host),
844
+ ...super.toLogEntry(ctx),
809
845
  message: {
810
846
  "aggregated endpoint": this.aggregatedEndpointIndex,
811
847
  members: this.members.join(", "),
@@ -817,28 +853,29 @@ exports.MultiChannelCCAggregatedMembersReport = MultiChannelCCAggregatedMembersR
817
853
  __decorate([
818
854
  (0, CommandClassDecorators_1.ccValue)(exports.MultiChannelCCValues.aggregatedEndpointMembers, (self) => [self.aggregatedEndpointIndex])
819
855
  ], MultiChannelCCAggregatedMembersReport.prototype, "members", void 0);
820
- exports.MultiChannelCCAggregatedMembersReport = MultiChannelCCAggregatedMembersReport = __decorate([
856
+ exports.MultiChannelCCAggregatedMembersReport = MultiChannelCCAggregatedMembersReport = MultiChannelCCAggregatedMembersReport_1 = __decorate([
821
857
  (0, CommandClassDecorators_1.CCCommand)(_Types_1.MultiChannelCommand.AggregatedMembersReport)
822
858
  ], MultiChannelCCAggregatedMembersReport);
823
859
  let MultiChannelCCAggregatedMembersGet = class MultiChannelCCAggregatedMembersGet extends MultiChannelCC {
824
- constructor(host, options) {
825
- super(host, options);
826
- if ((0, CommandClass_1.gotDeserializationOptions)(options)) {
827
- // TODO: Deserialize payload
828
- throw new safe_1.ZWaveError(`${this.constructor.name}: deserialization not implemented`, safe_1.ZWaveErrorCodes.Deserialization_NotImplemented);
829
- }
830
- else {
831
- this.requestedEndpoint = options.requestedEndpoint;
832
- }
860
+ constructor(options) {
861
+ super(options);
862
+ this.requestedEndpoint = options.requestedEndpoint;
863
+ }
864
+ static from(_raw, _ctx) {
865
+ // TODO: Deserialize payload
866
+ throw new safe_1.ZWaveError(`${this.name}: deserialization not implemented`, safe_1.ZWaveErrorCodes.Deserialization_NotImplemented);
867
+ // return new MultiChannelCCAggregatedMembersGet({
868
+ // nodeId: ctx.sourceNodeId,
869
+ // });
833
870
  }
834
871
  requestedEndpoint;
835
- serialize() {
872
+ serialize(ctx) {
836
873
  this.payload = Buffer.from([this.requestedEndpoint & 0b0111_1111]);
837
- return super.serialize();
874
+ return super.serialize(ctx);
838
875
  }
839
- toLogEntry(host) {
876
+ toLogEntry(ctx) {
840
877
  return {
841
- ...super.toLogEntry(host),
878
+ ...super.toLogEntry(ctx),
842
879
  message: { endpoint: this.requestedEndpoint },
843
880
  };
844
881
  }
@@ -871,55 +908,69 @@ function testResponseForCommandEncapsulation(sent, received) {
871
908
  }
872
909
  return false;
873
910
  }
874
- let MultiChannelCCCommandEncapsulation = class MultiChannelCCCommandEncapsulation extends MultiChannelCC {
875
- constructor(host, options) {
876
- super(host, options);
877
- if ((0, CommandClass_1.gotDeserializationOptions)(options)) {
878
- (0, safe_1.validatePayload)(this.payload.length >= 2);
879
- if (this.host.getDeviceConfig?.(this.nodeId)?.compat
880
- ?.treatDestinationEndpointAsSource) {
881
- // This device incorrectly uses the destination field to indicate the source endpoint
882
- this.endpointIndex = this.payload[1] & 0b0111_1111;
883
- this.destination = 0;
911
+ let MultiChannelCCCommandEncapsulation = MultiChannelCCCommandEncapsulation_1 = class MultiChannelCCCommandEncapsulation extends MultiChannelCC {
912
+ constructor(options) {
913
+ super(options);
914
+ this.encapsulated = options.encapsulated;
915
+ this.encapsulated.encapsulatingCC = this;
916
+ // Propagate the endpoint index all the way down
917
+ let cur = this;
918
+ while (cur) {
919
+ if ((0, EncapsulatingCommandClass_1.isMultiEncapsulatingCommandClass)(cur)) {
920
+ for (const cc of cur.encapsulated) {
921
+ cc.endpointIndex = this.endpointIndex;
922
+ }
923
+ break;
924
+ }
925
+ else if ((0, EncapsulatingCommandClass_1.isEncapsulatingCommandClass)(cur)) {
926
+ cur.encapsulated.endpointIndex = this.endpointIndex;
927
+ cur = cur.encapsulated;
884
928
  }
885
929
  else {
886
- // Parse normally
887
- this.endpointIndex = this.payload[0] & 0b0111_1111;
888
- const isBitMask = !!(this.payload[1] & 0b1000_0000);
889
- const destination = this.payload[1] & 0b0111_1111;
890
- if (isBitMask) {
891
- this.destination = (0, safe_1.parseBitMask)(Buffer.from([destination]));
892
- }
893
- else {
894
- this.destination = destination;
895
- }
930
+ break;
896
931
  }
897
- // No need to validate further, each CC does it for itself
898
- this.encapsulated = CommandClass_1.CommandClass.from(this.host, {
899
- data: this.payload.subarray(2),
900
- fromEncapsulation: true,
901
- encapCC: this,
902
- origin: options.origin,
903
- frameType: options.frameType,
904
- });
932
+ }
933
+ this.destination = options.destination;
934
+ }
935
+ static from(raw, ctx) {
936
+ (0, safe_1.validatePayload)(raw.payload.length >= 2);
937
+ let endpointIndex;
938
+ let destination;
939
+ if (ctx.getDeviceConfig?.(ctx.sourceNodeId)
940
+ ?.compat?.treatDestinationEndpointAsSource) {
941
+ // This device incorrectly uses the destination field to indicate the source endpoint
942
+ endpointIndex = raw.payload[1] & 0b0111_1111;
943
+ destination = 0;
905
944
  }
906
945
  else {
907
- this.encapsulated = options.encapsulated;
908
- options.encapsulated.encapsulatingCC = this;
909
- this.destination = options.destination;
910
- if (this.host.getDeviceConfig?.(this.nodeId)?.compat
911
- ?.treatDestinationEndpointAsSource) {
912
- // This device incorrectly responds from the endpoint we've passed as our source endpoint
913
- if (typeof this.destination === "number") {
914
- this.endpointIndex = this.destination;
915
- }
946
+ // Parse normally
947
+ endpointIndex = raw.payload[0] & 0b0111_1111;
948
+ const isBitMask = !!(raw.payload[1] & 0b1000_0000);
949
+ destination = raw.payload[1] & 0b0111_1111;
950
+ if (isBitMask) {
951
+ destination = (0, safe_1.parseBitMask)(Buffer.from([destination]));
916
952
  }
917
953
  }
954
+ // No need to validate further, each CC does it for itself
955
+ const encapsulated = CommandClass_1.CommandClass.parse(raw.payload.subarray(2), ctx);
956
+ return new MultiChannelCCCommandEncapsulation_1({
957
+ nodeId: ctx.sourceNodeId,
958
+ endpointIndex,
959
+ destination,
960
+ encapsulated,
961
+ });
918
962
  }
919
963
  encapsulated;
920
964
  /** The destination end point (0-127) or an array of destination end points (1-7) */
921
965
  destination;
922
- serialize() {
966
+ serialize(ctx) {
967
+ if (ctx.getDeviceConfig?.(this.nodeId)?.compat
968
+ ?.treatDestinationEndpointAsSource) {
969
+ // This device incorrectly responds from the endpoint we've passed as our source endpoint
970
+ if (typeof this.destination === "number") {
971
+ this.endpointIndex = this.destination;
972
+ }
973
+ }
923
974
  const destination = typeof this.destination === "number"
924
975
  // The destination is a single number
925
976
  ? this.destination & 0b0111_1111
@@ -927,13 +978,13 @@ let MultiChannelCCCommandEncapsulation = class MultiChannelCCCommandEncapsulatio
927
978
  : (0, safe_1.encodeBitMask)(this.destination, 7)[0] | 0b1000_0000;
928
979
  this.payload = Buffer.concat([
929
980
  Buffer.from([this.endpointIndex & 0b0111_1111, destination]),
930
- this.encapsulated.serialize(),
981
+ this.encapsulated.serialize(ctx),
931
982
  ]);
932
- return super.serialize();
983
+ return super.serialize(ctx);
933
984
  }
934
- toLogEntry(host) {
985
+ toLogEntry(ctx) {
935
986
  return {
936
- ...super.toLogEntry(host),
987
+ ...super.toLogEntry(ctx),
937
988
  message: {
938
989
  source: this.endpointIndex,
939
990
  destination: typeof this.destination === "number"
@@ -948,23 +999,33 @@ let MultiChannelCCCommandEncapsulation = class MultiChannelCCCommandEncapsulatio
948
999
  }
949
1000
  };
950
1001
  exports.MultiChannelCCCommandEncapsulation = MultiChannelCCCommandEncapsulation;
951
- exports.MultiChannelCCCommandEncapsulation = MultiChannelCCCommandEncapsulation = __decorate([
1002
+ exports.MultiChannelCCCommandEncapsulation = MultiChannelCCCommandEncapsulation = MultiChannelCCCommandEncapsulation_1 = __decorate([
952
1003
  (0, CommandClassDecorators_1.CCCommand)(_Types_1.MultiChannelCommand.CommandEncapsulation),
953
1004
  (0, CommandClassDecorators_1.expectedCCResponse)(getCCResponseForCommandEncapsulation, testResponseForCommandEncapsulation)
954
1005
  ], MultiChannelCCCommandEncapsulation);
955
- let MultiChannelCCV1Report = class MultiChannelCCV1Report extends MultiChannelCC {
956
- constructor(host, options) {
957
- super(host, options);
1006
+ let MultiChannelCCV1Report = MultiChannelCCV1Report_1 = class MultiChannelCCV1Report extends MultiChannelCC {
1007
+ constructor(options) {
1008
+ super(options);
1009
+ // TODO: Check implementation:
1010
+ this.requestedCC = options.requestedCC;
1011
+ this.endpointCount = options.endpointCount;
1012
+ }
1013
+ static from(raw, ctx) {
958
1014
  // V1 won't be extended in the future, so do an exact check
959
- (0, safe_1.validatePayload)(this.payload.length === 2);
960
- this.requestedCC = this.payload[0];
961
- this.endpointCount = this.payload[1];
1015
+ (0, safe_1.validatePayload)(raw.payload.length === 2);
1016
+ const requestedCC = raw.payload[0];
1017
+ const endpointCount = raw.payload[1];
1018
+ return new MultiChannelCCV1Report_1({
1019
+ nodeId: ctx.sourceNodeId,
1020
+ requestedCC,
1021
+ endpointCount,
1022
+ });
962
1023
  }
963
1024
  requestedCC;
964
1025
  endpointCount;
965
- toLogEntry(host) {
1026
+ toLogEntry(ctx) {
966
1027
  return {
967
- ...super.toLogEntry(host),
1028
+ ...super.toLogEntry(ctx),
968
1029
  message: {
969
1030
  CC: (0, safe_1.getCCName)(this.requestedCC),
970
1031
  "# of endpoints": this.endpointCount,
@@ -973,31 +1034,32 @@ let MultiChannelCCV1Report = class MultiChannelCCV1Report extends MultiChannelCC
973
1034
  }
974
1035
  };
975
1036
  exports.MultiChannelCCV1Report = MultiChannelCCV1Report;
976
- exports.MultiChannelCCV1Report = MultiChannelCCV1Report = __decorate([
1037
+ exports.MultiChannelCCV1Report = MultiChannelCCV1Report = MultiChannelCCV1Report_1 = __decorate([
977
1038
  (0, CommandClassDecorators_1.CCCommand)(_Types_1.MultiChannelCommand.ReportV1)
978
1039
  ], MultiChannelCCV1Report);
979
1040
  function testResponseForMultiChannelV1Get(sent, received) {
980
1041
  return sent.requestedCC === received.requestedCC;
981
1042
  }
982
1043
  let MultiChannelCCV1Get = class MultiChannelCCV1Get extends MultiChannelCC {
983
- constructor(host, options) {
984
- super(host, options);
985
- if ((0, CommandClass_1.gotDeserializationOptions)(options)) {
986
- // TODO: Deserialize payload
987
- throw new safe_1.ZWaveError(`${this.constructor.name}: deserialization not implemented`, safe_1.ZWaveErrorCodes.Deserialization_NotImplemented);
988
- }
989
- else {
990
- this.requestedCC = options.requestedCC;
991
- }
1044
+ constructor(options) {
1045
+ super(options);
1046
+ this.requestedCC = options.requestedCC;
1047
+ }
1048
+ static from(_raw, _ctx) {
1049
+ // TODO: Deserialize payload
1050
+ throw new safe_1.ZWaveError(`${this.name}: deserialization not implemented`, safe_1.ZWaveErrorCodes.Deserialization_NotImplemented);
1051
+ // return new MultiChannelCCV1Get({
1052
+ // nodeId: ctx.sourceNodeId,
1053
+ // });
992
1054
  }
993
1055
  requestedCC;
994
- serialize() {
1056
+ serialize(ctx) {
995
1057
  this.payload = Buffer.from([this.requestedCC]);
996
- return super.serialize();
1058
+ return super.serialize(ctx);
997
1059
  }
998
- toLogEntry(host) {
1060
+ toLogEntry(ctx) {
999
1061
  return {
1000
- ...super.toLogEntry(host),
1062
+ ...super.toLogEntry(ctx),
1001
1063
  message: { CC: (0, safe_1.getCCName)(this.requestedCC) },
1002
1064
  };
1003
1065
  }
@@ -1018,52 +1080,49 @@ function testResponseForV1CommandEncapsulation(sent, received) {
1018
1080
  }
1019
1081
  return false;
1020
1082
  }
1021
- let MultiChannelCCV1CommandEncapsulation = class MultiChannelCCV1CommandEncapsulation extends MultiChannelCC {
1022
- constructor(host, options) {
1023
- super(host, options);
1024
- if ((0, CommandClass_1.gotDeserializationOptions)(options)) {
1025
- (0, safe_1.validatePayload)(this.payload.length >= 1);
1026
- this.endpointIndex = this.payload[0];
1027
- // Some devices send invalid reports, i.e. MultiChannelCCV1CommandEncapsulation, but with V2+ binary format
1028
- // This would be a NoOp CC, but it makes no sense to encapsulate that.
1029
- const isV2withV1Header = this.payload.length >= 2
1030
- && this.payload[1] === 0x00;
1031
- // No need to validate further, each CC does it for itself
1032
- this.encapsulated = CommandClass_1.CommandClass.from(this.host, {
1033
- data: this.payload.subarray(isV2withV1Header ? 2 : 1),
1034
- fromEncapsulation: true,
1035
- encapCC: this,
1036
- origin: options.origin,
1037
- frameType: options.frameType,
1038
- });
1039
- }
1040
- else {
1041
- this.encapsulated = options.encapsulated;
1042
- // No need to distinguish between source and destination in V1
1043
- this.endpointIndex = this.encapsulated.endpointIndex;
1044
- }
1083
+ let MultiChannelCCV1CommandEncapsulation = MultiChannelCCV1CommandEncapsulation_1 = class MultiChannelCCV1CommandEncapsulation extends MultiChannelCC {
1084
+ constructor(options) {
1085
+ super(options);
1086
+ this.encapsulated = options.encapsulated;
1087
+ // No need to distinguish between source and destination in V1
1088
+ this.endpointIndex = this.encapsulated.endpointIndex;
1089
+ }
1090
+ static from(raw, ctx) {
1091
+ (0, safe_1.validatePayload)(raw.payload.length >= 1);
1092
+ const endpointIndex = raw.payload[0];
1093
+ // Some devices send invalid reports, i.e. MultiChannelCCV1CommandEncapsulation, but with V2+ binary format
1094
+ // This would be a NoOp CC, but it makes no sense to encapsulate that.
1095
+ const isV2withV1Header = raw.payload.length >= 2
1096
+ && raw.payload[1] === 0x00;
1097
+ // No need to validate further, each CC does it for itself
1098
+ const encapsulated = CommandClass_1.CommandClass.parse(raw.payload.subarray(isV2withV1Header ? 2 : 1), ctx);
1099
+ return new MultiChannelCCV1CommandEncapsulation_1({
1100
+ nodeId: ctx.sourceNodeId,
1101
+ endpointIndex,
1102
+ encapsulated,
1103
+ });
1045
1104
  }
1046
1105
  encapsulated;
1047
- serialize() {
1106
+ serialize(ctx) {
1048
1107
  this.payload = Buffer.concat([
1049
1108
  Buffer.from([this.endpointIndex]),
1050
- this.encapsulated.serialize(),
1109
+ this.encapsulated.serialize(ctx),
1051
1110
  ]);
1052
- return super.serialize();
1111
+ return super.serialize(ctx);
1053
1112
  }
1054
1113
  computeEncapsulationOverhead() {
1055
1114
  // Multi Channel CC V1 adds one byte for the endpoint index
1056
1115
  return super.computeEncapsulationOverhead() + 1;
1057
1116
  }
1058
- toLogEntry(host) {
1117
+ toLogEntry(ctx) {
1059
1118
  return {
1060
- ...super.toLogEntry(host),
1119
+ ...super.toLogEntry(ctx),
1061
1120
  message: { source: this.endpointIndex },
1062
1121
  };
1063
1122
  }
1064
1123
  };
1065
1124
  exports.MultiChannelCCV1CommandEncapsulation = MultiChannelCCV1CommandEncapsulation;
1066
- exports.MultiChannelCCV1CommandEncapsulation = MultiChannelCCV1CommandEncapsulation = __decorate([
1125
+ exports.MultiChannelCCV1CommandEncapsulation = MultiChannelCCV1CommandEncapsulation = MultiChannelCCV1CommandEncapsulation_1 = __decorate([
1067
1126
  (0, CommandClassDecorators_1.CCCommand)(_Types_1.MultiChannelCommand.CommandEncapsulationV1),
1068
1127
  (0, CommandClassDecorators_1.expectedCCResponse)(getResponseForV1CommandEncapsulation, testResponseForV1CommandEncapsulation)
1069
1128
  ], MultiChannelCCV1CommandEncapsulation);