@zwave-js/cc 9.3.1-0-pr-4662-79458fb

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 (297) hide show
  1. package/build/cc/AlarmSensorCC.d.ts +54 -0
  2. package/build/cc/AlarmSensorCC.d.ts.map +1 -0
  3. package/build/cc/AlarmSensorCC.js +378 -0
  4. package/build/cc/AlarmSensorCC.js.map +1 -0
  5. package/build/cc/AssociationCC.d.ts +123 -0
  6. package/build/cc/AssociationCC.d.ts.map +1 -0
  7. package/build/cc/AssociationCC.js +615 -0
  8. package/build/cc/AssociationCC.js.map +1 -0
  9. package/build/cc/AssociationGroupInfoCC.d.ts +97 -0
  10. package/build/cc/AssociationGroupInfoCC.d.ts.map +1 -0
  11. package/build/cc/AssociationGroupInfoCC.js +530 -0
  12. package/build/cc/AssociationGroupInfoCC.js.map +1 -0
  13. package/build/cc/BarrierOperatorCC.d.ts +75 -0
  14. package/build/cc/BarrierOperatorCC.d.ts.map +1 -0
  15. package/build/cc/BarrierOperatorCC.js +492 -0
  16. package/build/cc/BarrierOperatorCC.js.map +1 -0
  17. package/build/cc/BasicCC.d.ts +51 -0
  18. package/build/cc/BasicCC.d.ts.map +1 -0
  19. package/build/cc/BasicCC.js +344 -0
  20. package/build/cc/BasicCC.js.map +1 -0
  21. package/build/cc/BatteryCC.d.ts +56 -0
  22. package/build/cc/BatteryCC.d.ts.map +1 -0
  23. package/build/cc/BatteryCC.js +417 -0
  24. package/build/cc/BatteryCC.js.map +1 -0
  25. package/build/cc/BinarySensorCC.d.ts +52 -0
  26. package/build/cc/BinarySensorCC.d.ts.map +1 -0
  27. package/build/cc/BinarySensorCC.js +321 -0
  28. package/build/cc/BinarySensorCC.js.map +1 -0
  29. package/build/cc/BinarySwitchCC.d.ts +55 -0
  30. package/build/cc/BinarySwitchCC.d.ts.map +1 -0
  31. package/build/cc/BinarySwitchCC.js +327 -0
  32. package/build/cc/BinarySwitchCC.js.map +1 -0
  33. package/build/cc/CRC16CC.d.ts +28 -0
  34. package/build/cc/CRC16CC.d.ts.map +1 -0
  35. package/build/cc/CRC16CC.js +109 -0
  36. package/build/cc/CRC16CC.js.map +1 -0
  37. package/build/cc/CentralSceneCC.d.ts +69 -0
  38. package/build/cc/CentralSceneCC.d.ts.map +1 -0
  39. package/build/cc/CentralSceneCC.js +443 -0
  40. package/build/cc/CentralSceneCC.js.map +1 -0
  41. package/build/cc/ClimateControlScheduleCC.d.ts +78 -0
  42. package/build/cc/ClimateControlScheduleCC.d.ts.map +1 -0
  43. package/build/cc/ClimateControlScheduleCC.js +417 -0
  44. package/build/cc/ClimateControlScheduleCC.js.map +1 -0
  45. package/build/cc/ClockCC.d.ts +40 -0
  46. package/build/cc/ClockCC.d.ts.map +1 -0
  47. package/build/cc/ClockCC.js +185 -0
  48. package/build/cc/ClockCC.js.map +1 -0
  49. package/build/cc/ColorSwitchCC.d.ts +98 -0
  50. package/build/cc/ColorSwitchCC.d.ts.map +1 -0
  51. package/build/cc/ColorSwitchCC.js +1045 -0
  52. package/build/cc/ColorSwitchCC.js.map +1 -0
  53. package/build/cc/ConfigurationCC.d.ts +315 -0
  54. package/build/cc/ConfigurationCC.d.ts.map +1 -0
  55. package/build/cc/ConfigurationCC.js +2257 -0
  56. package/build/cc/ConfigurationCC.js.map +1 -0
  57. package/build/cc/DeviceResetLocallyCC.d.ts +9 -0
  58. package/build/cc/DeviceResetLocallyCC.d.ts.map +1 -0
  59. package/build/cc/DeviceResetLocallyCC.js +28 -0
  60. package/build/cc/DeviceResetLocallyCC.js.map +1 -0
  61. package/build/cc/DoorLockCC.d.ts +116 -0
  62. package/build/cc/DoorLockCC.d.ts.map +1 -0
  63. package/build/cc/DoorLockCC.js +1112 -0
  64. package/build/cc/DoorLockCC.js.map +1 -0
  65. package/build/cc/DoorLockLoggingCC.d.ts +41 -0
  66. package/build/cc/DoorLockLoggingCC.d.ts.map +1 -0
  67. package/build/cc/DoorLockLoggingCC.js +288 -0
  68. package/build/cc/DoorLockLoggingCC.js.map +1 -0
  69. package/build/cc/EntryControlCC.d.ts +71 -0
  70. package/build/cc/EntryControlCC.d.ts.map +1 -0
  71. package/build/cc/EntryControlCC.js +492 -0
  72. package/build/cc/EntryControlCC.js.map +1 -0
  73. package/build/cc/FirmwareUpdateMetaDataCC.d.ts +148 -0
  74. package/build/cc/FirmwareUpdateMetaDataCC.d.ts.map +1 -0
  75. package/build/cc/FirmwareUpdateMetaDataCC.js +727 -0
  76. package/build/cc/FirmwareUpdateMetaDataCC.js.map +1 -0
  77. package/build/cc/HailCC.d.ts +6 -0
  78. package/build/cc/HailCC.d.ts.map +1 -0
  79. package/build/cc/HailCC.js +23 -0
  80. package/build/cc/HailCC.js.map +1 -0
  81. package/build/cc/HumidityControlModeCC.d.ts +47 -0
  82. package/build/cc/HumidityControlModeCC.d.ts.map +1 -0
  83. package/build/cc/HumidityControlModeCC.js +288 -0
  84. package/build/cc/HumidityControlModeCC.js.map +1 -0
  85. package/build/cc/HumidityControlOperatingStateCC.d.ts +24 -0
  86. package/build/cc/HumidityControlOperatingStateCC.d.ts.map +1 -0
  87. package/build/cc/HumidityControlOperatingStateCC.js +129 -0
  88. package/build/cc/HumidityControlOperatingStateCC.js.map +1 -0
  89. package/build/cc/HumidityControlSetpointCC.d.ts +103 -0
  90. package/build/cc/HumidityControlSetpointCC.d.ts.map +1 -0
  91. package/build/cc/HumidityControlSetpointCC.js +626 -0
  92. package/build/cc/HumidityControlSetpointCC.js.map +1 -0
  93. package/build/cc/IndicatorCC.d.ts +88 -0
  94. package/build/cc/IndicatorCC.d.ts.map +1 -0
  95. package/build/cc/IndicatorCC.js +758 -0
  96. package/build/cc/IndicatorCC.js.map +1 -0
  97. package/build/cc/IrrigationCC.d.ts +278 -0
  98. package/build/cc/IrrigationCC.d.ts.map +1 -0
  99. package/build/cc/IrrigationCC.js +2062 -0
  100. package/build/cc/IrrigationCC.js.map +1 -0
  101. package/build/cc/LanguageCC.d.ts +41 -0
  102. package/build/cc/LanguageCC.d.ts.map +1 -0
  103. package/build/cc/LanguageCC.js +220 -0
  104. package/build/cc/LanguageCC.js.map +1 -0
  105. package/build/cc/LockCC.d.ts +41 -0
  106. package/build/cc/LockCC.d.ts.map +1 -0
  107. package/build/cc/LockCC.js +185 -0
  108. package/build/cc/LockCC.js.map +1 -0
  109. package/build/cc/ManufacturerProprietaryCC.d.ts +31 -0
  110. package/build/cc/ManufacturerProprietaryCC.d.ts.map +1 -0
  111. package/build/cc/ManufacturerProprietaryCC.js +275 -0
  112. package/build/cc/ManufacturerProprietaryCC.js.map +1 -0
  113. package/build/cc/ManufacturerSpecificCC.d.ts +59 -0
  114. package/build/cc/ManufacturerSpecificCC.d.ts.map +1 -0
  115. package/build/cc/ManufacturerSpecificCC.js +285 -0
  116. package/build/cc/ManufacturerSpecificCC.js.map +1 -0
  117. package/build/cc/MeterCC.d.ts +100 -0
  118. package/build/cc/MeterCC.d.ts.map +1 -0
  119. package/build/cc/MeterCC.js +820 -0
  120. package/build/cc/MeterCC.js.map +1 -0
  121. package/build/cc/MultiChannelAssociationCC.d.ts +127 -0
  122. package/build/cc/MultiChannelAssociationCC.d.ts.map +1 -0
  123. package/build/cc/MultiChannelAssociationCC.js +883 -0
  124. package/build/cc/MultiChannelAssociationCC.js.map +1 -0
  125. package/build/cc/MultiChannelCC.d.ts +164 -0
  126. package/build/cc/MultiChannelCC.d.ts.map +1 -0
  127. package/build/cc/MultiChannelCC.js +1004 -0
  128. package/build/cc/MultiChannelCC.js.map +1 -0
  129. package/build/cc/MultiCommandCC.d.ts +28 -0
  130. package/build/cc/MultiCommandCC.d.ts.map +1 -0
  131. package/build/cc/MultiCommandCC.js +137 -0
  132. package/build/cc/MultiCommandCC.js.map +1 -0
  133. package/build/cc/MultilevelSensorCC.d.ts +83 -0
  134. package/build/cc/MultilevelSensorCC.d.ts.map +1 -0
  135. package/build/cc/MultilevelSensorCC.js +633 -0
  136. package/build/cc/MultilevelSensorCC.js.map +1 -0
  137. package/build/cc/MultilevelSwitchCC.d.ts +86 -0
  138. package/build/cc/MultilevelSwitchCC.d.ts.map +1 -0
  139. package/build/cc/MultilevelSwitchCC.js +774 -0
  140. package/build/cc/MultilevelSwitchCC.js.map +1 -0
  141. package/build/cc/NoOperationCC.d.ts +17 -0
  142. package/build/cc/NoOperationCC.d.ts.map +1 -0
  143. package/build/cc/NoOperationCC.js +50 -0
  144. package/build/cc/NoOperationCC.js.map +1 -0
  145. package/build/cc/NodeNamingCC.d.ts +57 -0
  146. package/build/cc/NodeNamingCC.d.ts.map +1 -0
  147. package/build/cc/NodeNamingCC.js +313 -0
  148. package/build/cc/NodeNamingCC.js.map +1 -0
  149. package/build/cc/NotificationCC.d.ts +127 -0
  150. package/build/cc/NotificationCC.d.ts.map +1 -0
  151. package/build/cc/NotificationCC.js +1193 -0
  152. package/build/cc/NotificationCC.js.map +1 -0
  153. package/build/cc/PowerlevelCC.d.ts +63 -0
  154. package/build/cc/PowerlevelCC.d.ts.map +1 -0
  155. package/build/cc/PowerlevelCC.js +262 -0
  156. package/build/cc/PowerlevelCC.js.map +1 -0
  157. package/build/cc/ProtectionCC.d.ts +94 -0
  158. package/build/cc/ProtectionCC.d.ts.map +1 -0
  159. package/build/cc/ProtectionCC.js +630 -0
  160. package/build/cc/ProtectionCC.js.map +1 -0
  161. package/build/cc/SceneActivationCC.d.ts +34 -0
  162. package/build/cc/SceneActivationCC.d.ts.map +1 -0
  163. package/build/cc/SceneActivationCC.js +170 -0
  164. package/build/cc/SceneActivationCC.js.map +1 -0
  165. package/build/cc/SceneActuatorConfigurationCC.d.ts +52 -0
  166. package/build/cc/SceneActuatorConfigurationCC.d.ts.map +1 -0
  167. package/build/cc/SceneActuatorConfigurationCC.js +368 -0
  168. package/build/cc/SceneActuatorConfigurationCC.js.map +1 -0
  169. package/build/cc/SceneControllerConfigurationCC.d.ts +61 -0
  170. package/build/cc/SceneControllerConfigurationCC.d.ts.map +1 -0
  171. package/build/cc/SceneControllerConfigurationCC.js +444 -0
  172. package/build/cc/SceneControllerConfigurationCC.js.map +1 -0
  173. package/build/cc/Security2CC.d.ts +213 -0
  174. package/build/cc/Security2CC.d.ts.map +1 -0
  175. package/build/cc/Security2CC.js +1124 -0
  176. package/build/cc/Security2CC.js.map +1 -0
  177. package/build/cc/SecurityCC.d.ts +109 -0
  178. package/build/cc/SecurityCC.d.ts.map +1 -0
  179. package/build/cc/SecurityCC.js +609 -0
  180. package/build/cc/SecurityCC.js.map +1 -0
  181. package/build/cc/SoundSwitchCC.d.ts +87 -0
  182. package/build/cc/SoundSwitchCC.d.ts.map +1 -0
  183. package/build/cc/SoundSwitchCC.js +548 -0
  184. package/build/cc/SoundSwitchCC.js.map +1 -0
  185. package/build/cc/SupervisionCC.d.ts +63 -0
  186. package/build/cc/SupervisionCC.d.ts.map +1 -0
  187. package/build/cc/SupervisionCC.js +239 -0
  188. package/build/cc/SupervisionCC.js.map +1 -0
  189. package/build/cc/ThermostatFanModeCC.d.ts +53 -0
  190. package/build/cc/ThermostatFanModeCC.d.ts.map +1 -0
  191. package/build/cc/ThermostatFanModeCC.js +359 -0
  192. package/build/cc/ThermostatFanModeCC.js.map +1 -0
  193. package/build/cc/ThermostatFanStateCC.d.ts +24 -0
  194. package/build/cc/ThermostatFanStateCC.d.ts.map +1 -0
  195. package/build/cc/ThermostatFanStateCC.js +131 -0
  196. package/build/cc/ThermostatFanStateCC.js.map +1 -0
  197. package/build/cc/ThermostatModeCC.d.ts +58 -0
  198. package/build/cc/ThermostatModeCC.d.ts.map +1 -0
  199. package/build/cc/ThermostatModeCC.js +370 -0
  200. package/build/cc/ThermostatModeCC.js.map +1 -0
  201. package/build/cc/ThermostatOperatingStateCC.d.ts +24 -0
  202. package/build/cc/ThermostatOperatingStateCC.d.ts.map +1 -0
  203. package/build/cc/ThermostatOperatingStateCC.js +127 -0
  204. package/build/cc/ThermostatOperatingStateCC.js.map +1 -0
  205. package/build/cc/ThermostatSetbackCC.d.ts +42 -0
  206. package/build/cc/ThermostatSetbackCC.d.ts.map +1 -0
  207. package/build/cc/ThermostatSetbackCC.js +237 -0
  208. package/build/cc/ThermostatSetbackCC.js.map +1 -0
  209. package/build/cc/ThermostatSetpointCC.d.ts +98 -0
  210. package/build/cc/ThermostatSetpointCC.d.ts.map +1 -0
  211. package/build/cc/ThermostatSetpointCC.js +707 -0
  212. package/build/cc/ThermostatSetpointCC.js.map +1 -0
  213. package/build/cc/TimeCC.d.ts +78 -0
  214. package/build/cc/TimeCC.d.ts.map +1 -0
  215. package/build/cc/TimeCC.js +373 -0
  216. package/build/cc/TimeCC.js.map +1 -0
  217. package/build/cc/TimeParametersCC.d.ts +40 -0
  218. package/build/cc/TimeParametersCC.d.ts.map +1 -0
  219. package/build/cc/TimeParametersCC.js +275 -0
  220. package/build/cc/TimeParametersCC.js.map +1 -0
  221. package/build/cc/TransportServiceCC.d.ts +101 -0
  222. package/build/cc/TransportServiceCC.d.ts.map +1 -0
  223. package/build/cc/TransportServiceCC.js +404 -0
  224. package/build/cc/TransportServiceCC.js.map +1 -0
  225. package/build/cc/UserCodeCC.d.ts +219 -0
  226. package/build/cc/UserCodeCC.d.ts.map +1 -0
  227. package/build/cc/UserCodeCC.js +1526 -0
  228. package/build/cc/UserCodeCC.js.map +1 -0
  229. package/build/cc/VersionCC.d.ts +91 -0
  230. package/build/cc/VersionCC.d.ts.map +1 -0
  231. package/build/cc/VersionCC.js +654 -0
  232. package/build/cc/VersionCC.js.map +1 -0
  233. package/build/cc/WakeUpCC.d.ts +67 -0
  234. package/build/cc/WakeUpCC.d.ts.map +1 -0
  235. package/build/cc/WakeUpCC.js +425 -0
  236. package/build/cc/WakeUpCC.js.map +1 -0
  237. package/build/cc/ZWavePlusCC.d.ts +40 -0
  238. package/build/cc/ZWavePlusCC.d.ts.map +1 -0
  239. package/build/cc/ZWavePlusCC.js +269 -0
  240. package/build/cc/ZWavePlusCC.js.map +1 -0
  241. package/build/cc/index.d.ts +64 -0
  242. package/build/cc/index.d.ts.map +1 -0
  243. package/build/cc/index.js +496 -0
  244. package/build/cc/index.js.map +1 -0
  245. package/build/cc/manufacturerProprietary/FibaroCC.d.ts +62 -0
  246. package/build/cc/manufacturerProprietary/FibaroCC.d.ts.map +1 -0
  247. package/build/cc/manufacturerProprietary/FibaroCC.js +247 -0
  248. package/build/cc/manufacturerProprietary/FibaroCC.js.map +1 -0
  249. package/build/index.d.ts +11 -0
  250. package/build/index.d.ts.map +1 -0
  251. package/build/index.js +48 -0
  252. package/build/index.js.map +1 -0
  253. package/build/index_safe.d.ts +4 -0
  254. package/build/index_safe.d.ts.map +1 -0
  255. package/build/index_safe.js +30 -0
  256. package/build/index_safe.js.map +1 -0
  257. package/build/lib/API.d.ts +176 -0
  258. package/build/lib/API.d.ts.map +1 -0
  259. package/build/lib/API.js +325 -0
  260. package/build/lib/API.js.map +1 -0
  261. package/build/lib/CommandClass.d.ts +341 -0
  262. package/build/lib/CommandClass.d.ts.map +1 -0
  263. package/build/lib/CommandClass.js +1088 -0
  264. package/build/lib/CommandClass.js.map +1 -0
  265. package/build/lib/EncapsulatingCommandClass.d.ts +35 -0
  266. package/build/lib/EncapsulatingCommandClass.d.ts.map +1 -0
  267. package/build/lib/EncapsulatingCommandClass.js +53 -0
  268. package/build/lib/EncapsulatingCommandClass.js.map +1 -0
  269. package/build/lib/ICommandClassContainer.d.ts +9 -0
  270. package/build/lib/ICommandClassContainer.d.ts.map +1 -0
  271. package/build/lib/ICommandClassContainer.js +12 -0
  272. package/build/lib/ICommandClassContainer.js.map +1 -0
  273. package/build/lib/NotificationEventPayload.d.ts +11 -0
  274. package/build/lib/NotificationEventPayload.d.ts.map +1 -0
  275. package/build/lib/NotificationEventPayload.js +11 -0
  276. package/build/lib/NotificationEventPayload.js.map +1 -0
  277. package/build/lib/Security2/Extension.d.ts +87 -0
  278. package/build/lib/Security2/Extension.d.ts.map +1 -0
  279. package/build/lib/Security2/Extension.js +235 -0
  280. package/build/lib/Security2/Extension.js.map +1 -0
  281. package/build/lib/Security2/shared.d.ts +31 -0
  282. package/build/lib/Security2/shared.d.ts.map +1 -0
  283. package/build/lib/Security2/shared.js +37 -0
  284. package/build/lib/Security2/shared.js.map +1 -0
  285. package/build/lib/_Types.d.ts +1446 -0
  286. package/build/lib/_Types.d.ts.map +1 -0
  287. package/build/lib/_Types.js +1334 -0
  288. package/build/lib/_Types.js.map +1 -0
  289. package/build/lib/serializers.d.ts +24 -0
  290. package/build/lib/serializers.d.ts.map +1 -0
  291. package/build/lib/serializers.js +66 -0
  292. package/build/lib/serializers.js.map +1 -0
  293. package/build/lib/utils.d.ts +13 -0
  294. package/build/lib/utils.d.ts.map +1 -0
  295. package/build/lib/utils.js +675 -0
  296. package/build/lib/utils.js.map +1 -0
  297. package/package.json +77 -0
@@ -0,0 +1,2257 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
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
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var _a, _b;
9
+ Object.defineProperty(exports, "__esModule", { value: true });
10
+ exports.ConfigurationCCDefaultReset = exports.ConfigurationCCPropertiesGet = exports.ConfigurationCCPropertiesReport = exports.ConfigurationCCInfoGet = exports.ConfigurationCCInfoReport = exports.ConfigurationCCNameGet = exports.ConfigurationCCNameReport = exports.ConfigurationCCBulkGet = exports.ConfigurationCCBulkReport = exports.ConfigurationCCBulkSet = exports.ConfigurationCCSet = exports.ConfigurationCCGet = exports.ConfigurationCCReport = exports.ConfigurationCC = exports.ConfigurationCCAPI = exports.getParamInformationValueID = exports.ConfigurationCCError = void 0;
11
+ function __assertType(argName, typeName, boundHasError) {
12
+ const { ZWaveError, ZWaveErrorCodes } = require("@zwave-js/core");
13
+ if (boundHasError()) {
14
+ throw new ZWaveError(typeName ? `${argName} is not a ${typeName}` : `${argName} has the wrong type`, ZWaveErrorCodes.Argument_Invalid);
15
+ }
16
+ }
17
+ const __assertType__number = $o => {
18
+ function _number($o) {
19
+ return typeof $o !== "number" ? {} : null;
20
+ }
21
+ return _number($o);
22
+ };
23
+ const __assertType__optional__0 = $o => {
24
+ function _number($o) {
25
+ return typeof $o !== "number" ? {} : null;
26
+ }
27
+ function _boolean($o) {
28
+ return typeof $o !== "boolean" ? {} : null;
29
+ }
30
+ function _0($o) {
31
+ if (typeof $o !== "object" || $o === null || Array.isArray($o))
32
+ return {};
33
+ if ("valueBitMask" in $o && $o["valueBitMask"] !== undefined) {
34
+ const error = _number($o["valueBitMask"]);
35
+ if (error)
36
+ return error;
37
+ }
38
+ if ("allowUnexpectedResponse" in $o && $o["allowUnexpectedResponse"] !== undefined) {
39
+ const error = _boolean($o["allowUnexpectedResponse"]);
40
+ if (error)
41
+ return error;
42
+ }
43
+ return null;
44
+ }
45
+ function optional__0($o) {
46
+ if ($o !== undefined) {
47
+ const error = _0($o);
48
+ if (error)
49
+ return error;
50
+ }
51
+ return null;
52
+ }
53
+ return optional__0($o);
54
+ };
55
+ const __assertType__sa__2_ea_2 = $o => {
56
+ function _number($o) {
57
+ return typeof $o !== "number" ? {} : null;
58
+ }
59
+ function _2($o) {
60
+ if (typeof $o !== "object" || $o === null || Array.isArray($o))
61
+ return {};
62
+ if ("parameter" in $o && $o["parameter"] !== undefined) {
63
+ const error = _number($o["parameter"]);
64
+ if (error)
65
+ return error;
66
+ }
67
+ else
68
+ return {};
69
+ if ("bitMask" in $o && $o["bitMask"] !== undefined) {
70
+ const error = _number($o["bitMask"]);
71
+ if (error)
72
+ return error;
73
+ }
74
+ return null;
75
+ }
76
+ function sa__2_ea_2($o) {
77
+ if (!Array.isArray($o))
78
+ return {};
79
+ for (let i = 0; i < $o.length; i++) {
80
+ const error = _2($o[i]);
81
+ if (error)
82
+ return error;
83
+ }
84
+ return null;
85
+ }
86
+ return sa__2_ea_2($o);
87
+ };
88
+ const __assertType__su_st__number_su__number__8_4_4_4_eu_su__11__12__13_eu_su__undefined__17__18__19__20_eu_et_4_6_10_15_4_6_10_15_4_6_10_15_st_su_si__26__27_ei_si__26__29_ei_si__26__31_ei_eu_et_24_24_24_eu = $o => {
89
+ function _number($o) {
90
+ return typeof $o !== "number" ? {} : null;
91
+ }
92
+ function _undefined($o) {
93
+ return $o !== undefined ? {} : null;
94
+ }
95
+ function _ignore() {
96
+ return null;
97
+ }
98
+ function su__number__8_4_4_4_eu($o) {
99
+ const conditions = [_number, _ignore];
100
+ for (const condition of conditions) {
101
+ const error = condition($o);
102
+ if (!error)
103
+ return null;
104
+ }
105
+ return {};
106
+ }
107
+ function _11($o) {
108
+ return $o !== 2 ? {} : null;
109
+ }
110
+ function _12($o) {
111
+ return $o !== 1 ? {} : null;
112
+ }
113
+ function _13($o) {
114
+ return $o !== 4 ? {} : null;
115
+ }
116
+ function su__11__12__13_eu($o) {
117
+ const conditions = [_11, _12, _13];
118
+ for (const condition of conditions) {
119
+ const error = condition($o);
120
+ if (!error)
121
+ return null;
122
+ }
123
+ return {};
124
+ }
125
+ function _17($o) {
126
+ return $o !== 0 ? {} : null;
127
+ }
128
+ function _18($o) {
129
+ return $o !== 1 ? {} : null;
130
+ }
131
+ function _19($o) {
132
+ return $o !== 2 ? {} : null;
133
+ }
134
+ function _20($o) {
135
+ return $o !== 3 ? {} : null;
136
+ }
137
+ function su__undefined__17__18__19__20_eu($o) {
138
+ const conditions = [_undefined, _17, _18, _19, _20];
139
+ for (const condition of conditions) {
140
+ const error = condition($o);
141
+ if (!error)
142
+ return null;
143
+ }
144
+ return {};
145
+ }
146
+ function st__number_su__number__8_4_4_4_eu_su__11__12__13_eu_su__undefined__17__18__19__20_eu_et_4_6_10_15($o) {
147
+ if (!Array.isArray($o) || $o.length < 3 || 4 < $o.length)
148
+ return {};
149
+ {
150
+ const error = _number($o[0]);
151
+ if (error)
152
+ return error;
153
+ }
154
+ {
155
+ const error = su__number__8_4_4_4_eu($o[1]);
156
+ if (error)
157
+ return error;
158
+ }
159
+ {
160
+ const error = su__11__12__13_eu($o[2]);
161
+ if (error)
162
+ return error;
163
+ }
164
+ {
165
+ const error = su__undefined__17__18__19__20_eu($o[3]);
166
+ if (error)
167
+ return error;
168
+ }
169
+ return null;
170
+ }
171
+ function _26($o) {
172
+ if (typeof $o !== "object" || $o === null || Array.isArray($o))
173
+ return {};
174
+ if ("parameter" in $o && $o["parameter"] !== undefined) {
175
+ const error = _number($o["parameter"]);
176
+ if (error)
177
+ return error;
178
+ }
179
+ else
180
+ return {};
181
+ return null;
182
+ }
183
+ function _27($o) {
184
+ if (typeof $o !== "object" || $o === null || Array.isArray($o))
185
+ return {};
186
+ if ("bitMask" in $o && $o["bitMask"] !== undefined) {
187
+ const error = _undefined($o["bitMask"]);
188
+ if (error)
189
+ return error;
190
+ }
191
+ if ("value" in $o && $o["value"] !== undefined) {
192
+ const error = su__number__8_4_4_4_eu($o["value"]);
193
+ if (error)
194
+ return error;
195
+ }
196
+ else
197
+ return {};
198
+ return null;
199
+ }
200
+ function si__26__27_ei($o) {
201
+ const conditions = [_26, _27];
202
+ for (const condition of conditions) {
203
+ const error = condition($o);
204
+ if (error)
205
+ return error;
206
+ }
207
+ return null;
208
+ }
209
+ function su__17__18__19__20_eu($o) {
210
+ return ![0, 1, 2, 3].includes($o) ? {} : null;
211
+ }
212
+ function _29($o) {
213
+ if (typeof $o !== "object" || $o === null || Array.isArray($o))
214
+ return {};
215
+ if ("bitMask" in $o && $o["bitMask"] !== undefined) {
216
+ const error = _undefined($o["bitMask"]);
217
+ if (error)
218
+ return error;
219
+ }
220
+ if ("value" in $o && $o["value"] !== undefined) {
221
+ const error = su__number__8_4_4_4_eu($o["value"]);
222
+ if (error)
223
+ return error;
224
+ }
225
+ else
226
+ return {};
227
+ if ("valueSize" in $o && $o["valueSize"] !== undefined) {
228
+ const error = su__11__12__13_eu($o["valueSize"]);
229
+ if (error)
230
+ return error;
231
+ }
232
+ else
233
+ return {};
234
+ if ("valueFormat" in $o && $o["valueFormat"] !== undefined) {
235
+ const error = su__17__18__19__20_eu($o["valueFormat"]);
236
+ if (error)
237
+ return error;
238
+ }
239
+ else
240
+ return {};
241
+ return null;
242
+ }
243
+ function si__26__29_ei($o) {
244
+ const conditions = [_26, _29];
245
+ for (const condition of conditions) {
246
+ const error = condition($o);
247
+ if (error)
248
+ return error;
249
+ }
250
+ return null;
251
+ }
252
+ function _31($o) {
253
+ if (typeof $o !== "object" || $o === null || Array.isArray($o))
254
+ return {};
255
+ if ("bitMask" in $o && $o["bitMask"] !== undefined) {
256
+ const error = _number($o["bitMask"]);
257
+ if (error)
258
+ return error;
259
+ }
260
+ else
261
+ return {};
262
+ if ("value" in $o && $o["value"] !== undefined) {
263
+ const error = _number($o["value"]);
264
+ if (error)
265
+ return error;
266
+ }
267
+ else
268
+ return {};
269
+ return null;
270
+ }
271
+ function si__26__31_ei($o) {
272
+ const conditions = [_26, _31];
273
+ for (const condition of conditions) {
274
+ const error = condition($o);
275
+ if (error)
276
+ return error;
277
+ }
278
+ return null;
279
+ }
280
+ function su_si__26__27_ei_si__26__29_ei_si__26__31_ei_eu($o) {
281
+ const conditions = [si__26__27_ei, si__26__29_ei, si__26__31_ei];
282
+ for (const condition of conditions) {
283
+ const error = condition($o);
284
+ if (!error)
285
+ return null;
286
+ }
287
+ return {};
288
+ }
289
+ function st_su_si__26__27_ei_si__26__29_ei_si__26__31_ei_eu_et_24($o) {
290
+ if (!Array.isArray($o) || $o.length < 1 || 1 < $o.length)
291
+ return {};
292
+ {
293
+ const error = su_si__26__27_ei_si__26__29_ei_si__26__31_ei_eu($o[0]);
294
+ if (error)
295
+ return error;
296
+ }
297
+ return null;
298
+ }
299
+ function su_st__number_su__number__8_4_4_4_eu_su__11__12__13_eu_su__undefined__17__18__19__20_eu_et_4_6_10_15_4_6_10_15_4_6_10_15_st_su_si__26__27_ei_si__26__29_ei_si__26__31_ei_eu_et_24_24_24_eu($o) {
300
+ const conditions = [st__number_su__number__8_4_4_4_eu_su__11__12__13_eu_su__undefined__17__18__19__20_eu_et_4_6_10_15, st_su_si__26__27_ei_si__26__29_ei_si__26__31_ei_eu_et_24];
301
+ for (const condition of conditions) {
302
+ const error = condition($o);
303
+ if (!error)
304
+ return null;
305
+ }
306
+ return {};
307
+ }
308
+ return su_st__number_su__number__8_4_4_4_eu_su__11__12__13_eu_su__undefined__17__18__19__20_eu_et_4_6_10_15_4_6_10_15_4_6_10_15_st_su_si__26__27_ei_si__26__29_ei_si__26__31_ei_eu_et_24_24_24_eu($o);
309
+ };
310
+ const __assertType__sa_su_si__4__5_ei_si__4__7_ei_si__4__9_ei_eu_ea_2 = $o => {
311
+ function _number($o) {
312
+ return typeof $o !== "number" ? {} : null;
313
+ }
314
+ function _4($o) {
315
+ if (typeof $o !== "object" || $o === null || Array.isArray($o))
316
+ return {};
317
+ if ("parameter" in $o && $o["parameter"] !== undefined) {
318
+ const error = _number($o["parameter"]);
319
+ if (error)
320
+ return error;
321
+ }
322
+ else
323
+ return {};
324
+ return null;
325
+ }
326
+ function _undefined($o) {
327
+ return $o !== undefined ? {} : null;
328
+ }
329
+ function _ignore() {
330
+ return null;
331
+ }
332
+ function su__number__13_11_11_11_eu($o) {
333
+ const conditions = [_number, _ignore];
334
+ for (const condition of conditions) {
335
+ const error = condition($o);
336
+ if (!error)
337
+ return null;
338
+ }
339
+ return {};
340
+ }
341
+ function _5($o) {
342
+ if (typeof $o !== "object" || $o === null || Array.isArray($o))
343
+ return {};
344
+ if ("bitMask" in $o && $o["bitMask"] !== undefined) {
345
+ const error = _undefined($o["bitMask"]);
346
+ if (error)
347
+ return error;
348
+ }
349
+ if ("value" in $o && $o["value"] !== undefined) {
350
+ const error = su__number__13_11_11_11_eu($o["value"]);
351
+ if (error)
352
+ return error;
353
+ }
354
+ else
355
+ return {};
356
+ return null;
357
+ }
358
+ function si__4__5_ei($o) {
359
+ const conditions = [_4, _5];
360
+ for (const condition of conditions) {
361
+ const error = condition($o);
362
+ if (error)
363
+ return error;
364
+ }
365
+ return null;
366
+ }
367
+ function _15($o) {
368
+ return $o !== 2 ? {} : null;
369
+ }
370
+ function _16($o) {
371
+ return $o !== 1 ? {} : null;
372
+ }
373
+ function _17($o) {
374
+ return $o !== 4 ? {} : null;
375
+ }
376
+ function su__15__16__17_eu($o) {
377
+ const conditions = [_15, _16, _17];
378
+ for (const condition of conditions) {
379
+ const error = condition($o);
380
+ if (!error)
381
+ return null;
382
+ }
383
+ return {};
384
+ }
385
+ function su__19__20__21__22_eu($o) {
386
+ return ![0, 1, 2, 3].includes($o) ? {} : null;
387
+ }
388
+ function _7($o) {
389
+ if (typeof $o !== "object" || $o === null || Array.isArray($o))
390
+ return {};
391
+ if ("bitMask" in $o && $o["bitMask"] !== undefined) {
392
+ const error = _undefined($o["bitMask"]);
393
+ if (error)
394
+ return error;
395
+ }
396
+ if ("value" in $o && $o["value"] !== undefined) {
397
+ const error = su__number__13_11_11_11_eu($o["value"]);
398
+ if (error)
399
+ return error;
400
+ }
401
+ else
402
+ return {};
403
+ if ("valueSize" in $o && $o["valueSize"] !== undefined) {
404
+ const error = su__15__16__17_eu($o["valueSize"]);
405
+ if (error)
406
+ return error;
407
+ }
408
+ else
409
+ return {};
410
+ if ("valueFormat" in $o && $o["valueFormat"] !== undefined) {
411
+ const error = su__19__20__21__22_eu($o["valueFormat"]);
412
+ if (error)
413
+ return error;
414
+ }
415
+ else
416
+ return {};
417
+ return null;
418
+ }
419
+ function si__4__7_ei($o) {
420
+ const conditions = [_4, _7];
421
+ for (const condition of conditions) {
422
+ const error = condition($o);
423
+ if (error)
424
+ return error;
425
+ }
426
+ return null;
427
+ }
428
+ function _9($o) {
429
+ if (typeof $o !== "object" || $o === null || Array.isArray($o))
430
+ return {};
431
+ if ("bitMask" in $o && $o["bitMask"] !== undefined) {
432
+ const error = _number($o["bitMask"]);
433
+ if (error)
434
+ return error;
435
+ }
436
+ else
437
+ return {};
438
+ if ("value" in $o && $o["value"] !== undefined) {
439
+ const error = _number($o["value"]);
440
+ if (error)
441
+ return error;
442
+ }
443
+ else
444
+ return {};
445
+ return null;
446
+ }
447
+ function si__4__9_ei($o) {
448
+ const conditions = [_4, _9];
449
+ for (const condition of conditions) {
450
+ const error = condition($o);
451
+ if (error)
452
+ return error;
453
+ }
454
+ return null;
455
+ }
456
+ function su_si__4__5_ei_si__4__7_ei_si__4__9_ei_eu($o) {
457
+ const conditions = [si__4__5_ei, si__4__7_ei, si__4__9_ei];
458
+ for (const condition of conditions) {
459
+ const error = condition($o);
460
+ if (!error)
461
+ return null;
462
+ }
463
+ return {};
464
+ }
465
+ function sa_su_si__4__5_ei_si__4__7_ei_si__4__9_ei_eu_ea_2($o) {
466
+ if (!Array.isArray($o))
467
+ return {};
468
+ for (let i = 0; i < $o.length; i++) {
469
+ const error = su_si__4__5_ei_si__4__7_ei_si__4__9_ei_eu($o[i]);
470
+ if (error)
471
+ return error;
472
+ }
473
+ return null;
474
+ }
475
+ return sa_su_si__4__5_ei_si__4__7_ei_si__4__9_ei_eu_ea_2($o);
476
+ };
477
+ const __assertType__sa__number_ea_2 = $o => {
478
+ function _number($o) {
479
+ return typeof $o !== "number" ? {} : null;
480
+ }
481
+ function sa__number_ea_2($o) {
482
+ if (!Array.isArray($o))
483
+ return {};
484
+ for (let i = 0; i < $o.length; i++) {
485
+ const error = _number($o[i]);
486
+ if (error)
487
+ return error;
488
+ }
489
+ return null;
490
+ }
491
+ return sa__number_ea_2($o);
492
+ };
493
+ const safe_1 = require("@zwave-js/core/safe");
494
+ const safe_2 = require("@zwave-js/shared/safe");
495
+ const arrays_1 = require("alcalzone-shared/arrays");
496
+ const objects_1 = require("alcalzone-shared/objects");
497
+ const strings_1 = require("alcalzone-shared/strings");
498
+ const API_1 = require("../lib/API");
499
+ const CommandClass_1 = require("../lib/CommandClass");
500
+ const _Types_1 = require("../lib/_Types");
501
+ function configValueToString(value) {
502
+ if (typeof value === "number")
503
+ return value.toString();
504
+ else
505
+ return [...value].join(", ");
506
+ }
507
+ class ConfigurationCCError extends safe_1.ZWaveError {
508
+ constructor(message, code, argument) {
509
+ super(message, code);
510
+ this.message = message;
511
+ this.code = code;
512
+ this.argument = argument;
513
+ // We need to set the prototype explicitly
514
+ Object.setPrototypeOf(this, ConfigurationCCError.prototype);
515
+ }
516
+ }
517
+ exports.ConfigurationCCError = ConfigurationCCError;
518
+ function getParamInformationValueID(parameter, bitMask) {
519
+ return {
520
+ commandClass: safe_1.CommandClasses.Configuration,
521
+ property: parameter,
522
+ propertyKey: bitMask,
523
+ };
524
+ }
525
+ exports.getParamInformationValueID = getParamInformationValueID;
526
+ const isParamInfoFromConfigValueId = {
527
+ commandClass: safe_1.CommandClasses.Configuration,
528
+ property: "isParamInformationFromConfig",
529
+ };
530
+ function createConfigurationCCInstance(applHost, endpoint) {
531
+ return CommandClass_1.CommandClass.createInstanceUnchecked(applHost, endpoint.virtual ? endpoint.node.physicalNodes[0] : endpoint, ConfigurationCC);
532
+ }
533
+ function normalizeConfigurationCCAPISetOptions(applHost, endpoint, options) {
534
+ if ("bitMask" in options && options.bitMask) {
535
+ // Variant 3: Partial param, look it up in the device config
536
+ const ccc = createConfigurationCCInstance(applHost, endpoint);
537
+ const paramInfo = ccc.getParamInformation(applHost, options.parameter, options.bitMask);
538
+ if (!paramInfo.isFromConfig) {
539
+ throw new safe_1.ZWaveError("Setting a partial configuration parameter requires it to be defined in a device config file!", safe_1.ZWaveErrorCodes.Argument_Invalid);
540
+ }
541
+ return {
542
+ parameter: options.parameter,
543
+ bitMask: options.bitMask,
544
+ value: options.value,
545
+ valueSize: paramInfo.valueSize,
546
+ valueFormat: paramInfo.format,
547
+ };
548
+ }
549
+ else if ("valueSize" in options) {
550
+ // Variant 2: Normal parameter, not defined in a config file
551
+ return (0, safe_2.pick)(options, [
552
+ "parameter",
553
+ "value",
554
+ "valueSize",
555
+ "valueFormat",
556
+ ]);
557
+ }
558
+ else {
559
+ // Variant 1: Normal parameter, defined in a config file
560
+ const ccc = createConfigurationCCInstance(applHost, endpoint);
561
+ const paramInfo = ccc.getParamInformation(applHost, options.parameter, options.bitMask);
562
+ if (!paramInfo.isFromConfig) {
563
+ throw new safe_1.ZWaveError("Setting a configuration parameter without specifying a value size and format requires it to be defined in a device config file!", safe_1.ZWaveErrorCodes.Argument_Invalid);
564
+ }
565
+ return {
566
+ parameter: options.parameter,
567
+ value: options.value,
568
+ valueSize: paramInfo.valueSize,
569
+ valueFormat: paramInfo.format,
570
+ };
571
+ }
572
+ }
573
+ function bulkMergePartialParamValues(applHost, endpoint, options) {
574
+ // Merge partial parameters before doing anything else. Therefore, take the non-partials, ...
575
+ const allParams = options.filter((o) => o.bitMask == undefined);
576
+ // ... group the partials by parameter
577
+ const unmergedPartials = new Map();
578
+ for (const partial of options.filter((o) => o.bitMask != undefined)) {
579
+ if (!unmergedPartials.has(partial.parameter)) {
580
+ unmergedPartials.set(partial.parameter, []);
581
+ }
582
+ unmergedPartials.get(partial.parameter).push(partial);
583
+ }
584
+ // and push the merged result into the array we'll be working with
585
+ if (unmergedPartials.size) {
586
+ const ccc = createConfigurationCCInstance(applHost, endpoint);
587
+ for (const [parameter, partials] of unmergedPartials) {
588
+ allParams.push({
589
+ parameter,
590
+ value: ccc.composePartialParamValues(applHost, parameter, partials.map((p) => ({
591
+ bitMask: p.bitMask,
592
+ partialValue: p.value,
593
+ }))),
594
+ valueSize: partials[0].valueSize,
595
+ valueFormat: partials[0].valueFormat,
596
+ });
597
+ }
598
+ }
599
+ return allParams;
600
+ }
601
+ /** Determines whether a partial parameter needs to be interpreted as signed */
602
+ function isSignedPartial(bitMask, format) {
603
+ // Only treat partial params as signed if they span more than 1 bit.
604
+ // Otherwise we cannot model 0/1 properly.
605
+ return ((0, safe_1.getBitMaskWidth)(bitMask) > 1 &&
606
+ (format !== null && format !== void 0 ? format : safe_1.ConfigValueFormat.SignedInteger) ===
607
+ safe_1.ConfigValueFormat.SignedInteger);
608
+ }
609
+ function reInterpretSignedValue(value, valueSize, targetFormat) {
610
+ // Re-interpret the value with the new format
611
+ const raw = Buffer.allocUnsafe(valueSize);
612
+ serializeValue(raw, 0, valueSize, safe_1.ConfigValueFormat.SignedInteger, value);
613
+ return parseValue(raw, valueSize, targetFormat);
614
+ }
615
+ let ConfigurationCCAPI = class ConfigurationCCAPI extends API_1.CCAPI {
616
+ constructor() {
617
+ super(...arguments);
618
+ this[_a] = async ({ property, propertyKey }, value) => {
619
+ // Config parameters are addressed with numeric properties/keys
620
+ if (typeof property !== "number") {
621
+ (0, API_1.throwUnsupportedProperty)(this.ccId, property);
622
+ }
623
+ if (propertyKey != undefined && typeof propertyKey !== "number") {
624
+ (0, API_1.throwUnsupportedPropertyKey)(this.ccId, property, propertyKey);
625
+ }
626
+ if (typeof value !== "number") {
627
+ (0, API_1.throwWrongValueType)(this.ccId, property, "number", typeof value);
628
+ }
629
+ let ccInstance;
630
+ const applHost = this.applHost;
631
+ if (this.isSinglecast()) {
632
+ ccInstance = createConfigurationCCInstance(this.applHost, this.endpoint);
633
+ }
634
+ else if (this.isMulticast()) {
635
+ // Multicast is only possible if the parameter definition is the same on all target nodes
636
+ const nodes = this.endpoint.node.physicalNodes;
637
+ if (!nodes.every((node) => {
638
+ var _c;
639
+ return (_c = node
640
+ .getEndpoint(this.endpoint.index)) === null || _c === void 0 ? void 0 : _c.supportsCC(safe_1.CommandClasses.Configuration);
641
+ })) {
642
+ throw new safe_1.ZWaveError(`The multicast setValue API for Configuration CC requires all virtual target endpoints to support Configuration CC!`, safe_1.ZWaveErrorCodes.CC_Invalid);
643
+ }
644
+ // Figure out if all the relevant info is the same
645
+ const paramInfos = this.endpoint.node.physicalNodes.map((node) => createConfigurationCCInstance(this.applHost, node.getEndpoint(this.endpoint.index)).getParamInformation(this.applHost, property, propertyKey));
646
+ if (!paramInfos.length ||
647
+ !paramInfos.every((info, index) => {
648
+ if (index === 0)
649
+ return true;
650
+ return (info.valueSize === paramInfos[0].valueSize &&
651
+ info.format === paramInfos[0].format);
652
+ })) {
653
+ throw new safe_1.ZWaveError(`The multicast setValue API for Configuration CC requires all virtual target nodes to have the same parameter definition!`, safe_1.ZWaveErrorCodes.CC_Invalid);
654
+ }
655
+ // If it is, just use the first node to create the CC instance
656
+ ccInstance = createConfigurationCCInstance(this.applHost, this.endpoint);
657
+ }
658
+ else {
659
+ throw new safe_1.ZWaveError(`The setValue API for Configuration CC is not supported via broadcast!`, safe_1.ZWaveErrorCodes.CC_NotSupported);
660
+ }
661
+ let { valueSize, format: valueFormat = safe_1.ConfigValueFormat.SignedInteger, } = ccInstance.getParamInformation(applHost, property);
662
+ let targetValue;
663
+ if (propertyKey) {
664
+ // This is a partial value, we need to update some bits only
665
+ // Find out the correct value size
666
+ if (!valueSize) {
667
+ valueSize = ccInstance.getParamInformation(applHost, property, propertyKey).valueSize;
668
+ }
669
+ // Add the target value to the remaining partial values
670
+ targetValue = ccInstance.composePartialParamValue(applHost, property, propertyKey, value);
671
+ // Partial parameters are internally converted to unsigned values - update the valueFormat accordingly
672
+ valueFormat = safe_1.ConfigValueFormat.UnsignedInteger;
673
+ }
674
+ else {
675
+ targetValue = value;
676
+ }
677
+ if (!valueSize) {
678
+ // If there's no value size configured, figure out a matching value size
679
+ valueSize = (0, safe_1.getMinIntegerSize)(targetValue, valueFormat === safe_1.ConfigValueFormat.SignedInteger);
680
+ // Throw if the value is too large or too small
681
+ if (!valueSize) {
682
+ throw new safe_1.ZWaveError(`The value ${targetValue} is not valid for configuration parameters!`, safe_1.ZWaveErrorCodes.Argument_Invalid);
683
+ }
684
+ }
685
+ // Make sure that the given value fits into the value size
686
+ if (!isSafeValue(targetValue, valueSize, valueFormat)) {
687
+ // If there is a value size configured, check that the given value is compatible
688
+ throwInvalidValueError(targetValue, property, valueSize, valueFormat);
689
+ }
690
+ await this.set({
691
+ parameter: property,
692
+ value: targetValue,
693
+ valueSize: valueSize,
694
+ valueFormat,
695
+ });
696
+ if (this.isSinglecast()) {
697
+ // Verify the current value after a delay
698
+ this.schedulePoll({ property, propertyKey }, targetValue,
699
+ // Configuration changes are instant
700
+ { transition: "fast" });
701
+ }
702
+ };
703
+ this[_b] = async ({ property, propertyKey, }) => {
704
+ // Config parameters are addressed with numeric properties/keys
705
+ if (typeof property !== "number") {
706
+ (0, API_1.throwUnsupportedProperty)(this.ccId, property);
707
+ }
708
+ if (propertyKey != undefined && typeof propertyKey !== "number") {
709
+ (0, API_1.throwUnsupportedPropertyKey)(this.ccId, property, propertyKey);
710
+ }
711
+ return this.get(property, { valueBitMask: propertyKey });
712
+ };
713
+ }
714
+ supportsCommand(cmd) {
715
+ switch (cmd) {
716
+ case _Types_1.ConfigurationCommand.Get:
717
+ case _Types_1.ConfigurationCommand.Set:
718
+ return true; // This is mandatory
719
+ case _Types_1.ConfigurationCommand.BulkGet:
720
+ case _Types_1.ConfigurationCommand.BulkSet:
721
+ return this.version >= 2;
722
+ case _Types_1.ConfigurationCommand.NameGet:
723
+ case _Types_1.ConfigurationCommand.InfoGet:
724
+ case _Types_1.ConfigurationCommand.PropertiesGet:
725
+ return this.version >= 3;
726
+ case _Types_1.ConfigurationCommand.DefaultReset:
727
+ return this.version >= 4;
728
+ }
729
+ return super.supportsCommand(cmd);
730
+ }
731
+ /**
732
+ * Requests the current value of a given config parameter from the device.
733
+ * This may timeout and return `undefined` if the node does not respond.
734
+ * If the node replied with a different parameter number, a `ConfigurationCCError`
735
+ * is thrown with the `argument` property set to the reported parameter number.
736
+ */
737
+ async get(parameter, options) {
738
+ __assertType("parameter", "number", __assertType__number.bind(void 0, parameter));
739
+ __assertType("options", undefined, __assertType__optional__0.bind(void 0, options));
740
+ // Get-type commands are only possible in singlecast
741
+ this.assertPhysicalEndpoint(this.endpoint);
742
+ this.assertSupportsCommand(_Types_1.ConfigurationCommand, _Types_1.ConfigurationCommand.Get);
743
+ const { valueBitMask, allowUnexpectedResponse } = options !== null && options !== void 0 ? options : {};
744
+ const cc = new ConfigurationCCGet(this.applHost, {
745
+ nodeId: this.endpoint.nodeId,
746
+ // Don't set an endpoint here, Configuration is device specific, not endpoint specific
747
+ parameter,
748
+ allowUnexpectedResponse,
749
+ });
750
+ const response = await this.applHost.sendCommand(cc, this.commandOptions);
751
+ if (!response)
752
+ return;
753
+ // Nodes may respond with a different parameter, e.g. if we
754
+ // requested a non-existing one
755
+ if (response.parameter === parameter) {
756
+ if (!valueBitMask)
757
+ return response.value;
758
+ // If a partial parameter was requested, extract that value
759
+ const paramInfo = cc.getParamInformation(this.applHost, response.parameter, valueBitMask);
760
+ return (0, safe_1.parsePartial)(response.value, valueBitMask, isSignedPartial(valueBitMask, paramInfo.format));
761
+ }
762
+ this.applHost.controllerLog.logNode(this.endpoint.nodeId, {
763
+ message: `Received unexpected ConfigurationReport (param = ${response.parameter}, value = ${response.value.toString()})`,
764
+ direction: "inbound",
765
+ level: "error",
766
+ });
767
+ throw new ConfigurationCCError(`The first existing parameter on this node is ${response.parameter}`, safe_1.ZWaveErrorCodes.ConfigurationCC_FirstParameterNumber, response.parameter);
768
+ }
769
+ /**
770
+ * Requests the current value of the config parameters from the device.
771
+ * When the node does not respond due to a timeout, the `value` in the returned array will be `undefined`.
772
+ */
773
+ async getBulk(options) {
774
+ __assertType("options", undefined, __assertType__sa__2_ea_2.bind(void 0, options));
775
+ // Get-type commands are only possible in singlecast
776
+ this.assertPhysicalEndpoint(this.endpoint);
777
+ let values;
778
+ // If the parameters are consecutive, we may use BulkGet
779
+ const distinctParameters = (0, arrays_1.distinct)(options.map((o) => o.parameter));
780
+ if (this.supportsCommand(_Types_1.ConfigurationCommand.BulkGet) &&
781
+ (0, safe_1.isConsecutiveArray)(distinctParameters)) {
782
+ const cc = new ConfigurationCCBulkGet(this.applHost, {
783
+ nodeId: this.endpoint.nodeId,
784
+ // Don't set an endpoint here, Configuration is device specific, not endpoint specific
785
+ parameters: distinctParameters,
786
+ });
787
+ const response = await this.applHost.sendCommand(cc, this.commandOptions);
788
+ if (response)
789
+ values = response.values;
790
+ }
791
+ else {
792
+ this.assertSupportsCommand(_Types_1.ConfigurationCommand, _Types_1.ConfigurationCommand.Get);
793
+ const _values = new Map();
794
+ for (const parameter of distinctParameters) {
795
+ const cc = new ConfigurationCCGet(this.applHost, {
796
+ nodeId: this.endpoint.nodeId,
797
+ // Don't set an endpoint here, Configuration is device specific, not endpoint specific
798
+ parameter,
799
+ });
800
+ const response = await this.applHost.sendCommand(cc, this.commandOptions);
801
+ if (response) {
802
+ _values.set(response.parameter, response.value);
803
+ }
804
+ }
805
+ values = _values;
806
+ }
807
+ // Combine the returned values with the requested ones
808
+ const cc = createConfigurationCCInstance(this.applHost, this.endpoint);
809
+ return options.map((o) => {
810
+ let value = values.get(o.parameter);
811
+ if (typeof value === "number" && o.bitMask) {
812
+ const paramInfo = cc.getParamInformation(this.applHost, o.parameter, o.bitMask);
813
+ value = (0, safe_1.parsePartial)(value, o.bitMask, isSignedPartial(o.bitMask, paramInfo.format));
814
+ }
815
+ return { ...o, value };
816
+ });
817
+ }
818
+ /**
819
+ * Sets a new value for a given config parameter of the device.
820
+ */
821
+ async set(...args) {
822
+ var _c;
823
+ __assertType("args", undefined, __assertType__su_st__number_su__number__8_4_4_4_eu_su__11__12__13_eu_su__undefined__17__18__19__20_eu_et_4_6_10_15_4_6_10_15_4_6_10_15_st_su_si__26__27_ei_si__26__29_ei_si__26__31_ei_eu_et_24_24_24_eu.bind(void 0, args));
824
+ this.assertSupportsCommand(_Types_1.ConfigurationCommand, _Types_1.ConfigurationCommand.Set);
825
+ let cc;
826
+ if (args.length === 1) {
827
+ const options = normalizeConfigurationCCAPISetOptions(this.applHost, this.endpoint, args[0]);
828
+ let value = options.value;
829
+ if (options.bitMask) {
830
+ const ccc = createConfigurationCCInstance(this.applHost, this.endpoint);
831
+ value = ccc.composePartialParamValue(this.applHost, options.parameter, options.bitMask, options.value);
832
+ }
833
+ cc = new ConfigurationCCSet(this.applHost, {
834
+ nodeId: this.endpoint.nodeId,
835
+ // Don't set an endpoint here, Configuration is device specific, not endpoint specific
836
+ resetToDefault: false,
837
+ parameter: options.parameter,
838
+ value,
839
+ valueSize: options.valueSize,
840
+ valueFormat: options.valueFormat,
841
+ });
842
+ }
843
+ else {
844
+ cc = new ConfigurationCCSet(this.applHost, {
845
+ nodeId: this.endpoint.nodeId,
846
+ // Don't set an endpoint here, Configuration is device specific, not endpoint specific
847
+ resetToDefault: false,
848
+ parameter: args[0],
849
+ value: args[1],
850
+ valueSize: args[2],
851
+ valueFormat: (_c = args[3]) !== null && _c !== void 0 ? _c : safe_1.ConfigValueFormat.SignedInteger,
852
+ });
853
+ }
854
+ await this.applHost.sendCommand(cc, this.commandOptions);
855
+ }
856
+ /**
857
+ * Sets new values for multiple config parameters of the device. Uses the `BulkSet` command if supported, otherwise falls back to individual `Set` commands.
858
+ */
859
+ async setBulk(values) {
860
+ __assertType("values", undefined, __assertType__sa_su_si__4__5_ei_si__4__7_ei_si__4__9_ei_eu_ea_2.bind(void 0, values));
861
+ // Normalize the values so we can better work with them
862
+ const normalized = values.map((v) => normalizeConfigurationCCAPISetOptions(this.applHost, this.endpoint, v));
863
+ // And merge multiple partials that belong the same "full" value
864
+ const allParams = bulkMergePartialParamValues(this.applHost, this.endpoint, normalized);
865
+ const canUseBulkSet = this.supportsCommand(_Types_1.ConfigurationCommand.BulkSet) &&
866
+ // For Bulk Set we need consecutive parameters
867
+ (0, safe_1.isConsecutiveArray)(allParams.map((v) => v.parameter)) &&
868
+ // and identical format
869
+ new Set(allParams.map((v) => v.valueFormat)).size === 1 &&
870
+ // and identical size
871
+ new Set(allParams.map((v) => v.valueSize)).size === 1;
872
+ if (canUseBulkSet) {
873
+ const cc = new ConfigurationCCBulkSet(this.applHost, {
874
+ nodeId: this.endpoint.nodeId,
875
+ // Don't set an endpoint here, Configuration is device specific, not endpoint specific
876
+ parameters: allParams.map((v) => v.parameter),
877
+ valueSize: allParams[0].valueSize,
878
+ valueFormat: allParams[0].valueFormat,
879
+ values: allParams.map((v) => v.value),
880
+ handshake: true,
881
+ });
882
+ await this.applHost.sendCommand(cc, this.commandOptions);
883
+ }
884
+ else {
885
+ this.assertSupportsCommand(_Types_1.ConfigurationCommand, _Types_1.ConfigurationCommand.Set);
886
+ for (const { parameter, value, valueSize, valueFormat, } of allParams) {
887
+ const cc = new ConfigurationCCSet(this.applHost, {
888
+ nodeId: this.endpoint.nodeId,
889
+ // Don't set an endpoint here, Configuration is device specific, not endpoint specific
890
+ parameter,
891
+ value,
892
+ valueSize,
893
+ valueFormat,
894
+ });
895
+ await this.applHost.sendCommand(cc, this.commandOptions);
896
+ }
897
+ }
898
+ }
899
+ /**
900
+ * Resets a configuration parameter to its default value.
901
+ *
902
+ * WARNING: This will throw on legacy devices (ConfigurationCC v3 and below)
903
+ */
904
+ async reset(parameter) {
905
+ __assertType("parameter", "number", __assertType__number.bind(void 0, parameter));
906
+ this.assertSupportsCommand(_Types_1.ConfigurationCommand, _Types_1.ConfigurationCommand.Set);
907
+ const cc = new ConfigurationCCSet(this.applHost, {
908
+ nodeId: this.endpoint.nodeId,
909
+ // Don't set an endpoint here, Configuration is device specific, not endpoint specific
910
+ parameter,
911
+ resetToDefault: true,
912
+ });
913
+ await this.applHost.sendCommand(cc, this.commandOptions);
914
+ }
915
+ /**
916
+ * Resets multiple configuration parameters to their default value. Uses BulkSet if supported, otherwise falls back to individual Set commands.
917
+ *
918
+ * WARNING: This will throw on legacy devices (ConfigurationCC v3 and below)
919
+ */
920
+ async resetBulk(parameters) {
921
+ __assertType("parameters", undefined, __assertType__sa__number_ea_2.bind(void 0, parameters));
922
+ if ((0, safe_1.isConsecutiveArray)(parameters) &&
923
+ this.supportsCommand(_Types_1.ConfigurationCommand.BulkSet)) {
924
+ const cc = new ConfigurationCCBulkSet(this.applHost, {
925
+ nodeId: this.endpoint.nodeId,
926
+ // Don't set an endpoint here, Configuration is device specific, not endpoint specific
927
+ parameters,
928
+ resetToDefault: true,
929
+ });
930
+ await this.applHost.sendCommand(cc, this.commandOptions);
931
+ }
932
+ else {
933
+ this.assertSupportsCommand(_Types_1.ConfigurationCommand, _Types_1.ConfigurationCommand.Set);
934
+ const CCs = (0, arrays_1.distinct)(parameters).map((parameter) => new ConfigurationCCSet(this.applHost, {
935
+ nodeId: this.endpoint.nodeId,
936
+ // Don't set an endpoint here, Configuration is device specific, not endpoint specific
937
+ parameter,
938
+ resetToDefault: true,
939
+ }));
940
+ for (const cc of CCs) {
941
+ await this.applHost.sendCommand(cc, this.commandOptions);
942
+ }
943
+ }
944
+ }
945
+ /** Resets all configuration parameters to their default value */
946
+ async resetAll() {
947
+ // This is dangerous - don't allow resetting all parameters via multicast
948
+ this.assertPhysicalEndpoint(this.endpoint);
949
+ this.assertSupportsCommand(_Types_1.ConfigurationCommand, _Types_1.ConfigurationCommand.DefaultReset);
950
+ const cc = new ConfigurationCCDefaultReset(this.applHost, {
951
+ nodeId: this.endpoint.nodeId,
952
+ // Don't set an endpoint here, Configuration is device specific, not endpoint specific
953
+ });
954
+ await this.applHost.sendCommand(cc, this.commandOptions);
955
+ }
956
+ async getProperties(parameter) {
957
+ __assertType("parameter", "number", __assertType__number.bind(void 0, parameter));
958
+ // Get-type commands are only possible in singlecast
959
+ this.assertPhysicalEndpoint(this.endpoint);
960
+ const cc = new ConfigurationCCPropertiesGet(this.applHost, {
961
+ nodeId: this.endpoint.nodeId,
962
+ // Don't set an endpoint here, Configuration is device specific, not endpoint specific
963
+ parameter,
964
+ });
965
+ const response = await this.applHost.sendCommand(cc, this.commandOptions);
966
+ if (response) {
967
+ return (0, safe_2.pick)(response, [
968
+ "valueSize",
969
+ "valueFormat",
970
+ "minValue",
971
+ "maxValue",
972
+ "defaultValue",
973
+ "nextParameter",
974
+ "altersCapabilities",
975
+ "isReadonly",
976
+ "isAdvanced",
977
+ "noBulkSupport",
978
+ ]);
979
+ }
980
+ }
981
+ /** Requests the name of a configuration parameter from the node */
982
+ async getName(parameter) {
983
+ __assertType("parameter", "number", __assertType__number.bind(void 0, parameter));
984
+ // Get-type commands are only possible in singlecast
985
+ this.assertPhysicalEndpoint(this.endpoint);
986
+ const cc = new ConfigurationCCNameGet(this.applHost, {
987
+ nodeId: this.endpoint.nodeId,
988
+ // Don't set an endpoint here, Configuration is device specific, not endpoint specific
989
+ parameter,
990
+ });
991
+ const response = await this.applHost.sendCommand(cc, this.commandOptions);
992
+ return response === null || response === void 0 ? void 0 : response.name;
993
+ }
994
+ /** Requests usage info for a configuration parameter from the node */
995
+ async getInfo(parameter) {
996
+ __assertType("parameter", "number", __assertType__number.bind(void 0, parameter));
997
+ // Get-type commands are only possible in singlecast
998
+ this.assertPhysicalEndpoint(this.endpoint);
999
+ const cc = new ConfigurationCCInfoGet(this.applHost, {
1000
+ nodeId: this.endpoint.nodeId,
1001
+ // Don't set an endpoint here, Configuration is device specific, not endpoint specific
1002
+ parameter,
1003
+ });
1004
+ const response = await this.applHost.sendCommand(cc, this.commandOptions);
1005
+ return response === null || response === void 0 ? void 0 : response.info;
1006
+ }
1007
+ /**
1008
+ * This scans the node for the existing parameters. Found parameters will be reported
1009
+ * through the `value added` and `value updated` events.
1010
+ *
1011
+ * WARNING: This method throws for newer devices.
1012
+ *
1013
+ * WARNING: On nodes implementing V1 and V2, this process may take
1014
+ * **up to an hour**, depending on the configured timeout.
1015
+ *
1016
+ * WARNING: On nodes implementing V2, all parameters after 255 will be ignored.
1017
+ */
1018
+ async scanParametersLegacy() {
1019
+ if (this.version >= 3) {
1020
+ throw new safe_1.ZWaveError("Use ConfigurationCC.interview instead of scanning parameters for versions 3 and above.", safe_1.ZWaveErrorCodes.ConfigurationCC_NoLegacyScanOnNewDevices);
1021
+ }
1022
+ // Get-type commands are only possible in singlecast
1023
+ this.assertPhysicalEndpoint(this.endpoint);
1024
+ // TODO: Reduce the priority of the messages
1025
+ this.applHost.controllerLog.logNode(this.endpoint.nodeId, `Scanning available parameters...`);
1026
+ const ccInstance = createConfigurationCCInstance(this.applHost, this.endpoint);
1027
+ for (let param = 1; param <= 255; param++) {
1028
+ // Check if the parameter is readable
1029
+ let originalValue;
1030
+ this.applHost.controllerLog.logNode(this.endpoint.nodeId, {
1031
+ message: ` trying param ${param}...`,
1032
+ direction: "outbound",
1033
+ });
1034
+ try {
1035
+ originalValue = await this.get(param, {
1036
+ // When requesting a non-existing parameter, a node SHOULD respond with the
1037
+ // first available parameter. We use this for the first param only,
1038
+ // because delayed responses might otherwise confuse the interview process
1039
+ allowUnexpectedResponse: param === 1,
1040
+ });
1041
+ if (originalValue != undefined) {
1042
+ const logMessage = ` Param ${param}:
1043
+ readable = true
1044
+ valueSize = ${ccInstance.getParamInformation(this.applHost, param).valueSize}
1045
+ value = ${originalValue.toString()}`;
1046
+ this.applHost.controllerLog.logNode(this.endpoint.nodeId, {
1047
+ message: logMessage,
1048
+ direction: "inbound",
1049
+ });
1050
+ }
1051
+ }
1052
+ catch (e) {
1053
+ if (e instanceof ConfigurationCCError &&
1054
+ e.code ===
1055
+ safe_1.ZWaveErrorCodes.ConfigurationCC_FirstParameterNumber) {
1056
+ // Continue iterating with the next param
1057
+ if (e.argument - 1 > param)
1058
+ param = e.argument - 1;
1059
+ continue;
1060
+ }
1061
+ throw e;
1062
+ }
1063
+ }
1064
+ }
1065
+ };
1066
+ _a = API_1.SET_VALUE, _b = API_1.POLL_VALUE;
1067
+ ConfigurationCCAPI = __decorate([
1068
+ (0, CommandClass_1.API)(safe_1.CommandClasses.Configuration)
1069
+ ], ConfigurationCCAPI);
1070
+ exports.ConfigurationCCAPI = ConfigurationCCAPI;
1071
+ let ConfigurationCC = class ConfigurationCC extends CommandClass_1.CommandClass {
1072
+ constructor(host, options) {
1073
+ super(host, options);
1074
+ this.registerValue("isParamInformationFromConfig", {
1075
+ internal: true,
1076
+ });
1077
+ }
1078
+ async interview(applHost) {
1079
+ var _c, _d, _e, _f, _g, _h, _j, _k, _l;
1080
+ const node = this.getNode(applHost);
1081
+ const endpoint = this.getEndpoint(applHost);
1082
+ const api = API_1.CCAPI.create(safe_1.CommandClasses.Configuration, applHost, endpoint).withOptions({
1083
+ priority: safe_1.MessagePriority.NodeQuery,
1084
+ });
1085
+ applHost.controllerLog.logNode(node.id, {
1086
+ endpoint: this.endpointIndex,
1087
+ message: `Interviewing ${this.ccName}...`,
1088
+ direction: "none",
1089
+ });
1090
+ const deviceConfig = (_c = applHost.getDeviceConfig) === null || _c === void 0 ? void 0 : _c.call(applHost, node.id);
1091
+ const paramInfo = deviceConfig === null || deviceConfig === void 0 ? void 0 : deviceConfig.paramInformation;
1092
+ if (paramInfo) {
1093
+ applHost.controllerLog.logNode(node.id, {
1094
+ endpoint: this.endpointIndex,
1095
+ message: `${this.constructor.name}: Loading configuration parameters from device config`,
1096
+ direction: "none",
1097
+ });
1098
+ this.deserializeParamInformationFromConfig(applHost, paramInfo);
1099
+ }
1100
+ if (this.version >= 3) {
1101
+ applHost.controllerLog.logNode(node.id, {
1102
+ endpoint: this.endpointIndex,
1103
+ message: "finding first configuration parameter...",
1104
+ direction: "outbound",
1105
+ });
1106
+ const param0props = await api.getProperties(0);
1107
+ let param;
1108
+ if (param0props) {
1109
+ param = param0props.nextParameter;
1110
+ if (param === 0) {
1111
+ applHost.controllerLog.logNode(node.id, {
1112
+ endpoint: this.endpointIndex,
1113
+ message: `didn't report any config params, trying #1 just to be sure...`,
1114
+ direction: "inbound",
1115
+ });
1116
+ param = 1;
1117
+ }
1118
+ }
1119
+ else {
1120
+ applHost.controllerLog.logNode(node.id, {
1121
+ endpoint: this.endpointIndex,
1122
+ message: "Finding first configuration parameter timed out, skipping interview...",
1123
+ level: "warn",
1124
+ });
1125
+ return;
1126
+ }
1127
+ while (param > 0) {
1128
+ applHost.controllerLog.logNode(node.id, {
1129
+ endpoint: this.endpointIndex,
1130
+ message: `querying parameter #${param} information...`,
1131
+ direction: "outbound",
1132
+ });
1133
+ // Query properties and the next param
1134
+ const props = await api.getProperties(param);
1135
+ if (!props) {
1136
+ applHost.controllerLog.logNode(node.id, {
1137
+ endpoint: this.endpointIndex,
1138
+ message: `Querying parameter #${param} information timed out, skipping interview...`,
1139
+ level: "warn",
1140
+ });
1141
+ return;
1142
+ }
1143
+ const { nextParameter, ...properties } = props;
1144
+ let logMessage;
1145
+ if (properties.valueSize === 0) {
1146
+ logMessage = `Parameter #${param} is unsupported. Next parameter: ${nextParameter}`;
1147
+ }
1148
+ else {
1149
+ // Query name and info only if the parameter is supported, but skip the query for bugged devices
1150
+ let name;
1151
+ if (!((_d = deviceConfig === null || deviceConfig === void 0 ? void 0 : deviceConfig.compat) === null || _d === void 0 ? void 0 : _d.skipConfigurationNameQuery)) {
1152
+ name = await api.getName(param);
1153
+ }
1154
+ // Skip the info query for bugged devices
1155
+ if (!((_e = deviceConfig === null || deviceConfig === void 0 ? void 0 : deviceConfig.compat) === null || _e === void 0 ? void 0 : _e.skipConfigurationInfoQuery)) {
1156
+ await api.getInfo(param);
1157
+ }
1158
+ logMessage = `received information for parameter #${param}:`;
1159
+ if (name) {
1160
+ logMessage += `
1161
+ parameter name: ${name}`;
1162
+ }
1163
+ logMessage += `
1164
+ value format: ${(0, safe_2.getEnumMemberName)(safe_1.ConfigValueFormat, properties.valueFormat)}
1165
+ value size: ${properties.valueSize} bytes
1166
+ min value: ${(_g = (_f = properties.minValue) === null || _f === void 0 ? void 0 : _f.toString()) !== null && _g !== void 0 ? _g : "undefined"}
1167
+ max value: ${(_j = (_h = properties.maxValue) === null || _h === void 0 ? void 0 : _h.toString()) !== null && _j !== void 0 ? _j : "undefined"}
1168
+ default value: ${(_l = (_k = properties.defaultValue) === null || _k === void 0 ? void 0 : _k.toString()) !== null && _l !== void 0 ? _l : "undefined"}
1169
+ is read-only: ${!!properties.isReadonly}
1170
+ is advanced (UI): ${!!properties.isAdvanced}
1171
+ has bulk support: ${!properties.noBulkSupport}
1172
+ alters capabilities: ${!!properties.altersCapabilities}`;
1173
+ }
1174
+ applHost.controllerLog.logNode(node.id, {
1175
+ endpoint: this.endpointIndex,
1176
+ message: logMessage,
1177
+ direction: "inbound",
1178
+ });
1179
+ // Some devices report their parameter 1 instead of 0 as the next one
1180
+ // when reaching the end. To avoid infinite loops, stop scanning
1181
+ // once the next parameter is lower than the current one
1182
+ if (nextParameter > param) {
1183
+ param = nextParameter;
1184
+ }
1185
+ else {
1186
+ break;
1187
+ }
1188
+ }
1189
+ }
1190
+ await this.refreshValues(applHost);
1191
+ // Remember that the interview is complete
1192
+ this.setInterviewComplete(applHost, true);
1193
+ }
1194
+ async refreshValues(applHost) {
1195
+ var _c, _d, _e;
1196
+ const node = this.getNode(applHost);
1197
+ const endpoint = this.getEndpoint(applHost);
1198
+ const api = API_1.CCAPI.create(safe_1.CommandClasses.Configuration, applHost, endpoint).withOptions({
1199
+ priority: safe_1.MessagePriority.NodeQuery,
1200
+ });
1201
+ if (this.version < 3) {
1202
+ // V1/V2: Query all values defined in the config file
1203
+ const paramInfo = (_d = (_c = applHost.getDeviceConfig) === null || _c === void 0 ? void 0 : _c.call(applHost, node.id)) === null || _d === void 0 ? void 0 : _d.paramInformation;
1204
+ if (paramInfo === null || paramInfo === void 0 ? void 0 : paramInfo.size) {
1205
+ // Because partial params share the same parameter number,
1206
+ // we need to remember which ones we have already queried.
1207
+ const alreadyQueried = new Set();
1208
+ for (const param of paramInfo.keys()) {
1209
+ // No need to query writeonly params
1210
+ if ((_e = paramInfo.get(param)) === null || _e === void 0 ? void 0 : _e.writeOnly)
1211
+ continue;
1212
+ // Don't double-query params
1213
+ if (alreadyQueried.has(param.parameter))
1214
+ continue;
1215
+ alreadyQueried.add(param.parameter);
1216
+ // Query the current value
1217
+ applHost.controllerLog.logNode(node.id, {
1218
+ endpoint: this.endpointIndex,
1219
+ message: `querying parameter #${param.parameter} value...`,
1220
+ direction: "outbound",
1221
+ });
1222
+ // ... at least try to
1223
+ const paramValue = await api.get(param.parameter);
1224
+ if (typeof paramValue === "number") {
1225
+ applHost.controllerLog.logNode(node.id, {
1226
+ endpoint: this.endpointIndex,
1227
+ message: `parameter #${param.parameter} has value: ${paramValue}`,
1228
+ direction: "inbound",
1229
+ });
1230
+ }
1231
+ else if (!paramValue) {
1232
+ applHost.controllerLog.logNode(node.id, {
1233
+ endpoint: this.endpointIndex,
1234
+ message: `received no value for parameter #${param.parameter}`,
1235
+ direction: "inbound",
1236
+ level: "warn",
1237
+ });
1238
+ }
1239
+ }
1240
+ }
1241
+ else {
1242
+ applHost.controllerLog.logNode(node.id, {
1243
+ endpoint: this.endpointIndex,
1244
+ message: `${this.constructor.name}: skipping interview because CC version is < 3 and there is no config file`,
1245
+ direction: "none",
1246
+ });
1247
+ }
1248
+ }
1249
+ else {
1250
+ // V3+: Query the values of discovered parameters
1251
+ const parameters = (0, arrays_1.distinct)(this.getDefinedValueIDs(applHost)
1252
+ .map((v) => v.property)
1253
+ .filter((p) => typeof p === "number"));
1254
+ for (const param of parameters) {
1255
+ if (this.getParamInformation(applHost, param).readable !== false) {
1256
+ applHost.controllerLog.logNode(node.id, {
1257
+ endpoint: this.endpointIndex,
1258
+ message: `querying parameter #${param} value...`,
1259
+ direction: "outbound",
1260
+ });
1261
+ await api.get(param);
1262
+ }
1263
+ else {
1264
+ applHost.controllerLog.logNode(node.id, {
1265
+ endpoint: this.endpointIndex,
1266
+ message: `not querying parameter #${param} value, because it is writeonly`,
1267
+ direction: "none",
1268
+ });
1269
+ }
1270
+ }
1271
+ }
1272
+ }
1273
+ /**
1274
+ * Whether this node's param information was loaded from a config file.
1275
+ * If this is true, we don't trust what the node reports
1276
+ */
1277
+ isParamInformationFromConfig(applHost) {
1278
+ return (this.getValueDB(applHost).getValue(isParamInfoFromConfigValueId) ===
1279
+ true);
1280
+ }
1281
+ /**
1282
+ * @internal
1283
+ * Stores config parameter metadata for this CC's node
1284
+ */
1285
+ extendParamInformation(applHost, parameter, valueBitMask, info) {
1286
+ // Don't trust param information that a node reports if we have already loaded it from a config file
1287
+ if (this.isParamInformationFromConfig(applHost))
1288
+ return;
1289
+ const valueDB = this.getValueDB(applHost);
1290
+ const valueId = getParamInformationValueID(parameter, valueBitMask);
1291
+ // Retrieve the base metadata
1292
+ const metadata = this.getParamInformation(applHost, parameter, valueBitMask);
1293
+ // Override it with new data
1294
+ Object.assign(metadata, info);
1295
+ // And store it back
1296
+ valueDB.setMetadata(valueId, metadata);
1297
+ }
1298
+ /**
1299
+ * @internal
1300
+ * Returns stored config parameter metadata for this CC's node
1301
+ */
1302
+ getParamInformation(applHost, parameter, valueBitMask) {
1303
+ var _c;
1304
+ const valueDB = this.getValueDB(applHost);
1305
+ const valueId = getParamInformationValueID(parameter, valueBitMask);
1306
+ return ((_c = valueDB.getMetadata(valueId)) !== null && _c !== void 0 ? _c : {
1307
+ ...safe_1.ValueMetadata.Any,
1308
+ });
1309
+ }
1310
+ /**
1311
+ * **INTERNAL:** Returns the param info that was queried for this node. This returns the information that was returned by the node
1312
+ * and does not include partial parameters.
1313
+ */
1314
+ getQueriedParamInfos(applHost) {
1315
+ const parameters = (0, arrays_1.distinct)(this.getDefinedValueIDs(applHost)
1316
+ .map((v) => v.property)
1317
+ .filter((p) => typeof p === "number"));
1318
+ return (0, objects_1.composeObject)(parameters.map((p) => [
1319
+ p,
1320
+ this.getParamInformation(applHost, p),
1321
+ ]));
1322
+ }
1323
+ /**
1324
+ * Returns stored config parameter metadata for all partial config params addressed with the given parameter number
1325
+ */
1326
+ getPartialParamInfos(applHost, parameter) {
1327
+ const valueDB = this.getValueDB(applHost);
1328
+ return valueDB.findMetadata((id) => id.commandClass === this.ccId &&
1329
+ id.property === parameter &&
1330
+ id.propertyKey != undefined);
1331
+ }
1332
+ /**
1333
+ * Computes the full value of a parameter after applying a partial param value
1334
+ */
1335
+ composePartialParamValue(applHost, parameter, bitMask, partialValue) {
1336
+ return this.composePartialParamValues(applHost, parameter, [
1337
+ { bitMask, partialValue },
1338
+ ]);
1339
+ }
1340
+ /**
1341
+ * Computes the full value of a parameter after applying multiple partial param values
1342
+ */
1343
+ composePartialParamValues(applHost, parameter, partials) {
1344
+ const valueDB = this.getValueDB(applHost);
1345
+ // Add the other values together
1346
+ const otherValues = valueDB.findValues((id) => id.commandClass === this.ccId &&
1347
+ id.property === parameter &&
1348
+ id.propertyKey != undefined &&
1349
+ !partials.some((p) => id.propertyKey === p.bitMask));
1350
+ let ret = 0;
1351
+ for (const { propertyKey: bitMask, value: partialValue, } of otherValues) {
1352
+ ret = (0, safe_1.encodePartial)(ret, partialValue, bitMask);
1353
+ }
1354
+ for (const { bitMask, partialValue } of partials) {
1355
+ ret = (0, safe_1.encodePartial)(ret, partialValue, bitMask);
1356
+ }
1357
+ return ret;
1358
+ }
1359
+ /** Deserializes the config parameter info from a config file */
1360
+ deserializeParamInformationFromConfig(applHost, config) {
1361
+ const valueDB = this.getValueDB(applHost);
1362
+ // Clear old param information
1363
+ for (const meta of valueDB.getAllMetadata(this.ccId)) {
1364
+ if (typeof meta.property === "number") {
1365
+ // this is a param information, delete it
1366
+ valueDB.setMetadata(meta, undefined,
1367
+ // Don't emit the added/updated events, as this will spam applications with untranslated events
1368
+ { noEvent: true });
1369
+ }
1370
+ }
1371
+ // Allow overwriting the param info (mark it as unloaded)
1372
+ valueDB.setValue(isParamInfoFromConfigValueId, false);
1373
+ for (const [param, info] of config.entries()) {
1374
+ // We need to make the config information compatible with the
1375
+ // format that ConfigurationCC reports
1376
+ const paramInfo = (0, safe_1.stripUndefined)({
1377
+ // TODO: Make this smarter! (0...1 ==> boolean)
1378
+ type: "number",
1379
+ valueSize: info.valueSize,
1380
+ min: info.minValue,
1381
+ max: info.maxValue,
1382
+ default: info.defaultValue,
1383
+ unit: info.unit,
1384
+ format: info.unsigned
1385
+ ? safe_1.ConfigValueFormat.UnsignedInteger
1386
+ : safe_1.ConfigValueFormat.SignedInteger,
1387
+ readable: !info.writeOnly,
1388
+ writeable: !info.readOnly,
1389
+ allowManualEntry: info.allowManualEntry,
1390
+ states: info.options.length > 0
1391
+ ? (0, objects_1.composeObject)(info.options.map(({ label, value }) => [
1392
+ value.toString(),
1393
+ label,
1394
+ ]))
1395
+ : undefined,
1396
+ label: info.label,
1397
+ description: info.description,
1398
+ isFromConfig: true,
1399
+ });
1400
+ this.extendParamInformation(applHost, param.parameter, param.valueBitMask, paramInfo);
1401
+ }
1402
+ // Remember that we loaded the param information from a config file
1403
+ valueDB.setValue(isParamInfoFromConfigValueId, true);
1404
+ }
1405
+ translatePropertyKey(applHost, property, propertyKey) {
1406
+ if (typeof property === "number" &&
1407
+ (propertyKey == undefined || typeof propertyKey === "number")) {
1408
+ // This CC names all configuration parameters differently,
1409
+ // so no name for the property key is required
1410
+ return undefined;
1411
+ }
1412
+ return super.translateProperty(applHost, property, propertyKey);
1413
+ }
1414
+ translateProperty(applHost, property, propertyKey) {
1415
+ // Try to retrieve the configured param label
1416
+ if (typeof property === "number" &&
1417
+ (propertyKey == undefined || typeof propertyKey === "number")) {
1418
+ const paramInfo = this.getParamInformation(applHost, property, propertyKey);
1419
+ if (paramInfo.label)
1420
+ return paramInfo.label;
1421
+ // fall back to paramXYZ[_key] if none is defined
1422
+ let ret = `param${(0, strings_1.padStart)(property.toString(), 3, "0")}`;
1423
+ if (propertyKey != undefined) {
1424
+ ret += "_" + propertyKey.toString();
1425
+ }
1426
+ return ret;
1427
+ }
1428
+ return super.translateProperty(applHost, property, propertyKey);
1429
+ }
1430
+ };
1431
+ ConfigurationCC = __decorate([
1432
+ (0, CommandClass_1.commandClass)(safe_1.CommandClasses.Configuration),
1433
+ (0, CommandClass_1.implementedVersion)(4)
1434
+ ], ConfigurationCC);
1435
+ exports.ConfigurationCC = ConfigurationCC;
1436
+ let ConfigurationCCReport = class ConfigurationCCReport extends ConfigurationCC {
1437
+ constructor(host, options) {
1438
+ super(host, options);
1439
+ // All fields must be present
1440
+ (0, safe_1.validatePayload)(this.payload.length > 2);
1441
+ this._parameter = this.payload[0];
1442
+ this._valueSize = this.payload[1] & 0b111;
1443
+ // Ensure we received a valid report
1444
+ (0, safe_1.validatePayload)(this._valueSize >= 1, this._valueSize <= 4, this.payload.length >= 2 + this._valueSize);
1445
+ // Default to parsing the value as SignedInteger, like the specs say.
1446
+ // We try to re-interpret the value in persistValues()
1447
+ this._value = parseValue(this.payload.slice(2), this._valueSize, safe_1.ConfigValueFormat.SignedInteger);
1448
+ }
1449
+ persistValues(applHost) {
1450
+ if (!super.persistValues(applHost))
1451
+ return false;
1452
+ const valueDB = this.getValueDB(applHost);
1453
+ // Check if the initial assumption of SignedInteger holds true
1454
+ const oldParamInformation = this.getParamInformation(applHost, this._parameter);
1455
+ if (oldParamInformation.format != undefined &&
1456
+ oldParamInformation.format !== safe_1.ConfigValueFormat.SignedInteger) {
1457
+ // Re-interpret the value with the new format
1458
+ this._value = reInterpretSignedValue(this._value, this._valueSize, oldParamInformation.format);
1459
+ }
1460
+ // Store the parameter size and value
1461
+ this.extendParamInformation(applHost, this._parameter, undefined, {
1462
+ valueSize: this._valueSize,
1463
+ type: oldParamInformation.format === safe_1.ConfigValueFormat.BitField
1464
+ ? "number[]"
1465
+ : "number",
1466
+ });
1467
+ if (this.version < 3 &&
1468
+ !this.isParamInformationFromConfig &&
1469
+ oldParamInformation.min == undefined &&
1470
+ oldParamInformation.max == undefined) {
1471
+ const isSigned = oldParamInformation.format == undefined ||
1472
+ oldParamInformation.format === safe_1.ConfigValueFormat.SignedInteger;
1473
+ this.extendParamInformation(applHost, this._parameter, undefined, (0, safe_1.getIntegerLimits)(this._valueSize, isSigned));
1474
+ }
1475
+ // And store the value itself
1476
+ // If we have partial config params defined, we need to split the value
1477
+ const partialParams = this.getPartialParamInfos(applHost, this._parameter);
1478
+ if (partialParams.length > 0) {
1479
+ for (const param of partialParams) {
1480
+ if (typeof param.propertyKey === "number") {
1481
+ valueDB.setValue({
1482
+ commandClass: this.ccId,
1483
+ property: this._parameter,
1484
+ propertyKey: param.propertyKey,
1485
+ }, (0, safe_1.parsePartial)(this._value, param.propertyKey, isSignedPartial(param.propertyKey, param.metadata.format)));
1486
+ }
1487
+ }
1488
+ }
1489
+ else {
1490
+ // This is a single param
1491
+ valueDB.setValue({
1492
+ commandClass: this.ccId,
1493
+ property: this._parameter,
1494
+ }, this._value);
1495
+ }
1496
+ return true;
1497
+ }
1498
+ get parameter() {
1499
+ return this._parameter;
1500
+ }
1501
+ get value() {
1502
+ return this._value;
1503
+ }
1504
+ get valueSize() {
1505
+ return this._valueSize;
1506
+ }
1507
+ toLogEntry(applHost) {
1508
+ return {
1509
+ ...super.toLogEntry(applHost),
1510
+ message: {
1511
+ "parameter #": this.parameter,
1512
+ "value size": this.valueSize,
1513
+ value: configValueToString(this.value),
1514
+ },
1515
+ };
1516
+ }
1517
+ };
1518
+ ConfigurationCCReport = __decorate([
1519
+ (0, CommandClass_1.CCCommand)(_Types_1.ConfigurationCommand.Report)
1520
+ ], ConfigurationCCReport);
1521
+ exports.ConfigurationCCReport = ConfigurationCCReport;
1522
+ function testResponseForConfigurationGet(sent, received) {
1523
+ // We expect a Configuration Report that matches the requested parameter
1524
+ return (sent.parameter === received.parameter || sent.allowUnexpectedResponse);
1525
+ }
1526
+ let ConfigurationCCGet = class ConfigurationCCGet extends ConfigurationCC {
1527
+ constructor(host, options) {
1528
+ var _c;
1529
+ super(host, options);
1530
+ if ((0, CommandClass_1.gotDeserializationOptions)(options)) {
1531
+ // TODO: Deserialize payload
1532
+ throw new safe_1.ZWaveError(`${this.constructor.name}: deserialization not implemented`, safe_1.ZWaveErrorCodes.Deserialization_NotImplemented);
1533
+ }
1534
+ else {
1535
+ this.parameter = options.parameter;
1536
+ this.allowUnexpectedResponse =
1537
+ (_c = options.allowUnexpectedResponse) !== null && _c !== void 0 ? _c : false;
1538
+ }
1539
+ }
1540
+ serialize() {
1541
+ this.payload = Buffer.from([this.parameter]);
1542
+ return super.serialize();
1543
+ }
1544
+ toLogEntry(applHost) {
1545
+ return {
1546
+ ...super.toLogEntry(applHost),
1547
+ message: { "parameter #": this.parameter },
1548
+ };
1549
+ }
1550
+ };
1551
+ ConfigurationCCGet = __decorate([
1552
+ (0, CommandClass_1.CCCommand)(_Types_1.ConfigurationCommand.Get),
1553
+ (0, CommandClass_1.expectedCCResponse)(ConfigurationCCReport, testResponseForConfigurationGet)
1554
+ ], ConfigurationCCGet);
1555
+ exports.ConfigurationCCGet = ConfigurationCCGet;
1556
+ let ConfigurationCCSet = class ConfigurationCCSet extends ConfigurationCC {
1557
+ constructor(host, options) {
1558
+ var _c;
1559
+ super(host, options);
1560
+ if ((0, CommandClass_1.gotDeserializationOptions)(options)) {
1561
+ // TODO: Deserialize payload
1562
+ throw new safe_1.ZWaveError(`${this.constructor.name}: deserialization not implemented`, safe_1.ZWaveErrorCodes.Deserialization_NotImplemented);
1563
+ }
1564
+ else {
1565
+ this.parameter = options.parameter;
1566
+ // According to SDS14223 this flag SHOULD NOT be set
1567
+ // Because we don't want to test the behavior, we enforce that it MUST not be set
1568
+ // on legacy nodes
1569
+ if (options.resetToDefault && this.version <= 3) {
1570
+ throw new safe_1.ZWaveError(`The resetToDefault flag MUST not be used on nodes implementing ConfigurationCC V3 or less!`, safe_1.ZWaveErrorCodes.ConfigurationCC_NoResetToDefaultOnLegacyDevices);
1571
+ }
1572
+ this.resetToDefault = !!options.resetToDefault;
1573
+ if (!options.resetToDefault) {
1574
+ // TODO: Default to the stored value size
1575
+ this.valueSize = options.valueSize;
1576
+ this.valueFormat =
1577
+ (_c = options.valueFormat) !== null && _c !== void 0 ? _c : safe_1.ConfigValueFormat.SignedInteger;
1578
+ this.value = options.value;
1579
+ }
1580
+ }
1581
+ }
1582
+ serialize() {
1583
+ const valueSize = this.resetToDefault ? 1 : this.valueSize;
1584
+ const payloadLength = 2 + valueSize;
1585
+ this.payload = Buffer.alloc(payloadLength, 0);
1586
+ this.payload[0] = this.parameter;
1587
+ this.payload[1] =
1588
+ (this.resetToDefault ? 128 : 0) | (valueSize & 0b111);
1589
+ if (!this.resetToDefault) {
1590
+ // Make sure that the given value fits into the value size
1591
+ if (typeof this.value === "number" &&
1592
+ !isSafeValue(this.value, valueSize, this.valueFormat)) {
1593
+ // If there is a value size configured, check that the given value is compatible
1594
+ throwInvalidValueError(this.value, this.parameter, valueSize, this.valueFormat);
1595
+ }
1596
+ try {
1597
+ serializeValue(this.payload, 2, valueSize, this.valueFormat, this.value);
1598
+ }
1599
+ catch (e) {
1600
+ tryCatchOutOfBoundsError(e, this.value, this.parameter, valueSize, this.valueFormat);
1601
+ }
1602
+ }
1603
+ return super.serialize();
1604
+ }
1605
+ toLogEntry(applHost) {
1606
+ const message = {
1607
+ "parameter #": this.parameter,
1608
+ "reset to default": this.resetToDefault,
1609
+ };
1610
+ if (this.valueSize != undefined) {
1611
+ message["value size"] = this.valueSize;
1612
+ }
1613
+ if (this.valueFormat != undefined) {
1614
+ message["value format"] = (0, safe_2.getEnumMemberName)(safe_1.ConfigValueFormat, this.valueFormat);
1615
+ }
1616
+ if (this.value != undefined) {
1617
+ message.value = configValueToString(this.value);
1618
+ }
1619
+ return {
1620
+ ...super.toLogEntry(applHost),
1621
+ message,
1622
+ };
1623
+ }
1624
+ };
1625
+ ConfigurationCCSet = __decorate([
1626
+ (0, CommandClass_1.CCCommand)(_Types_1.ConfigurationCommand.Set)
1627
+ ], ConfigurationCCSet);
1628
+ exports.ConfigurationCCSet = ConfigurationCCSet;
1629
+ function getResponseForBulkSet(cc) {
1630
+ return cc.handshake ? ConfigurationCCBulkReport : undefined;
1631
+ }
1632
+ let ConfigurationCCBulkSet = class ConfigurationCCBulkSet extends ConfigurationCC {
1633
+ constructor(host, options) {
1634
+ var _c;
1635
+ super(host, options);
1636
+ if ((0, CommandClass_1.gotDeserializationOptions)(options)) {
1637
+ // TODO: Deserialize payload
1638
+ throw new safe_1.ZWaveError(`${this.constructor.name}: deserialization not implemented`, safe_1.ZWaveErrorCodes.Deserialization_NotImplemented);
1639
+ }
1640
+ else {
1641
+ this._parameters = options.parameters;
1642
+ if (this._parameters.length < 1) {
1643
+ throw new safe_1.ZWaveError(`In a ConfigurationCC.BulkSet, parameters must be a non-empty array`, safe_1.ZWaveErrorCodes.CC_Invalid);
1644
+ }
1645
+ else if (!(0, safe_1.isConsecutiveArray)(this._parameters)) {
1646
+ throw new safe_1.ZWaveError(`A ConfigurationCC.BulkSet can only be used for consecutive parameters`, safe_1.ZWaveErrorCodes.CC_Invalid);
1647
+ }
1648
+ this._handshake = !!options.handshake;
1649
+ this._resetToDefault = !!options.resetToDefault;
1650
+ if (!!options.resetToDefault) {
1651
+ this._valueSize = 1;
1652
+ this._valueFormat = safe_1.ConfigValueFormat.SignedInteger;
1653
+ this._values = this._parameters.map(() => 0);
1654
+ }
1655
+ else {
1656
+ this._valueSize = options.valueSize;
1657
+ this._valueFormat =
1658
+ (_c = options.valueFormat) !== null && _c !== void 0 ? _c : safe_1.ConfigValueFormat.SignedInteger;
1659
+ this._values = options.values;
1660
+ }
1661
+ }
1662
+ }
1663
+ get parameters() {
1664
+ return this._parameters;
1665
+ }
1666
+ get resetToDefault() {
1667
+ return this._resetToDefault;
1668
+ }
1669
+ get valueSize() {
1670
+ return this._valueSize;
1671
+ }
1672
+ get valueFormat() {
1673
+ return this._valueFormat;
1674
+ }
1675
+ get values() {
1676
+ return this._values;
1677
+ }
1678
+ get handshake() {
1679
+ return this._handshake;
1680
+ }
1681
+ serialize() {
1682
+ const valueSize = this._resetToDefault ? 1 : this.valueSize;
1683
+ const payloadLength = 4 + valueSize * this.parameters.length;
1684
+ this.payload = Buffer.alloc(payloadLength, 0);
1685
+ this.payload.writeUInt16BE(this.parameters[0], 0);
1686
+ this.payload[2] = this.parameters.length;
1687
+ this.payload[3] =
1688
+ (this._resetToDefault ? 128 : 0) |
1689
+ (this.handshake ? 64 : 0) |
1690
+ (valueSize & 0b111);
1691
+ if (!this._resetToDefault) {
1692
+ for (let i = 0; i < this.parameters.length; i++) {
1693
+ const value = this._values[i];
1694
+ const param = this._parameters[i];
1695
+ // Make sure that the given value fits into the value size
1696
+ if (!isSafeValue(value, valueSize, this._valueFormat)) {
1697
+ // If there is a value size configured, check that the given value is compatible
1698
+ throwInvalidValueError(value, param, valueSize, this._valueFormat);
1699
+ }
1700
+ try {
1701
+ serializeValue(this.payload, 4 + i * valueSize, valueSize, this._valueFormat, value);
1702
+ }
1703
+ catch (e) {
1704
+ tryCatchOutOfBoundsError(e, value, param, valueSize, this._valueFormat);
1705
+ }
1706
+ }
1707
+ }
1708
+ return super.serialize();
1709
+ }
1710
+ toLogEntry(applHost) {
1711
+ const message = {
1712
+ handshake: this.handshake,
1713
+ "reset to default": this.resetToDefault,
1714
+ "value size": this.valueSize,
1715
+ };
1716
+ if (this._values.length > 0) {
1717
+ message.values = this._values
1718
+ .map((value, i) => `\n· #${this._parameters[i]}: ${configValueToString(value)}`)
1719
+ .join("");
1720
+ }
1721
+ return {
1722
+ ...super.toLogEntry(applHost),
1723
+ message,
1724
+ };
1725
+ }
1726
+ };
1727
+ ConfigurationCCBulkSet = __decorate([
1728
+ (0, CommandClass_1.CCCommand)(_Types_1.ConfigurationCommand.BulkSet),
1729
+ (0, CommandClass_1.expectedCCResponse)(getResponseForBulkSet)
1730
+ ], ConfigurationCCBulkSet);
1731
+ exports.ConfigurationCCBulkSet = ConfigurationCCBulkSet;
1732
+ let ConfigurationCCBulkReport = class ConfigurationCCBulkReport extends ConfigurationCC {
1733
+ constructor(host, options) {
1734
+ super(host, options);
1735
+ this._values = new Map();
1736
+ // Ensure we received enough bytes for the preamble
1737
+ (0, safe_1.validatePayload)(this.payload.length >= 5);
1738
+ const firstParameter = this.payload.readUInt16BE(0);
1739
+ const numParams = this.payload[2];
1740
+ this._reportsToFollow = this.payload[3];
1741
+ this._defaultValues = !!(this.payload[4] & 128);
1742
+ this._isHandshakeResponse = !!(this.payload[4] & 64);
1743
+ this._valueSize = this.payload[4] & 0b111;
1744
+ // Ensure the payload is long enough for all reported values
1745
+ (0, safe_1.validatePayload)(this.payload.length >= 5 + numParams * this._valueSize);
1746
+ for (let i = 0; i < numParams; i++) {
1747
+ const param = firstParameter + i;
1748
+ this._values.set(param,
1749
+ // Default to parsing the value as SignedInteger, like the specs say.
1750
+ // We try to re-interpret the value in persistValues()
1751
+ parseValue(this.payload.slice(5 + i * this.valueSize), this.valueSize, safe_1.ConfigValueFormat.SignedInteger));
1752
+ }
1753
+ }
1754
+ persistValues(applHost) {
1755
+ if (!super.persistValues(applHost))
1756
+ return false;
1757
+ const valueDB = this.getValueDB(applHost);
1758
+ // Store every received parameter
1759
+ // eslint-disable-next-line prefer-const
1760
+ for (let [parameter, value] of this._values.entries()) {
1761
+ // Check if the initial assumption of SignedInteger holds true
1762
+ const oldParamInformation = this.getParamInformation(applHost, parameter);
1763
+ if (oldParamInformation.format != undefined &&
1764
+ oldParamInformation.format !== safe_1.ConfigValueFormat.SignedInteger) {
1765
+ // Re-interpret the value with the new format
1766
+ value = reInterpretSignedValue(value, this._valueSize, oldParamInformation.format);
1767
+ this._values.set(parameter, value);
1768
+ }
1769
+ valueDB.setValue({
1770
+ commandClass: this.ccId,
1771
+ property: parameter,
1772
+ }, value);
1773
+ }
1774
+ return true;
1775
+ }
1776
+ get reportsToFollow() {
1777
+ return this._reportsToFollow;
1778
+ }
1779
+ getPartialCCSessionId() {
1780
+ // We don't expect the applHost to merge CCs but we want to wait until all reports have been received
1781
+ return {};
1782
+ }
1783
+ expectMoreMessages() {
1784
+ return this._reportsToFollow > 0;
1785
+ }
1786
+ get defaultValues() {
1787
+ return this._defaultValues;
1788
+ }
1789
+ get isHandshakeResponse() {
1790
+ return this._isHandshakeResponse;
1791
+ }
1792
+ get valueSize() {
1793
+ return this._valueSize;
1794
+ }
1795
+ get values() {
1796
+ return this._values;
1797
+ }
1798
+ toLogEntry(applHost) {
1799
+ const message = {
1800
+ "handshake response": this._isHandshakeResponse,
1801
+ "default values": this._defaultValues,
1802
+ "value size": this._valueSize,
1803
+ "reports to follow": this.reportsToFollow,
1804
+ };
1805
+ if (this._values.size > 0) {
1806
+ message.values = [...this._values]
1807
+ .map(([param, value]) => `
1808
+ · #${param}: ${configValueToString(value)}`)
1809
+ .join("");
1810
+ }
1811
+ return {
1812
+ ...super.toLogEntry(applHost),
1813
+ message,
1814
+ };
1815
+ }
1816
+ };
1817
+ ConfigurationCCBulkReport = __decorate([
1818
+ (0, CommandClass_1.CCCommand)(_Types_1.ConfigurationCommand.BulkReport)
1819
+ ], ConfigurationCCBulkReport);
1820
+ exports.ConfigurationCCBulkReport = ConfigurationCCBulkReport;
1821
+ let ConfigurationCCBulkGet = class ConfigurationCCBulkGet extends ConfigurationCC {
1822
+ constructor(host, options) {
1823
+ super(host, options);
1824
+ if ((0, CommandClass_1.gotDeserializationOptions)(options)) {
1825
+ // TODO: Deserialize payload
1826
+ throw new safe_1.ZWaveError(`${this.constructor.name}: deserialization not implemented`, safe_1.ZWaveErrorCodes.Deserialization_NotImplemented);
1827
+ }
1828
+ else {
1829
+ this._parameters = options.parameters.sort();
1830
+ if (!(0, safe_1.isConsecutiveArray)(this.parameters)) {
1831
+ throw new safe_1.ZWaveError(`A ConfigurationCC.BulkGet can only be used for consecutive parameters`, safe_1.ZWaveErrorCodes.CC_Invalid);
1832
+ }
1833
+ }
1834
+ }
1835
+ get parameters() {
1836
+ return this._parameters;
1837
+ }
1838
+ serialize() {
1839
+ this.payload = Buffer.allocUnsafe(3);
1840
+ this.payload.writeUInt16BE(this.parameters[0], 0);
1841
+ this.payload[2] = this.parameters.length;
1842
+ return super.serialize();
1843
+ }
1844
+ toLogEntry(applHost) {
1845
+ return {
1846
+ ...super.toLogEntry(applHost),
1847
+ message: { parameters: this.parameters.join(", ") },
1848
+ };
1849
+ }
1850
+ };
1851
+ ConfigurationCCBulkGet = __decorate([
1852
+ (0, CommandClass_1.CCCommand)(_Types_1.ConfigurationCommand.BulkGet),
1853
+ (0, CommandClass_1.expectedCCResponse)(ConfigurationCCBulkReport)
1854
+ ], ConfigurationCCBulkGet);
1855
+ exports.ConfigurationCCBulkGet = ConfigurationCCBulkGet;
1856
+ let ConfigurationCCNameReport = class ConfigurationCCNameReport extends ConfigurationCC {
1857
+ constructor(host, options) {
1858
+ super(host, options);
1859
+ // Parameter and # of reports must be present
1860
+ (0, safe_1.validatePayload)(this.payload.length >= 3);
1861
+ this._parameter = this.payload.readUInt16BE(0);
1862
+ this._reportsToFollow = this.payload[2];
1863
+ if (this._reportsToFollow > 0) {
1864
+ // If more reports follow, the info must at least be one byte
1865
+ (0, safe_1.validatePayload)(this.payload.length >= 4);
1866
+ }
1867
+ this._name = this.payload.slice(3).toString("utf8");
1868
+ }
1869
+ persistValues(applHost) {
1870
+ if (!super.persistValues(applHost))
1871
+ return false;
1872
+ this.extendParamInformation(applHost, this.parameter, undefined, {
1873
+ name: this.name,
1874
+ });
1875
+ return true;
1876
+ }
1877
+ get parameter() {
1878
+ return this._parameter;
1879
+ }
1880
+ get name() {
1881
+ return this._name;
1882
+ }
1883
+ get reportsToFollow() {
1884
+ return this._reportsToFollow;
1885
+ }
1886
+ getPartialCCSessionId() {
1887
+ // Distinguish sessions by the parameter number
1888
+ return { parameter: this._parameter };
1889
+ }
1890
+ expectMoreMessages() {
1891
+ return this._reportsToFollow > 0;
1892
+ }
1893
+ mergePartialCCs(applHost, partials) {
1894
+ // Concat the name
1895
+ this._name = [...partials, this]
1896
+ .map((report) => report._name)
1897
+ .reduce((prev, cur) => prev + cur, "");
1898
+ }
1899
+ toLogEntry(applHost) {
1900
+ return {
1901
+ ...super.toLogEntry(applHost),
1902
+ message: {
1903
+ "parameter #": this.parameter,
1904
+ name: this.name,
1905
+ "reports to follow": this.reportsToFollow,
1906
+ },
1907
+ };
1908
+ }
1909
+ };
1910
+ ConfigurationCCNameReport = __decorate([
1911
+ (0, CommandClass_1.CCCommand)(_Types_1.ConfigurationCommand.NameReport)
1912
+ ], ConfigurationCCNameReport);
1913
+ exports.ConfigurationCCNameReport = ConfigurationCCNameReport;
1914
+ let ConfigurationCCNameGet = class ConfigurationCCNameGet extends ConfigurationCC {
1915
+ constructor(host, options) {
1916
+ super(host, options);
1917
+ if ((0, CommandClass_1.gotDeserializationOptions)(options)) {
1918
+ // TODO: Deserialize payload
1919
+ throw new safe_1.ZWaveError(`${this.constructor.name}: deserialization not implemented`, safe_1.ZWaveErrorCodes.Deserialization_NotImplemented);
1920
+ }
1921
+ else {
1922
+ this.parameter = options.parameter;
1923
+ }
1924
+ }
1925
+ serialize() {
1926
+ this.payload = Buffer.allocUnsafe(2);
1927
+ this.payload.writeUInt16BE(this.parameter, 0);
1928
+ return super.serialize();
1929
+ }
1930
+ toLogEntry(applHost) {
1931
+ return {
1932
+ ...super.toLogEntry(applHost),
1933
+ message: { "parameter #": this.parameter },
1934
+ };
1935
+ }
1936
+ };
1937
+ ConfigurationCCNameGet = __decorate([
1938
+ (0, CommandClass_1.CCCommand)(_Types_1.ConfigurationCommand.NameGet),
1939
+ (0, CommandClass_1.expectedCCResponse)(ConfigurationCCNameReport)
1940
+ ], ConfigurationCCNameGet);
1941
+ exports.ConfigurationCCNameGet = ConfigurationCCNameGet;
1942
+ let ConfigurationCCInfoReport = class ConfigurationCCInfoReport extends ConfigurationCC {
1943
+ constructor(host, options) {
1944
+ super(host, options);
1945
+ // Parameter and # of reports must be present
1946
+ (0, safe_1.validatePayload)(this.payload.length >= 3);
1947
+ this._parameter = this.payload.readUInt16BE(0);
1948
+ this._reportsToFollow = this.payload[2];
1949
+ if (this._reportsToFollow > 0) {
1950
+ // If more reports follow, the info must at least be one byte
1951
+ (0, safe_1.validatePayload)(this.payload.length >= 4);
1952
+ }
1953
+ this._info = this.payload.slice(3).toString("utf8");
1954
+ }
1955
+ persistValues(applHost) {
1956
+ if (!super.persistValues(applHost))
1957
+ return false;
1958
+ this.extendParamInformation(applHost, this._parameter, undefined, {
1959
+ info: this._info,
1960
+ });
1961
+ return true;
1962
+ }
1963
+ get parameter() {
1964
+ return this._parameter;
1965
+ }
1966
+ get info() {
1967
+ return this._info;
1968
+ }
1969
+ get reportsToFollow() {
1970
+ return this._reportsToFollow;
1971
+ }
1972
+ getPartialCCSessionId() {
1973
+ // Distinguish sessions by the parameter number
1974
+ return { parameter: this._parameter };
1975
+ }
1976
+ expectMoreMessages() {
1977
+ return this._reportsToFollow > 0;
1978
+ }
1979
+ mergePartialCCs(applHost, partials) {
1980
+ // Concat the info
1981
+ this._info = [...partials, this]
1982
+ .map((report) => report._info)
1983
+ .reduce((prev, cur) => prev + cur, "");
1984
+ }
1985
+ toLogEntry(applHost) {
1986
+ return {
1987
+ ...super.toLogEntry(applHost),
1988
+ message: {
1989
+ "parameter #": this.parameter,
1990
+ info: this.info,
1991
+ "reports to follow": this.reportsToFollow,
1992
+ },
1993
+ };
1994
+ }
1995
+ };
1996
+ ConfigurationCCInfoReport = __decorate([
1997
+ (0, CommandClass_1.CCCommand)(_Types_1.ConfigurationCommand.InfoReport)
1998
+ ], ConfigurationCCInfoReport);
1999
+ exports.ConfigurationCCInfoReport = ConfigurationCCInfoReport;
2000
+ let ConfigurationCCInfoGet = class ConfigurationCCInfoGet extends ConfigurationCC {
2001
+ constructor(host, options) {
2002
+ super(host, options);
2003
+ if ((0, CommandClass_1.gotDeserializationOptions)(options)) {
2004
+ // TODO: Deserialize payload
2005
+ throw new safe_1.ZWaveError(`${this.constructor.name}: deserialization not implemented`, safe_1.ZWaveErrorCodes.Deserialization_NotImplemented);
2006
+ }
2007
+ else {
2008
+ this.parameter = options.parameter;
2009
+ }
2010
+ }
2011
+ serialize() {
2012
+ this.payload = Buffer.allocUnsafe(2);
2013
+ this.payload.writeUInt16BE(this.parameter, 0);
2014
+ return super.serialize();
2015
+ }
2016
+ toLogEntry(applHost) {
2017
+ return {
2018
+ ...super.toLogEntry(applHost),
2019
+ message: { "parameter #": this.parameter },
2020
+ };
2021
+ }
2022
+ };
2023
+ ConfigurationCCInfoGet = __decorate([
2024
+ (0, CommandClass_1.CCCommand)(_Types_1.ConfigurationCommand.InfoGet),
2025
+ (0, CommandClass_1.expectedCCResponse)(ConfigurationCCInfoReport)
2026
+ ], ConfigurationCCInfoGet);
2027
+ exports.ConfigurationCCInfoGet = ConfigurationCCInfoGet;
2028
+ let ConfigurationCCPropertiesReport = class ConfigurationCCPropertiesReport extends ConfigurationCC {
2029
+ constructor(host, options) {
2030
+ super(host, options);
2031
+ (0, safe_1.validatePayload)(this.payload.length >= 3);
2032
+ this._parameter = this.payload.readUInt16BE(0);
2033
+ this._valueFormat = (this.payload[2] & 0b111000) >>> 3;
2034
+ this._valueSize = this.payload[2] & 0b111;
2035
+ // GH#1309 Some devices don't tell us the first parameter if we query #0
2036
+ // Instead, they contain 0x000000
2037
+ if (this._valueSize === 0 && this.payload.length < 5) {
2038
+ this._nextParameter = 0;
2039
+ return;
2040
+ }
2041
+ // Ensure the payload contains the two bytes for next parameter
2042
+ const nextParameterOffset = 3 + 3 * this._valueSize;
2043
+ (0, safe_1.validatePayload)(this.payload.length >= nextParameterOffset + 2);
2044
+ if (this.valueSize > 0) {
2045
+ if (this._valueFormat !== safe_1.ConfigValueFormat.BitField) {
2046
+ this._minValue = parseValue(this.payload.slice(3), this._valueSize, this._valueFormat);
2047
+ }
2048
+ this._maxValue = parseValue(this.payload.slice(3 + this._valueSize), this._valueSize, this._valueFormat);
2049
+ this._defaultValue = parseValue(this.payload.slice(3 + 2 * this._valueSize), this._valueSize, this._valueFormat);
2050
+ }
2051
+ if (this.version < 4) {
2052
+ // Read the last 2 bytes to work around nodes not omitting min/max value when their size is 0
2053
+ this._nextParameter = this.payload.readUInt16BE(this.payload.length - 2);
2054
+ }
2055
+ else {
2056
+ this._nextParameter =
2057
+ this.payload.readUInt16BE(nextParameterOffset);
2058
+ // Ensure the payload contains a byte for the 2nd option flags
2059
+ (0, safe_1.validatePayload)(this.payload.length >= nextParameterOffset + 3);
2060
+ const options1 = this.payload[2];
2061
+ const options2 = this.payload[3 + 3 * this.valueSize + 2];
2062
+ this._altersCapabilities = !!(options1 & 128);
2063
+ this._isReadonly = !!(options1 & 64);
2064
+ this._isAdvanced = !!(options2 & 0b1);
2065
+ this._noBulkSupport = !!(options2 & 0b10);
2066
+ }
2067
+ }
2068
+ persistValues(applHost) {
2069
+ if (!super.persistValues(applHost))
2070
+ return false;
2071
+ // If we actually received parameter info, store it
2072
+ if (this._valueSize > 0) {
2073
+ const valueType = this._valueFormat === safe_1.ConfigValueFormat.SignedInteger ||
2074
+ this._valueFormat === safe_1.ConfigValueFormat.UnsignedInteger
2075
+ ? "number"
2076
+ : "number[]";
2077
+ const paramInfo = (0, safe_1.stripUndefined)({
2078
+ type: valueType,
2079
+ valueFormat: this._valueFormat,
2080
+ valueSize: this._valueSize,
2081
+ minValue: this._minValue,
2082
+ maxValue: this._maxValue,
2083
+ defaultValue: this._defaultValue,
2084
+ requiresReInclusion: this._altersCapabilities,
2085
+ writeable: !this._isReadonly,
2086
+ isAdvanced: this._isAdvanced,
2087
+ noBulkSupport: this._noBulkSupport,
2088
+ });
2089
+ this.extendParamInformation(applHost, this._parameter, undefined, paramInfo);
2090
+ }
2091
+ return true;
2092
+ }
2093
+ get parameter() {
2094
+ return this._parameter;
2095
+ }
2096
+ get valueSize() {
2097
+ return this._valueSize;
2098
+ }
2099
+ get valueFormat() {
2100
+ return this._valueFormat;
2101
+ }
2102
+ get minValue() {
2103
+ return this._minValue;
2104
+ }
2105
+ get maxValue() {
2106
+ return this._maxValue;
2107
+ }
2108
+ get defaultValue() {
2109
+ return this._defaultValue;
2110
+ }
2111
+ get nextParameter() {
2112
+ return this._nextParameter;
2113
+ }
2114
+ get altersCapabilities() {
2115
+ return this._altersCapabilities;
2116
+ }
2117
+ get isReadonly() {
2118
+ return this._isReadonly;
2119
+ }
2120
+ get isAdvanced() {
2121
+ return this._isAdvanced;
2122
+ }
2123
+ get noBulkSupport() {
2124
+ return this._noBulkSupport;
2125
+ }
2126
+ toLogEntry(applHost) {
2127
+ const message = {
2128
+ "parameter #": this._parameter,
2129
+ "next param #": this._nextParameter,
2130
+ "value size": this._valueSize,
2131
+ "value format": (0, safe_2.getEnumMemberName)(safe_1.ConfigValueFormat, this._valueFormat),
2132
+ };
2133
+ if (this._minValue != undefined) {
2134
+ message["min value"] = configValueToString(this._minValue);
2135
+ }
2136
+ if (this._maxValue != undefined) {
2137
+ message["max value"] = configValueToString(this._maxValue);
2138
+ }
2139
+ if (this._defaultValue != undefined) {
2140
+ message["default value"] = configValueToString(this._defaultValue);
2141
+ }
2142
+ if (this._altersCapabilities != undefined) {
2143
+ message["alters capabilities"] = this._altersCapabilities;
2144
+ }
2145
+ if (this._isReadonly != undefined) {
2146
+ message.readonly = this._isReadonly;
2147
+ }
2148
+ if (this._isAdvanced != undefined) {
2149
+ message.advanced = this._isAdvanced;
2150
+ }
2151
+ if (this._noBulkSupport != undefined) {
2152
+ message["bulk support"] = !this._noBulkSupport;
2153
+ }
2154
+ return {
2155
+ ...super.toLogEntry(applHost),
2156
+ message,
2157
+ };
2158
+ }
2159
+ };
2160
+ ConfigurationCCPropertiesReport = __decorate([
2161
+ (0, CommandClass_1.CCCommand)(_Types_1.ConfigurationCommand.PropertiesReport)
2162
+ ], ConfigurationCCPropertiesReport);
2163
+ exports.ConfigurationCCPropertiesReport = ConfigurationCCPropertiesReport;
2164
+ let ConfigurationCCPropertiesGet = class ConfigurationCCPropertiesGet extends ConfigurationCC {
2165
+ constructor(host, options) {
2166
+ super(host, options);
2167
+ if ((0, CommandClass_1.gotDeserializationOptions)(options)) {
2168
+ // TODO: Deserialize payload
2169
+ throw new safe_1.ZWaveError(`${this.constructor.name}: deserialization not implemented`, safe_1.ZWaveErrorCodes.Deserialization_NotImplemented);
2170
+ }
2171
+ else {
2172
+ this.parameter = options.parameter;
2173
+ }
2174
+ }
2175
+ serialize() {
2176
+ this.payload = Buffer.allocUnsafe(2);
2177
+ this.payload.writeUInt16BE(this.parameter, 0);
2178
+ return super.serialize();
2179
+ }
2180
+ toLogEntry(applHost) {
2181
+ return {
2182
+ ...super.toLogEntry(applHost),
2183
+ message: { "parameter #": this.parameter },
2184
+ };
2185
+ }
2186
+ };
2187
+ ConfigurationCCPropertiesGet = __decorate([
2188
+ (0, CommandClass_1.CCCommand)(_Types_1.ConfigurationCommand.PropertiesGet),
2189
+ (0, CommandClass_1.expectedCCResponse)(ConfigurationCCPropertiesReport)
2190
+ ], ConfigurationCCPropertiesGet);
2191
+ exports.ConfigurationCCPropertiesGet = ConfigurationCCPropertiesGet;
2192
+ let ConfigurationCCDefaultReset = class ConfigurationCCDefaultReset extends ConfigurationCC {
2193
+ };
2194
+ ConfigurationCCDefaultReset = __decorate([
2195
+ (0, CommandClass_1.CCCommand)(_Types_1.ConfigurationCommand.DefaultReset)
2196
+ ], ConfigurationCCDefaultReset);
2197
+ exports.ConfigurationCCDefaultReset = ConfigurationCCDefaultReset;
2198
+ function isSafeValue(value, size, format) {
2199
+ let minValue;
2200
+ let maxValue;
2201
+ switch (format) {
2202
+ case safe_1.ConfigValueFormat.SignedInteger:
2203
+ minValue = -Math.pow(2, 8 * size - 1);
2204
+ maxValue = Math.pow(2, 8 * size - 1) - 1;
2205
+ break;
2206
+ case safe_1.ConfigValueFormat.UnsignedInteger:
2207
+ case safe_1.ConfigValueFormat.Enumerated:
2208
+ minValue = 0;
2209
+ maxValue = Math.pow(2, 8 * size);
2210
+ break;
2211
+ case safe_1.ConfigValueFormat.BitField:
2212
+ default:
2213
+ throw new Error("not implemented");
2214
+ }
2215
+ return minValue <= value && value <= maxValue;
2216
+ }
2217
+ /** Interprets values from the payload depending on the value format */
2218
+ function parseValue(raw, size, format) {
2219
+ switch (format) {
2220
+ case safe_1.ConfigValueFormat.SignedInteger:
2221
+ return raw.readIntBE(0, size);
2222
+ case safe_1.ConfigValueFormat.UnsignedInteger:
2223
+ case safe_1.ConfigValueFormat.Enumerated:
2224
+ return raw.readUIntBE(0, size);
2225
+ case safe_1.ConfigValueFormat.BitField:
2226
+ return new Set((0, safe_1.parseBitMask)(raw.slice(0, size)));
2227
+ }
2228
+ }
2229
+ function throwInvalidValueError(value, parameter, valueSize, valueFormat) {
2230
+ throw new safe_1.ZWaveError(`The value ${value} is invalid for configuration parameter ${parameter} (size = ${valueSize}, format = ${(0, safe_2.getEnumMemberName)(safe_1.ConfigValueFormat, valueFormat)})!`, safe_1.ZWaveErrorCodes.Argument_Invalid);
2231
+ }
2232
+ function tryCatchOutOfBoundsError(e, value, parameter, valueSize, valueFormat) {
2233
+ if (e.message.includes("out of bounds")) {
2234
+ throwInvalidValueError(value, parameter, valueSize, valueFormat);
2235
+ }
2236
+ else {
2237
+ throw e;
2238
+ }
2239
+ }
2240
+ /** Serializes values into the payload according to the value format */
2241
+ function serializeValue(payload, offset, size, format, value) {
2242
+ switch (format) {
2243
+ case safe_1.ConfigValueFormat.SignedInteger:
2244
+ payload.writeIntBE(value, offset, size);
2245
+ return;
2246
+ case safe_1.ConfigValueFormat.UnsignedInteger:
2247
+ case safe_1.ConfigValueFormat.Enumerated:
2248
+ payload.writeUIntBE(value, offset, size);
2249
+ return;
2250
+ case safe_1.ConfigValueFormat.BitField: {
2251
+ const mask = (0, safe_1.encodeBitMask)([...value.values()], size * 8);
2252
+ mask.copy(payload, offset);
2253
+ return;
2254
+ }
2255
+ }
2256
+ }
2257
+ //# sourceMappingURL=ConfigurationCC.js.map