@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
@@ -1,104 +1,128 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.InvalidCC = exports.CommandClass = void 0;
4
- exports.gotDeserializationOptions = gotDeserializationOptions;
5
- exports.assertValidCCs = assertValidCCs;
3
+ exports.InvalidCC = exports.CommandClass = exports.CCRaw = void 0;
4
+ exports.getEffectiveCCVersion = getEffectiveCCVersion;
6
5
  const core_1 = require("@zwave-js/core");
7
- const serial_1 = require("@zwave-js/serial");
8
6
  const shared_1 = require("@zwave-js/shared");
9
7
  const typeguards_1 = require("alcalzone-shared/typeguards");
10
8
  const CommandClassDecorators_1 = require("./CommandClassDecorators");
11
9
  const EncapsulatingCommandClass_1 = require("./EncapsulatingCommandClass");
12
- const ICommandClassContainer_1 = require("./ICommandClassContainer");
13
10
  const Values_1 = require("./Values");
14
- function gotDeserializationOptions(options) {
15
- return "data" in options && Buffer.isBuffer(options.data);
11
+ function getEffectiveCCVersion(ctx, cc, defaultVersion) {
12
+ // For multicast and broadcast CCs, just use the highest implemented version to serialize
13
+ // Older nodes will ignore the additional fields
14
+ if (typeof cc.nodeId !== "number"
15
+ || cc.nodeId === core_1.NODE_ID_BROADCAST
16
+ || cc.nodeId === core_1.NODE_ID_BROADCAST_LR) {
17
+ return (0, CommandClassDecorators_1.getImplementedVersion)(cc.ccId);
18
+ }
19
+ // For singlecast CCs, set the CC version as high as possible
20
+ return ctx.getSupportedCCVersion(cc.ccId, cc.nodeId, cc.endpointIndex)
21
+ || (defaultVersion ?? (0, CommandClassDecorators_1.getImplementedVersion)(cc.ccId));
16
22
  }
17
- function gotCCCommandOptions(options) {
18
- return typeof options.nodeId === "number" || (0, typeguards_1.isArray)(options.nodeId);
23
+ class CCRaw {
24
+ ccId;
25
+ ccCommand;
26
+ payload;
27
+ constructor(ccId, ccCommand, payload) {
28
+ this.ccId = ccId;
29
+ this.ccCommand = ccCommand;
30
+ this.payload = payload;
31
+ }
32
+ static parse(data) {
33
+ const { ccId, bytesRead: ccIdLength } = (0, core_1.parseCCId)(data);
34
+ // There are so few exceptions that we can handle them here manually
35
+ if (ccId === core_1.CommandClasses["No Operation"]) {
36
+ return new CCRaw(ccId, undefined, Buffer.allocUnsafe(0));
37
+ }
38
+ let ccCommand = data[ccIdLength];
39
+ let payload = data.subarray(ccIdLength + 1);
40
+ if (ccId === core_1.CommandClasses["Transport Service"]) {
41
+ // Transport Service only uses the higher 5 bits for the command
42
+ // and re-uses the lower 3 bits of the ccCommand as payload
43
+ payload = Buffer.concat([
44
+ Buffer.from([ccCommand & 0b111]),
45
+ payload,
46
+ ]);
47
+ ccCommand = ccCommand & 0b11111_000;
48
+ }
49
+ else if (ccId === core_1.CommandClasses["Manufacturer Proprietary"]) {
50
+ // ManufacturerProprietaryCC has no CC command, so the first
51
+ // payload byte is stored in ccCommand.
52
+ payload = Buffer.concat([
53
+ Buffer.from([ccCommand]),
54
+ payload,
55
+ ]);
56
+ ccCommand = undefined;
57
+ }
58
+ return new CCRaw(ccId, ccCommand, payload);
59
+ }
60
+ withPayload(payload) {
61
+ return new CCRaw(this.ccId, this.ccCommand, payload);
62
+ }
19
63
  }
64
+ exports.CCRaw = CCRaw;
20
65
  // @publicAPI
21
66
  class CommandClass {
22
67
  // empty constructor to parse messages
23
- constructor(host, options) {
24
- this.host = host;
25
- // Default to the root endpoint - Inherited classes may override this behavior
26
- this.endpointIndex =
27
- ("endpoint" in options ? options.endpoint : undefined) ?? 0;
28
- // We cannot use @ccValue for non-derived classes, so register interviewComplete as an internal value here
29
- // this.registerValue("interviewComplete", { internal: true });
30
- if (gotDeserializationOptions(options)) {
31
- // For deserialized commands, try to invoke the correct subclass constructor
32
- const CCConstructor = (0, CommandClassDecorators_1.getCCConstructor)(CommandClass.getCommandClass(options.data))
33
- ?? CommandClass;
34
- const ccId = CommandClass.getCommandClass(options.data);
35
- const ccCommand = CCConstructor.getCCCommand(options.data);
36
- if (ccCommand != undefined) {
37
- const CommandConstructor = (0, CommandClassDecorators_1.getCCCommandConstructor)(ccId, ccCommand);
38
- if (CommandConstructor
39
- && new.target !== CommandConstructor) {
40
- return new CommandConstructor(host, options);
41
- }
42
- }
43
- // If the constructor is correct or none was found, fall back to normal deserialization
44
- if (options.fromEncapsulation) {
45
- // Propagate the node ID and endpoint index from the encapsulating CC
46
- this.nodeId = options.encapCC.nodeId;
47
- if (!this.endpointIndex && options.encapCC.endpointIndex) {
48
- this.endpointIndex = options.encapCC.endpointIndex;
49
- }
50
- // And remember which CC encapsulates this CC
51
- this.encapsulatingCC = options.encapCC;
52
- }
53
- else {
54
- this.nodeId = options.nodeId;
55
- }
56
- this.frameType = options.frameType;
57
- ({
58
- ccId: this.ccId,
59
- ccCommand: this.ccCommand,
60
- payload: this.payload,
61
- } = this.deserialize(options.data));
62
- }
63
- else if (gotCCCommandOptions(options)) {
64
- const { nodeId, endpoint = 0, ccId = (0, CommandClassDecorators_1.getCommandClass)(this), ccCommand = (0, CommandClassDecorators_1.getCCCommand)(this), payload = Buffer.allocUnsafe(0), } = options;
65
- this.nodeId = nodeId;
66
- this.endpointIndex = endpoint;
67
- this.ccId = ccId;
68
- this.ccCommand = ccCommand;
69
- this.payload = payload;
70
- }
71
- if (this instanceof InvalidCC)
72
- return;
73
- if (options.origin !== serial_1.MessageOrigin.Host && this.isSinglecast()) {
74
- try {
75
- // For singlecast CCs, set the CC version as high as possible
76
- this.version = this.host.getSafeCCVersion(this.ccId, this.nodeId, this.endpointIndex);
77
- // But remember which version the node supports
78
- this._knownVersion = this.host.getSupportedCCVersion(this.ccId, this.nodeId, this.endpointIndex);
79
- }
80
- catch (e) {
81
- if ((0, core_1.isZWaveError)(e)
82
- && e.code === core_1.ZWaveErrorCodes.CC_NotImplemented) {
83
- // Someone tried to create a CC that is not implemented. Just set all versions to 0.
84
- this.version = 0;
85
- this._knownVersion = 0;
86
- }
87
- else {
88
- throw e;
68
+ constructor(options) {
69
+ const { nodeId, endpointIndex = 0, ccId = (0, CommandClassDecorators_1.getCommandClass)(this), ccCommand = (0, CommandClassDecorators_1.getCCCommand)(this), payload = Buffer.allocUnsafe(0), } = options;
70
+ this.nodeId = nodeId;
71
+ this.endpointIndex = endpointIndex;
72
+ this.ccId = ccId;
73
+ this.ccCommand = ccCommand;
74
+ this.payload = payload;
75
+ }
76
+ static parse(data, ctx) {
77
+ const raw = CCRaw.parse(data);
78
+ // Find the correct subclass constructor to invoke
79
+ const CCConstructor = (0, CommandClassDecorators_1.getCCConstructor)(raw.ccId);
80
+ if (!CCConstructor) {
81
+ // None -> fall back to the default constructor
82
+ return CommandClass.from(raw, ctx);
83
+ }
84
+ let CommandConstructor;
85
+ if (raw.ccCommand != undefined) {
86
+ CommandConstructor = (0, CommandClassDecorators_1.getCCCommandConstructor)(raw.ccId, raw.ccCommand);
87
+ }
88
+ // Not every CC has a constructor for its commands. In that case,
89
+ // call the CC constructor directly
90
+ try {
91
+ return (CommandConstructor ?? CCConstructor).from(raw, ctx);
92
+ }
93
+ catch (e) {
94
+ // Indicate invalid payloads with a special CC type
95
+ if ((0, core_1.isZWaveError)(e)
96
+ && e.code === core_1.ZWaveErrorCodes.PacketFormat_InvalidPayload) {
97
+ const ccName = CommandConstructor?.name
98
+ ?? `${(0, core_1.getCCName)(raw.ccId)} CC`;
99
+ // Preserve why the command was invalid
100
+ let reason;
101
+ if (typeof e.context === "string"
102
+ || (typeof e.context === "number"
103
+ && core_1.ZWaveErrorCodes[e.context] != undefined)) {
104
+ reason = e.context;
89
105
  }
106
+ const ret = new InvalidCC({
107
+ nodeId: ctx.sourceNodeId,
108
+ ccId: raw.ccId,
109
+ ccCommand: raw.ccCommand,
110
+ ccName,
111
+ reason,
112
+ });
113
+ return ret;
90
114
  }
91
- // Send secure commands if necessary
92
- this.toggleEncapsulationFlag(core_1.EncapsulationFlags.Security, this.host.isCCSecure(this.ccId, this.nodeId, this.endpointIndex));
93
- }
94
- else {
95
- // For multicast and broadcast CCs, we just use the highest implemented version to serialize
96
- // Older nodes will ignore the additional fields
97
- this.version = (0, CommandClassDecorators_1.getImplementedVersion)(this.ccId);
98
- this._knownVersion = this.version;
115
+ throw e;
99
116
  }
100
117
  }
101
- host;
118
+ static from(raw, ctx) {
119
+ return new this({
120
+ nodeId: ctx.sourceNodeId,
121
+ ccId: raw.ccId,
122
+ ccCommand: raw.ccCommand,
123
+ payload: raw.payload,
124
+ });
125
+ }
102
126
  /** This CC's identifier */
103
127
  ccId;
104
128
  ccCommand;
@@ -109,11 +133,6 @@ class CommandClass {
109
133
  nodeId;
110
134
  // Work around https://github.com/Microsoft/TypeScript/issues/27555
111
135
  payload;
112
- /** The version of the command class used */
113
- // Work around https://github.com/Microsoft/TypeScript/issues/27555
114
- version;
115
- /** The version of the CC the node has reported support for */
116
- _knownVersion;
117
136
  /** Which endpoint of the node this CC belongs to. 0 for the root device. */
118
137
  endpointIndex;
119
138
  /**
@@ -155,33 +174,11 @@ class CommandClass {
155
174
  property: "interviewComplete",
156
175
  }, complete);
157
176
  }
158
- /**
159
- * Deserializes a CC from a buffer that contains a serialized CC
160
- */
161
- // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
162
- deserialize(data) {
163
- const ccId = CommandClass.getCommandClass(data);
164
- const ccIdLength = this.isExtended() ? 2 : 1;
165
- if (data.length > ccIdLength) {
166
- // This is not a NoOp CC (contains command and payload)
167
- const ccCommand = data[ccIdLength];
168
- const payload = data.subarray(ccIdLength + 1);
169
- return {
170
- ccId,
171
- ccCommand,
172
- payload,
173
- };
174
- }
175
- else {
176
- // NoOp CC (no command, no payload)
177
- const payload = Buffer.allocUnsafe(0);
178
- return { ccId, payload };
179
- }
180
- }
181
177
  /**
182
178
  * Serializes this CommandClass to be embedded in a message payload or another CC
183
179
  */
184
- serialize() {
180
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
181
+ serialize(ctx) {
185
182
  // NoOp CCs have no command and no payload
186
183
  if (this.ccId === core_1.CommandClasses["No Operation"]) {
187
184
  return Buffer.from([this.ccId]);
@@ -202,95 +199,23 @@ class CommandClass {
202
199
  prepareRetransmission() {
203
200
  // Do nothing by default
204
201
  }
205
- /** Extracts the CC id from a buffer that contains a serialized CC */
206
- static getCommandClass(data) {
207
- return (0, core_1.parseCCId)(data).ccId;
208
- }
209
- /** Extracts the CC command from a buffer that contains a serialized CC */
210
- static getCCCommand(data) {
211
- if (data[0] === 0)
212
- return undefined; // NoOp
213
- const isExtendedCC = data[0] >= 0xf1;
214
- return isExtendedCC ? data[2] : data[1];
215
- }
216
- /**
217
- * Retrieves the correct constructor for the CommandClass in the given Buffer.
218
- * It is assumed that the buffer only contains the serialized CC. This throws if the CC is not implemented.
219
- */
220
- static getConstructor(ccData) {
221
- const cc = CommandClass.getCommandClass(ccData);
222
- const ret = (0, CommandClassDecorators_1.getCCConstructor)(cc);
223
- if (!ret) {
224
- const ccName = (0, core_1.getCCName)(cc);
225
- throw new core_1.ZWaveError(`The command class ${ccName} is not implemented`, core_1.ZWaveErrorCodes.CC_NotImplemented);
226
- }
227
- return ret;
228
- }
229
- /**
230
- * Creates an instance of the CC that is serialized in the given buffer
231
- */
232
- static from(host, options) {
233
- // Fall back to unspecified command class in case we receive one that is not implemented
234
- const ccId = CommandClass.getCommandClass(options.data);
235
- const Constructor = (0, CommandClassDecorators_1.getCCConstructor)(ccId) ?? CommandClass;
236
- try {
237
- return new Constructor(host, options);
238
- }
239
- catch (e) {
240
- // Indicate invalid payloads with a special CC type
241
- if ((0, core_1.isZWaveError)(e)
242
- && e.code === core_1.ZWaveErrorCodes.PacketFormat_InvalidPayload) {
243
- const nodeId = options.fromEncapsulation
244
- ? options.encapCC.nodeId
245
- : options.nodeId;
246
- let ccName;
247
- const ccId = CommandClass.getCommandClass(options.data);
248
- const ccCommand = CommandClass.getCCCommand(options.data);
249
- if (ccCommand != undefined) {
250
- ccName = (0, CommandClassDecorators_1.getCCCommandConstructor)(ccId, ccCommand)?.name;
251
- }
252
- // Fall back to the unspecified CC if the command cannot be determined
253
- if (!ccName) {
254
- ccName = `${(0, core_1.getCCName)(ccId)} CC`;
255
- }
256
- // Preserve why the command was invalid
257
- let reason;
258
- if (typeof e.context === "string"
259
- || (typeof e.context === "number"
260
- && core_1.ZWaveErrorCodes[e.context] != undefined)) {
261
- reason = e.context;
262
- }
263
- const ret = new InvalidCC(host, {
264
- nodeId,
265
- ccId,
266
- ccName,
267
- reason,
268
- });
269
- if (options.fromEncapsulation) {
270
- ret.encapsulatingCC = options.encapCC;
271
- }
272
- return ret;
273
- }
274
- throw e;
275
- }
276
- }
277
202
  /**
278
203
  * Create an instance of the given CC without checking whether it is supported.
279
204
  * If the CC is implemented, this returns an instance of the given CC which is linked to the given endpoint.
280
205
  *
281
206
  * **INTERNAL:** Applications should not use this directly.
282
207
  */
283
- static createInstanceUnchecked(host, endpoint, cc) {
208
+ static createInstanceUnchecked(endpoint, cc) {
284
209
  const Constructor = typeof cc === "number" ? (0, CommandClassDecorators_1.getCCConstructor)(cc) : cc;
285
210
  if (Constructor) {
286
- return new Constructor(host, {
211
+ return new Constructor({
287
212
  nodeId: endpoint.nodeId,
288
- endpoint: endpoint.index,
213
+ endpointIndex: endpoint.index,
289
214
  });
290
215
  }
291
216
  }
292
217
  /** Generates a representation of this CC for the log */
293
- toLogEntry(_host) {
218
+ toLogEntry(_ctx) {
294
219
  let tag = this.constructor.name;
295
220
  const message = {};
296
221
  if (this.constructor === CommandClass) {
@@ -330,20 +255,20 @@ class CommandClass {
330
255
  /**
331
256
  * Performs the interview procedure for this CC according to SDS14223
332
257
  */
333
- async interview(_applHost) {
258
+ async interview(_ctx) {
334
259
  // This needs to be overwritten per command class. In the default implementation, don't do anything
335
260
  }
336
261
  /**
337
262
  * Refreshes all dynamic values of this CC
338
263
  */
339
- async refreshValues(_applHost) {
264
+ async refreshValues(_ctx) {
340
265
  // This needs to be overwritten per command class. In the default implementation, don't do anything
341
266
  }
342
267
  /**
343
268
  * Checks if the CC values need to be manually refreshed.
344
269
  * This should be called regularly and when sleeping nodes wake up
345
270
  */
346
- shouldRefreshValues(_applHost) {
271
+ shouldRefreshValues(_ctx) {
347
272
  // This needs to be overwritten per command class.
348
273
  // In the default implementation, don't require a refresh
349
274
  return false;
@@ -368,7 +293,7 @@ class CommandClass {
368
293
  * Maps a BasicCC value to a more specific CC implementation. Returns true if the value was mapped, false otherwise.
369
294
  * @param _value The value of the received BasicCC
370
295
  */
371
- setMappedBasicValue(_applHost, _value) {
296
+ setMappedBasicValue(_ctx, _value) {
372
297
  // By default, don't map
373
298
  return false;
374
299
  }
@@ -401,18 +326,18 @@ class CommandClass {
401
326
  /**
402
327
  * Returns the node this CC is linked to. Throws if the controller is not yet ready.
403
328
  */
404
- getNode(applHost) {
329
+ getNode(ctx) {
405
330
  if (this.isSinglecast()) {
406
- return applHost.nodes.get(this.nodeId);
331
+ return ctx.getNode(this.nodeId);
407
332
  }
408
333
  }
409
334
  /**
410
335
  * @internal
411
336
  * Returns the node this CC is linked to (or undefined if the node doesn't exist)
412
337
  */
413
- getNodeUnsafe(applHost) {
338
+ tryGetNode(ctx) {
414
339
  try {
415
- return this.getNode(applHost);
340
+ return this.getNode(ctx);
416
341
  }
417
342
  catch (e) {
418
343
  // This was expected
@@ -423,14 +348,14 @@ class CommandClass {
423
348
  throw e;
424
349
  }
425
350
  }
426
- getEndpoint(applHost) {
427
- return this.getNode(applHost)?.getEndpoint(this.endpointIndex);
351
+ getEndpoint(ctx) {
352
+ return this.getNode(ctx)?.getEndpoint(this.endpointIndex);
428
353
  }
429
354
  /** Returns the value DB for this CC's node */
430
- getValueDB(host) {
355
+ getValueDB(ctx) {
431
356
  if (this.isSinglecast()) {
432
357
  try {
433
- return host.getValueDB(this.nodeId);
358
+ return ctx.getValueDB(this.nodeId);
434
359
  }
435
360
  catch {
436
361
  throw new core_1.ZWaveError("The node for this CC does not exist or the driver is not ready yet", core_1.ZWaveErrorCodes.Driver_NotReady);
@@ -443,8 +368,8 @@ class CommandClass {
443
368
  * The endpoint index of the current CC instance is automatically taken into account.
444
369
  * @param meta Will be used in place of the predefined metadata when given
445
370
  */
446
- ensureMetadata(host, ccValue, meta) {
447
- const valueDB = this.getValueDB(host);
371
+ ensureMetadata(ctx, ccValue, meta) {
372
+ const valueDB = this.getValueDB(ctx);
448
373
  const valueId = ccValue.endpoint(this.endpointIndex);
449
374
  if (!valueDB.hasMetadata(valueId)) {
450
375
  valueDB.setMetadata(valueId, meta ?? ccValue.meta);
@@ -454,8 +379,8 @@ class CommandClass {
454
379
  * Removes the metadata for the given CC value from the value DB.
455
380
  * The endpoint index of the current CC instance is automatically taken into account.
456
381
  */
457
- removeMetadata(host, ccValue) {
458
- const valueDB = this.getValueDB(host);
382
+ removeMetadata(ctx, ccValue) {
383
+ const valueDB = this.getValueDB(ctx);
459
384
  const valueId = ccValue.endpoint(this.endpointIndex);
460
385
  valueDB.setMetadata(valueId, undefined);
461
386
  }
@@ -464,8 +389,8 @@ class CommandClass {
464
389
  * The endpoint index of the current CC instance is automatically taken into account.
465
390
  * @param meta Will be used in place of the predefined metadata when given
466
391
  */
467
- setMetadata(host, ccValue, meta) {
468
- const valueDB = this.getValueDB(host);
392
+ setMetadata(ctx, ccValue, meta) {
393
+ const valueDB = this.getValueDB(ctx);
469
394
  const valueId = ccValue.endpoint(this.endpointIndex);
470
395
  valueDB.setMetadata(valueId, meta ?? ccValue.meta);
471
396
  }
@@ -473,8 +398,8 @@ class CommandClass {
473
398
  * Reads the metadata for the given CC value from the Value DB.
474
399
  * The endpoint index of the current CC instance is automatically taken into account.
475
400
  */
476
- getMetadata(host, ccValue) {
477
- const valueDB = this.getValueDB(host);
401
+ getMetadata(ctx, ccValue) {
402
+ const valueDB = this.getValueDB(ctx);
478
403
  const valueId = ccValue.endpoint(this.endpointIndex);
479
404
  return valueDB.getMetadata(valueId);
480
405
  }
@@ -482,8 +407,8 @@ class CommandClass {
482
407
  * Stores the given value under the value ID for the given CC value in the value DB.
483
408
  * The endpoint index of the current CC instance is automatically taken into account.
484
409
  */
485
- setValue(host, ccValue, value) {
486
- const valueDB = this.getValueDB(host);
410
+ setValue(ctx, ccValue, value) {
411
+ const valueDB = this.getValueDB(ctx);
487
412
  const valueId = ccValue.endpoint(this.endpointIndex);
488
413
  valueDB.setValue(valueId, value);
489
414
  }
@@ -491,8 +416,8 @@ class CommandClass {
491
416
  * Removes the value for the given CC value from the value DB.
492
417
  * The endpoint index of the current CC instance is automatically taken into account.
493
418
  */
494
- removeValue(host, ccValue) {
495
- const valueDB = this.getValueDB(host);
419
+ removeValue(ctx, ccValue) {
420
+ const valueDB = this.getValueDB(ctx);
496
421
  const valueId = ccValue.endpoint(this.endpointIndex);
497
422
  valueDB.removeValue(valueId);
498
423
  }
@@ -500,8 +425,8 @@ class CommandClass {
500
425
  * Reads the value stored for the value ID of the given CC value from the value DB.
501
426
  * The endpoint index of the current CC instance is automatically taken into account.
502
427
  */
503
- getValue(host, ccValue) {
504
- const valueDB = this.getValueDB(host);
428
+ getValue(ctx, ccValue) {
429
+ const valueDB = this.getValueDB(ctx);
505
430
  const valueId = ccValue.endpoint(this.endpointIndex);
506
431
  return valueDB.getValue(valueId);
507
432
  }
@@ -509,8 +434,8 @@ class CommandClass {
509
434
  * Reads when the value stored for the value ID of the given CC value was last updated in the value DB.
510
435
  * The endpoint index of the current CC instance is automatically taken into account.
511
436
  */
512
- getValueTimestamp(host, ccValue) {
513
- const valueDB = this.getValueDB(host);
437
+ getValueTimestamp(ctx, ccValue) {
438
+ const valueDB = this.getValueDB(ctx);
514
439
  const valueId = ccValue.endpoint(this.endpointIndex);
515
440
  return valueDB.getTimestamp(valueId);
516
441
  }
@@ -534,13 +459,17 @@ class CommandClass {
534
459
  ...properties,
535
460
  }));
536
461
  }
537
- shouldAutoCreateValue(applHost, value) {
462
+ shouldAutoCreateValue(ctx, value) {
538
463
  return (value.options.autoCreate === true
539
464
  || (typeof value.options.autoCreate === "function"
540
- && value.options.autoCreate(applHost, this.getEndpoint(applHost))));
465
+ && value.options.autoCreate(ctx, {
466
+ virtual: false,
467
+ nodeId: this.nodeId,
468
+ index: this.endpointIndex,
469
+ })));
541
470
  }
542
471
  /** Returns a list of all value names that are defined for this CommandClass */
543
- getDefinedValueIDs(applHost, includeInternal = false) {
472
+ getDefinedValueIDs(ctx, includeInternal = false) {
544
473
  // In order to compare value ids, we need them to be strings
545
474
  const ret = new Map();
546
475
  const addValueId = (property, propertyKey) => {
@@ -555,12 +484,21 @@ class CommandClass {
555
484
  ret.set(dbKey, valueId);
556
485
  };
557
486
  // Return all value IDs for this CC...
558
- const valueDB = this.getValueDB(applHost);
487
+ const valueDB = this.getValueDB(ctx);
559
488
  // ...which either have metadata or a value
560
489
  const existingValueIds = [
561
490
  ...valueDB.getValues(this.ccId),
562
491
  ...valueDB.getAllMetadata(this.ccId),
563
492
  ];
493
+ // To determine which value IDs to expose, we need to know the CC version
494
+ // that we're doing this for
495
+ const supportedVersion = typeof this.nodeId === "number"
496
+ && this.nodeId !== core_1.NODE_ID_BROADCAST
497
+ && this.nodeId !== core_1.NODE_ID_BROADCAST_LR
498
+ // On singlecast CCs, use the version the node reported support for,
499
+ ? ctx.getSupportedCCVersion(this.ccId, this.nodeId, this.endpointIndex)
500
+ // on multicast/broadcast, use the highest version we implement
501
+ : (0, CommandClassDecorators_1.getImplementedVersion)(this.ccId);
564
502
  // ...or which are statically defined using @ccValues(...)
565
503
  for (const value of Object.values((0, CommandClassDecorators_1.getCCValues)(this) ?? {})) {
566
504
  // Skip dynamic CC values - they need a specific subclass instance to be evaluated
@@ -568,14 +506,14 @@ class CommandClass {
568
506
  continue;
569
507
  // Skip those values that are only supported in higher versions of the CC
570
508
  if (value.options.minVersion != undefined
571
- && value.options.minVersion > this._knownVersion) {
509
+ && value.options.minVersion > supportedVersion) {
572
510
  continue;
573
511
  }
574
512
  // Skip internal values
575
513
  if (value.options.internal && !includeInternal)
576
514
  continue;
577
515
  // And determine if this value should be automatically "created"
578
- if (!this.shouldAutoCreateValue(applHost, value))
516
+ if (!this.shouldAutoCreateValue(ctx, value))
579
517
  continue;
580
518
  existingValueIds.push(value.endpoint(this.endpointIndex));
581
519
  }
@@ -619,21 +557,26 @@ class CommandClass {
619
557
  * Persists all values for this CC instance into the value DB which are annotated with @ccValue.
620
558
  * Returns `true` if the process succeeded, `false` if the value DB cannot be accessed.
621
559
  */
622
- persistValues(applHost) {
560
+ persistValues(ctx) {
623
561
  let valueDB;
624
562
  try {
625
- valueDB = this.getValueDB(applHost);
563
+ valueDB = this.getValueDB(ctx);
626
564
  }
627
565
  catch {
628
566
  return false;
629
567
  }
568
+ // To determine which value IDs to expose, we need to know the CC version
569
+ // that we're doing this for
570
+ const supportedVersion = ctx.getSupportedCCVersion(this.ccId,
571
+ // Values are only persisted for singlecast, so we know nodeId is a number
572
+ this.nodeId, this.endpointIndex) || 1;
630
573
  // Get all properties of this CC which are annotated with a @ccValue decorator and store them.
631
574
  for (const [prop, _value] of (0, CommandClassDecorators_1.getCCValueProperties)(this)) {
632
575
  // Evaluate dynamic CC values first
633
576
  const value = typeof _value === "function" ? _value(this) : _value;
634
577
  // Skip those values that are only supported in higher versions of the CC
635
578
  if (value.options.minVersion != undefined
636
- && value.options.minVersion > this.version) {
579
+ && value.options.minVersion > supportedVersion) {
637
580
  continue;
638
581
  }
639
582
  const valueId = value.endpoint(this.endpointIndex);
@@ -644,8 +587,8 @@ class CommandClass {
644
587
  && (sourceValue != undefined
645
588
  // ... or if we know which CC version the node supports
646
589
  // and the value may be automatically created
647
- || (this._knownVersion >= value.options.minVersion
648
- && this.shouldAutoCreateValue(applHost, value)));
590
+ || (supportedVersion >= value.options.minVersion
591
+ && this.shouldAutoCreateValue(ctx, value)));
649
592
  if (createMetadata && !valueDB.hasMetadata(valueId)) {
650
593
  valueDB.setMetadata(valueId, value.meta);
651
594
  }
@@ -674,8 +617,7 @@ class CommandClass {
674
617
  return false; // By default, all CCs are monolithic
675
618
  }
676
619
  /** Include previously received partial responses into a final CC */
677
- /* istanbul ignore next */
678
- mergePartialCCs(_applHost, _partials) {
620
+ mergePartialCCs(_partials, _ctx) {
679
621
  // This is highly CC dependent
680
622
  // Overwrite this in derived classes, by default do nothing
681
623
  }
@@ -742,7 +684,7 @@ class CommandClass {
742
684
  * @param property The property identifier that should be translated
743
685
  * @param _propertyKey The (optional) property key the translated name may depend on
744
686
  */
745
- translateProperty(_applHost, property, _propertyKey) {
687
+ translateProperty(_ctx, property, _propertyKey) {
746
688
  // Overwrite this in derived classes, by default just return the property key
747
689
  return property.toString();
748
690
  }
@@ -751,7 +693,7 @@ class CommandClass {
751
693
  * @param _property The property the key in question belongs to
752
694
  * @param propertyKey The property key for which the speaking name should be retrieved
753
695
  */
754
- translatePropertyKey(_applHost, _property, propertyKey) {
696
+ translatePropertyKey(_ctx, _property, propertyKey) {
755
697
  // Overwrite this in derived classes, by default just return the property key
756
698
  return propertyKey.toString();
757
699
  }
@@ -818,8 +760,8 @@ class CommandClass {
818
760
  }
819
761
  exports.CommandClass = CommandClass;
820
762
  class InvalidCC extends CommandClass {
821
- constructor(host, options) {
822
- super(host, options);
763
+ constructor(options) {
764
+ super(options);
823
765
  this._ccName = options.ccName;
824
766
  // Numeric reasons are used internally to communicate problems with a CC
825
767
  // without ignoring them entirely
@@ -830,7 +772,7 @@ class InvalidCC extends CommandClass {
830
772
  return this._ccName;
831
773
  }
832
774
  reason;
833
- toLogEntry(_host) {
775
+ toLogEntry(_ctx) {
834
776
  return {
835
777
  tags: [this.ccName, "INVALID"],
836
778
  message: this.reason != undefined
@@ -844,18 +786,4 @@ class InvalidCC extends CommandClass {
844
786
  }
845
787
  }
846
788
  exports.InvalidCC = InvalidCC;
847
- /** @publicAPI */
848
- function assertValidCCs(container) {
849
- if (container.command instanceof InvalidCC) {
850
- if (typeof container.command.reason === "number") {
851
- throw new core_1.ZWaveError("The message payload failed validation!", container.command.reason);
852
- }
853
- else {
854
- throw new core_1.ZWaveError("The message payload is invalid!", core_1.ZWaveErrorCodes.PacketFormat_InvalidPayload, container.command.reason);
855
- }
856
- }
857
- else if ((0, ICommandClassContainer_1.isCommandClassContainer)(container.command)) {
858
- assertValidCCs(container.command);
859
- }
860
- }
861
789
  //# sourceMappingURL=CommandClass.js.map