@zwave-js/cc 15.16.0 → 15.18.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (254) hide show
  1. package/build/cjs/cc/AlarmSensorCC.js +1 -1
  2. package/build/cjs/cc/AlarmSensorCC.js.map +1 -1
  3. package/build/cjs/cc/ApplicationStatusCC.d.ts +33 -0
  4. package/build/cjs/cc/ApplicationStatusCC.js +229 -0
  5. package/build/cjs/cc/ApplicationStatusCC.js.map +7 -0
  6. package/build/cjs/cc/AssociationCC.js.map +1 -1
  7. package/build/cjs/cc/AssociationGroupInfoCC.js +4 -4
  8. package/build/cjs/cc/AssociationGroupInfoCC.js.map +2 -2
  9. package/build/cjs/cc/BarrierOperatorCC.js +9 -2
  10. package/build/cjs/cc/BarrierOperatorCC.js.map +2 -2
  11. package/build/cjs/cc/BasicCC.js +1 -1
  12. package/build/cjs/cc/BasicCC.js.map +1 -1
  13. package/build/cjs/cc/BatteryCC.js +2 -2
  14. package/build/cjs/cc/BatteryCC.js.map +1 -1
  15. package/build/cjs/cc/BinarySwitchCC.js +1 -1
  16. package/build/cjs/cc/BinarySwitchCC.js.map +1 -1
  17. package/build/cjs/cc/CRC16CC.js +2 -2
  18. package/build/cjs/cc/CRC16CC.js.map +2 -2
  19. package/build/cjs/cc/CentralSceneCC.js +2 -2
  20. package/build/cjs/cc/CentralSceneCC.js.map +1 -1
  21. package/build/cjs/cc/ClimateControlScheduleCC.js +5 -5
  22. package/build/cjs/cc/ClimateControlScheduleCC.js.map +2 -2
  23. package/build/cjs/cc/ClockCC.js +1 -1
  24. package/build/cjs/cc/ClockCC.js.map +1 -1
  25. package/build/cjs/cc/ColorSwitchCC.js.map +1 -1
  26. package/build/cjs/cc/ConfigurationCC.js +10 -3
  27. package/build/cjs/cc/ConfigurationCC.js.map +2 -2
  28. package/build/cjs/cc/DoorLockCC.js +3 -3
  29. package/build/cjs/cc/DoorLockCC.js.map +1 -1
  30. package/build/cjs/cc/EntryControlCC.js +3 -6
  31. package/build/cjs/cc/EntryControlCC.js.map +2 -2
  32. package/build/cjs/cc/IndicatorCC.js +5 -5
  33. package/build/cjs/cc/IndicatorCC.js.map +2 -2
  34. package/build/cjs/cc/IrrigationCC.js +3 -3
  35. package/build/cjs/cc/IrrigationCC.js.map +1 -1
  36. package/build/cjs/cc/LanguageCC.js +1 -1
  37. package/build/cjs/cc/LanguageCC.js.map +1 -1
  38. package/build/cjs/cc/ManufacturerProprietaryCC.js +1 -1
  39. package/build/cjs/cc/ManufacturerProprietaryCC.js.map +2 -2
  40. package/build/cjs/cc/ManufacturerSpecificCC.js +1 -1
  41. package/build/cjs/cc/ManufacturerSpecificCC.js.map +1 -1
  42. package/build/cjs/cc/MeterCC.js +3 -3
  43. package/build/cjs/cc/MeterCC.js.map +2 -2
  44. package/build/cjs/cc/MultiChannelAssociationCC.js.map +1 -1
  45. package/build/cjs/cc/MultiChannelCC.js +8 -8
  46. package/build/cjs/cc/MultiChannelCC.js.map +2 -2
  47. package/build/cjs/cc/MultilevelSensorCC.js.map +1 -1
  48. package/build/cjs/cc/MultilevelSwitchCC.js +1 -1
  49. package/build/cjs/cc/MultilevelSwitchCC.js.map +1 -1
  50. package/build/cjs/cc/NotificationCC.js +29 -23
  51. package/build/cjs/cc/NotificationCC.js.map +2 -2
  52. package/build/cjs/cc/ProtectionCC.js +10 -3
  53. package/build/cjs/cc/ProtectionCC.js.map +2 -2
  54. package/build/cjs/cc/SceneActuatorConfigurationCC.js +0 -1
  55. package/build/cjs/cc/SceneActuatorConfigurationCC.js.map +2 -2
  56. package/build/cjs/cc/SceneControllerConfigurationCC.js +0 -1
  57. package/build/cjs/cc/SceneControllerConfigurationCC.js.map +2 -2
  58. package/build/cjs/cc/ScheduleEntryLockCC.js +1 -1
  59. package/build/cjs/cc/ScheduleEntryLockCC.js.map +1 -1
  60. package/build/cjs/cc/Security2CC.js +6 -5
  61. package/build/cjs/cc/Security2CC.js.map +2 -2
  62. package/build/cjs/cc/SecurityCC.js +3 -3
  63. package/build/cjs/cc/SecurityCC.js.map +2 -2
  64. package/build/cjs/cc/SoundSwitchCC._validateArgs.js +1 -1
  65. package/build/cjs/cc/SoundSwitchCC._validateArgs.js.map +1 -1
  66. package/build/cjs/cc/SoundSwitchCC.d.ts +7 -3
  67. package/build/cjs/cc/SoundSwitchCC.js +6 -6
  68. package/build/cjs/cc/SoundSwitchCC.js.map +2 -2
  69. package/build/cjs/cc/SupervisionCC.js +1 -1
  70. package/build/cjs/cc/SupervisionCC.js.map +2 -2
  71. package/build/cjs/cc/ThermostatFanModeCC.js +1 -1
  72. package/build/cjs/cc/ThermostatFanModeCC.js.map +1 -1
  73. package/build/cjs/cc/ThermostatFanStateCC.js +1 -1
  74. package/build/cjs/cc/ThermostatFanStateCC.js.map +1 -1
  75. package/build/cjs/cc/ThermostatModeCC.js +2 -2
  76. package/build/cjs/cc/ThermostatModeCC.js.map +2 -2
  77. package/build/cjs/cc/ThermostatSetbackCC.js +1 -1
  78. package/build/cjs/cc/ThermostatSetbackCC.js.map +1 -1
  79. package/build/cjs/cc/ThermostatSetpointCC.js.map +1 -1
  80. package/build/cjs/cc/TimeCC.js +2 -2
  81. package/build/cjs/cc/TimeCC.js.map +1 -1
  82. package/build/cjs/cc/TransportServiceCC.js +1 -1
  83. package/build/cjs/cc/TransportServiceCC.js.map +2 -2
  84. package/build/cjs/cc/UserCodeCC.d.ts +9 -1
  85. package/build/cjs/cc/UserCodeCC.js +50 -8
  86. package/build/cjs/cc/UserCodeCC.js.map +2 -2
  87. package/build/cjs/cc/VersionCC.js +3 -3
  88. package/build/cjs/cc/VersionCC.js.map +1 -1
  89. package/build/cjs/cc/WakeUpCC.js +2 -2
  90. package/build/cjs/cc/WakeUpCC.js.map +1 -1
  91. package/build/cjs/cc/WindowCoveringCC.d.ts +3 -1
  92. package/build/cjs/cc/WindowCoveringCC.js +28 -8
  93. package/build/cjs/cc/WindowCoveringCC.js.map +2 -2
  94. package/build/cjs/cc/ZWavePlusCC.js +1 -1
  95. package/build/cjs/cc/ZWavePlusCC.js.map +1 -1
  96. package/build/cjs/cc/ZWaveProtocolCC.js.map +2 -2
  97. package/build/cjs/cc/_CCValues.generated.js.map +1 -1
  98. package/build/cjs/cc/index.d.ts +3 -0
  99. package/build/cjs/cc/index.js +553 -65
  100. package/build/cjs/cc/index.js.map +2 -2
  101. package/build/cjs/cc/manufacturerProprietary/FibaroCC.js +1 -1
  102. package/build/cjs/cc/manufacturerProprietary/FibaroCC.js.map +1 -1
  103. package/build/cjs/lib/API.d.ts +2 -0
  104. package/build/cjs/lib/API.js +2 -2
  105. package/build/cjs/lib/API.js.map +2 -2
  106. package/build/cjs/lib/CommandClass.d.ts +3 -3
  107. package/build/cjs/lib/CommandClass.js +6 -6
  108. package/build/cjs/lib/CommandClass.js.map +2 -2
  109. package/build/cjs/lib/_Types.d.ts +9 -0
  110. package/build/cjs/lib/_Types.js +15 -0
  111. package/build/cjs/lib/_Types.js.map +3 -3
  112. package/build/cjs/lib/utils.js +1 -1
  113. package/build/cjs/lib/utils.js.map +2 -2
  114. package/build/esm/cc/AlarmSensorCC.js +1 -1
  115. package/build/esm/cc/AlarmSensorCC.js.map +1 -1
  116. package/build/esm/cc/ApplicationStatusCC.d.ts +33 -0
  117. package/build/esm/cc/ApplicationStatusCC.d.ts.map +1 -0
  118. package/build/esm/cc/ApplicationStatusCC.js +175 -0
  119. package/build/esm/cc/ApplicationStatusCC.js.map +1 -0
  120. package/build/esm/cc/AssociationGroupInfoCC.d.ts.map +1 -1
  121. package/build/esm/cc/AssociationGroupInfoCC.js +4 -4
  122. package/build/esm/cc/AssociationGroupInfoCC.js.map +1 -1
  123. package/build/esm/cc/BarrierOperatorCC.d.ts.map +1 -1
  124. package/build/esm/cc/BarrierOperatorCC.js +13 -2
  125. package/build/esm/cc/BarrierOperatorCC.js.map +1 -1
  126. package/build/esm/cc/BasicCC.js +1 -1
  127. package/build/esm/cc/BasicCC.js.map +1 -1
  128. package/build/esm/cc/BatteryCC.js +2 -2
  129. package/build/esm/cc/BatteryCC.js.map +1 -1
  130. package/build/esm/cc/BinarySwitchCC.js +1 -1
  131. package/build/esm/cc/BinarySwitchCC.js.map +1 -1
  132. package/build/esm/cc/CRC16CC.d.ts.map +1 -1
  133. package/build/esm/cc/CRC16CC.js +2 -2
  134. package/build/esm/cc/CRC16CC.js.map +1 -1
  135. package/build/esm/cc/CentralSceneCC.js +2 -2
  136. package/build/esm/cc/CentralSceneCC.js.map +1 -1
  137. package/build/esm/cc/ClimateControlScheduleCC.d.ts.map +1 -1
  138. package/build/esm/cc/ClimateControlScheduleCC.js +5 -5
  139. package/build/esm/cc/ClimateControlScheduleCC.js.map +1 -1
  140. package/build/esm/cc/ClockCC.js +1 -1
  141. package/build/esm/cc/ClockCC.js.map +1 -1
  142. package/build/esm/cc/ConfigurationCC.d.ts.map +1 -1
  143. package/build/esm/cc/ConfigurationCC.js +12 -4
  144. package/build/esm/cc/ConfigurationCC.js.map +1 -1
  145. package/build/esm/cc/DoorLockCC.js +3 -3
  146. package/build/esm/cc/DoorLockCC.js.map +1 -1
  147. package/build/esm/cc/EntryControlCC.d.ts.map +1 -1
  148. package/build/esm/cc/EntryControlCC.js +4 -6
  149. package/build/esm/cc/EntryControlCC.js.map +1 -1
  150. package/build/esm/cc/IndicatorCC.d.ts.map +1 -1
  151. package/build/esm/cc/IndicatorCC.js +6 -6
  152. package/build/esm/cc/IndicatorCC.js.map +1 -1
  153. package/build/esm/cc/IrrigationCC.js +3 -3
  154. package/build/esm/cc/IrrigationCC.js.map +1 -1
  155. package/build/esm/cc/LanguageCC.js +1 -1
  156. package/build/esm/cc/LanguageCC.js.map +1 -1
  157. package/build/esm/cc/ManufacturerProprietaryCC.d.ts.map +1 -1
  158. package/build/esm/cc/ManufacturerProprietaryCC.js +1 -1
  159. package/build/esm/cc/ManufacturerProprietaryCC.js.map +1 -1
  160. package/build/esm/cc/ManufacturerSpecificCC.js +1 -1
  161. package/build/esm/cc/ManufacturerSpecificCC.js.map +1 -1
  162. package/build/esm/cc/MeterCC.d.ts.map +1 -1
  163. package/build/esm/cc/MeterCC.js +3 -3
  164. package/build/esm/cc/MeterCC.js.map +1 -1
  165. package/build/esm/cc/MultiChannelCC.d.ts.map +1 -1
  166. package/build/esm/cc/MultiChannelCC.js +8 -8
  167. package/build/esm/cc/MultiChannelCC.js.map +1 -1
  168. package/build/esm/cc/MultilevelSwitchCC.js +1 -1
  169. package/build/esm/cc/MultilevelSwitchCC.js.map +1 -1
  170. package/build/esm/cc/NotificationCC.d.ts.map +1 -1
  171. package/build/esm/cc/NotificationCC.js +43 -31
  172. package/build/esm/cc/NotificationCC.js.map +1 -1
  173. package/build/esm/cc/ProtectionCC.d.ts.map +1 -1
  174. package/build/esm/cc/ProtectionCC.js +16 -3
  175. package/build/esm/cc/ProtectionCC.js.map +1 -1
  176. package/build/esm/cc/SceneActuatorConfigurationCC.d.ts.map +1 -1
  177. package/build/esm/cc/SceneActuatorConfigurationCC.js +0 -1
  178. package/build/esm/cc/SceneActuatorConfigurationCC.js.map +1 -1
  179. package/build/esm/cc/SceneControllerConfigurationCC.d.ts.map +1 -1
  180. package/build/esm/cc/SceneControllerConfigurationCC.js +0 -1
  181. package/build/esm/cc/SceneControllerConfigurationCC.js.map +1 -1
  182. package/build/esm/cc/ScheduleEntryLockCC.js +1 -1
  183. package/build/esm/cc/ScheduleEntryLockCC.js.map +1 -1
  184. package/build/esm/cc/Security2CC.d.ts.map +1 -1
  185. package/build/esm/cc/Security2CC.js +6 -5
  186. package/build/esm/cc/Security2CC.js.map +1 -1
  187. package/build/esm/cc/SecurityCC.d.ts.map +1 -1
  188. package/build/esm/cc/SecurityCC.js +3 -3
  189. package/build/esm/cc/SecurityCC.js.map +1 -1
  190. package/build/esm/cc/SoundSwitchCC._validateArgs.js +1 -1
  191. package/build/esm/cc/SoundSwitchCC._validateArgs.js.map +1 -1
  192. package/build/esm/cc/SoundSwitchCC.d.ts +7 -3
  193. package/build/esm/cc/SoundSwitchCC.d.ts.map +1 -1
  194. package/build/esm/cc/SoundSwitchCC.js +6 -6
  195. package/build/esm/cc/SoundSwitchCC.js.map +1 -1
  196. package/build/esm/cc/SupervisionCC.js +1 -1
  197. package/build/esm/cc/SupervisionCC.js.map +1 -1
  198. package/build/esm/cc/ThermostatFanModeCC.js +1 -1
  199. package/build/esm/cc/ThermostatFanModeCC.js.map +1 -1
  200. package/build/esm/cc/ThermostatFanStateCC.js +1 -1
  201. package/build/esm/cc/ThermostatFanStateCC.js.map +1 -1
  202. package/build/esm/cc/ThermostatModeCC.js +2 -2
  203. package/build/esm/cc/ThermostatModeCC.js.map +1 -1
  204. package/build/esm/cc/ThermostatSetbackCC.js +1 -1
  205. package/build/esm/cc/ThermostatSetbackCC.js.map +1 -1
  206. package/build/esm/cc/TimeCC.js +2 -2
  207. package/build/esm/cc/TimeCC.js.map +1 -1
  208. package/build/esm/cc/TransportServiceCC.d.ts.map +1 -1
  209. package/build/esm/cc/TransportServiceCC.js +2 -1
  210. package/build/esm/cc/TransportServiceCC.js.map +1 -1
  211. package/build/esm/cc/UserCodeCC.d.ts +9 -1
  212. package/build/esm/cc/UserCodeCC.d.ts.map +1 -1
  213. package/build/esm/cc/UserCodeCC.js +61 -12
  214. package/build/esm/cc/UserCodeCC.js.map +1 -1
  215. package/build/esm/cc/VersionCC.js +3 -3
  216. package/build/esm/cc/VersionCC.js.map +1 -1
  217. package/build/esm/cc/WakeUpCC.js +2 -2
  218. package/build/esm/cc/WakeUpCC.js.map +1 -1
  219. package/build/esm/cc/WindowCoveringCC.d.ts +3 -1
  220. package/build/esm/cc/WindowCoveringCC.d.ts.map +1 -1
  221. package/build/esm/cc/WindowCoveringCC.js +30 -9
  222. package/build/esm/cc/WindowCoveringCC.js.map +1 -1
  223. package/build/esm/cc/ZWavePlusCC.js +1 -1
  224. package/build/esm/cc/ZWavePlusCC.js.map +1 -1
  225. package/build/esm/cc/ZWaveProtocolCC.d.ts.map +1 -1
  226. package/build/esm/cc/ZWaveProtocolCC.js.map +1 -1
  227. package/build/esm/cc/index.d.ts +3 -0
  228. package/build/esm/cc/index.d.ts.map +1 -1
  229. package/build/esm/cc/index.js +548 -524
  230. package/build/esm/cc/index.js.map +1 -1
  231. package/build/esm/cc/manufacturerProprietary/FibaroCC.js +1 -1
  232. package/build/esm/cc/manufacturerProprietary/FibaroCC.js.map +1 -1
  233. package/build/esm/lib/API.d.ts +2 -0
  234. package/build/esm/lib/API.d.ts.map +1 -1
  235. package/build/esm/lib/API.js +2 -2
  236. package/build/esm/lib/API.js.map +1 -1
  237. package/build/esm/lib/CommandClass.d.ts +3 -3
  238. package/build/esm/lib/CommandClass.d.ts.map +1 -1
  239. package/build/esm/lib/CommandClass.js +6 -6
  240. package/build/esm/lib/CommandClass.js.map +1 -1
  241. package/build/esm/lib/_Types.d.ts +9 -0
  242. package/build/esm/lib/_Types.d.ts.map +1 -1
  243. package/build/esm/lib/_Types.js +11 -0
  244. package/build/esm/lib/_Types.js.map +1 -1
  245. package/build/esm/lib/utils.js +1 -1
  246. package/build/esm/lib/utils.js.map +1 -1
  247. package/package.json +10 -11
  248. package/build/cjs/lib/ICommandClassContainer.d.ts +0 -2
  249. package/build/cjs/lib/ICommandClassContainer.js +0 -17
  250. package/build/cjs/lib/ICommandClassContainer.js.map +0 -7
  251. package/build/esm/lib/ICommandClassContainer.d.ts +0 -2
  252. package/build/esm/lib/ICommandClassContainer.d.ts.map +0 -1
  253. package/build/esm/lib/ICommandClassContainer.js +0 -2
  254. package/build/esm/lib/ICommandClassContainer.js.map +0 -1
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/cc/ThermostatSetpointCC.ts"],
4
- "sourcesContent": ["import type { CCEncodingContext, CCParsingContext } from \"@zwave-js/cc\";\nimport {\n\tCommandClasses,\n\ttype GetValueDB,\n\ttype MaybeNotKnown,\n\ttype MessageOrCCLogEntry,\n\tMessagePriority,\n\ttype Scale,\n\ttype SupervisionResult,\n\tValueMetadata,\n\ttype ValueMetadataNumeric,\n\ttype WithAddress,\n\tZWaveError,\n\tZWaveErrorCodes,\n\tencodeBitMask,\n\tencodeFloatWithScale,\n\tgetNamedScale,\n\tgetUnknownScale,\n\tparseBitMask,\n\tparseFloatWithScale,\n\tsupervisedCommandSucceeded,\n\tvalidatePayload,\n} from \"@zwave-js/core\";\nimport { Bytes, getEnumMemberName, pick } from \"@zwave-js/shared\";\nimport { validateArgs } from \"@zwave-js/transformers\";\nimport {\n\tCCAPI,\n\tPOLL_VALUE,\n\ttype PollValueImplementation,\n\tSET_VALUE,\n\ttype SetValueImplementation,\n\tthrowUnsupportedProperty,\n\tthrowWrongValueType,\n} from \"../lib/API.js\";\nimport {\n\ttype CCRaw,\n\tCommandClass,\n\ttype InterviewContext,\n\ttype PersistValuesContext,\n\ttype RefreshValuesContext,\n} from \"../lib/CommandClass.js\";\nimport {\n\tAPI,\n\tCCCommand,\n\tccValueProperty,\n\tccValues,\n\tcommandClass,\n\texpectedCCResponse,\n\timplementedVersion,\n\tuseSupervision,\n} from \"../lib/CommandClassDecorators.js\";\nimport { V } from \"../lib/Values.js\";\nimport {\n\tThermostatSetpointCommand,\n\tThermostatSetpointType,\n} from \"../lib/_Types.js\";\n\n// This array is used to map the advertised supported types (interpretation A)\n// to the actual enum values\nconst thermostatSetpointTypeMap = [\n\t0x00,\n\t0x01,\n\t0x02,\n\t0x07,\n\t0x08,\n\t0x09,\n\t0x0a,\n\t0x0b,\n\t0x0c,\n\t0x0d,\n\t0x0e,\n\t0x0f,\n];\n\nfunction getScale(scale: number): Scale {\n\treturn getNamedScale(\"temperature\", scale as any)\n\t\t?? getUnknownScale(scale);\n}\nfunction getSetpointUnit(scale: number): string {\n\treturn getScale(scale).unit ?? \"\";\n}\n\nexport const ThermostatSetpointCCValues = V.defineCCValues(\n\tCommandClasses[\"Thermostat Setpoint\"],\n\t{\n\t\t...V.staticProperty(\"supportedSetpointTypes\", undefined, {\n\t\t\tinternal: true,\n\t\t}),\n\t\t...V.dynamicPropertyAndKeyWithName(\n\t\t\t\"setpoint\",\n\t\t\t\"setpoint\",\n\t\t\t(setpointType: ThermostatSetpointType) => setpointType,\n\t\t\t({ property, propertyKey }) =>\n\t\t\t\tproperty === \"setpoint\" && typeof propertyKey === \"number\",\n\t\t\t(setpointType: ThermostatSetpointType) => ({\n\t\t\t\t...ValueMetadata.Number,\n\t\t\t\tlabel: `Setpoint (${\n\t\t\t\t\tgetEnumMemberName(\n\t\t\t\t\t\tThermostatSetpointType,\n\t\t\t\t\t\tsetpointType,\n\t\t\t\t\t)\n\t\t\t\t})`,\n\t\t\t\tccSpecific: { setpointType },\n\t\t\t} as const),\n\t\t),\n\t\t...V.dynamicPropertyAndKeyWithName(\n\t\t\t\"setpointScale\",\n\t\t\t\"setpointScale\",\n\t\t\t(setpointType: ThermostatSetpointType) => setpointType,\n\t\t\t({ property, propertyKey }) =>\n\t\t\t\tproperty === \"setpointScale\" && typeof propertyKey === \"number\",\n\t\t\tundefined,\n\t\t\t{ internal: true },\n\t\t),\n\t},\n);\n\n@API(CommandClasses[\"Thermostat Setpoint\"])\nexport class ThermostatSetpointCCAPI extends CCAPI {\n\tpublic supportsCommand(\n\t\tcmd: ThermostatSetpointCommand,\n\t): MaybeNotKnown<boolean> {\n\t\tswitch (cmd) {\n\t\t\tcase ThermostatSetpointCommand.Get:\n\t\t\tcase ThermostatSetpointCommand.SupportedGet:\n\t\t\t\treturn this.isSinglecast();\n\t\t\tcase ThermostatSetpointCommand.Set:\n\t\t\t\treturn true; // This is mandatory\n\t\t\tcase ThermostatSetpointCommand.CapabilitiesGet:\n\t\t\t\treturn this.version >= 3 && this.isSinglecast();\n\t\t}\n\t\treturn super.supportsCommand(cmd);\n\t}\n\n\tprotected override get [SET_VALUE](): SetValueImplementation {\n\t\treturn async function(\n\t\t\tthis: ThermostatSetpointCCAPI,\n\t\t\t{ property, propertyKey },\n\t\t\tvalue,\n\t\t) {\n\t\t\tif (property !== \"setpoint\") {\n\t\t\t\tthrowUnsupportedProperty(this.ccId, property);\n\t\t\t}\n\t\t\tif (typeof propertyKey !== \"number\") {\n\t\t\t\tthrow new ZWaveError(\n\t\t\t\t\t`${\n\t\t\t\t\t\tCommandClasses[this.ccId]\n\t\t\t\t\t}: \"${property}\" must be further specified by a numeric property key`,\n\t\t\t\t\tZWaveErrorCodes.Argument_Invalid,\n\t\t\t\t);\n\t\t\t}\n\t\t\tif (typeof value !== \"number\") {\n\t\t\t\tthrowWrongValueType(\n\t\t\t\t\tthis.ccId,\n\t\t\t\t\tproperty,\n\t\t\t\t\t\"number\",\n\t\t\t\t\ttypeof value,\n\t\t\t\t);\n\t\t\t}\n\n\t\t\t// SDS14223: The Scale field value MUST be identical to the value received in the Thermostat Setpoint Report for the\n\t\t\t// actual Setpoint Type during the node interview. Fall back to the first scale if none is known\n\t\t\tconst preferredScale = this.tryGetValueDB()?.getValue<number>(\n\t\t\t\tThermostatSetpointCCValues.setpointScale(propertyKey).endpoint(\n\t\t\t\t\tthis.endpoint.index,\n\t\t\t\t),\n\t\t\t);\n\t\t\tconst result = await this.set(\n\t\t\t\tpropertyKey,\n\t\t\t\tvalue,\n\t\t\t\tpreferredScale ?? 0,\n\t\t\t);\n\n\t\t\t// Verify the current value after a delay, unless the command was supervised and successful\n\t\t\tif (this.isSinglecast() && !supervisedCommandSucceeded(result)) {\n\t\t\t\t// TODO: Ideally this would be a short delay, but some thermostats like Remotec ZXT-600\n\t\t\t\t// aren't able to handle the GET this quickly.\n\t\t\t\tthis.schedulePoll({ property, propertyKey }, value);\n\t\t\t}\n\n\t\t\treturn result;\n\t\t};\n\t}\n\n\tprotected get [POLL_VALUE](): PollValueImplementation {\n\t\treturn async function(\n\t\t\tthis: ThermostatSetpointCCAPI,\n\t\t\t{ property, propertyKey },\n\t\t) {\n\t\t\tswitch (property) {\n\t\t\t\tcase \"setpoint\":\n\t\t\t\t\tif (typeof propertyKey !== \"number\") {\n\t\t\t\t\t\tthrow new ZWaveError(\n\t\t\t\t\t\t\t`${\n\t\t\t\t\t\t\t\tCommandClasses[this.ccId]\n\t\t\t\t\t\t\t}: \"${property}\" must be further specified by a numeric property key`,\n\t\t\t\t\t\t\tZWaveErrorCodes.Argument_Invalid,\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\n\t\t\t\t\treturn (await this.get(propertyKey))?.value;\n\t\t\t\tdefault:\n\t\t\t\t\tthrowUnsupportedProperty(this.ccId, property);\n\t\t\t}\n\t\t};\n\t}\n\n\t@validateArgs()\n\tpublic async get(\n\t\tsetpointType: ThermostatSetpointType,\n\t): Promise<{ value: number; scale: Scale } | undefined> {\n\t\tthis.assertSupportsCommand(\n\t\t\tThermostatSetpointCommand,\n\t\t\tThermostatSetpointCommand.Get,\n\t\t);\n\n\t\tconst cc = new ThermostatSetpointCCGet({\n\t\t\tnodeId: this.endpoint.nodeId,\n\t\t\tendpointIndex: this.endpoint.index,\n\t\t\tsetpointType,\n\t\t});\n\t\tconst response = await this.host.sendCommand<\n\t\t\tThermostatSetpointCCReport\n\t\t>(\n\t\t\tcc,\n\t\t\tthis.commandOptions,\n\t\t);\n\t\tif (!response) return;\n\t\tif (response.type !== ThermostatSetpointType[\"N/A\"]) {\n\t\t\t// This is a supported setpoint\n\t\t\tconst scale = getScale(response.scale);\n\t\t\treturn {\n\t\t\t\tvalue: response.value,\n\t\t\t\tscale,\n\t\t\t};\n\t\t}\n\t}\n\n\t@validateArgs()\n\tpublic async set(\n\t\tsetpointType: ThermostatSetpointType,\n\t\tvalue: number,\n\t\tscale: number,\n\t): Promise<SupervisionResult | undefined> {\n\t\tthis.assertSupportsCommand(\n\t\t\tThermostatSetpointCommand,\n\t\t\tThermostatSetpointCommand.Set,\n\t\t);\n\n\t\tconst cc = new ThermostatSetpointCCSet({\n\t\t\tnodeId: this.endpoint.nodeId,\n\t\t\tendpointIndex: this.endpoint.index,\n\t\t\tsetpointType,\n\t\t\tvalue,\n\t\t\tscale,\n\t\t});\n\t\treturn this.host.sendCommand(cc, this.commandOptions);\n\t}\n\n\t@validateArgs()\n\t// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types\n\tpublic async getCapabilities(setpointType: ThermostatSetpointType) {\n\t\tthis.assertSupportsCommand(\n\t\t\tThermostatSetpointCommand,\n\t\t\tThermostatSetpointCommand.CapabilitiesGet,\n\t\t);\n\n\t\tconst cc = new ThermostatSetpointCCCapabilitiesGet({\n\t\t\tnodeId: this.endpoint.nodeId,\n\t\t\tendpointIndex: this.endpoint.index,\n\t\t\tsetpointType,\n\t\t});\n\t\tconst response = await this.host.sendCommand<\n\t\t\tThermostatSetpointCCCapabilitiesReport\n\t\t>(\n\t\t\tcc,\n\t\t\tthis.commandOptions,\n\t\t);\n\t\tif (response) {\n\t\t\treturn pick(response, [\n\t\t\t\t\"minValue\",\n\t\t\t\t\"maxValue\",\n\t\t\t\t\"minValueScale\",\n\t\t\t\t\"maxValueScale\",\n\t\t\t]);\n\t\t}\n\t}\n\n\t/**\n\t * Requests the supported setpoint types from the node. Due to inconsistencies it is NOT recommended\n\t * to use this method on nodes with CC versions 1 and 2. Instead rely on the information determined\n\t * during node interview.\n\t */\n\tpublic async getSupportedSetpointTypes(): Promise<\n\t\tMaybeNotKnown<readonly ThermostatSetpointType[]>\n\t> {\n\t\tthis.assertSupportsCommand(\n\t\t\tThermostatSetpointCommand,\n\t\t\tThermostatSetpointCommand.SupportedGet,\n\t\t);\n\n\t\tconst cc = new ThermostatSetpointCCSupportedGet({\n\t\t\tnodeId: this.endpoint.nodeId,\n\t\t\tendpointIndex: this.endpoint.index,\n\t\t});\n\t\tconst response = await this.host.sendCommand<\n\t\t\tThermostatSetpointCCSupportedReport\n\t\t>(\n\t\t\tcc,\n\t\t\tthis.commandOptions,\n\t\t);\n\t\treturn response?.supportedSetpointTypes;\n\t}\n}\n\n@commandClass(CommandClasses[\"Thermostat Setpoint\"])\n@implementedVersion(3)\n@ccValues(ThermostatSetpointCCValues)\nexport class ThermostatSetpointCC extends CommandClass {\n\tdeclare ccCommand: ThermostatSetpointCommand;\n\n\tpublic translatePropertyKey(\n\t\tctx: GetValueDB,\n\t\tproperty: string | number,\n\t\tpropertyKey: string | number,\n\t): string | undefined {\n\t\tif (property === \"setpoint\") {\n\t\t\treturn getEnumMemberName(\n\t\t\t\tThermostatSetpointType,\n\t\t\t\tpropertyKey as any,\n\t\t\t);\n\t\t} else {\n\t\t\treturn super.translatePropertyKey(ctx, property, propertyKey);\n\t\t}\n\t}\n\n\tpublic async interview(\n\t\tctx: InterviewContext,\n\t): Promise<void> {\n\t\tconst node = this.getNode(ctx)!;\n\t\tconst endpoint = this.getEndpoint(ctx)!;\n\t\tconst api = CCAPI.create(\n\t\t\tCommandClasses[\"Thermostat Setpoint\"],\n\t\t\tctx,\n\t\t\tendpoint,\n\t\t).withOptions({\n\t\t\tpriority: MessagePriority.NodeQuery,\n\t\t});\n\n\t\tctx.logNode(node.id, {\n\t\t\tendpoint: this.endpointIndex,\n\t\t\tmessage: `Interviewing ${this.ccName}...`,\n\t\t\tdirection: \"none\",\n\t\t});\n\n\t\tif (api.version <= 2) {\n\t\t\t// It has been found that early implementations of this Command Class applied two non-interoperable\n\t\t\t// interpretations of the bit mask advertising the support for specific Setpoint Types in the Thermostat\n\t\t\t// Setpoint Supported Report Command.\n\t\t\t// A controlling node SHOULD determine the supported Setpoint Types of a version 1 and version 2\n\t\t\t// supporting node by sending one Thermostat Setpoint Get Command at a time while incrementing\n\t\t\t// the requested Setpoint Type.\n\t\t\t// If the same Setpoint Type is advertised in the returned Thermostat Setpoint Report Command, the\n\t\t\t// controlling node MUST conclude that the actual Setpoint Type is supported.\n\t\t\t// If the Setpoint Type 0x00 (type N/A) is advertised in the returned Thermostat Setpoint Report\n\t\t\t// Command, the controlling node MUST conclude that the actual Setpoint Type is not supported.\n\n\t\t\t// The specs require us to query the list of supported setpoint types anyways, even if the response is ignored\n\t\t\tawait api.getSupportedSetpointTypes();\n\n\t\t\t// Now scan all endpoints. Each type we received a value for gets marked as supported\n\t\t\tconst supportedSetpointTypes: ThermostatSetpointType[] = [];\n\t\t\tfor (\n\t\t\t\tlet type: ThermostatSetpointType =\n\t\t\t\t\tThermostatSetpointType.Heating;\n\t\t\t\ttype <= ThermostatSetpointType[\"Full Power\"];\n\t\t\t\ttype++\n\t\t\t) {\n\t\t\t\tconst setpointName = getEnumMemberName(\n\t\t\t\t\tThermostatSetpointType,\n\t\t\t\t\ttype,\n\t\t\t\t);\n\t\t\t\t// Every time, query the current value\n\t\t\t\tctx.logNode(node.id, {\n\t\t\t\t\tendpoint: this.endpointIndex,\n\t\t\t\t\tmessage:\n\t\t\t\t\t\t`querying current value of setpoint ${setpointName}...`,\n\t\t\t\t\tdirection: \"outbound\",\n\t\t\t\t});\n\n\t\t\t\tconst setpoint = await api.get(type);\n\t\t\t\t// If the node did not respond, assume the setpoint type is not supported\n\n\t\t\t\tlet logMessage: string;\n\t\t\t\tif (setpoint) {\n\t\t\t\t\t// Setpoint supported, remember the type\n\t\t\t\t\tsupportedSetpointTypes.push(type);\n\t\t\t\t\tlogMessage =\n\t\t\t\t\t\t`received current value of setpoint ${setpointName}: ${setpoint.value} ${\n\t\t\t\t\t\t\tsetpoint.scale.unit ?? \"\"\n\t\t\t\t\t\t}`;\n\t\t\t\t} else {\n\t\t\t\t\t// We're sure about the interpretation - this should not happen\n\t\t\t\t\tlogMessage = `setpoint ${setpointName} is not supported`;\n\t\t\t\t}\n\t\t\t\tctx.logNode(node.id, {\n\t\t\t\t\tendpoint: this.endpointIndex,\n\t\t\t\t\tmessage: logMessage,\n\t\t\t\t\tdirection: \"inbound\",\n\t\t\t\t});\n\t\t\t}\n\n\t\t\t// Remember which setpoint types are actually supported\n\t\t\tthis.setValue(\n\t\t\t\tctx,\n\t\t\t\tThermostatSetpointCCValues.supportedSetpointTypes,\n\t\t\t\tsupportedSetpointTypes,\n\t\t\t);\n\t\t} else {\n\t\t\t// Versions >= 3 adhere to bitmap interpretation A, so we can rely on getSupportedSetpointTypes\n\n\t\t\t// Query the supported setpoint types\n\t\t\tlet setpointTypes: ThermostatSetpointType[] = [];\n\t\t\tctx.logNode(node.id, {\n\t\t\t\tendpoint: this.endpointIndex,\n\t\t\t\tmessage: \"retrieving supported setpoint types...\",\n\t\t\t\tdirection: \"outbound\",\n\t\t\t});\n\t\t\tconst resp = await api.getSupportedSetpointTypes();\n\t\t\tif (resp) {\n\t\t\t\tsetpointTypes = [...resp];\n\t\t\t\tconst logMessage = \"received supported setpoint types:\\n\"\n\t\t\t\t\t+ setpointTypes\n\t\t\t\t\t\t.map((type) =>\n\t\t\t\t\t\t\tgetEnumMemberName(ThermostatSetpointType, type)\n\t\t\t\t\t\t)\n\t\t\t\t\t\t.map((name) => `\u00B7 ${name}`)\n\t\t\t\t\t\t.join(\"\\n\");\n\t\t\t\tctx.logNode(node.id, {\n\t\t\t\t\tendpoint: this.endpointIndex,\n\t\t\t\t\tmessage: logMessage,\n\t\t\t\t\tdirection: \"inbound\",\n\t\t\t\t});\n\t\t\t} else {\n\t\t\t\tctx.logNode(node.id, {\n\t\t\t\t\tendpoint: this.endpointIndex,\n\t\t\t\t\tmessage:\n\t\t\t\t\t\t\"Querying supported setpoint types timed out, skipping interview...\",\n\t\t\t\t\tlevel: \"warn\",\n\t\t\t\t});\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tfor (const type of setpointTypes) {\n\t\t\t\tconst setpointName = getEnumMemberName(\n\t\t\t\t\tThermostatSetpointType,\n\t\t\t\t\ttype,\n\t\t\t\t);\n\t\t\t\t// Find out the capabilities of this setpoint\n\t\t\t\tctx.logNode(node.id, {\n\t\t\t\t\tendpoint: this.endpointIndex,\n\t\t\t\t\tmessage:\n\t\t\t\t\t\t`retrieving capabilities for setpoint ${setpointName}...`,\n\t\t\t\t\tdirection: \"outbound\",\n\t\t\t\t});\n\t\t\t\tconst setpointCaps = await api.getCapabilities(type);\n\t\t\t\tif (setpointCaps) {\n\t\t\t\t\tconst minValueUnit = getSetpointUnit(\n\t\t\t\t\t\tsetpointCaps.minValueScale,\n\t\t\t\t\t);\n\t\t\t\t\tconst maxValueUnit = getSetpointUnit(\n\t\t\t\t\t\tsetpointCaps.maxValueScale,\n\t\t\t\t\t);\n\t\t\t\t\tconst logMessage =\n\t\t\t\t\t\t`received capabilities for setpoint ${setpointName}:\nminimum value: ${setpointCaps.minValue} ${minValueUnit}\nmaximum value: ${setpointCaps.maxValue} ${maxValueUnit}`;\n\t\t\t\t\tctx.logNode(node.id, {\n\t\t\t\t\t\tendpoint: this.endpointIndex,\n\t\t\t\t\t\tmessage: logMessage,\n\t\t\t\t\t\tdirection: \"inbound\",\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Query the current value for all setpoint types\n\t\t\tawait this.refreshValues(ctx);\n\t\t}\n\n\t\t// Remember that the interview is complete\n\t\tthis.setInterviewComplete(ctx, true);\n\t}\n\n\tpublic async refreshValues(\n\t\tctx: RefreshValuesContext,\n\t): Promise<void> {\n\t\tconst node = this.getNode(ctx)!;\n\t\tconst endpoint = this.getEndpoint(ctx)!;\n\t\tconst api = CCAPI.create(\n\t\t\tCommandClasses[\"Thermostat Setpoint\"],\n\t\t\tctx,\n\t\t\tendpoint,\n\t\t).withOptions({\n\t\t\tpriority: MessagePriority.NodeQuery,\n\t\t});\n\n\t\tconst setpointTypes: ThermostatSetpointType[] = this.getValue(\n\t\t\tctx,\n\t\t\tThermostatSetpointCCValues.supportedSetpointTypes,\n\t\t) ?? [];\n\n\t\t// Query each setpoint's current value\n\t\tfor (const type of setpointTypes) {\n\t\t\tconst setpointName = getEnumMemberName(\n\t\t\t\tThermostatSetpointType,\n\t\t\t\ttype,\n\t\t\t);\n\t\t\t// Every time, query the current value\n\t\t\tctx.logNode(node.id, {\n\t\t\t\tendpoint: this.endpointIndex,\n\t\t\t\tmessage:\n\t\t\t\t\t`querying current value of setpoint ${setpointName}...`,\n\t\t\t\tdirection: \"outbound\",\n\t\t\t});\n\t\t\tconst setpoint = await api.get(type);\n\t\t\tif (setpoint) {\n\t\t\t\tconst logMessage =\n\t\t\t\t\t`received current value of setpoint ${setpointName}: ${setpoint.value} ${\n\t\t\t\t\t\tsetpoint.scale.unit ?? \"\"\n\t\t\t\t\t}`;\n\t\t\t\tctx.logNode(node.id, {\n\t\t\t\t\tendpoint: this.endpointIndex,\n\t\t\t\t\tmessage: logMessage,\n\t\t\t\t\tdirection: \"inbound\",\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\t}\n}\n\n// @publicAPI\nexport interface ThermostatSetpointCCSetOptions {\n\tsetpointType: ThermostatSetpointType;\n\tvalue: number;\n\tscale: number;\n}\n\n@CCCommand(ThermostatSetpointCommand.Set)\n@useSupervision()\nexport class ThermostatSetpointCCSet extends ThermostatSetpointCC {\n\tpublic constructor(\n\t\toptions: WithAddress<ThermostatSetpointCCSetOptions>,\n\t) {\n\t\tsuper(options);\n\t\tthis.setpointType = options.setpointType;\n\t\tthis.value = options.value;\n\t\tthis.scale = options.scale;\n\t}\n\n\tpublic static from(\n\t\traw: CCRaw,\n\t\tctx: CCParsingContext,\n\t): ThermostatSetpointCCSet {\n\t\tvalidatePayload(raw.payload.length >= 1);\n\t\tconst setpointType: ThermostatSetpointType = raw.payload[0] & 0b1111;\n\n\t\t// parseFloatWithScale does its own validation\n\t\tconst { value, scale } = parseFloatWithScale(\n\t\t\traw.payload.subarray(1),\n\t\t);\n\n\t\treturn new this({\n\t\t\tnodeId: ctx.sourceNodeId,\n\t\t\tsetpointType,\n\t\t\tvalue,\n\t\t\tscale,\n\t\t});\n\t}\n\n\tpublic setpointType: ThermostatSetpointType;\n\tpublic value: number;\n\tpublic scale: number;\n\n\tpublic serialize(ctx: CCEncodingContext): Promise<Bytes> {\n\t\t// If a config file overwrites how the float should be encoded, use that information\n\t\tconst override = ctx.getDeviceConfig?.(this.nodeId as number)\n\t\t\t?.compat?.overrideFloatEncoding;\n\t\tthis.payload = Bytes.concat([\n\t\t\tBytes.from([this.setpointType & 0b1111]),\n\t\t\tencodeFloatWithScale(this.value, this.scale, override),\n\t\t]);\n\t\treturn super.serialize(ctx);\n\t}\n\n\tpublic toLogEntry(ctx?: GetValueDB): MessageOrCCLogEntry {\n\t\tconst scale = getScale(this.scale);\n\t\treturn {\n\t\t\t...super.toLogEntry(ctx),\n\t\t\tmessage: {\n\t\t\t\t\"setpoint type\": getEnumMemberName(\n\t\t\t\t\tThermostatSetpointType,\n\t\t\t\t\tthis.setpointType,\n\t\t\t\t),\n\t\t\t\tvalue: `${this.value} ${scale.unit}`,\n\t\t\t},\n\t\t};\n\t}\n}\n\n// @publicAPI\nexport interface ThermostatSetpointCCReportOptions {\n\ttype: ThermostatSetpointType;\n\tvalue: number;\n\tscale: number;\n}\n\n@CCCommand(ThermostatSetpointCommand.Report)\nexport class ThermostatSetpointCCReport extends ThermostatSetpointCC {\n\tpublic constructor(\n\t\toptions: WithAddress<ThermostatSetpointCCReportOptions>,\n\t) {\n\t\tsuper(options);\n\n\t\tthis.type = options.type;\n\t\tthis.value = options.value;\n\t\tthis.scale = options.scale;\n\t}\n\n\tpublic static from(\n\t\traw: CCRaw,\n\t\tctx: CCParsingContext,\n\t): ThermostatSetpointCCReport {\n\t\tvalidatePayload(raw.payload.length >= 1);\n\t\tconst type: ThermostatSetpointType = raw.payload[0] & 0b1111;\n\n\t\tif (type === 0) {\n\t\t\t// Not supported\n\t\t\treturn new this({\n\t\t\t\tnodeId: ctx.sourceNodeId,\n\t\t\t\ttype,\n\t\t\t\tvalue: 0,\n\t\t\t\tscale: 0,\n\t\t\t});\n\t\t}\n\n\t\t// parseFloatWithScale does its own validation\n\t\tconst { value, scale } = parseFloatWithScale(\n\t\t\traw.payload.subarray(1),\n\t\t);\n\n\t\treturn new this({\n\t\t\tnodeId: ctx.sourceNodeId,\n\t\t\ttype,\n\t\t\tvalue,\n\t\t\tscale,\n\t\t});\n\t}\n\n\tpublic persistValues(ctx: PersistValuesContext): boolean {\n\t\tif (!super.persistValues(ctx)) return false;\n\n\t\tconst scale = getScale(this.scale);\n\n\t\tconst setpointValue = ThermostatSetpointCCValues.setpoint(this.type);\n\t\tconst existingMetadata = this.getMetadata<ValueMetadataNumeric>(\n\t\t\tctx,\n\t\t\tsetpointValue,\n\t\t);\n\n\t\t// Update the metadata when it is missing or the unit has changed\n\t\tif (existingMetadata?.unit !== scale.unit) {\n\t\t\tthis.setMetadata(ctx, setpointValue, {\n\t\t\t\t...(existingMetadata ?? setpointValue.meta),\n\t\t\t\tunit: scale.unit,\n\t\t\t});\n\t\t}\n\t\tthis.setValue(ctx, setpointValue, this.value);\n\n\t\t// Remember the device-preferred setpoint scale so it can be used in SET commands\n\t\tthis.setValue(\n\t\t\tctx,\n\t\t\tThermostatSetpointCCValues.setpointScale(this.type),\n\t\t\tscale.key,\n\t\t);\n\t\treturn true;\n\t}\n\n\tpublic type: ThermostatSetpointType;\n\tpublic scale: number;\n\tpublic value: number;\n\n\tpublic serialize(ctx: CCEncodingContext): Promise<Bytes> {\n\t\tthis.payload = Bytes.concat([\n\t\t\tBytes.from([this.type & 0b1111]),\n\t\t\tencodeFloatWithScale(this.value, this.scale),\n\t\t]);\n\t\treturn super.serialize(ctx);\n\t}\n\n\tpublic toLogEntry(ctx?: GetValueDB): MessageOrCCLogEntry {\n\t\tconst scale = getScale(this.scale);\n\t\treturn {\n\t\t\t...super.toLogEntry(ctx),\n\t\t\tmessage: {\n\t\t\t\t\"setpoint type\": getEnumMemberName(\n\t\t\t\t\tThermostatSetpointType,\n\t\t\t\t\tthis.type,\n\t\t\t\t),\n\t\t\t\tvalue: `${this.value} ${scale.unit}`,\n\t\t\t},\n\t\t};\n\t}\n}\n\nfunction testResponseForThermostatSetpointGet(\n\tsent: ThermostatSetpointCCGet,\n\treceived: ThermostatSetpointCCReport,\n) {\n\t// We expect a Thermostat Setpoint Report that matches the requested setpoint type\n\treturn received.type === sent.setpointType;\n}\n\n// @publicAPI\nexport interface ThermostatSetpointCCGetOptions {\n\tsetpointType: ThermostatSetpointType;\n}\n\n@CCCommand(ThermostatSetpointCommand.Get)\n@expectedCCResponse(\n\tThermostatSetpointCCReport,\n\ttestResponseForThermostatSetpointGet,\n)\nexport class ThermostatSetpointCCGet extends ThermostatSetpointCC {\n\tpublic constructor(\n\t\toptions: WithAddress<ThermostatSetpointCCGetOptions>,\n\t) {\n\t\tsuper(options);\n\t\tthis.setpointType = options.setpointType;\n\t}\n\n\tpublic static from(\n\t\traw: CCRaw,\n\t\tctx: CCParsingContext,\n\t): ThermostatSetpointCCGet {\n\t\tvalidatePayload(raw.payload.length >= 1);\n\t\tconst setpointType: ThermostatSetpointType = raw.payload[0] & 0b1111;\n\n\t\treturn new this({\n\t\t\tnodeId: ctx.sourceNodeId,\n\t\t\tsetpointType,\n\t\t});\n\t}\n\n\tpublic setpointType: ThermostatSetpointType;\n\n\tpublic serialize(ctx: CCEncodingContext): Promise<Bytes> {\n\t\tthis.payload = Bytes.from([this.setpointType & 0b1111]);\n\t\treturn super.serialize(ctx);\n\t}\n\n\tpublic toLogEntry(ctx?: GetValueDB): MessageOrCCLogEntry {\n\t\treturn {\n\t\t\t...super.toLogEntry(ctx),\n\t\t\tmessage: {\n\t\t\t\t\"setpoint type\": getEnumMemberName(\n\t\t\t\t\tThermostatSetpointType,\n\t\t\t\t\tthis.setpointType,\n\t\t\t\t),\n\t\t\t},\n\t\t};\n\t}\n}\n\n// @publicAPI\nexport interface ThermostatSetpointCCCapabilitiesReportOptions {\n\ttype: ThermostatSetpointType;\n\tminValue: number;\n\tminValueScale: number;\n\tmaxValue: number;\n\tmaxValueScale: number;\n}\n\n@CCCommand(ThermostatSetpointCommand.CapabilitiesReport)\nexport class ThermostatSetpointCCCapabilitiesReport\n\textends ThermostatSetpointCC\n{\n\tpublic constructor(\n\t\toptions: WithAddress<ThermostatSetpointCCCapabilitiesReportOptions>,\n\t) {\n\t\tsuper(options);\n\n\t\tthis.type = options.type;\n\t\tthis.minValue = options.minValue;\n\t\tthis.minValueScale = options.minValueScale;\n\t\tthis.maxValue = options.maxValue;\n\t\tthis.maxValueScale = options.maxValueScale;\n\t}\n\n\tpublic static from(\n\t\traw: CCRaw,\n\t\tctx: CCParsingContext,\n\t): ThermostatSetpointCCCapabilitiesReport {\n\t\tvalidatePayload(raw.payload.length >= 1);\n\t\tconst type: ThermostatSetpointType = raw.payload[0];\n\t\t// parseFloatWithScale does its own validation\n\t\tconst {\n\t\t\tvalue: minValue,\n\t\t\tscale: minValueScale,\n\t\t\tbytesRead,\n\t\t} = parseFloatWithScale(raw.payload.subarray(1));\n\t\tconst { value: maxValue, scale: maxValueScale } = parseFloatWithScale(\n\t\t\traw.payload.subarray(1 + bytesRead),\n\t\t);\n\n\t\treturn new this({\n\t\t\tnodeId: ctx.sourceNodeId,\n\t\t\ttype,\n\t\t\tminValue,\n\t\t\tminValueScale,\n\t\t\tmaxValue,\n\t\t\tmaxValueScale,\n\t\t});\n\t}\n\n\tpublic persistValues(ctx: PersistValuesContext): boolean {\n\t\tif (!super.persistValues(ctx)) return false;\n\n\t\t// Predefine the metadata\n\t\tconst setpointValue = ThermostatSetpointCCValues.setpoint(this.type);\n\t\tthis.setMetadata(ctx, setpointValue, {\n\t\t\t...setpointValue.meta,\n\t\t\tmin: this.minValue,\n\t\t\tmax: this.maxValue,\n\t\t\tunit: getSetpointUnit(this.minValueScale)\n\t\t\t\t|| getSetpointUnit(this.maxValueScale),\n\t\t});\n\n\t\treturn true;\n\t}\n\n\tpublic type: ThermostatSetpointType;\n\tpublic minValue: number;\n\tpublic maxValue: number;\n\tpublic minValueScale: number;\n\tpublic maxValueScale: number;\n\n\tpublic serialize(ctx: CCEncodingContext): Promise<Bytes> {\n\t\tconst min = encodeFloatWithScale(this.minValue, this.minValueScale);\n\t\tconst max = encodeFloatWithScale(this.maxValue, this.maxValueScale);\n\t\tthis.payload = Bytes.concat([Bytes.from([this.type]), min, max]);\n\t\treturn super.serialize(ctx);\n\t}\n\n\tpublic toLogEntry(ctx?: GetValueDB): MessageOrCCLogEntry {\n\t\tconst minValueScale = getScale(this.minValueScale);\n\t\tconst maxValueScale = getScale(this.maxValueScale);\n\t\treturn {\n\t\t\t...super.toLogEntry(ctx),\n\t\t\tmessage: {\n\t\t\t\t\"setpoint type\": getEnumMemberName(\n\t\t\t\t\tThermostatSetpointType,\n\t\t\t\t\tthis.type,\n\t\t\t\t),\n\t\t\t\t\"min value\": `${this.minValue} ${minValueScale.unit}`,\n\t\t\t\t\"max value\": `${this.maxValue} ${maxValueScale.unit}`,\n\t\t\t},\n\t\t};\n\t}\n}\n\n// @publicAPI\nexport interface ThermostatSetpointCCCapabilitiesGetOptions {\n\tsetpointType: ThermostatSetpointType;\n}\n\n@CCCommand(ThermostatSetpointCommand.CapabilitiesGet)\n@expectedCCResponse(ThermostatSetpointCCCapabilitiesReport)\nexport class ThermostatSetpointCCCapabilitiesGet extends ThermostatSetpointCC {\n\tpublic constructor(\n\t\toptions: WithAddress<ThermostatSetpointCCCapabilitiesGetOptions>,\n\t) {\n\t\tsuper(options);\n\t\tthis.setpointType = options.setpointType;\n\t}\n\n\tpublic static from(\n\t\traw: CCRaw,\n\t\tctx: CCParsingContext,\n\t): ThermostatSetpointCCCapabilitiesGet {\n\t\tvalidatePayload(raw.payload.length >= 1);\n\t\tconst setpointType: ThermostatSetpointType = raw.payload[0] & 0b1111;\n\n\t\treturn new this({\n\t\t\tnodeId: ctx.sourceNodeId,\n\t\t\tsetpointType,\n\t\t});\n\t}\n\n\tpublic setpointType: ThermostatSetpointType;\n\n\tpublic serialize(ctx: CCEncodingContext): Promise<Bytes> {\n\t\tthis.payload = Bytes.from([this.setpointType & 0b1111]);\n\t\treturn super.serialize(ctx);\n\t}\n\n\tpublic toLogEntry(ctx?: GetValueDB): MessageOrCCLogEntry {\n\t\treturn {\n\t\t\t...super.toLogEntry(ctx),\n\t\t\tmessage: {\n\t\t\t\t\"setpoint type\": getEnumMemberName(\n\t\t\t\t\tThermostatSetpointType,\n\t\t\t\t\tthis.setpointType,\n\t\t\t\t),\n\t\t\t},\n\t\t};\n\t}\n}\n\n// @publicAPI\nexport interface ThermostatSetpointCCSupportedReportOptions {\n\tsupportedSetpointTypes: ThermostatSetpointType[];\n}\n\n@CCCommand(ThermostatSetpointCommand.SupportedReport)\n@ccValueProperty(\n\t\"supportedSetpointTypes\",\n\tThermostatSetpointCCValues.supportedSetpointTypes,\n)\nexport class ThermostatSetpointCCSupportedReport extends ThermostatSetpointCC {\n\tpublic constructor(\n\t\toptions: WithAddress<ThermostatSetpointCCSupportedReportOptions>,\n\t) {\n\t\tsuper(options);\n\n\t\tif (options.supportedSetpointTypes.length === 0) {\n\t\t\tthrow new ZWaveError(\n\t\t\t\t`At least one setpoint type must be supported`,\n\t\t\t\tZWaveErrorCodes.Argument_Invalid,\n\t\t\t);\n\t\t}\n\t\tthis.supportedSetpointTypes = options.supportedSetpointTypes;\n\t}\n\n\tpublic static from(\n\t\traw: CCRaw,\n\t\tctx: CCParsingContext,\n\t): ThermostatSetpointCCSupportedReport {\n\t\tvalidatePayload(raw.payload.length >= 1);\n\t\tconst bitMask = raw.payload;\n\t\tconst supported = parseBitMask(\n\t\t\tbitMask,\n\t\t\tThermostatSetpointType[\"N/A\"],\n\t\t);\n\t\t// We use this command only when we are sure that bitmask interpretation A is used\n\t\t// FIXME: Figure out if we can do this without the CC version\n\t\tconst supportedSetpointTypes: ThermostatSetpointType[] = supported.map(\n\t\t\t(i) => thermostatSetpointTypeMap[i],\n\t\t);\n\n\t\treturn new this({\n\t\t\tnodeId: ctx.sourceNodeId,\n\t\t\tsupportedSetpointTypes,\n\t\t});\n\t}\n\n\tpublic readonly supportedSetpointTypes: readonly ThermostatSetpointType[];\n\n\tpublic serialize(ctx: CCEncodingContext): Promise<Bytes> {\n\t\tthis.payload = encodeBitMask(\n\t\t\t// Encode as interpretation A\n\t\t\tthis.supportedSetpointTypes\n\t\t\t\t.map((t) => thermostatSetpointTypeMap.indexOf(t))\n\t\t\t\t.filter((t) => t !== -1),\n\t\t\tundefined,\n\t\t\tThermostatSetpointType[\"N/A\"],\n\t\t);\n\t\treturn super.serialize(ctx);\n\t}\n\n\tpublic toLogEntry(ctx?: GetValueDB): MessageOrCCLogEntry {\n\t\treturn {\n\t\t\t...super.toLogEntry(ctx),\n\t\t\tmessage: {\n\t\t\t\t\"supported setpoint types\": this.supportedSetpointTypes\n\t\t\t\t\t.map(\n\t\t\t\t\t\t(t) =>\n\t\t\t\t\t\t\t`\\n\u00B7 ${\n\t\t\t\t\t\t\t\tgetEnumMemberName(\n\t\t\t\t\t\t\t\t\tThermostatSetpointType,\n\t\t\t\t\t\t\t\t\tt,\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t}`,\n\t\t\t\t\t)\n\t\t\t\t\t.join(\"\"),\n\t\t\t},\n\t\t};\n\t}\n}\n\n@CCCommand(ThermostatSetpointCommand.SupportedGet)\n@expectedCCResponse(ThermostatSetpointCCSupportedReport)\n/**\n * Issues a SupportedGet command to the node. Due to inconsistencies in interpretation,\n * this command should not be used for nodes with CC versions 1 or 2\n */\nexport class ThermostatSetpointCCSupportedGet extends ThermostatSetpointCC {}\n"],
4
+ "sourcesContent": ["import type { CCEncodingContext, CCParsingContext } from \"@zwave-js/cc\";\nimport {\n\tCommandClasses,\n\ttype GetValueDB,\n\ttype MaybeNotKnown,\n\ttype MessageOrCCLogEntry,\n\tMessagePriority,\n\ttype Scale,\n\ttype SupervisionResult,\n\tValueMetadata,\n\ttype ValueMetadataNumeric,\n\ttype WithAddress,\n\tZWaveError,\n\tZWaveErrorCodes,\n\tencodeBitMask,\n\tencodeFloatWithScale,\n\tgetNamedScale,\n\tgetUnknownScale,\n\tparseBitMask,\n\tparseFloatWithScale,\n\tsupervisedCommandSucceeded,\n\tvalidatePayload,\n} from \"@zwave-js/core\";\nimport { Bytes, getEnumMemberName, pick } from \"@zwave-js/shared\";\nimport { validateArgs } from \"@zwave-js/transformers\";\nimport {\n\tCCAPI,\n\tPOLL_VALUE,\n\ttype PollValueImplementation,\n\tSET_VALUE,\n\ttype SetValueImplementation,\n\tthrowUnsupportedProperty,\n\tthrowWrongValueType,\n} from \"../lib/API.js\";\nimport {\n\ttype CCRaw,\n\tCommandClass,\n\ttype InterviewContext,\n\ttype PersistValuesContext,\n\ttype RefreshValuesContext,\n} from \"../lib/CommandClass.js\";\nimport {\n\tAPI,\n\tCCCommand,\n\tccValueProperty,\n\tccValues,\n\tcommandClass,\n\texpectedCCResponse,\n\timplementedVersion,\n\tuseSupervision,\n} from \"../lib/CommandClassDecorators.js\";\nimport { V } from \"../lib/Values.js\";\nimport {\n\tThermostatSetpointCommand,\n\tThermostatSetpointType,\n} from \"../lib/_Types.js\";\n\n// This array is used to map the advertised supported types (interpretation A)\n// to the actual enum values\nconst thermostatSetpointTypeMap = [\n\t0x00,\n\t0x01,\n\t0x02,\n\t0x07,\n\t0x08,\n\t0x09,\n\t0x0a,\n\t0x0b,\n\t0x0c,\n\t0x0d,\n\t0x0e,\n\t0x0f,\n];\n\nfunction getScale(scale: number): Scale {\n\treturn getNamedScale(\"temperature\", scale as any)\n\t\t?? getUnknownScale(scale);\n}\nfunction getSetpointUnit(scale: number): string {\n\treturn getScale(scale).unit ?? \"\";\n}\n\nexport const ThermostatSetpointCCValues = V.defineCCValues(\n\tCommandClasses[\"Thermostat Setpoint\"],\n\t{\n\t\t...V.staticProperty(\"supportedSetpointTypes\", undefined, {\n\t\t\tinternal: true,\n\t\t}),\n\t\t...V.dynamicPropertyAndKeyWithName(\n\t\t\t\"setpoint\",\n\t\t\t\"setpoint\",\n\t\t\t(setpointType: ThermostatSetpointType) => setpointType,\n\t\t\t({ property, propertyKey }) =>\n\t\t\t\tproperty === \"setpoint\" && typeof propertyKey === \"number\",\n\t\t\t(setpointType: ThermostatSetpointType) => ({\n\t\t\t\t...ValueMetadata.Number,\n\t\t\t\tlabel: `Setpoint (${\n\t\t\t\t\tgetEnumMemberName(\n\t\t\t\t\t\tThermostatSetpointType,\n\t\t\t\t\t\tsetpointType,\n\t\t\t\t\t)\n\t\t\t\t})`,\n\t\t\t\tccSpecific: { setpointType },\n\t\t\t} as const),\n\t\t),\n\t\t...V.dynamicPropertyAndKeyWithName(\n\t\t\t\"setpointScale\",\n\t\t\t\"setpointScale\",\n\t\t\t(setpointType: ThermostatSetpointType) => setpointType,\n\t\t\t({ property, propertyKey }) =>\n\t\t\t\tproperty === \"setpointScale\" && typeof propertyKey === \"number\",\n\t\t\tundefined,\n\t\t\t{ internal: true },\n\t\t),\n\t},\n);\n\n@API(CommandClasses[\"Thermostat Setpoint\"])\nexport class ThermostatSetpointCCAPI extends CCAPI {\n\tpublic supportsCommand(\n\t\tcmd: ThermostatSetpointCommand,\n\t): MaybeNotKnown<boolean> {\n\t\tswitch (cmd) {\n\t\t\tcase ThermostatSetpointCommand.Get:\n\t\t\tcase ThermostatSetpointCommand.SupportedGet:\n\t\t\t\treturn this.isSinglecast();\n\t\t\tcase ThermostatSetpointCommand.Set:\n\t\t\t\treturn true; // This is mandatory\n\t\t\tcase ThermostatSetpointCommand.CapabilitiesGet:\n\t\t\t\treturn this.version >= 3 && this.isSinglecast();\n\t\t}\n\t\treturn super.supportsCommand(cmd);\n\t}\n\n\tprotected override get [SET_VALUE](): SetValueImplementation {\n\t\treturn async function(\n\t\t\tthis: ThermostatSetpointCCAPI,\n\t\t\t{ property, propertyKey },\n\t\t\tvalue,\n\t\t) {\n\t\t\tif (property !== \"setpoint\") {\n\t\t\t\tthrowUnsupportedProperty(this.ccId, property);\n\t\t\t}\n\t\t\tif (typeof propertyKey !== \"number\") {\n\t\t\t\tthrow new ZWaveError(\n\t\t\t\t\t`${\n\t\t\t\t\t\tCommandClasses[this.ccId]\n\t\t\t\t\t}: \"${property}\" must be further specified by a numeric property key`,\n\t\t\t\t\tZWaveErrorCodes.Argument_Invalid,\n\t\t\t\t);\n\t\t\t}\n\t\t\tif (typeof value !== \"number\") {\n\t\t\t\tthrowWrongValueType(\n\t\t\t\t\tthis.ccId,\n\t\t\t\t\tproperty,\n\t\t\t\t\t\"number\",\n\t\t\t\t\ttypeof value,\n\t\t\t\t);\n\t\t\t}\n\n\t\t\t// SDS14223: The Scale field value MUST be identical to the value received in the Thermostat Setpoint Report for the\n\t\t\t// actual Setpoint Type during the node interview. Fall back to the first scale if none is known\n\t\t\tconst preferredScale = this.tryGetValueDB()?.getValue<number>(\n\t\t\t\tThermostatSetpointCCValues.setpointScale(propertyKey).endpoint(\n\t\t\t\t\tthis.endpoint.index,\n\t\t\t\t),\n\t\t\t);\n\t\t\tconst result = await this.set(\n\t\t\t\tpropertyKey,\n\t\t\t\tvalue,\n\t\t\t\tpreferredScale ?? 0,\n\t\t\t);\n\n\t\t\t// Verify the current value after a delay, unless the command was supervised and successful\n\t\t\tif (this.isSinglecast() && !supervisedCommandSucceeded(result)) {\n\t\t\t\t// TODO: Ideally this would be a short delay, but some thermostats like Remotec ZXT-600\n\t\t\t\t// aren't able to handle the GET this quickly.\n\t\t\t\tthis.schedulePoll({ property, propertyKey }, value);\n\t\t\t}\n\n\t\t\treturn result;\n\t\t};\n\t}\n\n\tprotected get [POLL_VALUE](): PollValueImplementation {\n\t\treturn async function(\n\t\t\tthis: ThermostatSetpointCCAPI,\n\t\t\t{ property, propertyKey },\n\t\t) {\n\t\t\tswitch (property) {\n\t\t\t\tcase \"setpoint\":\n\t\t\t\t\tif (typeof propertyKey !== \"number\") {\n\t\t\t\t\t\tthrow new ZWaveError(\n\t\t\t\t\t\t\t`${\n\t\t\t\t\t\t\t\tCommandClasses[this.ccId]\n\t\t\t\t\t\t\t}: \"${property}\" must be further specified by a numeric property key`,\n\t\t\t\t\t\t\tZWaveErrorCodes.Argument_Invalid,\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\n\t\t\t\t\treturn (await this.get(propertyKey))?.value;\n\t\t\t\tdefault:\n\t\t\t\t\tthrowUnsupportedProperty(this.ccId, property);\n\t\t\t}\n\t\t};\n\t}\n\n\t@validateArgs()\n\tpublic async get(\n\t\tsetpointType: ThermostatSetpointType,\n\t): Promise<{ value: number; scale: Scale } | undefined> {\n\t\tthis.assertSupportsCommand(\n\t\t\tThermostatSetpointCommand,\n\t\t\tThermostatSetpointCommand.Get,\n\t\t);\n\n\t\tconst cc = new ThermostatSetpointCCGet({\n\t\t\tnodeId: this.endpoint.nodeId,\n\t\t\tendpointIndex: this.endpoint.index,\n\t\t\tsetpointType,\n\t\t});\n\t\tconst response = await this.host.sendCommand<\n\t\t\tThermostatSetpointCCReport\n\t\t>(\n\t\t\tcc,\n\t\t\tthis.commandOptions,\n\t\t);\n\t\tif (!response) return;\n\t\tif (response.type !== ThermostatSetpointType[\"N/A\"]) {\n\t\t\t// This is a supported setpoint\n\t\t\tconst scale = getScale(response.scale);\n\t\t\treturn {\n\t\t\t\tvalue: response.value,\n\t\t\t\tscale,\n\t\t\t};\n\t\t}\n\t}\n\n\t@validateArgs()\n\tpublic async set(\n\t\tsetpointType: ThermostatSetpointType,\n\t\tvalue: number,\n\t\tscale: number,\n\t): Promise<SupervisionResult | undefined> {\n\t\tthis.assertSupportsCommand(\n\t\t\tThermostatSetpointCommand,\n\t\t\tThermostatSetpointCommand.Set,\n\t\t);\n\n\t\tconst cc = new ThermostatSetpointCCSet({\n\t\t\tnodeId: this.endpoint.nodeId,\n\t\t\tendpointIndex: this.endpoint.index,\n\t\t\tsetpointType,\n\t\t\tvalue,\n\t\t\tscale,\n\t\t});\n\t\treturn this.host.sendCommand(cc, this.commandOptions);\n\t}\n\n\t@validateArgs()\n\t// oxlint-disable-next-line typescript/explicit-module-boundary-types\n\tpublic async getCapabilities(setpointType: ThermostatSetpointType) {\n\t\tthis.assertSupportsCommand(\n\t\t\tThermostatSetpointCommand,\n\t\t\tThermostatSetpointCommand.CapabilitiesGet,\n\t\t);\n\n\t\tconst cc = new ThermostatSetpointCCCapabilitiesGet({\n\t\t\tnodeId: this.endpoint.nodeId,\n\t\t\tendpointIndex: this.endpoint.index,\n\t\t\tsetpointType,\n\t\t});\n\t\tconst response = await this.host.sendCommand<\n\t\t\tThermostatSetpointCCCapabilitiesReport\n\t\t>(\n\t\t\tcc,\n\t\t\tthis.commandOptions,\n\t\t);\n\t\tif (response) {\n\t\t\treturn pick(response, [\n\t\t\t\t\"minValue\",\n\t\t\t\t\"maxValue\",\n\t\t\t\t\"minValueScale\",\n\t\t\t\t\"maxValueScale\",\n\t\t\t]);\n\t\t}\n\t}\n\n\t/**\n\t * Requests the supported setpoint types from the node. Due to inconsistencies it is NOT recommended\n\t * to use this method on nodes with CC versions 1 and 2. Instead rely on the information determined\n\t * during node interview.\n\t */\n\tpublic async getSupportedSetpointTypes(): Promise<\n\t\tMaybeNotKnown<readonly ThermostatSetpointType[]>\n\t> {\n\t\tthis.assertSupportsCommand(\n\t\t\tThermostatSetpointCommand,\n\t\t\tThermostatSetpointCommand.SupportedGet,\n\t\t);\n\n\t\tconst cc = new ThermostatSetpointCCSupportedGet({\n\t\t\tnodeId: this.endpoint.nodeId,\n\t\t\tendpointIndex: this.endpoint.index,\n\t\t});\n\t\tconst response = await this.host.sendCommand<\n\t\t\tThermostatSetpointCCSupportedReport\n\t\t>(\n\t\t\tcc,\n\t\t\tthis.commandOptions,\n\t\t);\n\t\treturn response?.supportedSetpointTypes;\n\t}\n}\n\n@commandClass(CommandClasses[\"Thermostat Setpoint\"])\n@implementedVersion(3)\n@ccValues(ThermostatSetpointCCValues)\nexport class ThermostatSetpointCC extends CommandClass {\n\tdeclare ccCommand: ThermostatSetpointCommand;\n\n\tpublic translatePropertyKey(\n\t\tctx: GetValueDB,\n\t\tproperty: string | number,\n\t\tpropertyKey: string | number,\n\t): string | undefined {\n\t\tif (property === \"setpoint\") {\n\t\t\treturn getEnumMemberName(\n\t\t\t\tThermostatSetpointType,\n\t\t\t\tpropertyKey as any,\n\t\t\t);\n\t\t} else {\n\t\t\treturn super.translatePropertyKey(ctx, property, propertyKey);\n\t\t}\n\t}\n\n\tpublic async interview(\n\t\tctx: InterviewContext,\n\t): Promise<void> {\n\t\tconst node = this.getNode(ctx)!;\n\t\tconst endpoint = this.getEndpoint(ctx)!;\n\t\tconst api = CCAPI.create(\n\t\t\tCommandClasses[\"Thermostat Setpoint\"],\n\t\t\tctx,\n\t\t\tendpoint,\n\t\t).withOptions({\n\t\t\tpriority: MessagePriority.NodeQuery,\n\t\t});\n\n\t\tctx.logNode(node.id, {\n\t\t\tendpoint: this.endpointIndex,\n\t\t\tmessage: `Interviewing ${this.ccName}...`,\n\t\t\tdirection: \"none\",\n\t\t});\n\n\t\tif (api.version <= 2) {\n\t\t\t// It has been found that early implementations of this Command Class applied two non-interoperable\n\t\t\t// interpretations of the bit mask advertising the support for specific Setpoint Types in the Thermostat\n\t\t\t// Setpoint Supported Report Command.\n\t\t\t// A controlling node SHOULD determine the supported Setpoint Types of a version 1 and version 2\n\t\t\t// supporting node by sending one Thermostat Setpoint Get Command at a time while incrementing\n\t\t\t// the requested Setpoint Type.\n\t\t\t// If the same Setpoint Type is advertised in the returned Thermostat Setpoint Report Command, the\n\t\t\t// controlling node MUST conclude that the actual Setpoint Type is supported.\n\t\t\t// If the Setpoint Type 0x00 (type N/A) is advertised in the returned Thermostat Setpoint Report\n\t\t\t// Command, the controlling node MUST conclude that the actual Setpoint Type is not supported.\n\n\t\t\t// The specs require us to query the list of supported setpoint types anyways, even if the response is ignored\n\t\t\tawait api.getSupportedSetpointTypes();\n\n\t\t\t// Now scan all endpoints. Each type we received a value for gets marked as supported\n\t\t\tconst supportedSetpointTypes: ThermostatSetpointType[] = [];\n\t\t\tfor (\n\t\t\t\tlet type: ThermostatSetpointType =\n\t\t\t\t\tThermostatSetpointType.Heating;\n\t\t\t\ttype <= ThermostatSetpointType[\"Full Power\"];\n\t\t\t\ttype++\n\t\t\t) {\n\t\t\t\tconst setpointName = getEnumMemberName(\n\t\t\t\t\tThermostatSetpointType,\n\t\t\t\t\ttype,\n\t\t\t\t);\n\t\t\t\t// Every time, query the current value\n\t\t\t\tctx.logNode(node.id, {\n\t\t\t\t\tendpoint: this.endpointIndex,\n\t\t\t\t\tmessage:\n\t\t\t\t\t\t`querying current value of setpoint ${setpointName}...`,\n\t\t\t\t\tdirection: \"outbound\",\n\t\t\t\t});\n\n\t\t\t\tconst setpoint = await api.get(type);\n\t\t\t\t// If the node did not respond, assume the setpoint type is not supported\n\n\t\t\t\tlet logMessage: string;\n\t\t\t\tif (setpoint) {\n\t\t\t\t\t// Setpoint supported, remember the type\n\t\t\t\t\tsupportedSetpointTypes.push(type);\n\t\t\t\t\tlogMessage =\n\t\t\t\t\t\t`received current value of setpoint ${setpointName}: ${setpoint.value} ${\n\t\t\t\t\t\t\tsetpoint.scale.unit ?? \"\"\n\t\t\t\t\t\t}`;\n\t\t\t\t} else {\n\t\t\t\t\t// We're sure about the interpretation - this should not happen\n\t\t\t\t\tlogMessage = `setpoint ${setpointName} is not supported`;\n\t\t\t\t}\n\t\t\t\tctx.logNode(node.id, {\n\t\t\t\t\tendpoint: this.endpointIndex,\n\t\t\t\t\tmessage: logMessage,\n\t\t\t\t\tdirection: \"inbound\",\n\t\t\t\t});\n\t\t\t}\n\n\t\t\t// Remember which setpoint types are actually supported\n\t\t\tthis.setValue(\n\t\t\t\tctx,\n\t\t\t\tThermostatSetpointCCValues.supportedSetpointTypes,\n\t\t\t\tsupportedSetpointTypes,\n\t\t\t);\n\t\t} else {\n\t\t\t// Versions >= 3 adhere to bitmap interpretation A, so we can rely on getSupportedSetpointTypes\n\n\t\t\t// Query the supported setpoint types\n\t\t\tlet setpointTypes: ThermostatSetpointType[] = [];\n\t\t\tctx.logNode(node.id, {\n\t\t\t\tendpoint: this.endpointIndex,\n\t\t\t\tmessage: \"retrieving supported setpoint types...\",\n\t\t\t\tdirection: \"outbound\",\n\t\t\t});\n\t\t\tconst resp = await api.getSupportedSetpointTypes();\n\t\t\tif (resp) {\n\t\t\t\tsetpointTypes = [...resp];\n\t\t\t\tconst logMessage = \"received supported setpoint types:\\n\"\n\t\t\t\t\t+ setpointTypes\n\t\t\t\t\t\t.map((type) =>\n\t\t\t\t\t\t\tgetEnumMemberName(ThermostatSetpointType, type)\n\t\t\t\t\t\t)\n\t\t\t\t\t\t.map((name) => `\u00B7 ${name}`)\n\t\t\t\t\t\t.join(\"\\n\");\n\t\t\t\tctx.logNode(node.id, {\n\t\t\t\t\tendpoint: this.endpointIndex,\n\t\t\t\t\tmessage: logMessage,\n\t\t\t\t\tdirection: \"inbound\",\n\t\t\t\t});\n\t\t\t} else {\n\t\t\t\tctx.logNode(node.id, {\n\t\t\t\t\tendpoint: this.endpointIndex,\n\t\t\t\t\tmessage:\n\t\t\t\t\t\t\"Querying supported setpoint types timed out, skipping interview...\",\n\t\t\t\t\tlevel: \"warn\",\n\t\t\t\t});\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tfor (const type of setpointTypes) {\n\t\t\t\tconst setpointName = getEnumMemberName(\n\t\t\t\t\tThermostatSetpointType,\n\t\t\t\t\ttype,\n\t\t\t\t);\n\t\t\t\t// Find out the capabilities of this setpoint\n\t\t\t\tctx.logNode(node.id, {\n\t\t\t\t\tendpoint: this.endpointIndex,\n\t\t\t\t\tmessage:\n\t\t\t\t\t\t`retrieving capabilities for setpoint ${setpointName}...`,\n\t\t\t\t\tdirection: \"outbound\",\n\t\t\t\t});\n\t\t\t\tconst setpointCaps = await api.getCapabilities(type);\n\t\t\t\tif (setpointCaps) {\n\t\t\t\t\tconst minValueUnit = getSetpointUnit(\n\t\t\t\t\t\tsetpointCaps.minValueScale,\n\t\t\t\t\t);\n\t\t\t\t\tconst maxValueUnit = getSetpointUnit(\n\t\t\t\t\t\tsetpointCaps.maxValueScale,\n\t\t\t\t\t);\n\t\t\t\t\tconst logMessage =\n\t\t\t\t\t\t`received capabilities for setpoint ${setpointName}:\nminimum value: ${setpointCaps.minValue} ${minValueUnit}\nmaximum value: ${setpointCaps.maxValue} ${maxValueUnit}`;\n\t\t\t\t\tctx.logNode(node.id, {\n\t\t\t\t\t\tendpoint: this.endpointIndex,\n\t\t\t\t\t\tmessage: logMessage,\n\t\t\t\t\t\tdirection: \"inbound\",\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Query the current value for all setpoint types\n\t\t\tawait this.refreshValues(ctx);\n\t\t}\n\n\t\t// Remember that the interview is complete\n\t\tthis.setInterviewComplete(ctx, true);\n\t}\n\n\tpublic async refreshValues(\n\t\tctx: RefreshValuesContext,\n\t): Promise<void> {\n\t\tconst node = this.getNode(ctx)!;\n\t\tconst endpoint = this.getEndpoint(ctx)!;\n\t\tconst api = CCAPI.create(\n\t\t\tCommandClasses[\"Thermostat Setpoint\"],\n\t\t\tctx,\n\t\t\tendpoint,\n\t\t).withOptions({\n\t\t\tpriority: MessagePriority.NodeQuery,\n\t\t});\n\n\t\tconst setpointTypes: ThermostatSetpointType[] = this.getValue(\n\t\t\tctx,\n\t\t\tThermostatSetpointCCValues.supportedSetpointTypes,\n\t\t) ?? [];\n\n\t\t// Query each setpoint's current value\n\t\tfor (const type of setpointTypes) {\n\t\t\tconst setpointName = getEnumMemberName(\n\t\t\t\tThermostatSetpointType,\n\t\t\t\ttype,\n\t\t\t);\n\t\t\t// Every time, query the current value\n\t\t\tctx.logNode(node.id, {\n\t\t\t\tendpoint: this.endpointIndex,\n\t\t\t\tmessage:\n\t\t\t\t\t`querying current value of setpoint ${setpointName}...`,\n\t\t\t\tdirection: \"outbound\",\n\t\t\t});\n\t\t\tconst setpoint = await api.get(type);\n\t\t\tif (setpoint) {\n\t\t\t\tconst logMessage =\n\t\t\t\t\t`received current value of setpoint ${setpointName}: ${setpoint.value} ${\n\t\t\t\t\t\tsetpoint.scale.unit ?? \"\"\n\t\t\t\t\t}`;\n\t\t\t\tctx.logNode(node.id, {\n\t\t\t\t\tendpoint: this.endpointIndex,\n\t\t\t\t\tmessage: logMessage,\n\t\t\t\t\tdirection: \"inbound\",\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\t}\n}\n\n// @publicAPI\nexport interface ThermostatSetpointCCSetOptions {\n\tsetpointType: ThermostatSetpointType;\n\tvalue: number;\n\tscale: number;\n}\n\n@CCCommand(ThermostatSetpointCommand.Set)\n@useSupervision()\nexport class ThermostatSetpointCCSet extends ThermostatSetpointCC {\n\tpublic constructor(\n\t\toptions: WithAddress<ThermostatSetpointCCSetOptions>,\n\t) {\n\t\tsuper(options);\n\t\tthis.setpointType = options.setpointType;\n\t\tthis.value = options.value;\n\t\tthis.scale = options.scale;\n\t}\n\n\tpublic static from(\n\t\traw: CCRaw,\n\t\tctx: CCParsingContext,\n\t): ThermostatSetpointCCSet {\n\t\tvalidatePayload(raw.payload.length >= 1);\n\t\tconst setpointType: ThermostatSetpointType = raw.payload[0] & 0b1111;\n\n\t\t// parseFloatWithScale does its own validation\n\t\tconst { value, scale } = parseFloatWithScale(\n\t\t\traw.payload.subarray(1),\n\t\t);\n\n\t\treturn new this({\n\t\t\tnodeId: ctx.sourceNodeId,\n\t\t\tsetpointType,\n\t\t\tvalue,\n\t\t\tscale,\n\t\t});\n\t}\n\n\tpublic setpointType: ThermostatSetpointType;\n\tpublic value: number;\n\tpublic scale: number;\n\n\tpublic serialize(ctx: CCEncodingContext): Promise<Bytes> {\n\t\t// If a config file overwrites how the float should be encoded, use that information\n\t\tconst override = ctx.getDeviceConfig?.(this.nodeId as number)\n\t\t\t?.compat?.overrideFloatEncoding;\n\t\tthis.payload = Bytes.concat([\n\t\t\tBytes.from([this.setpointType & 0b1111]),\n\t\t\tencodeFloatWithScale(this.value, this.scale, override),\n\t\t]);\n\t\treturn super.serialize(ctx);\n\t}\n\n\tpublic toLogEntry(ctx?: GetValueDB): MessageOrCCLogEntry {\n\t\tconst scale = getScale(this.scale);\n\t\treturn {\n\t\t\t...super.toLogEntry(ctx),\n\t\t\tmessage: {\n\t\t\t\t\"setpoint type\": getEnumMemberName(\n\t\t\t\t\tThermostatSetpointType,\n\t\t\t\t\tthis.setpointType,\n\t\t\t\t),\n\t\t\t\tvalue: `${this.value} ${scale.unit}`,\n\t\t\t},\n\t\t};\n\t}\n}\n\n// @publicAPI\nexport interface ThermostatSetpointCCReportOptions {\n\ttype: ThermostatSetpointType;\n\tvalue: number;\n\tscale: number;\n}\n\n@CCCommand(ThermostatSetpointCommand.Report)\nexport class ThermostatSetpointCCReport extends ThermostatSetpointCC {\n\tpublic constructor(\n\t\toptions: WithAddress<ThermostatSetpointCCReportOptions>,\n\t) {\n\t\tsuper(options);\n\n\t\tthis.type = options.type;\n\t\tthis.value = options.value;\n\t\tthis.scale = options.scale;\n\t}\n\n\tpublic static from(\n\t\traw: CCRaw,\n\t\tctx: CCParsingContext,\n\t): ThermostatSetpointCCReport {\n\t\tvalidatePayload(raw.payload.length >= 1);\n\t\tconst type: ThermostatSetpointType = raw.payload[0] & 0b1111;\n\n\t\tif (type === 0) {\n\t\t\t// Not supported\n\t\t\treturn new this({\n\t\t\t\tnodeId: ctx.sourceNodeId,\n\t\t\t\ttype,\n\t\t\t\tvalue: 0,\n\t\t\t\tscale: 0,\n\t\t\t});\n\t\t}\n\n\t\t// parseFloatWithScale does its own validation\n\t\tconst { value, scale } = parseFloatWithScale(\n\t\t\traw.payload.subarray(1),\n\t\t);\n\n\t\treturn new this({\n\t\t\tnodeId: ctx.sourceNodeId,\n\t\t\ttype,\n\t\t\tvalue,\n\t\t\tscale,\n\t\t});\n\t}\n\n\tpublic persistValues(ctx: PersistValuesContext): boolean {\n\t\tif (!super.persistValues(ctx)) return false;\n\n\t\tconst scale = getScale(this.scale);\n\n\t\tconst setpointValue = ThermostatSetpointCCValues.setpoint(this.type);\n\t\tconst existingMetadata = this.getMetadata<ValueMetadataNumeric>(\n\t\t\tctx,\n\t\t\tsetpointValue,\n\t\t);\n\n\t\t// Update the metadata when it is missing or the unit has changed\n\t\tif (existingMetadata?.unit !== scale.unit) {\n\t\t\tthis.setMetadata(ctx, setpointValue, {\n\t\t\t\t...(existingMetadata ?? setpointValue.meta),\n\t\t\t\tunit: scale.unit,\n\t\t\t});\n\t\t}\n\t\tthis.setValue(ctx, setpointValue, this.value);\n\n\t\t// Remember the device-preferred setpoint scale so it can be used in SET commands\n\t\tthis.setValue(\n\t\t\tctx,\n\t\t\tThermostatSetpointCCValues.setpointScale(this.type),\n\t\t\tscale.key,\n\t\t);\n\t\treturn true;\n\t}\n\n\tpublic type: ThermostatSetpointType;\n\tpublic scale: number;\n\tpublic value: number;\n\n\tpublic serialize(ctx: CCEncodingContext): Promise<Bytes> {\n\t\tthis.payload = Bytes.concat([\n\t\t\tBytes.from([this.type & 0b1111]),\n\t\t\tencodeFloatWithScale(this.value, this.scale),\n\t\t]);\n\t\treturn super.serialize(ctx);\n\t}\n\n\tpublic toLogEntry(ctx?: GetValueDB): MessageOrCCLogEntry {\n\t\tconst scale = getScale(this.scale);\n\t\treturn {\n\t\t\t...super.toLogEntry(ctx),\n\t\t\tmessage: {\n\t\t\t\t\"setpoint type\": getEnumMemberName(\n\t\t\t\t\tThermostatSetpointType,\n\t\t\t\t\tthis.type,\n\t\t\t\t),\n\t\t\t\tvalue: `${this.value} ${scale.unit}`,\n\t\t\t},\n\t\t};\n\t}\n}\n\nfunction testResponseForThermostatSetpointGet(\n\tsent: ThermostatSetpointCCGet,\n\treceived: ThermostatSetpointCCReport,\n) {\n\t// We expect a Thermostat Setpoint Report that matches the requested setpoint type\n\treturn received.type === sent.setpointType;\n}\n\n// @publicAPI\nexport interface ThermostatSetpointCCGetOptions {\n\tsetpointType: ThermostatSetpointType;\n}\n\n@CCCommand(ThermostatSetpointCommand.Get)\n@expectedCCResponse(\n\tThermostatSetpointCCReport,\n\ttestResponseForThermostatSetpointGet,\n)\nexport class ThermostatSetpointCCGet extends ThermostatSetpointCC {\n\tpublic constructor(\n\t\toptions: WithAddress<ThermostatSetpointCCGetOptions>,\n\t) {\n\t\tsuper(options);\n\t\tthis.setpointType = options.setpointType;\n\t}\n\n\tpublic static from(\n\t\traw: CCRaw,\n\t\tctx: CCParsingContext,\n\t): ThermostatSetpointCCGet {\n\t\tvalidatePayload(raw.payload.length >= 1);\n\t\tconst setpointType: ThermostatSetpointType = raw.payload[0] & 0b1111;\n\n\t\treturn new this({\n\t\t\tnodeId: ctx.sourceNodeId,\n\t\t\tsetpointType,\n\t\t});\n\t}\n\n\tpublic setpointType: ThermostatSetpointType;\n\n\tpublic serialize(ctx: CCEncodingContext): Promise<Bytes> {\n\t\tthis.payload = Bytes.from([this.setpointType & 0b1111]);\n\t\treturn super.serialize(ctx);\n\t}\n\n\tpublic toLogEntry(ctx?: GetValueDB): MessageOrCCLogEntry {\n\t\treturn {\n\t\t\t...super.toLogEntry(ctx),\n\t\t\tmessage: {\n\t\t\t\t\"setpoint type\": getEnumMemberName(\n\t\t\t\t\tThermostatSetpointType,\n\t\t\t\t\tthis.setpointType,\n\t\t\t\t),\n\t\t\t},\n\t\t};\n\t}\n}\n\n// @publicAPI\nexport interface ThermostatSetpointCCCapabilitiesReportOptions {\n\ttype: ThermostatSetpointType;\n\tminValue: number;\n\tminValueScale: number;\n\tmaxValue: number;\n\tmaxValueScale: number;\n}\n\n@CCCommand(ThermostatSetpointCommand.CapabilitiesReport)\nexport class ThermostatSetpointCCCapabilitiesReport\n\textends ThermostatSetpointCC\n{\n\tpublic constructor(\n\t\toptions: WithAddress<ThermostatSetpointCCCapabilitiesReportOptions>,\n\t) {\n\t\tsuper(options);\n\n\t\tthis.type = options.type;\n\t\tthis.minValue = options.minValue;\n\t\tthis.minValueScale = options.minValueScale;\n\t\tthis.maxValue = options.maxValue;\n\t\tthis.maxValueScale = options.maxValueScale;\n\t}\n\n\tpublic static from(\n\t\traw: CCRaw,\n\t\tctx: CCParsingContext,\n\t): ThermostatSetpointCCCapabilitiesReport {\n\t\tvalidatePayload(raw.payload.length >= 1);\n\t\tconst type: ThermostatSetpointType = raw.payload[0];\n\t\t// parseFloatWithScale does its own validation\n\t\tconst {\n\t\t\tvalue: minValue,\n\t\t\tscale: minValueScale,\n\t\t\tbytesRead,\n\t\t} = parseFloatWithScale(raw.payload.subarray(1));\n\t\tconst { value: maxValue, scale: maxValueScale } = parseFloatWithScale(\n\t\t\traw.payload.subarray(1 + bytesRead),\n\t\t);\n\n\t\treturn new this({\n\t\t\tnodeId: ctx.sourceNodeId,\n\t\t\ttype,\n\t\t\tminValue,\n\t\t\tminValueScale,\n\t\t\tmaxValue,\n\t\t\tmaxValueScale,\n\t\t});\n\t}\n\n\tpublic persistValues(ctx: PersistValuesContext): boolean {\n\t\tif (!super.persistValues(ctx)) return false;\n\n\t\t// Predefine the metadata\n\t\tconst setpointValue = ThermostatSetpointCCValues.setpoint(this.type);\n\t\tthis.setMetadata(ctx, setpointValue, {\n\t\t\t...setpointValue.meta,\n\t\t\tmin: this.minValue,\n\t\t\tmax: this.maxValue,\n\t\t\tunit: getSetpointUnit(this.minValueScale)\n\t\t\t\t|| getSetpointUnit(this.maxValueScale),\n\t\t});\n\n\t\treturn true;\n\t}\n\n\tpublic type: ThermostatSetpointType;\n\tpublic minValue: number;\n\tpublic maxValue: number;\n\tpublic minValueScale: number;\n\tpublic maxValueScale: number;\n\n\tpublic serialize(ctx: CCEncodingContext): Promise<Bytes> {\n\t\tconst min = encodeFloatWithScale(this.minValue, this.minValueScale);\n\t\tconst max = encodeFloatWithScale(this.maxValue, this.maxValueScale);\n\t\tthis.payload = Bytes.concat([Bytes.from([this.type]), min, max]);\n\t\treturn super.serialize(ctx);\n\t}\n\n\tpublic toLogEntry(ctx?: GetValueDB): MessageOrCCLogEntry {\n\t\tconst minValueScale = getScale(this.minValueScale);\n\t\tconst maxValueScale = getScale(this.maxValueScale);\n\t\treturn {\n\t\t\t...super.toLogEntry(ctx),\n\t\t\tmessage: {\n\t\t\t\t\"setpoint type\": getEnumMemberName(\n\t\t\t\t\tThermostatSetpointType,\n\t\t\t\t\tthis.type,\n\t\t\t\t),\n\t\t\t\t\"min value\": `${this.minValue} ${minValueScale.unit}`,\n\t\t\t\t\"max value\": `${this.maxValue} ${maxValueScale.unit}`,\n\t\t\t},\n\t\t};\n\t}\n}\n\n// @publicAPI\nexport interface ThermostatSetpointCCCapabilitiesGetOptions {\n\tsetpointType: ThermostatSetpointType;\n}\n\n@CCCommand(ThermostatSetpointCommand.CapabilitiesGet)\n@expectedCCResponse(ThermostatSetpointCCCapabilitiesReport)\nexport class ThermostatSetpointCCCapabilitiesGet extends ThermostatSetpointCC {\n\tpublic constructor(\n\t\toptions: WithAddress<ThermostatSetpointCCCapabilitiesGetOptions>,\n\t) {\n\t\tsuper(options);\n\t\tthis.setpointType = options.setpointType;\n\t}\n\n\tpublic static from(\n\t\traw: CCRaw,\n\t\tctx: CCParsingContext,\n\t): ThermostatSetpointCCCapabilitiesGet {\n\t\tvalidatePayload(raw.payload.length >= 1);\n\t\tconst setpointType: ThermostatSetpointType = raw.payload[0] & 0b1111;\n\n\t\treturn new this({\n\t\t\tnodeId: ctx.sourceNodeId,\n\t\t\tsetpointType,\n\t\t});\n\t}\n\n\tpublic setpointType: ThermostatSetpointType;\n\n\tpublic serialize(ctx: CCEncodingContext): Promise<Bytes> {\n\t\tthis.payload = Bytes.from([this.setpointType & 0b1111]);\n\t\treturn super.serialize(ctx);\n\t}\n\n\tpublic toLogEntry(ctx?: GetValueDB): MessageOrCCLogEntry {\n\t\treturn {\n\t\t\t...super.toLogEntry(ctx),\n\t\t\tmessage: {\n\t\t\t\t\"setpoint type\": getEnumMemberName(\n\t\t\t\t\tThermostatSetpointType,\n\t\t\t\t\tthis.setpointType,\n\t\t\t\t),\n\t\t\t},\n\t\t};\n\t}\n}\n\n// @publicAPI\nexport interface ThermostatSetpointCCSupportedReportOptions {\n\tsupportedSetpointTypes: ThermostatSetpointType[];\n}\n\n@CCCommand(ThermostatSetpointCommand.SupportedReport)\n@ccValueProperty(\n\t\"supportedSetpointTypes\",\n\tThermostatSetpointCCValues.supportedSetpointTypes,\n)\nexport class ThermostatSetpointCCSupportedReport extends ThermostatSetpointCC {\n\tpublic constructor(\n\t\toptions: WithAddress<ThermostatSetpointCCSupportedReportOptions>,\n\t) {\n\t\tsuper(options);\n\n\t\tif (options.supportedSetpointTypes.length === 0) {\n\t\t\tthrow new ZWaveError(\n\t\t\t\t`At least one setpoint type must be supported`,\n\t\t\t\tZWaveErrorCodes.Argument_Invalid,\n\t\t\t);\n\t\t}\n\t\tthis.supportedSetpointTypes = options.supportedSetpointTypes;\n\t}\n\n\tpublic static from(\n\t\traw: CCRaw,\n\t\tctx: CCParsingContext,\n\t): ThermostatSetpointCCSupportedReport {\n\t\tvalidatePayload(raw.payload.length >= 1);\n\t\tconst bitMask = raw.payload;\n\t\tconst supported = parseBitMask(\n\t\t\tbitMask,\n\t\t\tThermostatSetpointType[\"N/A\"],\n\t\t);\n\t\t// We use this command only when we are sure that bitmask interpretation A is used\n\t\t// FIXME: Figure out if we can do this without the CC version\n\t\tconst supportedSetpointTypes: ThermostatSetpointType[] = supported.map(\n\t\t\t(i) => thermostatSetpointTypeMap[i],\n\t\t);\n\n\t\treturn new this({\n\t\t\tnodeId: ctx.sourceNodeId,\n\t\t\tsupportedSetpointTypes,\n\t\t});\n\t}\n\n\tpublic readonly supportedSetpointTypes: readonly ThermostatSetpointType[];\n\n\tpublic serialize(ctx: CCEncodingContext): Promise<Bytes> {\n\t\tthis.payload = encodeBitMask(\n\t\t\t// Encode as interpretation A\n\t\t\tthis.supportedSetpointTypes\n\t\t\t\t.map((t) => thermostatSetpointTypeMap.indexOf(t))\n\t\t\t\t.filter((t) => t !== -1),\n\t\t\tundefined,\n\t\t\tThermostatSetpointType[\"N/A\"],\n\t\t);\n\t\treturn super.serialize(ctx);\n\t}\n\n\tpublic toLogEntry(ctx?: GetValueDB): MessageOrCCLogEntry {\n\t\treturn {\n\t\t\t...super.toLogEntry(ctx),\n\t\t\tmessage: {\n\t\t\t\t\"supported setpoint types\": this.supportedSetpointTypes\n\t\t\t\t\t.map(\n\t\t\t\t\t\t(t) =>\n\t\t\t\t\t\t\t`\\n\u00B7 ${\n\t\t\t\t\t\t\t\tgetEnumMemberName(\n\t\t\t\t\t\t\t\t\tThermostatSetpointType,\n\t\t\t\t\t\t\t\t\tt,\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t}`,\n\t\t\t\t\t)\n\t\t\t\t\t.join(\"\"),\n\t\t\t},\n\t\t};\n\t}\n}\n\n@CCCommand(ThermostatSetpointCommand.SupportedGet)\n@expectedCCResponse(ThermostatSetpointCCSupportedReport)\n/**\n * Issues a SupportedGet command to the node. Due to inconsistencies in interpretation,\n * this command should not be used for nodes with CC versions 1 or 2\n */\nexport class ThermostatSetpointCCSupportedGet extends ThermostatSetpointCC {}\n"],
5
5
  "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,kBAqBO;AACP,oBAA+C;AAE/C,iBAQO;AACP,0BAMO;AACP,oCASO;AACP,oBAAkB;AAClB,mBAGO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAIP,MAAM,4BAA4B;EACjC;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;AAGD,SAAS,SAAS,OAAa;AAC9B,aAAO,2BAAc,eAAe,KAAY,SAC5C,6BAAgB,KAAK;AAC1B;AAHS;AAIT,SAAS,gBAAgB,OAAa;AACrC,SAAO,SAAS,KAAK,EAAE,QAAQ;AAChC;AAFS;IAwCI,2BAAuB,MAAA;8BADnC,mCAAI,2BAAe,qBAAqB,CAAC,CAAC;;;;oBACE;;;;;+CAAA,YAAK;WAAA;;;;;;;;yBAyFhD,yCAAA,CAAc;yBA+Bd,yCAAA,CAAc;qCAqBd,qDAAA,CAAc;AAnDf,mBAAA,MAAA,MAAA,iBAAA,EAAA,MAAA,UAAA,MAAA,OAAA,QAAA,OAAA,SAAA,OAAA,QAAA,EAAA,KAAA,gCAAA,SAAA,KAAA,QAAA,KAAA,gCAAA,IAAa,KAAb,OAAgB,GAAA,UAAA,UAAA,GAAA,MAAA,0BAAA;AA+BhB,mBAAA,MAAA,MAAA,iBAAA,EAAA,MAAA,UAAA,MAAA,OAAA,QAAA,OAAA,SAAA,OAAA,QAAA,EAAA,KAAA,gCAAA,SAAA,KAAA,QAAA,K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,4BAAgB,gBAAgB;MAElC;AACA,WAAK,yBAAyB,QAAQ;IACvC;IAEO,OAAO,KACb,KACA,KAAqB;AAErB,uCAAgB,IAAI,QAAQ,UAAU,CAAC;AACvC,YAAM,UAAU,IAAI;AACpB,YAAM,gBAAY,0BACjB,SACA,oCAAuB,KAAK,CAAC;AAI9B,YAAM,yBAAmD,UAAU,IAClE,CAAC,MAAM,0BAA0B,CAAC,CAAC;AAGpC,aAAO,IAAI,KAAK;QACf,QAAQ,IAAI;QACZ;OACA;IACF;IAEgB;IAET,UAAU,KAAsB;AACtC,WAAK,cAAU;;QAEd,KAAK,uBACH,IAAI,CAAC,MAAM,0BAA0B,QAAQ,CAAC,CAAC,EAC/C,OAAO,CAAC,MAAM,MAAM,EAAE;QACxB;QACA,oCAAuB,KAAK;MAAC;AAE9B,aAAO,MAAM,UAAU,GAAG;IAC3B;IAEO,WAAW,KAAgB;AACjC,aAAO;QACN,GAAG,MAAM,WAAW,GAAG;QACvB,SAAS;UACR,4BAA4B,KAAK,uBAC/B,IACA,CAAC,MACA;WACC,iCACC,qCACA,CAAC,CAEH,EAAE,EAEH,KAAK,EAAE;;;IAGZ;;;;IASY,oCAAgC,MAAA;8BAN5C,yCAAU,uCAA0B,YAAY,OAChD,kDAAmB,mCAAmC,CAAC;;;;oBAKF;wDAAA,YAAoB;WAAA;;;;;;;;AAA1E,mBAAA,MAAA,mBAAA,EAAA,OAAA,WAAA,GAAA,kBAAA,EAAA,MAAA,SAAA,MAAA,WAAA,MAAA,UAAA,UAAA,GAAA,MAAA,uBAAA;;;AAAa,wBAAA,YAAA,uBAAA;;;;;",
6
6
  "names": []
7
7
  }
@@ -138,7 +138,7 @@ let TimeCCAPI = (() => {
138
138
  }
139
139
  return super.supportsCommand(cmd);
140
140
  }
141
- // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
141
+ // oxlint-disable-next-line typescript/explicit-module-boundary-types
142
142
  async getTime() {
143
143
  this.assertSupportsCommand(import_Types.TimeCommand, import_Types.TimeCommand.TimeGet);
144
144
  const cc = new TimeCCTimeGet({
@@ -161,7 +161,7 @@ let TimeCCAPI = (() => {
161
161
  });
162
162
  return this.host.sendCommand(cc, this.commandOptions);
163
163
  }
164
- // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
164
+ // oxlint-disable-next-line typescript/explicit-module-boundary-types
165
165
  async getDate() {
166
166
  this.assertSupportsCommand(import_Types.TimeCommand, import_Types.TimeCommand.DateGet);
167
167
  const cc = new TimeCCDateGet({
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/cc/TimeCC.ts"],
4
- "sourcesContent": ["import type { CCEncodingContext, CCParsingContext } from \"@zwave-js/cc\";\nimport {\n\tCommandClasses,\n\ttype DSTInfo,\n\ttype GetValueDB,\n\ttype MaybeNotKnown,\n\ttype MessageOrCCLogEntry,\n\tMessagePriority,\n\ttype SupervisionResult,\n\ttype WithAddress,\n\tZWaveError,\n\tZWaveErrorCodes,\n\tformatDate,\n\tgetDSTInfo,\n\tvalidatePayload,\n} from \"@zwave-js/core\";\nimport { Bytes, pick } from \"@zwave-js/shared\";\nimport { validateArgs } from \"@zwave-js/transformers\";\nimport { CCAPI } from \"../lib/API.js\";\nimport {\n\ttype CCRaw,\n\tCommandClass,\n\ttype InterviewContext,\n} from \"../lib/CommandClass.js\";\nimport {\n\tAPI,\n\tCCCommand,\n\tcommandClass,\n\texpectedCCResponse,\n\timplementedVersion,\n\tuseSupervision,\n} from \"../lib/CommandClassDecorators.js\";\nimport { TimeCommand } from \"../lib/_Types.js\";\nimport { encodeTimezone, parseTimezone } from \"../lib/serializers.js\";\n\n// @noSetValueAPI\n// Only the timezone information can be set and that accepts a non-primitive value\n\n@API(CommandClasses.Time)\nexport class TimeCCAPI extends CCAPI {\n\tpublic supportsCommand(cmd: TimeCommand): MaybeNotKnown<boolean> {\n\t\tswitch (cmd) {\n\t\t\tcase TimeCommand.TimeGet:\n\t\t\tcase TimeCommand.TimeReport:\n\t\t\tcase TimeCommand.DateGet:\n\t\t\tcase TimeCommand.DateReport:\n\t\t\t\treturn this.isSinglecast(); // \"mandatory\"\n\t\t\tcase TimeCommand.TimeOffsetGet:\n\t\t\tcase TimeCommand.TimeOffsetReport:\n\t\t\t\treturn this.version >= 2 && this.isSinglecast();\n\t\t\tcase TimeCommand.TimeOffsetSet:\n\t\t\t\treturn this.version >= 2;\n\t\t}\n\t\treturn super.supportsCommand(cmd);\n\t}\n\n\t// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types\n\tpublic async getTime() {\n\t\tthis.assertSupportsCommand(TimeCommand, TimeCommand.TimeGet);\n\n\t\tconst cc = new TimeCCTimeGet({\n\t\t\tnodeId: this.endpoint.nodeId,\n\t\t\tendpointIndex: this.endpoint.index,\n\t\t});\n\t\tconst response = await this.host.sendCommand<TimeCCTimeReport>(\n\t\t\tcc,\n\t\t\tthis.commandOptions,\n\t\t);\n\t\tif (response) {\n\t\t\treturn pick(response, [\"hour\", \"minute\", \"second\"]);\n\t\t}\n\t}\n\n\t@validateArgs()\n\tpublic async reportTime(\n\t\thour: number,\n\t\tminute: number,\n\t\tsecond: number,\n\t): Promise<SupervisionResult | undefined> {\n\t\tthis.assertSupportsCommand(TimeCommand, TimeCommand.TimeReport);\n\n\t\tconst cc = new TimeCCTimeReport({\n\t\t\tnodeId: this.endpoint.nodeId,\n\t\t\tendpointIndex: this.endpoint.index,\n\t\t\thour,\n\t\t\tminute,\n\t\t\tsecond,\n\t\t});\n\t\treturn this.host.sendCommand(cc, this.commandOptions);\n\t}\n\n\t// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types\n\tpublic async getDate() {\n\t\tthis.assertSupportsCommand(TimeCommand, TimeCommand.DateGet);\n\n\t\tconst cc = new TimeCCDateGet({\n\t\t\tnodeId: this.endpoint.nodeId,\n\t\t\tendpointIndex: this.endpoint.index,\n\t\t});\n\t\tconst response = await this.host.sendCommand<TimeCCDateReport>(\n\t\t\tcc,\n\t\t\tthis.commandOptions,\n\t\t);\n\t\tif (response) {\n\t\t\treturn pick(response, [\"day\", \"month\", \"year\"]);\n\t\t}\n\t}\n\n\t@validateArgs()\n\tpublic async reportDate(\n\t\tyear: number,\n\t\tmonth: number,\n\t\tday: number,\n\t): Promise<SupervisionResult | undefined> {\n\t\tthis.assertSupportsCommand(TimeCommand, TimeCommand.DateReport);\n\n\t\tconst cc = new TimeCCDateReport({\n\t\t\tnodeId: this.endpoint.nodeId,\n\t\t\tendpointIndex: this.endpoint.index,\n\t\t\tyear,\n\t\t\tmonth,\n\t\t\tday,\n\t\t});\n\t\treturn this.host.sendCommand(cc, this.commandOptions);\n\t}\n\n\t@validateArgs()\n\tpublic async setTimezone(\n\t\ttimezone: DSTInfo,\n\t): Promise<SupervisionResult | undefined> {\n\t\tthis.assertSupportsCommand(TimeCommand, TimeCommand.TimeOffsetSet);\n\n\t\tconst cc = new TimeCCTimeOffsetSet({\n\t\t\tnodeId: this.endpoint.nodeId,\n\t\t\tendpointIndex: this.endpoint.index,\n\t\t\tstandardOffset: timezone.standardOffset,\n\t\t\tdstOffset: timezone.dstOffset,\n\t\t\tdstStart: timezone.startDate,\n\t\t\tdstEnd: timezone.endDate,\n\t\t});\n\t\treturn this.host.sendCommand(cc, this.commandOptions);\n\t}\n\n\tpublic async getTimezone(): Promise<MaybeNotKnown<DSTInfo>> {\n\t\tthis.assertSupportsCommand(TimeCommand, TimeCommand.TimeOffsetGet);\n\n\t\tconst cc = new TimeCCTimeOffsetGet({\n\t\t\tnodeId: this.endpoint.nodeId,\n\t\t\tendpointIndex: this.endpoint.index,\n\t\t});\n\t\tconst response = await this.host.sendCommand<\n\t\t\tTimeCCTimeOffsetReport\n\t\t>(\n\t\t\tcc,\n\t\t\tthis.commandOptions,\n\t\t);\n\t\tif (response) {\n\t\t\treturn {\n\t\t\t\tstandardOffset: response.standardOffset,\n\t\t\t\tdstOffset: response.dstOffset,\n\t\t\t\tstartDate: response.dstStartDate,\n\t\t\t\tendDate: response.dstEndDate,\n\t\t\t};\n\t\t}\n\t}\n\n\t@validateArgs()\n\tpublic async reportTimezone(\n\t\ttimezone: DSTInfo,\n\t): Promise<SupervisionResult | undefined> {\n\t\tthis.assertSupportsCommand(TimeCommand, TimeCommand.TimeOffsetReport);\n\n\t\tconst cc = new TimeCCTimeOffsetReport({\n\t\t\tnodeId: this.endpoint.nodeId,\n\t\t\tendpointIndex: this.endpoint.index,\n\t\t\tstandardOffset: timezone.standardOffset,\n\t\t\tdstOffset: timezone.dstOffset,\n\t\t\tdstStart: timezone.startDate,\n\t\t\tdstEnd: timezone.endDate,\n\t\t});\n\t\treturn this.host.sendCommand(cc, this.commandOptions);\n\t}\n}\n\n@commandClass(CommandClasses.Time)\n@implementedVersion(2)\nexport class TimeCC extends CommandClass {\n\tdeclare ccCommand: TimeCommand;\n\n\tpublic async interview(\n\t\tctx: InterviewContext,\n\t): Promise<void> {\n\t\tconst node = this.getNode(ctx)!;\n\t\tconst endpoint = this.getEndpoint(ctx)!;\n\t\tconst api = CCAPI.create(\n\t\t\tCommandClasses.Time,\n\t\t\tctx,\n\t\t\tendpoint,\n\t\t).withOptions({\n\t\t\tpriority: MessagePriority.NodeQuery,\n\t\t});\n\n\t\tctx.logNode(node.id, {\n\t\t\tendpoint: this.endpointIndex,\n\t\t\tmessage: `Interviewing ${this.ccName}...`,\n\t\t\tdirection: \"none\",\n\t\t});\n\n\t\t// Synchronize the slave's time\n\t\tif (api.version >= 2) {\n\t\t\tctx.logNode(node.id, {\n\t\t\t\tendpoint: this.endpointIndex,\n\t\t\t\tmessage: \"setting timezone information...\",\n\t\t\t\tdirection: \"outbound\",\n\t\t\t});\n\t\t\t// Set the correct timezone on this node\n\t\t\tconst timezone = getDSTInfo();\n\t\t\tawait api.setTimezone(timezone);\n\t\t}\n\n\t\t// Remember that the interview is complete\n\t\tthis.setInterviewComplete(ctx, true);\n\t}\n}\n\n// @publicAPI\nexport interface TimeCCTimeReportOptions {\n\thour: number;\n\tminute: number;\n\tsecond: number;\n}\n\n@CCCommand(TimeCommand.TimeReport)\nexport class TimeCCTimeReport extends TimeCC {\n\tpublic constructor(\n\t\toptions: WithAddress<TimeCCTimeReportOptions>,\n\t) {\n\t\tsuper(options);\n\t\tthis.hour = options.hour;\n\t\tthis.minute = options.minute;\n\t\tthis.second = options.second;\n\t}\n\n\tpublic static from(raw: CCRaw, ctx: CCParsingContext): TimeCCTimeReport {\n\t\tvalidatePayload(raw.payload.length >= 3);\n\t\tconst hour = raw.payload[0] & 0b11111;\n\t\tconst minute = raw.payload[1];\n\t\tconst second = raw.payload[2];\n\n\t\tvalidatePayload(\n\t\t\thour >= 0,\n\t\t\thour <= 23,\n\t\t\tminute >= 0,\n\t\t\tminute <= 59,\n\t\t\tsecond >= 0,\n\t\t\tsecond <= 59,\n\t\t);\n\n\t\treturn new this({\n\t\t\tnodeId: ctx.sourceNodeId,\n\t\t\thour,\n\t\t\tminute,\n\t\t\tsecond,\n\t\t});\n\t}\n\n\tpublic hour: number;\n\tpublic minute: number;\n\tpublic second: number;\n\n\tpublic serialize(ctx: CCEncodingContext): Promise<Bytes> {\n\t\tthis.payload = Bytes.from([\n\t\t\tthis.hour & 0b11111,\n\t\t\tthis.minute,\n\t\t\tthis.second,\n\t\t]);\n\t\treturn super.serialize(ctx);\n\t}\n\n\tpublic toLogEntry(ctx?: GetValueDB): MessageOrCCLogEntry {\n\t\treturn {\n\t\t\t...super.toLogEntry(ctx),\n\t\t\tmessage: {\n\t\t\t\ttime: `${this.hour.toString().padStart(2, \"0\")}:${\n\t\t\t\t\tthis.minute.toString().padStart(2, \"0\")\n\t\t\t\t}:${this.second.toString().padStart(2, \"0\")}`,\n\t\t\t},\n\t\t};\n\t}\n}\n\n@CCCommand(TimeCommand.TimeGet)\n@expectedCCResponse(TimeCCTimeReport)\nexport class TimeCCTimeGet extends TimeCC {}\n\n// @publicAPI\nexport interface TimeCCDateReportOptions {\n\tyear: number;\n\tmonth: number;\n\tday: number;\n}\n\n@CCCommand(TimeCommand.DateReport)\nexport class TimeCCDateReport extends TimeCC {\n\tpublic constructor(\n\t\toptions: WithAddress<TimeCCDateReportOptions>,\n\t) {\n\t\tsuper(options);\n\t\tthis.year = options.year;\n\t\tthis.month = options.month;\n\t\tthis.day = options.day;\n\t}\n\n\tpublic static from(raw: CCRaw, ctx: CCParsingContext): TimeCCDateReport {\n\t\tvalidatePayload(raw.payload.length >= 4);\n\t\tconst year = raw.payload.readUInt16BE(0);\n\t\tconst month = raw.payload[2];\n\t\tconst day = raw.payload[3];\n\n\t\treturn new this({\n\t\t\tnodeId: ctx.sourceNodeId,\n\t\t\tyear,\n\t\t\tmonth,\n\t\t\tday,\n\t\t});\n\t}\n\n\tpublic year: number;\n\tpublic month: number;\n\tpublic day: number;\n\n\tpublic serialize(ctx: CCEncodingContext): Promise<Bytes> {\n\t\tthis.payload = Bytes.from([\n\t\t\t// 2 bytes placeholder for year\n\t\t\t0,\n\t\t\t0,\n\t\t\tthis.month,\n\t\t\tthis.day,\n\t\t]);\n\t\tthis.payload.writeUInt16BE(this.year, 0);\n\t\treturn super.serialize(ctx);\n\t}\n\n\tpublic toLogEntry(ctx?: GetValueDB): MessageOrCCLogEntry {\n\t\treturn {\n\t\t\t...super.toLogEntry(ctx),\n\t\t\tmessage: {\n\t\t\t\tdate: `${this.year.toString().padStart(4, \"0\")}-${\n\t\t\t\t\tthis.month.toString().padStart(2, \"0\")\n\t\t\t\t}-${this.day.toString().padStart(2, \"0\")}`,\n\t\t\t},\n\t\t};\n\t}\n}\n\n@CCCommand(TimeCommand.DateGet)\n@expectedCCResponse(TimeCCDateReport)\nexport class TimeCCDateGet extends TimeCC {}\n\n// @publicAPI\nexport interface TimeCCTimeOffsetSetOptions {\n\tstandardOffset: number;\n\tdstOffset: number;\n\tdstStart: Date;\n\tdstEnd: Date;\n}\n\n@CCCommand(TimeCommand.TimeOffsetSet)\n@useSupervision()\nexport class TimeCCTimeOffsetSet extends TimeCC {\n\tpublic constructor(\n\t\toptions: WithAddress<TimeCCTimeOffsetSetOptions>,\n\t) {\n\t\tsuper(options);\n\t\tthis.standardOffset = options.standardOffset;\n\t\tthis.dstOffset = options.dstOffset;\n\t\tthis.dstStartDate = options.dstStart;\n\t\tthis.dstEndDate = options.dstEnd;\n\t}\n\n\tpublic static from(\n\t\t_raw: CCRaw,\n\t\t_ctx: CCParsingContext,\n\t): TimeCCTimeOffsetSet {\n\t\t// TODO: Deserialize payload\n\t\tthrow new ZWaveError(\n\t\t\t`${this.name}: deserialization not implemented`,\n\t\t\tZWaveErrorCodes.Deserialization_NotImplemented,\n\t\t);\n\n\t\t// return new TimeCCTimeOffsetSet({\n\t\t// \tnodeId: ctx.sourceNodeId,\n\t\t// });\n\t}\n\n\tpublic standardOffset: number;\n\tpublic dstOffset: number;\n\tpublic dstStartDate: Date;\n\tpublic dstEndDate: Date;\n\n\tpublic serialize(ctx: CCEncodingContext): Promise<Bytes> {\n\t\tthis.payload = Bytes.concat([\n\t\t\tencodeTimezone({\n\t\t\t\tstandardOffset: this.standardOffset,\n\t\t\t\tdstOffset: this.dstOffset,\n\t\t\t}),\n\t\t\tBytes.from([\n\t\t\t\tthis.dstStartDate.getUTCMonth() + 1,\n\t\t\t\tthis.dstStartDate.getUTCDate(),\n\t\t\t\tthis.dstStartDate.getUTCHours(),\n\t\t\t\tthis.dstEndDate.getUTCMonth() + 1,\n\t\t\t\tthis.dstEndDate.getUTCDate(),\n\t\t\t\tthis.dstEndDate.getUTCHours(),\n\t\t\t]),\n\t\t]);\n\t\treturn super.serialize(ctx);\n\t}\n\n\tpublic toLogEntry(ctx?: GetValueDB): MessageOrCCLogEntry {\n\t\treturn {\n\t\t\t...super.toLogEntry(ctx),\n\t\t\tmessage: {\n\t\t\t\t\"standard time offset\": `${this.standardOffset} minutes`,\n\t\t\t\t\"DST offset\": `${this.dstOffset} minutes`,\n\t\t\t\t\"DST start date\": formatDate(this.dstStartDate, \"YYYY-MM-DD\"),\n\t\t\t\t\"DST end date\": formatDate(this.dstEndDate, \"YYYY-MM-DD\"),\n\t\t\t},\n\t\t};\n\t}\n}\n\n// @publicAPI\nexport interface TimeCCTimeOffsetReportOptions {\n\tstandardOffset: number;\n\tdstOffset: number;\n\tdstStart: Date;\n\tdstEnd: Date;\n}\n\n@CCCommand(TimeCommand.TimeOffsetReport)\nexport class TimeCCTimeOffsetReport extends TimeCC {\n\tpublic constructor(\n\t\toptions: WithAddress<TimeCCTimeOffsetReportOptions>,\n\t) {\n\t\tsuper(options);\n\t\tthis.standardOffset = options.standardOffset;\n\t\tthis.dstOffset = options.dstOffset;\n\t\tthis.dstStartDate = options.dstStart;\n\t\tthis.dstEndDate = options.dstEnd;\n\t}\n\n\tpublic static from(\n\t\traw: CCRaw,\n\t\tctx: CCParsingContext,\n\t): TimeCCTimeOffsetReport {\n\t\tvalidatePayload(raw.payload.length >= 9);\n\t\tconst { standardOffset, dstOffset } = parseTimezone(raw.payload);\n\t\tconst currentYear = new Date().getUTCFullYear();\n\t\tconst dstStartDate: Date = new Date(\n\t\t\tDate.UTC(\n\t\t\t\tcurrentYear,\n\t\t\t\traw.payload[3] - 1,\n\t\t\t\traw.payload[4],\n\t\t\t\traw.payload[5],\n\t\t\t),\n\t\t);\n\t\tconst dstEndDate: Date = new Date(\n\t\t\tDate.UTC(\n\t\t\t\tcurrentYear,\n\t\t\t\traw.payload[6] - 1,\n\t\t\t\traw.payload[7],\n\t\t\t\traw.payload[8],\n\t\t\t),\n\t\t);\n\n\t\treturn new this({\n\t\t\tnodeId: ctx.sourceNodeId,\n\t\t\tstandardOffset,\n\t\t\tdstOffset,\n\t\t\tdstStart: dstStartDate,\n\t\t\tdstEnd: dstEndDate,\n\t\t});\n\t}\n\n\tpublic standardOffset: number;\n\tpublic dstOffset: number;\n\tpublic dstStartDate: Date;\n\tpublic dstEndDate: Date;\n\n\tpublic serialize(ctx: CCEncodingContext): Promise<Bytes> {\n\t\tthis.payload = Bytes.concat([\n\t\t\tencodeTimezone({\n\t\t\t\tstandardOffset: this.standardOffset,\n\t\t\t\tdstOffset: this.dstOffset,\n\t\t\t}),\n\t\t\tBytes.from([\n\t\t\t\tthis.dstStartDate.getUTCMonth() + 1,\n\t\t\t\tthis.dstStartDate.getUTCDate(),\n\t\t\t\tthis.dstStartDate.getUTCHours(),\n\t\t\t\tthis.dstEndDate.getUTCMonth() + 1,\n\t\t\t\tthis.dstEndDate.getUTCDate(),\n\t\t\t\tthis.dstEndDate.getUTCHours(),\n\t\t\t]),\n\t\t]);\n\t\treturn super.serialize(ctx);\n\t}\n\n\tpublic toLogEntry(ctx?: GetValueDB): MessageOrCCLogEntry {\n\t\treturn {\n\t\t\t...super.toLogEntry(ctx),\n\t\t\tmessage: {\n\t\t\t\t\"standard time offset\": `${this.standardOffset} minutes`,\n\t\t\t\t\"DST offset\": `${this.dstOffset} minutes`,\n\t\t\t\t\"DST start date\": formatDate(this.dstStartDate, \"YYYY-MM-DD\"),\n\t\t\t\t\"DST end date\": formatDate(this.dstEndDate, \"YYYY-MM-DD\"),\n\t\t\t},\n\t\t};\n\t}\n}\n\n@CCCommand(TimeCommand.TimeOffsetGet)\n@expectedCCResponse(TimeCCTimeOffsetReport)\nexport class TimeCCTimeOffsetGet extends TimeCC {}\n"],
4
+ "sourcesContent": ["import type { CCEncodingContext, CCParsingContext } from \"@zwave-js/cc\";\nimport {\n\tCommandClasses,\n\ttype DSTInfo,\n\ttype GetValueDB,\n\ttype MaybeNotKnown,\n\ttype MessageOrCCLogEntry,\n\tMessagePriority,\n\ttype SupervisionResult,\n\ttype WithAddress,\n\tZWaveError,\n\tZWaveErrorCodes,\n\tformatDate,\n\tgetDSTInfo,\n\tvalidatePayload,\n} from \"@zwave-js/core\";\nimport { Bytes, pick } from \"@zwave-js/shared\";\nimport { validateArgs } from \"@zwave-js/transformers\";\nimport { CCAPI } from \"../lib/API.js\";\nimport {\n\ttype CCRaw,\n\tCommandClass,\n\ttype InterviewContext,\n} from \"../lib/CommandClass.js\";\nimport {\n\tAPI,\n\tCCCommand,\n\tcommandClass,\n\texpectedCCResponse,\n\timplementedVersion,\n\tuseSupervision,\n} from \"../lib/CommandClassDecorators.js\";\nimport { TimeCommand } from \"../lib/_Types.js\";\nimport { encodeTimezone, parseTimezone } from \"../lib/serializers.js\";\n\n// @noSetValueAPI\n// Only the timezone information can be set and that accepts a non-primitive value\n\n@API(CommandClasses.Time)\nexport class TimeCCAPI extends CCAPI {\n\tpublic supportsCommand(cmd: TimeCommand): MaybeNotKnown<boolean> {\n\t\tswitch (cmd) {\n\t\t\tcase TimeCommand.TimeGet:\n\t\t\tcase TimeCommand.TimeReport:\n\t\t\tcase TimeCommand.DateGet:\n\t\t\tcase TimeCommand.DateReport:\n\t\t\t\treturn this.isSinglecast(); // \"mandatory\"\n\t\t\tcase TimeCommand.TimeOffsetGet:\n\t\t\tcase TimeCommand.TimeOffsetReport:\n\t\t\t\treturn this.version >= 2 && this.isSinglecast();\n\t\t\tcase TimeCommand.TimeOffsetSet:\n\t\t\t\treturn this.version >= 2;\n\t\t}\n\t\treturn super.supportsCommand(cmd);\n\t}\n\n\t// oxlint-disable-next-line typescript/explicit-module-boundary-types\n\tpublic async getTime() {\n\t\tthis.assertSupportsCommand(TimeCommand, TimeCommand.TimeGet);\n\n\t\tconst cc = new TimeCCTimeGet({\n\t\t\tnodeId: this.endpoint.nodeId,\n\t\t\tendpointIndex: this.endpoint.index,\n\t\t});\n\t\tconst response = await this.host.sendCommand<TimeCCTimeReport>(\n\t\t\tcc,\n\t\t\tthis.commandOptions,\n\t\t);\n\t\tif (response) {\n\t\t\treturn pick(response, [\"hour\", \"minute\", \"second\"]);\n\t\t}\n\t}\n\n\t@validateArgs()\n\tpublic async reportTime(\n\t\thour: number,\n\t\tminute: number,\n\t\tsecond: number,\n\t): Promise<SupervisionResult | undefined> {\n\t\tthis.assertSupportsCommand(TimeCommand, TimeCommand.TimeReport);\n\n\t\tconst cc = new TimeCCTimeReport({\n\t\t\tnodeId: this.endpoint.nodeId,\n\t\t\tendpointIndex: this.endpoint.index,\n\t\t\thour,\n\t\t\tminute,\n\t\t\tsecond,\n\t\t});\n\t\treturn this.host.sendCommand(cc, this.commandOptions);\n\t}\n\n\t// oxlint-disable-next-line typescript/explicit-module-boundary-types\n\tpublic async getDate() {\n\t\tthis.assertSupportsCommand(TimeCommand, TimeCommand.DateGet);\n\n\t\tconst cc = new TimeCCDateGet({\n\t\t\tnodeId: this.endpoint.nodeId,\n\t\t\tendpointIndex: this.endpoint.index,\n\t\t});\n\t\tconst response = await this.host.sendCommand<TimeCCDateReport>(\n\t\t\tcc,\n\t\t\tthis.commandOptions,\n\t\t);\n\t\tif (response) {\n\t\t\treturn pick(response, [\"day\", \"month\", \"year\"]);\n\t\t}\n\t}\n\n\t@validateArgs()\n\tpublic async reportDate(\n\t\tyear: number,\n\t\tmonth: number,\n\t\tday: number,\n\t): Promise<SupervisionResult | undefined> {\n\t\tthis.assertSupportsCommand(TimeCommand, TimeCommand.DateReport);\n\n\t\tconst cc = new TimeCCDateReport({\n\t\t\tnodeId: this.endpoint.nodeId,\n\t\t\tendpointIndex: this.endpoint.index,\n\t\t\tyear,\n\t\t\tmonth,\n\t\t\tday,\n\t\t});\n\t\treturn this.host.sendCommand(cc, this.commandOptions);\n\t}\n\n\t@validateArgs()\n\tpublic async setTimezone(\n\t\ttimezone: DSTInfo,\n\t): Promise<SupervisionResult | undefined> {\n\t\tthis.assertSupportsCommand(TimeCommand, TimeCommand.TimeOffsetSet);\n\n\t\tconst cc = new TimeCCTimeOffsetSet({\n\t\t\tnodeId: this.endpoint.nodeId,\n\t\t\tendpointIndex: this.endpoint.index,\n\t\t\tstandardOffset: timezone.standardOffset,\n\t\t\tdstOffset: timezone.dstOffset,\n\t\t\tdstStart: timezone.startDate,\n\t\t\tdstEnd: timezone.endDate,\n\t\t});\n\t\treturn this.host.sendCommand(cc, this.commandOptions);\n\t}\n\n\tpublic async getTimezone(): Promise<MaybeNotKnown<DSTInfo>> {\n\t\tthis.assertSupportsCommand(TimeCommand, TimeCommand.TimeOffsetGet);\n\n\t\tconst cc = new TimeCCTimeOffsetGet({\n\t\t\tnodeId: this.endpoint.nodeId,\n\t\t\tendpointIndex: this.endpoint.index,\n\t\t});\n\t\tconst response = await this.host.sendCommand<\n\t\t\tTimeCCTimeOffsetReport\n\t\t>(\n\t\t\tcc,\n\t\t\tthis.commandOptions,\n\t\t);\n\t\tif (response) {\n\t\t\treturn {\n\t\t\t\tstandardOffset: response.standardOffset,\n\t\t\t\tdstOffset: response.dstOffset,\n\t\t\t\tstartDate: response.dstStartDate,\n\t\t\t\tendDate: response.dstEndDate,\n\t\t\t};\n\t\t}\n\t}\n\n\t@validateArgs()\n\tpublic async reportTimezone(\n\t\ttimezone: DSTInfo,\n\t): Promise<SupervisionResult | undefined> {\n\t\tthis.assertSupportsCommand(TimeCommand, TimeCommand.TimeOffsetReport);\n\n\t\tconst cc = new TimeCCTimeOffsetReport({\n\t\t\tnodeId: this.endpoint.nodeId,\n\t\t\tendpointIndex: this.endpoint.index,\n\t\t\tstandardOffset: timezone.standardOffset,\n\t\t\tdstOffset: timezone.dstOffset,\n\t\t\tdstStart: timezone.startDate,\n\t\t\tdstEnd: timezone.endDate,\n\t\t});\n\t\treturn this.host.sendCommand(cc, this.commandOptions);\n\t}\n}\n\n@commandClass(CommandClasses.Time)\n@implementedVersion(2)\nexport class TimeCC extends CommandClass {\n\tdeclare ccCommand: TimeCommand;\n\n\tpublic async interview(\n\t\tctx: InterviewContext,\n\t): Promise<void> {\n\t\tconst node = this.getNode(ctx)!;\n\t\tconst endpoint = this.getEndpoint(ctx)!;\n\t\tconst api = CCAPI.create(\n\t\t\tCommandClasses.Time,\n\t\t\tctx,\n\t\t\tendpoint,\n\t\t).withOptions({\n\t\t\tpriority: MessagePriority.NodeQuery,\n\t\t});\n\n\t\tctx.logNode(node.id, {\n\t\t\tendpoint: this.endpointIndex,\n\t\t\tmessage: `Interviewing ${this.ccName}...`,\n\t\t\tdirection: \"none\",\n\t\t});\n\n\t\t// Synchronize the slave's time\n\t\tif (api.version >= 2) {\n\t\t\tctx.logNode(node.id, {\n\t\t\t\tendpoint: this.endpointIndex,\n\t\t\t\tmessage: \"setting timezone information...\",\n\t\t\t\tdirection: \"outbound\",\n\t\t\t});\n\t\t\t// Set the correct timezone on this node\n\t\t\tconst timezone = getDSTInfo();\n\t\t\tawait api.setTimezone(timezone);\n\t\t}\n\n\t\t// Remember that the interview is complete\n\t\tthis.setInterviewComplete(ctx, true);\n\t}\n}\n\n// @publicAPI\nexport interface TimeCCTimeReportOptions {\n\thour: number;\n\tminute: number;\n\tsecond: number;\n}\n\n@CCCommand(TimeCommand.TimeReport)\nexport class TimeCCTimeReport extends TimeCC {\n\tpublic constructor(\n\t\toptions: WithAddress<TimeCCTimeReportOptions>,\n\t) {\n\t\tsuper(options);\n\t\tthis.hour = options.hour;\n\t\tthis.minute = options.minute;\n\t\tthis.second = options.second;\n\t}\n\n\tpublic static from(raw: CCRaw, ctx: CCParsingContext): TimeCCTimeReport {\n\t\tvalidatePayload(raw.payload.length >= 3);\n\t\tconst hour = raw.payload[0] & 0b11111;\n\t\tconst minute = raw.payload[1];\n\t\tconst second = raw.payload[2];\n\n\t\tvalidatePayload(\n\t\t\thour >= 0,\n\t\t\thour <= 23,\n\t\t\tminute >= 0,\n\t\t\tminute <= 59,\n\t\t\tsecond >= 0,\n\t\t\tsecond <= 59,\n\t\t);\n\n\t\treturn new this({\n\t\t\tnodeId: ctx.sourceNodeId,\n\t\t\thour,\n\t\t\tminute,\n\t\t\tsecond,\n\t\t});\n\t}\n\n\tpublic hour: number;\n\tpublic minute: number;\n\tpublic second: number;\n\n\tpublic serialize(ctx: CCEncodingContext): Promise<Bytes> {\n\t\tthis.payload = Bytes.from([\n\t\t\tthis.hour & 0b11111,\n\t\t\tthis.minute,\n\t\t\tthis.second,\n\t\t]);\n\t\treturn super.serialize(ctx);\n\t}\n\n\tpublic toLogEntry(ctx?: GetValueDB): MessageOrCCLogEntry {\n\t\treturn {\n\t\t\t...super.toLogEntry(ctx),\n\t\t\tmessage: {\n\t\t\t\ttime: `${this.hour.toString().padStart(2, \"0\")}:${\n\t\t\t\t\tthis.minute.toString().padStart(2, \"0\")\n\t\t\t\t}:${this.second.toString().padStart(2, \"0\")}`,\n\t\t\t},\n\t\t};\n\t}\n}\n\n@CCCommand(TimeCommand.TimeGet)\n@expectedCCResponse(TimeCCTimeReport)\nexport class TimeCCTimeGet extends TimeCC {}\n\n// @publicAPI\nexport interface TimeCCDateReportOptions {\n\tyear: number;\n\tmonth: number;\n\tday: number;\n}\n\n@CCCommand(TimeCommand.DateReport)\nexport class TimeCCDateReport extends TimeCC {\n\tpublic constructor(\n\t\toptions: WithAddress<TimeCCDateReportOptions>,\n\t) {\n\t\tsuper(options);\n\t\tthis.year = options.year;\n\t\tthis.month = options.month;\n\t\tthis.day = options.day;\n\t}\n\n\tpublic static from(raw: CCRaw, ctx: CCParsingContext): TimeCCDateReport {\n\t\tvalidatePayload(raw.payload.length >= 4);\n\t\tconst year = raw.payload.readUInt16BE(0);\n\t\tconst month = raw.payload[2];\n\t\tconst day = raw.payload[3];\n\n\t\treturn new this({\n\t\t\tnodeId: ctx.sourceNodeId,\n\t\t\tyear,\n\t\t\tmonth,\n\t\t\tday,\n\t\t});\n\t}\n\n\tpublic year: number;\n\tpublic month: number;\n\tpublic day: number;\n\n\tpublic serialize(ctx: CCEncodingContext): Promise<Bytes> {\n\t\tthis.payload = Bytes.from([\n\t\t\t// 2 bytes placeholder for year\n\t\t\t0,\n\t\t\t0,\n\t\t\tthis.month,\n\t\t\tthis.day,\n\t\t]);\n\t\tthis.payload.writeUInt16BE(this.year, 0);\n\t\treturn super.serialize(ctx);\n\t}\n\n\tpublic toLogEntry(ctx?: GetValueDB): MessageOrCCLogEntry {\n\t\treturn {\n\t\t\t...super.toLogEntry(ctx),\n\t\t\tmessage: {\n\t\t\t\tdate: `${this.year.toString().padStart(4, \"0\")}-${\n\t\t\t\t\tthis.month.toString().padStart(2, \"0\")\n\t\t\t\t}-${this.day.toString().padStart(2, \"0\")}`,\n\t\t\t},\n\t\t};\n\t}\n}\n\n@CCCommand(TimeCommand.DateGet)\n@expectedCCResponse(TimeCCDateReport)\nexport class TimeCCDateGet extends TimeCC {}\n\n// @publicAPI\nexport interface TimeCCTimeOffsetSetOptions {\n\tstandardOffset: number;\n\tdstOffset: number;\n\tdstStart: Date;\n\tdstEnd: Date;\n}\n\n@CCCommand(TimeCommand.TimeOffsetSet)\n@useSupervision()\nexport class TimeCCTimeOffsetSet extends TimeCC {\n\tpublic constructor(\n\t\toptions: WithAddress<TimeCCTimeOffsetSetOptions>,\n\t) {\n\t\tsuper(options);\n\t\tthis.standardOffset = options.standardOffset;\n\t\tthis.dstOffset = options.dstOffset;\n\t\tthis.dstStartDate = options.dstStart;\n\t\tthis.dstEndDate = options.dstEnd;\n\t}\n\n\tpublic static from(\n\t\t_raw: CCRaw,\n\t\t_ctx: CCParsingContext,\n\t): TimeCCTimeOffsetSet {\n\t\t// TODO: Deserialize payload\n\t\tthrow new ZWaveError(\n\t\t\t`${this.name}: deserialization not implemented`,\n\t\t\tZWaveErrorCodes.Deserialization_NotImplemented,\n\t\t);\n\n\t\t// return new TimeCCTimeOffsetSet({\n\t\t// \tnodeId: ctx.sourceNodeId,\n\t\t// });\n\t}\n\n\tpublic standardOffset: number;\n\tpublic dstOffset: number;\n\tpublic dstStartDate: Date;\n\tpublic dstEndDate: Date;\n\n\tpublic serialize(ctx: CCEncodingContext): Promise<Bytes> {\n\t\tthis.payload = Bytes.concat([\n\t\t\tencodeTimezone({\n\t\t\t\tstandardOffset: this.standardOffset,\n\t\t\t\tdstOffset: this.dstOffset,\n\t\t\t}),\n\t\t\tBytes.from([\n\t\t\t\tthis.dstStartDate.getUTCMonth() + 1,\n\t\t\t\tthis.dstStartDate.getUTCDate(),\n\t\t\t\tthis.dstStartDate.getUTCHours(),\n\t\t\t\tthis.dstEndDate.getUTCMonth() + 1,\n\t\t\t\tthis.dstEndDate.getUTCDate(),\n\t\t\t\tthis.dstEndDate.getUTCHours(),\n\t\t\t]),\n\t\t]);\n\t\treturn super.serialize(ctx);\n\t}\n\n\tpublic toLogEntry(ctx?: GetValueDB): MessageOrCCLogEntry {\n\t\treturn {\n\t\t\t...super.toLogEntry(ctx),\n\t\t\tmessage: {\n\t\t\t\t\"standard time offset\": `${this.standardOffset} minutes`,\n\t\t\t\t\"DST offset\": `${this.dstOffset} minutes`,\n\t\t\t\t\"DST start date\": formatDate(this.dstStartDate, \"YYYY-MM-DD\"),\n\t\t\t\t\"DST end date\": formatDate(this.dstEndDate, \"YYYY-MM-DD\"),\n\t\t\t},\n\t\t};\n\t}\n}\n\n// @publicAPI\nexport interface TimeCCTimeOffsetReportOptions {\n\tstandardOffset: number;\n\tdstOffset: number;\n\tdstStart: Date;\n\tdstEnd: Date;\n}\n\n@CCCommand(TimeCommand.TimeOffsetReport)\nexport class TimeCCTimeOffsetReport extends TimeCC {\n\tpublic constructor(\n\t\toptions: WithAddress<TimeCCTimeOffsetReportOptions>,\n\t) {\n\t\tsuper(options);\n\t\tthis.standardOffset = options.standardOffset;\n\t\tthis.dstOffset = options.dstOffset;\n\t\tthis.dstStartDate = options.dstStart;\n\t\tthis.dstEndDate = options.dstEnd;\n\t}\n\n\tpublic static from(\n\t\traw: CCRaw,\n\t\tctx: CCParsingContext,\n\t): TimeCCTimeOffsetReport {\n\t\tvalidatePayload(raw.payload.length >= 9);\n\t\tconst { standardOffset, dstOffset } = parseTimezone(raw.payload);\n\t\tconst currentYear = new Date().getUTCFullYear();\n\t\tconst dstStartDate: Date = new Date(\n\t\t\tDate.UTC(\n\t\t\t\tcurrentYear,\n\t\t\t\traw.payload[3] - 1,\n\t\t\t\traw.payload[4],\n\t\t\t\traw.payload[5],\n\t\t\t),\n\t\t);\n\t\tconst dstEndDate: Date = new Date(\n\t\t\tDate.UTC(\n\t\t\t\tcurrentYear,\n\t\t\t\traw.payload[6] - 1,\n\t\t\t\traw.payload[7],\n\t\t\t\traw.payload[8],\n\t\t\t),\n\t\t);\n\n\t\treturn new this({\n\t\t\tnodeId: ctx.sourceNodeId,\n\t\t\tstandardOffset,\n\t\t\tdstOffset,\n\t\t\tdstStart: dstStartDate,\n\t\t\tdstEnd: dstEndDate,\n\t\t});\n\t}\n\n\tpublic standardOffset: number;\n\tpublic dstOffset: number;\n\tpublic dstStartDate: Date;\n\tpublic dstEndDate: Date;\n\n\tpublic serialize(ctx: CCEncodingContext): Promise<Bytes> {\n\t\tthis.payload = Bytes.concat([\n\t\t\tencodeTimezone({\n\t\t\t\tstandardOffset: this.standardOffset,\n\t\t\t\tdstOffset: this.dstOffset,\n\t\t\t}),\n\t\t\tBytes.from([\n\t\t\t\tthis.dstStartDate.getUTCMonth() + 1,\n\t\t\t\tthis.dstStartDate.getUTCDate(),\n\t\t\t\tthis.dstStartDate.getUTCHours(),\n\t\t\t\tthis.dstEndDate.getUTCMonth() + 1,\n\t\t\t\tthis.dstEndDate.getUTCDate(),\n\t\t\t\tthis.dstEndDate.getUTCHours(),\n\t\t\t]),\n\t\t]);\n\t\treturn super.serialize(ctx);\n\t}\n\n\tpublic toLogEntry(ctx?: GetValueDB): MessageOrCCLogEntry {\n\t\treturn {\n\t\t\t...super.toLogEntry(ctx),\n\t\t\tmessage: {\n\t\t\t\t\"standard time offset\": `${this.standardOffset} minutes`,\n\t\t\t\t\"DST offset\": `${this.dstOffset} minutes`,\n\t\t\t\t\"DST start date\": formatDate(this.dstStartDate, \"YYYY-MM-DD\"),\n\t\t\t\t\"DST end date\": formatDate(this.dstEndDate, \"YYYY-MM-DD\"),\n\t\t\t},\n\t\t};\n\t}\n}\n\n@CCCommand(TimeCommand.TimeOffsetGet)\n@expectedCCResponse(TimeCCTimeOffsetReport)\nexport class TimeCCTimeOffsetGet extends TimeCC {}\n"],
5
5
  "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,kBAcO;AACP,oBAA4B;AAE5B,iBAAsB;AACtB,0BAIO;AAC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AA,SAAA,MAAA,WAAA,MAAA,UAAA,UAAA,GAAA,MAAA,uBAAA;;;AAAa,wBAAA,YAAA,uBAAA;;;;;",
6
6
  "names": []
7
7
  }
@@ -307,7 +307,7 @@ let TransportServiceCCSubsequentSegment = (() => {
307
307
  return true;
308
308
  }
309
309
  const datagramSize = session[0].datagramSize;
310
- const receivedBytes = new Array(datagramSize).fill(false);
310
+ const receivedBytes = Array.from({ length: datagramSize }).fill(false);
311
311
  for (const segment of [...session, this]) {
312
312
  const offset = segment instanceof TransportServiceCCFirstSegment ? 0 : segment.datagramOffset;
313
313
  for (let i = offset; i <= offset + segment.partialDatagram.length; i++) {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/cc/TransportServiceCC.ts"],
4
- "sourcesContent": ["import type { CCEncodingContext, CCParsingContext } from \"@zwave-js/cc\";\nimport {\n\tCRC16_CCITT,\n\tCommandClasses,\n\ttype GetValueDB,\n\ttype MessageOrCCLogEntry,\n\ttype SinglecastCC,\n\ttype WithAddress,\n\tZWaveError,\n\tZWaveErrorCodes,\n\tvalidatePayload,\n} from \"@zwave-js/core\";\nimport { Bytes, type BytesView, buffer2hex } from \"@zwave-js/shared\";\nimport { type CCRaw, CommandClass } from \"../lib/CommandClass.js\";\nimport {\n\tCCCommand,\n\tcommandClass,\n\timplementedVersion,\n} from \"../lib/CommandClassDecorators.js\";\nimport { TransportServiceCommand } from \"../lib/_Types.js\";\n\nexport const MAX_SEGMENT_SIZE = 39;\n\nexport const RELAXED_TIMING_THRESHOLD = 2;\n\n// TODO: Figure out how we know if communicating with R2 or R3\n/** @publicAPI */\nexport const TransportServiceTimeouts = {\n\t/** Waiting time before requesting a missing segment at data rate R2 */\n\trequestMissingSegmentR2: 800,\n\t/** Waiting time before requesting a missing segment at data rate R3 */\n\trequestMissingSegmentR3: 400,\n\t/** Waiting time before sending another datagram at data rate R2 */\n\tsegmentCompleteR2: 1000,\n\t/** Waiting time before sending another datagram at data rate R3 */\n\tsegmentCompleteR3: 500,\n\t/** Waiting time between segments when sending more than {@link RELAXED_TIMING_THRESHOLD} segments at data rate R2 */\n\trelaxedTimingDelayR2: 35,\n\t/** Waiting time between segments when sending more than {@link RELAXED_TIMING_THRESHOLD} segments at data rate R3 */\n\trelaxedTimingDelayR3: 15,\n};\n\n@commandClass(CommandClasses[\"Transport Service\"])\n@implementedVersion(2)\nexport class TransportServiceCC extends CommandClass\n\timplements SinglecastCC<TransportServiceCC>\n{\n\tdeclare ccCommand: TransportServiceCommand;\n\tdeclare nodeId: number;\n}\n\n// @publicAPI\nexport interface TransportServiceCCFirstSegmentOptions {\n\tdatagramSize: number;\n\tsessionId: number;\n\theaderExtension?: BytesView | undefined;\n\tpartialDatagram: BytesView;\n}\n\n/** @publicAPI */\nexport function isTransportServiceEncapsulation(\n\tcommand: CommandClass,\n): command is\n\t| TransportServiceCCFirstSegment\n\t| TransportServiceCCSubsequentSegment\n{\n\treturn (\n\t\tcommand.ccId === CommandClasses[\"Transport Service\"]\n\t\t&& (command.ccCommand === TransportServiceCommand.FirstSegment\n\t\t\t|| command.ccCommand === TransportServiceCommand.SubsequentSegment)\n\t);\n}\n\n@CCCommand(TransportServiceCommand.FirstSegment)\n// Handling expected responses is done by the RX state machine\nexport class TransportServiceCCFirstSegment extends TransportServiceCC {\n\tpublic constructor(\n\t\toptions: WithAddress<TransportServiceCCFirstSegmentOptions>,\n\t) {\n\t\tsuper(options);\n\t\tthis.datagramSize = options.datagramSize;\n\t\tthis.sessionId = options.sessionId;\n\t\tthis.headerExtension = options.headerExtension;\n\t\tthis.partialDatagram = options.partialDatagram;\n\t}\n\n\tpublic static from(\n\t\traw: CCRaw,\n\t\tctx: CCParsingContext,\n\t): TransportServiceCCFirstSegment {\n\t\t// Deserialization has already split the datagram size from the ccCommand.\n\t\t// Therefore we have one more payload byte\n\n\t\tvalidatePayload(raw.payload.length >= 6); // 2 bytes dgram size, 1 byte sessid/ext, 1+ bytes payload, 2 bytes checksum\n\n\t\t// Verify the CRC\n\t\tconst headerBuffer = Bytes.from([\n\t\t\tCommandClasses[\"Transport Service\"],\n\t\t\tTransportServiceCommand.FirstSegment | raw.payload[0],\n\t\t]);\n\t\tconst ccBuffer = raw.payload.subarray(1, -2);\n\t\tlet expectedCRC = CRC16_CCITT(headerBuffer);\n\t\texpectedCRC = CRC16_CCITT(ccBuffer, expectedCRC);\n\t\tconst actualCRC = raw.payload.readUInt16BE(\n\t\t\traw.payload.length - 2,\n\t\t);\n\t\tvalidatePayload(expectedCRC === actualCRC);\n\t\tconst datagramSize = raw.payload.readUInt16BE(0);\n\t\tconst sessionId = raw.payload[2] >>> 4;\n\t\tlet payloadOffset = 3;\n\n\t\t// If there is a header extension, read it\n\t\tconst hasHeaderExtension = !!(raw.payload[2] & 0b1000);\n\t\tlet headerExtension: BytesView | undefined;\n\n\t\tif (hasHeaderExtension) {\n\t\t\tconst extLength = raw.payload[3];\n\t\t\theaderExtension = raw.payload.subarray(4, 4 + extLength);\n\t\t\tpayloadOffset += 1 + extLength;\n\t\t}\n\t\tconst partialDatagram: BytesView = raw.payload.subarray(\n\t\t\tpayloadOffset,\n\t\t\t-2,\n\t\t);\n\n\t\t// A node supporting the Transport Service Command Class, version 2\n\t\t// MUST NOT send Transport Service segments with the Payload field longer than 39 bytes.\n\t\tvalidatePayload(partialDatagram.length <= MAX_SEGMENT_SIZE);\n\n\t\treturn new this({\n\t\t\tnodeId: ctx.sourceNodeId,\n\t\t\tdatagramSize,\n\t\t\tsessionId,\n\t\t\theaderExtension,\n\t\t\tpartialDatagram,\n\t\t});\n\t}\n\n\tpublic datagramSize: number;\n\tpublic sessionId: number;\n\tpublic headerExtension: BytesView | undefined;\n\tpublic partialDatagram: BytesView;\n\tpublic encapsulated!: CommandClass;\n\n\tpublic serialize(ctx: CCEncodingContext): Promise<Bytes> {\n\t\t// Transport Service re-uses the lower 3 bits of the ccCommand as payload\n\t\tthis.ccCommand = (this.ccCommand & 0b11111_000)\n\t\t\t| ((this.datagramSize >>> 8) & 0b111);\n\n\t\tconst ext = !!this.headerExtension && this.headerExtension.length >= 1;\n\t\tthis.payload = Bytes.from([\n\t\t\tthis.datagramSize & 0xff,\n\t\t\t((this.sessionId & 0b1111) << 4) | (ext ? 0b1000 : 0),\n\t\t]);\n\t\tif (ext) {\n\t\t\tthis.payload = Bytes.concat([\n\t\t\t\tthis.payload,\n\t\t\t\tBytes.from([this.headerExtension!.length]),\n\t\t\t\tthis.headerExtension!,\n\t\t\t]);\n\t\t}\n\t\tthis.payload = Bytes.concat([\n\t\t\tthis.payload,\n\t\t\tthis.partialDatagram,\n\t\t\tBytes.alloc(2, 0), // checksum\n\t\t]);\n\n\t\t// Compute and save the CRC16 in the payload\n\t\t// The CC header is included in the CRC computation\n\t\tconst headerBuffer = Bytes.from([this.ccId, this.ccCommand]);\n\t\tlet crc = CRC16_CCITT(headerBuffer);\n\t\tcrc = CRC16_CCITT(this.payload.subarray(0, -2), crc);\n\t\t// Write the checksum into the last two bytes of the payload\n\t\tthis.payload.writeUInt16BE(crc, this.payload.length - 2);\n\n\t\treturn super.serialize(ctx);\n\t}\n\n\tpublic expectMoreMessages(): boolean {\n\t\treturn true; // The FirstSegment message always expects more messages\n\t}\n\n\tpublic getPartialCCSessionId(): Record<string, any> | undefined {\n\t\t// Only use the session ID to identify the session, not the CC command\n\t\treturn { ccCommand: undefined, sessionId: this.sessionId };\n\t}\n\n\tprotected computeEncapsulationOverhead(): number {\n\t\t// Transport Service CC (first segment) adds 1 byte datagram size, 1 byte Session ID/..., 2 bytes checksum and (0 OR n+1) bytes header extension\n\t\treturn (\n\t\t\tsuper.computeEncapsulationOverhead()\n\t\t\t+ 4\n\t\t\t+ (this.headerExtension?.length\n\t\t\t\t? 1 + this.headerExtension.length\n\t\t\t\t: 0)\n\t\t);\n\t}\n\n\tpublic toLogEntry(ctx?: GetValueDB): MessageOrCCLogEntry {\n\t\treturn {\n\t\t\t...super.toLogEntry(ctx),\n\t\t\tmessage: {\n\t\t\t\t\"session ID\": this.sessionId,\n\t\t\t\t\"datagram size\": this.datagramSize,\n\t\t\t\t\"byte range\": `0...${this.partialDatagram.length - 1}`,\n\t\t\t\tpayload: buffer2hex(this.partialDatagram),\n\t\t\t},\n\t\t};\n\t}\n}\n\n// @publicAPI\nexport interface TransportServiceCCSubsequentSegmentOptions\n\textends TransportServiceCCFirstSegmentOptions\n{\n\tdatagramOffset: number;\n}\n\n@CCCommand(TransportServiceCommand.SubsequentSegment)\n// Handling expected responses is done by the RX state machine\nexport class TransportServiceCCSubsequentSegment extends TransportServiceCC {\n\tpublic constructor(\n\t\toptions: WithAddress<TransportServiceCCSubsequentSegmentOptions>,\n\t) {\n\t\tsuper(options);\n\t\tthis.datagramSize = options.datagramSize;\n\t\tthis.datagramOffset = options.datagramOffset;\n\t\tthis.sessionId = options.sessionId;\n\t\tthis.headerExtension = options.headerExtension;\n\t\tthis.partialDatagram = options.partialDatagram;\n\t}\n\n\tpublic static from(\n\t\traw: CCRaw,\n\t\tctx: CCParsingContext,\n\t): TransportServiceCCSubsequentSegment {\n\t\t// Deserialization has already split the datagram size from the ccCommand.\n\t\t// Therefore we have one more payload byte\n\n\t\tvalidatePayload(raw.payload.length >= 7); // 2 bytes dgram size, 1 byte sessid/ext/offset, 1 byte offset, 1+ bytes payload, 2 bytes checksum\n\n\t\t// Verify the CRC\n\t\tconst headerBuffer = Bytes.from([\n\t\t\tCommandClasses[\"Transport Service\"],\n\t\t\tTransportServiceCommand.SubsequentSegment | raw.payload[0],\n\t\t]);\n\t\tconst ccBuffer = raw.payload.subarray(1, -2);\n\t\tlet expectedCRC = CRC16_CCITT(headerBuffer);\n\t\texpectedCRC = CRC16_CCITT(ccBuffer, expectedCRC);\n\t\tconst actualCRC = raw.payload.readUInt16BE(\n\t\t\traw.payload.length - 2,\n\t\t);\n\t\tvalidatePayload(expectedCRC === actualCRC);\n\t\tconst datagramSize = raw.payload.readUInt16BE(0);\n\t\tconst sessionId = raw.payload[2] >>> 4;\n\t\tconst datagramOffset = ((raw.payload[2] & 0b111) << 8)\n\t\t\t+ raw.payload[3];\n\t\tlet payloadOffset = 4;\n\n\t\t// If there is a header extension, read it\n\t\tconst hasHeaderExtension = !!(raw.payload[2] & 0b1000);\n\t\tlet headerExtension: Bytes | undefined;\n\n\t\tif (hasHeaderExtension) {\n\t\t\tconst extLength = raw.payload[4];\n\t\t\theaderExtension = raw.payload.subarray(5, 5 + extLength);\n\t\t\tpayloadOffset += 1 + extLength;\n\t\t}\n\t\tconst partialDatagram: Bytes = raw.payload.subarray(payloadOffset, -2);\n\n\t\t// A node supporting the Transport Service Command Class, version 2\n\t\t// MUST NOT send Transport Service segments with the Payload field longer than 39 bytes.\n\t\tvalidatePayload(partialDatagram.length <= MAX_SEGMENT_SIZE);\n\n\t\treturn new this({\n\t\t\tnodeId: ctx.sourceNodeId,\n\t\t\tdatagramSize,\n\t\t\tsessionId,\n\t\t\tdatagramOffset,\n\t\t\theaderExtension,\n\t\t\tpartialDatagram,\n\t\t});\n\t}\n\n\tpublic datagramSize: number;\n\tpublic datagramOffset: number;\n\tpublic sessionId: number;\n\tpublic headerExtension: BytesView | undefined;\n\tpublic partialDatagram: BytesView;\n\n\t// This can only be received\n\tprivate _encapsulated!: CommandClass;\n\tpublic get encapsulated(): CommandClass {\n\t\treturn this._encapsulated;\n\t}\n\n\tpublic expectMoreMessages(\n\t\tsession: [\n\t\t\tTransportServiceCCFirstSegment,\n\t\t\t...TransportServiceCCSubsequentSegment[],\n\t\t],\n\t): boolean {\n\t\tif (!(session[0] instanceof TransportServiceCCFirstSegment)) {\n\t\t\t// First segment is missing\n\t\t\treturn true;\n\t\t}\n\t\tconst datagramSize = session[0].datagramSize;\n\t\tconst receivedBytes = new Array<boolean>(datagramSize).fill(false);\n\t\tfor (const segment of [...session, this]) {\n\t\t\tconst offset = segment instanceof TransportServiceCCFirstSegment\n\t\t\t\t? 0\n\t\t\t\t: segment.datagramOffset;\n\t\t\tfor (\n\t\t\t\tlet i = offset;\n\t\t\t\ti <= offset + segment.partialDatagram.length;\n\t\t\t\ti++\n\t\t\t) {\n\t\t\t\treceivedBytes[i] = true;\n\t\t\t}\n\t\t}\n\t\t// Expect more messages as long as we haven't received everything\n\t\treturn receivedBytes.includes(false);\n\t}\n\n\tpublic getPartialCCSessionId(): Record<string, any> | undefined {\n\t\t// Only use the session ID to identify the session, not the CC command\n\t\treturn { ccCommand: undefined, sessionId: this.sessionId };\n\t}\n\n\tpublic async mergePartialCCs(\n\t\tpartials: [\n\t\t\tTransportServiceCCFirstSegment,\n\t\t\t...TransportServiceCCSubsequentSegment[],\n\t\t],\n\t\tctx: CCParsingContext,\n\t): Promise<void> {\n\t\t// Concat the CC buffers\n\t\tconst datagram = new Bytes(this.datagramSize);\n\t\tfor (const partial of [...partials, this]) {\n\t\t\t// Ensure that we don't try to write out-of-bounds\n\t\t\tconst offset = partial instanceof TransportServiceCCFirstSegment\n\t\t\t\t? 0\n\t\t\t\t: partial.datagramOffset;\n\t\t\tif (offset + partial.partialDatagram.length > datagram.length) {\n\t\t\t\tthrow new ZWaveError(\n\t\t\t\t\t`The partial datagram offset and length in a segment are not compatible to the communicated datagram length`,\n\t\t\t\t\tZWaveErrorCodes.PacketFormat_InvalidPayload,\n\t\t\t\t);\n\t\t\t}\n\t\t\tdatagram.set(partial.partialDatagram, offset);\n\t\t}\n\n\t\t// and deserialize the CC\n\t\tthis._encapsulated = await CommandClass.parse(datagram, ctx);\n\t\tthis._encapsulated.encapsulatingCC = this as any;\n\t}\n\n\tpublic serialize(ctx: CCEncodingContext): Promise<Bytes> {\n\t\t// Transport Service re-uses the lower 3 bits of the ccCommand as payload\n\t\tthis.ccCommand = (this.ccCommand & 0b11111_000)\n\t\t\t| ((this.datagramSize >>> 8) & 0b111);\n\n\t\tconst ext = !!this.headerExtension && this.headerExtension.length >= 1;\n\t\tthis.payload = Bytes.from([\n\t\t\tthis.datagramSize & 0xff,\n\t\t\t((this.sessionId & 0b1111) << 4)\n\t\t\t| (ext ? 0b1000 : 0)\n\t\t\t| ((this.datagramOffset >>> 8) & 0b111),\n\t\t\tthis.datagramOffset & 0xff,\n\t\t]);\n\t\tif (ext) {\n\t\t\tthis.payload = Bytes.concat([\n\t\t\t\tthis.payload,\n\t\t\t\tBytes.from([this.headerExtension!.length]),\n\t\t\t\tthis.headerExtension!,\n\t\t\t]);\n\t\t}\n\t\tthis.payload = Bytes.concat([\n\t\t\tthis.payload,\n\t\t\tthis.partialDatagram,\n\t\t\tBytes.alloc(2, 0), // checksum\n\t\t]);\n\n\t\t// Compute and save the CRC16 in the payload\n\t\t// The CC header is included in the CRC computation\n\t\tconst headerBuffer = Bytes.from([this.ccId, this.ccCommand]);\n\t\tlet crc = CRC16_CCITT(headerBuffer);\n\t\tcrc = CRC16_CCITT(this.payload.subarray(0, -2), crc);\n\t\t// Write the checksum into the last two bytes of the payload\n\t\tthis.payload.writeUInt16BE(crc, this.payload.length - 2);\n\n\t\treturn super.serialize(ctx);\n\t}\n\n\tprotected computeEncapsulationOverhead(): number {\n\t\t// Transport Service CC (first segment) adds 1 byte datagram size, 1 byte Session ID/..., 1 byte offset, 2 bytes checksum and (0 OR n+1) bytes header extension\n\t\treturn (\n\t\t\tsuper.computeEncapsulationOverhead()\n\t\t\t+ 5\n\t\t\t+ (this.headerExtension?.length\n\t\t\t\t? 1 + this.headerExtension.length\n\t\t\t\t: 0)\n\t\t);\n\t}\n\n\tpublic toLogEntry(ctx?: GetValueDB): MessageOrCCLogEntry {\n\t\treturn {\n\t\t\t...super.toLogEntry(ctx),\n\t\t\tmessage: {\n\t\t\t\t\"session ID\": this.sessionId,\n\t\t\t\t\"datagram size\": this.datagramSize,\n\t\t\t\t\"byte range\": `${this.datagramOffset}...${\n\t\t\t\t\tthis.datagramOffset + this.partialDatagram.length - 1\n\t\t\t\t}`,\n\t\t\t\tpayload: buffer2hex(this.partialDatagram),\n\t\t\t},\n\t\t};\n\t}\n}\n\n// @publicAPI\nexport interface TransportServiceCCSegmentRequestOptions {\n\tsessionId: number;\n\tdatagramOffset: number;\n}\n\n@CCCommand(TransportServiceCommand.SegmentRequest)\n// Handling expected responses is done by the RX state machine\nexport class TransportServiceCCSegmentRequest extends TransportServiceCC {\n\tpublic constructor(\n\t\toptions: WithAddress<TransportServiceCCSegmentRequestOptions>,\n\t) {\n\t\tsuper(options);\n\t\tthis.sessionId = options.sessionId;\n\t\tthis.datagramOffset = options.datagramOffset;\n\t}\n\n\tpublic static from(\n\t\traw: CCRaw,\n\t\tctx: CCParsingContext,\n\t): TransportServiceCCSegmentRequest {\n\t\tvalidatePayload(raw.payload.length >= 3);\n\t\tconst sessionId = raw.payload[1] >>> 4;\n\t\tconst datagramOffset = ((raw.payload[1] & 0b111) << 8)\n\t\t\t+ raw.payload[2];\n\n\t\treturn new this({\n\t\t\tnodeId: ctx.sourceNodeId,\n\t\t\tsessionId,\n\t\t\tdatagramOffset,\n\t\t});\n\t}\n\n\tpublic sessionId: number;\n\tpublic datagramOffset: number;\n\n\tpublic serialize(ctx: CCEncodingContext): Promise<Bytes> {\n\t\tthis.payload = Bytes.from([\n\t\t\t((this.sessionId & 0b1111) << 4)\n\t\t\t| ((this.datagramOffset >>> 8) & 0b111),\n\t\t\tthis.datagramOffset & 0xff,\n\t\t]);\n\t\treturn super.serialize(ctx);\n\t}\n\n\tpublic toLogEntry(ctx?: GetValueDB): MessageOrCCLogEntry {\n\t\treturn {\n\t\t\t...super.toLogEntry(ctx),\n\t\t\tmessage: {\n\t\t\t\t\"session ID\": this.sessionId,\n\t\t\t\toffset: this.datagramOffset,\n\t\t\t},\n\t\t};\n\t}\n}\n\n// @publicAPI\nexport interface TransportServiceCCSegmentCompleteOptions {\n\tsessionId: number;\n}\n\n@CCCommand(TransportServiceCommand.SegmentComplete)\nexport class TransportServiceCCSegmentComplete extends TransportServiceCC {\n\tpublic constructor(\n\t\toptions: WithAddress<TransportServiceCCSegmentCompleteOptions>,\n\t) {\n\t\tsuper(options);\n\t\tthis.sessionId = options.sessionId;\n\t}\n\n\tpublic static from(\n\t\traw: CCRaw,\n\t\tctx: CCParsingContext,\n\t): TransportServiceCCSegmentComplete {\n\t\tvalidatePayload(raw.payload.length >= 2);\n\t\tconst sessionId = raw.payload[1] >>> 4;\n\n\t\treturn new this({\n\t\t\tnodeId: ctx.sourceNodeId,\n\t\t\tsessionId,\n\t\t});\n\t}\n\n\tpublic sessionId: number;\n\n\tpublic serialize(ctx: CCEncodingContext): Promise<Bytes> {\n\t\tthis.payload = Bytes.from([(this.sessionId & 0b1111) << 4]);\n\t\treturn super.serialize(ctx);\n\t}\n\n\tpublic toLogEntry(ctx?: GetValueDB): MessageOrCCLogEntry {\n\t\treturn {\n\t\t\t...super.toLogEntry(ctx),\n\t\t\tmessage: { \"session ID\": this.sessionId },\n\t\t};\n\t}\n}\n\n// @publicAPI\nexport interface TransportServiceCCSegmentWaitOptions {\n\tpendingSegments: number;\n}\n\n@CCCommand(TransportServiceCommand.SegmentWait)\nexport class TransportServiceCCSegmentWait extends TransportServiceCC {\n\tpublic constructor(\n\t\toptions: WithAddress<TransportServiceCCSegmentWaitOptions>,\n\t) {\n\t\tsuper(options);\n\t\tthis.pendingSegments = options.pendingSegments;\n\t}\n\n\tpublic static from(\n\t\traw: CCRaw,\n\t\tctx: CCParsingContext,\n\t): TransportServiceCCSegmentWait {\n\t\tvalidatePayload(raw.payload.length >= 2);\n\t\tconst pendingSegments = raw.payload[1];\n\n\t\treturn new this({\n\t\t\tnodeId: ctx.sourceNodeId,\n\t\t\tpendingSegments,\n\t\t});\n\t}\n\n\tpublic pendingSegments: number;\n\n\tpublic serialize(ctx: CCEncodingContext): Promise<Bytes> {\n\t\tthis.payload = Bytes.from([this.pendingSegments]);\n\t\treturn super.serialize(ctx);\n\t}\n\n\tpublic toLogEntry(ctx?: GetValueDB): MessageOrCCLogEntry {\n\t\treturn {\n\t\t\t...super.toLogEntry(ctx),\n\t\t\tmessage: { \"pending segments\": this.pendingSegments },\n\t\t};\n\t}\n}\n"],
5
- "mappings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C,YAAM,kBAAkB,IAAI,QAAQ,CAAC;AAErC,aAAO,IAAI,KAAK;QACf,QAAQ,IAAI;QACZ;OACA;IACF;IAEO;IAEA,UAAU,KAAsB;AACtC,WAAK,UAAU,oBAAM,KAAK,CAAC,KAAK,eAAe,CAAC;AAChD,aAAO,MAAM,UAAU,GAAG;IAC3B;IAEO,WAAW,KAAgB;AACjC,aAAO;QACN,GAAG,MAAM,WAAW,GAAG;QACvB,SAAS,EAAE,oBAAoB,KAAK,gBAAe;;IAErD;;;;",
4
+ "sourcesContent": ["import type { CCEncodingContext, CCParsingContext } from \"@zwave-js/cc\";\nimport {\n\tCRC16_CCITT,\n\tCommandClasses,\n\ttype GetValueDB,\n\ttype MessageOrCCLogEntry,\n\ttype SinglecastCC,\n\ttype WithAddress,\n\tZWaveError,\n\tZWaveErrorCodes,\n\tvalidatePayload,\n} from \"@zwave-js/core\";\nimport { Bytes, type BytesView, buffer2hex } from \"@zwave-js/shared\";\nimport { type CCRaw, CommandClass } from \"../lib/CommandClass.js\";\nimport {\n\tCCCommand,\n\tcommandClass,\n\timplementedVersion,\n} from \"../lib/CommandClassDecorators.js\";\nimport { TransportServiceCommand } from \"../lib/_Types.js\";\n\nexport const MAX_SEGMENT_SIZE = 39;\n\nexport const RELAXED_TIMING_THRESHOLD = 2;\n\n// TODO: Figure out how we know if communicating with R2 or R3\n/** @publicAPI */\nexport const TransportServiceTimeouts = {\n\t/** Waiting time before requesting a missing segment at data rate R2 */\n\trequestMissingSegmentR2: 800,\n\t/** Waiting time before requesting a missing segment at data rate R3 */\n\trequestMissingSegmentR3: 400,\n\t/** Waiting time before sending another datagram at data rate R2 */\n\tsegmentCompleteR2: 1000,\n\t/** Waiting time before sending another datagram at data rate R3 */\n\tsegmentCompleteR3: 500,\n\t/** Waiting time between segments when sending more than {@link RELAXED_TIMING_THRESHOLD} segments at data rate R2 */\n\trelaxedTimingDelayR2: 35,\n\t/** Waiting time between segments when sending more than {@link RELAXED_TIMING_THRESHOLD} segments at data rate R3 */\n\trelaxedTimingDelayR3: 15,\n};\n\n@commandClass(CommandClasses[\"Transport Service\"])\n@implementedVersion(2)\nexport class TransportServiceCC extends CommandClass\n\timplements SinglecastCC<TransportServiceCC>\n{\n\tdeclare ccCommand: TransportServiceCommand;\n\tdeclare nodeId: number;\n}\n\n// @publicAPI\nexport interface TransportServiceCCFirstSegmentOptions {\n\tdatagramSize: number;\n\tsessionId: number;\n\theaderExtension?: BytesView | undefined;\n\tpartialDatagram: BytesView;\n}\n\n/** @publicAPI */\nexport function isTransportServiceEncapsulation(\n\tcommand: CommandClass,\n): command is\n\t| TransportServiceCCFirstSegment\n\t| TransportServiceCCSubsequentSegment\n{\n\treturn (\n\t\tcommand.ccId === CommandClasses[\"Transport Service\"]\n\t\t&& (command.ccCommand === TransportServiceCommand.FirstSegment\n\t\t\t|| command.ccCommand === TransportServiceCommand.SubsequentSegment)\n\t);\n}\n\n@CCCommand(TransportServiceCommand.FirstSegment)\n// Handling expected responses is done by the RX state machine\nexport class TransportServiceCCFirstSegment extends TransportServiceCC {\n\tpublic constructor(\n\t\toptions: WithAddress<TransportServiceCCFirstSegmentOptions>,\n\t) {\n\t\tsuper(options);\n\t\tthis.datagramSize = options.datagramSize;\n\t\tthis.sessionId = options.sessionId;\n\t\tthis.headerExtension = options.headerExtension;\n\t\tthis.partialDatagram = options.partialDatagram;\n\t}\n\n\tpublic static from(\n\t\traw: CCRaw,\n\t\tctx: CCParsingContext,\n\t): TransportServiceCCFirstSegment {\n\t\t// Deserialization has already split the datagram size from the ccCommand.\n\t\t// Therefore we have one more payload byte\n\n\t\tvalidatePayload(raw.payload.length >= 6); // 2 bytes dgram size, 1 byte sessid/ext, 1+ bytes payload, 2 bytes checksum\n\n\t\t// Verify the CRC\n\t\tconst headerBuffer = Bytes.from([\n\t\t\tCommandClasses[\"Transport Service\"],\n\t\t\tTransportServiceCommand.FirstSegment | raw.payload[0],\n\t\t]);\n\t\tconst ccBuffer = raw.payload.subarray(1, -2);\n\t\tlet expectedCRC = CRC16_CCITT(headerBuffer);\n\t\texpectedCRC = CRC16_CCITT(ccBuffer, expectedCRC);\n\t\tconst actualCRC = raw.payload.readUInt16BE(\n\t\t\traw.payload.length - 2,\n\t\t);\n\t\tvalidatePayload(expectedCRC === actualCRC);\n\t\tconst datagramSize = raw.payload.readUInt16BE(0);\n\t\tconst sessionId = raw.payload[2] >>> 4;\n\t\tlet payloadOffset = 3;\n\n\t\t// If there is a header extension, read it\n\t\tconst hasHeaderExtension = !!(raw.payload[2] & 0b1000);\n\t\tlet headerExtension: BytesView | undefined;\n\n\t\tif (hasHeaderExtension) {\n\t\t\tconst extLength = raw.payload[3];\n\t\t\theaderExtension = raw.payload.subarray(4, 4 + extLength);\n\t\t\tpayloadOffset += 1 + extLength;\n\t\t}\n\t\tconst partialDatagram: BytesView = raw.payload.subarray(\n\t\t\tpayloadOffset,\n\t\t\t-2,\n\t\t);\n\n\t\t// A node supporting the Transport Service Command Class, version 2\n\t\t// MUST NOT send Transport Service segments with the Payload field longer than 39 bytes.\n\t\tvalidatePayload(partialDatagram.length <= MAX_SEGMENT_SIZE);\n\n\t\treturn new this({\n\t\t\tnodeId: ctx.sourceNodeId,\n\t\t\tdatagramSize,\n\t\t\tsessionId,\n\t\t\theaderExtension,\n\t\t\tpartialDatagram,\n\t\t});\n\t}\n\n\tpublic datagramSize: number;\n\tpublic sessionId: number;\n\tpublic headerExtension: BytesView | undefined;\n\tpublic partialDatagram: BytesView;\n\tpublic encapsulated!: CommandClass;\n\n\tpublic serialize(ctx: CCEncodingContext): Promise<Bytes> {\n\t\t// Transport Service re-uses the lower 3 bits of the ccCommand as payload\n\t\tthis.ccCommand = (this.ccCommand & 0b11111_000)\n\t\t\t| ((this.datagramSize >>> 8) & 0b111);\n\n\t\tconst ext = !!this.headerExtension && this.headerExtension.length >= 1;\n\t\tthis.payload = Bytes.from([\n\t\t\tthis.datagramSize & 0xff,\n\t\t\t((this.sessionId & 0b1111) << 4) | (ext ? 0b1000 : 0),\n\t\t]);\n\t\tif (ext) {\n\t\t\tthis.payload = Bytes.concat([\n\t\t\t\tthis.payload,\n\t\t\t\tBytes.from([this.headerExtension!.length]),\n\t\t\t\tthis.headerExtension!,\n\t\t\t]);\n\t\t}\n\t\tthis.payload = Bytes.concat([\n\t\t\tthis.payload,\n\t\t\tthis.partialDatagram,\n\t\t\tBytes.alloc(2, 0), // checksum\n\t\t]);\n\n\t\t// Compute and save the CRC16 in the payload\n\t\t// The CC header is included in the CRC computation\n\t\tconst headerBuffer = Bytes.from([this.ccId, this.ccCommand]);\n\t\tlet crc = CRC16_CCITT(headerBuffer);\n\t\tcrc = CRC16_CCITT(this.payload.subarray(0, -2), crc);\n\t\t// Write the checksum into the last two bytes of the payload\n\t\tthis.payload.writeUInt16BE(crc, this.payload.length - 2);\n\n\t\treturn super.serialize(ctx);\n\t}\n\n\tpublic expectMoreMessages(): boolean {\n\t\treturn true; // The FirstSegment message always expects more messages\n\t}\n\n\tpublic getPartialCCSessionId(): Record<string, any> | undefined {\n\t\t// Only use the session ID to identify the session, not the CC command\n\t\treturn { ccCommand: undefined, sessionId: this.sessionId };\n\t}\n\n\tprotected computeEncapsulationOverhead(): number {\n\t\t// Transport Service CC (first segment) adds 1 byte datagram size, 1 byte Session ID/..., 2 bytes checksum and (0 OR n+1) bytes header extension\n\t\treturn (\n\t\t\tsuper.computeEncapsulationOverhead()\n\t\t\t+ 4\n\t\t\t+ (this.headerExtension?.length\n\t\t\t\t? 1 + this.headerExtension.length\n\t\t\t\t: 0)\n\t\t);\n\t}\n\n\tpublic toLogEntry(ctx?: GetValueDB): MessageOrCCLogEntry {\n\t\treturn {\n\t\t\t...super.toLogEntry(ctx),\n\t\t\tmessage: {\n\t\t\t\t\"session ID\": this.sessionId,\n\t\t\t\t\"datagram size\": this.datagramSize,\n\t\t\t\t\"byte range\": `0...${this.partialDatagram.length - 1}`,\n\t\t\t\tpayload: buffer2hex(this.partialDatagram),\n\t\t\t},\n\t\t};\n\t}\n}\n\n// @publicAPI\nexport interface TransportServiceCCSubsequentSegmentOptions\n\textends TransportServiceCCFirstSegmentOptions\n{\n\tdatagramOffset: number;\n}\n\n@CCCommand(TransportServiceCommand.SubsequentSegment)\n// Handling expected responses is done by the RX state machine\nexport class TransportServiceCCSubsequentSegment extends TransportServiceCC {\n\tpublic constructor(\n\t\toptions: WithAddress<TransportServiceCCSubsequentSegmentOptions>,\n\t) {\n\t\tsuper(options);\n\t\tthis.datagramSize = options.datagramSize;\n\t\tthis.datagramOffset = options.datagramOffset;\n\t\tthis.sessionId = options.sessionId;\n\t\tthis.headerExtension = options.headerExtension;\n\t\tthis.partialDatagram = options.partialDatagram;\n\t}\n\n\tpublic static from(\n\t\traw: CCRaw,\n\t\tctx: CCParsingContext,\n\t): TransportServiceCCSubsequentSegment {\n\t\t// Deserialization has already split the datagram size from the ccCommand.\n\t\t// Therefore we have one more payload byte\n\n\t\tvalidatePayload(raw.payload.length >= 7); // 2 bytes dgram size, 1 byte sessid/ext/offset, 1 byte offset, 1+ bytes payload, 2 bytes checksum\n\n\t\t// Verify the CRC\n\t\tconst headerBuffer = Bytes.from([\n\t\t\tCommandClasses[\"Transport Service\"],\n\t\t\tTransportServiceCommand.SubsequentSegment | raw.payload[0],\n\t\t]);\n\t\tconst ccBuffer = raw.payload.subarray(1, -2);\n\t\tlet expectedCRC = CRC16_CCITT(headerBuffer);\n\t\texpectedCRC = CRC16_CCITT(ccBuffer, expectedCRC);\n\t\tconst actualCRC = raw.payload.readUInt16BE(\n\t\t\traw.payload.length - 2,\n\t\t);\n\t\tvalidatePayload(expectedCRC === actualCRC);\n\t\tconst datagramSize = raw.payload.readUInt16BE(0);\n\t\tconst sessionId = raw.payload[2] >>> 4;\n\t\tconst datagramOffset = ((raw.payload[2] & 0b111) << 8)\n\t\t\t+ raw.payload[3];\n\t\tlet payloadOffset = 4;\n\n\t\t// If there is a header extension, read it\n\t\tconst hasHeaderExtension = !!(raw.payload[2] & 0b1000);\n\t\tlet headerExtension: Bytes | undefined;\n\n\t\tif (hasHeaderExtension) {\n\t\t\tconst extLength = raw.payload[4];\n\t\t\theaderExtension = raw.payload.subarray(5, 5 + extLength);\n\t\t\tpayloadOffset += 1 + extLength;\n\t\t}\n\t\tconst partialDatagram: Bytes = raw.payload.subarray(payloadOffset, -2);\n\n\t\t// A node supporting the Transport Service Command Class, version 2\n\t\t// MUST NOT send Transport Service segments with the Payload field longer than 39 bytes.\n\t\tvalidatePayload(partialDatagram.length <= MAX_SEGMENT_SIZE);\n\n\t\treturn new this({\n\t\t\tnodeId: ctx.sourceNodeId,\n\t\t\tdatagramSize,\n\t\t\tsessionId,\n\t\t\tdatagramOffset,\n\t\t\theaderExtension,\n\t\t\tpartialDatagram,\n\t\t});\n\t}\n\n\tpublic datagramSize: number;\n\tpublic datagramOffset: number;\n\tpublic sessionId: number;\n\tpublic headerExtension: BytesView | undefined;\n\tpublic partialDatagram: BytesView;\n\n\t// This can only be received\n\tprivate _encapsulated!: CommandClass;\n\tpublic get encapsulated(): CommandClass {\n\t\treturn this._encapsulated;\n\t}\n\n\tpublic expectMoreMessages(\n\t\tsession: [\n\t\t\tTransportServiceCCFirstSegment,\n\t\t\t...TransportServiceCCSubsequentSegment[],\n\t\t],\n\t): boolean {\n\t\tif (!(session[0] instanceof TransportServiceCCFirstSegment)) {\n\t\t\t// First segment is missing\n\t\t\treturn true;\n\t\t}\n\t\tconst datagramSize = session[0].datagramSize;\n\t\tconst receivedBytes = Array.from<boolean>({ length: datagramSize })\n\t\t\t.fill(false);\n\t\tfor (const segment of [...session, this]) {\n\t\t\tconst offset = segment instanceof TransportServiceCCFirstSegment\n\t\t\t\t? 0\n\t\t\t\t: segment.datagramOffset;\n\t\t\tfor (\n\t\t\t\tlet i = offset;\n\t\t\t\ti <= offset + segment.partialDatagram.length;\n\t\t\t\ti++\n\t\t\t) {\n\t\t\t\treceivedBytes[i] = true;\n\t\t\t}\n\t\t}\n\t\t// Expect more messages as long as we haven't received everything\n\t\treturn receivedBytes.includes(false);\n\t}\n\n\tpublic getPartialCCSessionId(): Record<string, any> | undefined {\n\t\t// Only use the session ID to identify the session, not the CC command\n\t\treturn { ccCommand: undefined, sessionId: this.sessionId };\n\t}\n\n\tpublic async mergePartialCCs(\n\t\tpartials: [\n\t\t\tTransportServiceCCFirstSegment,\n\t\t\t...TransportServiceCCSubsequentSegment[],\n\t\t],\n\t\tctx: CCParsingContext,\n\t): Promise<void> {\n\t\t// Concat the CC buffers\n\t\tconst datagram = new Bytes(this.datagramSize);\n\t\tfor (const partial of [...partials, this]) {\n\t\t\t// Ensure that we don't try to write out-of-bounds\n\t\t\tconst offset = partial instanceof TransportServiceCCFirstSegment\n\t\t\t\t? 0\n\t\t\t\t: partial.datagramOffset;\n\t\t\tif (offset + partial.partialDatagram.length > datagram.length) {\n\t\t\t\tthrow new ZWaveError(\n\t\t\t\t\t`The partial datagram offset and length in a segment are not compatible to the communicated datagram length`,\n\t\t\t\t\tZWaveErrorCodes.PacketFormat_InvalidPayload,\n\t\t\t\t);\n\t\t\t}\n\t\t\tdatagram.set(partial.partialDatagram, offset);\n\t\t}\n\n\t\t// and deserialize the CC\n\t\tthis._encapsulated = await CommandClass.parse(datagram, ctx);\n\t\tthis._encapsulated.encapsulatingCC = this as any;\n\t}\n\n\tpublic serialize(ctx: CCEncodingContext): Promise<Bytes> {\n\t\t// Transport Service re-uses the lower 3 bits of the ccCommand as payload\n\t\tthis.ccCommand = (this.ccCommand & 0b11111_000)\n\t\t\t| ((this.datagramSize >>> 8) & 0b111);\n\n\t\tconst ext = !!this.headerExtension && this.headerExtension.length >= 1;\n\t\tthis.payload = Bytes.from([\n\t\t\tthis.datagramSize & 0xff,\n\t\t\t((this.sessionId & 0b1111) << 4)\n\t\t\t| (ext ? 0b1000 : 0)\n\t\t\t| ((this.datagramOffset >>> 8) & 0b111),\n\t\t\tthis.datagramOffset & 0xff,\n\t\t]);\n\t\tif (ext) {\n\t\t\tthis.payload = Bytes.concat([\n\t\t\t\tthis.payload,\n\t\t\t\tBytes.from([this.headerExtension!.length]),\n\t\t\t\tthis.headerExtension!,\n\t\t\t]);\n\t\t}\n\t\tthis.payload = Bytes.concat([\n\t\t\tthis.payload,\n\t\t\tthis.partialDatagram,\n\t\t\tBytes.alloc(2, 0), // checksum\n\t\t]);\n\n\t\t// Compute and save the CRC16 in the payload\n\t\t// The CC header is included in the CRC computation\n\t\tconst headerBuffer = Bytes.from([this.ccId, this.ccCommand]);\n\t\tlet crc = CRC16_CCITT(headerBuffer);\n\t\tcrc = CRC16_CCITT(this.payload.subarray(0, -2), crc);\n\t\t// Write the checksum into the last two bytes of the payload\n\t\tthis.payload.writeUInt16BE(crc, this.payload.length - 2);\n\n\t\treturn super.serialize(ctx);\n\t}\n\n\tprotected computeEncapsulationOverhead(): number {\n\t\t// Transport Service CC (first segment) adds 1 byte datagram size, 1 byte Session ID/..., 1 byte offset, 2 bytes checksum and (0 OR n+1) bytes header extension\n\t\treturn (\n\t\t\tsuper.computeEncapsulationOverhead()\n\t\t\t+ 5\n\t\t\t+ (this.headerExtension?.length\n\t\t\t\t? 1 + this.headerExtension.length\n\t\t\t\t: 0)\n\t\t);\n\t}\n\n\tpublic toLogEntry(ctx?: GetValueDB): MessageOrCCLogEntry {\n\t\treturn {\n\t\t\t...super.toLogEntry(ctx),\n\t\t\tmessage: {\n\t\t\t\t\"session ID\": this.sessionId,\n\t\t\t\t\"datagram size\": this.datagramSize,\n\t\t\t\t\"byte range\": `${this.datagramOffset}...${\n\t\t\t\t\tthis.datagramOffset + this.partialDatagram.length - 1\n\t\t\t\t}`,\n\t\t\t\tpayload: buffer2hex(this.partialDatagram),\n\t\t\t},\n\t\t};\n\t}\n}\n\n// @publicAPI\nexport interface TransportServiceCCSegmentRequestOptions {\n\tsessionId: number;\n\tdatagramOffset: number;\n}\n\n@CCCommand(TransportServiceCommand.SegmentRequest)\n// Handling expected responses is done by the RX state machine\nexport class TransportServiceCCSegmentRequest extends TransportServiceCC {\n\tpublic constructor(\n\t\toptions: WithAddress<TransportServiceCCSegmentRequestOptions>,\n\t) {\n\t\tsuper(options);\n\t\tthis.sessionId = options.sessionId;\n\t\tthis.datagramOffset = options.datagramOffset;\n\t}\n\n\tpublic static from(\n\t\traw: CCRaw,\n\t\tctx: CCParsingContext,\n\t): TransportServiceCCSegmentRequest {\n\t\tvalidatePayload(raw.payload.length >= 3);\n\t\tconst sessionId = raw.payload[1] >>> 4;\n\t\tconst datagramOffset = ((raw.payload[1] & 0b111) << 8)\n\t\t\t+ raw.payload[2];\n\n\t\treturn new this({\n\t\t\tnodeId: ctx.sourceNodeId,\n\t\t\tsessionId,\n\t\t\tdatagramOffset,\n\t\t});\n\t}\n\n\tpublic sessionId: number;\n\tpublic datagramOffset: number;\n\n\tpublic serialize(ctx: CCEncodingContext): Promise<Bytes> {\n\t\tthis.payload = Bytes.from([\n\t\t\t((this.sessionId & 0b1111) << 4)\n\t\t\t| ((this.datagramOffset >>> 8) & 0b111),\n\t\t\tthis.datagramOffset & 0xff,\n\t\t]);\n\t\treturn super.serialize(ctx);\n\t}\n\n\tpublic toLogEntry(ctx?: GetValueDB): MessageOrCCLogEntry {\n\t\treturn {\n\t\t\t...super.toLogEntry(ctx),\n\t\t\tmessage: {\n\t\t\t\t\"session ID\": this.sessionId,\n\t\t\t\toffset: this.datagramOffset,\n\t\t\t},\n\t\t};\n\t}\n}\n\n// @publicAPI\nexport interface TransportServiceCCSegmentCompleteOptions {\n\tsessionId: number;\n}\n\n@CCCommand(TransportServiceCommand.SegmentComplete)\nexport class TransportServiceCCSegmentComplete extends TransportServiceCC {\n\tpublic constructor(\n\t\toptions: WithAddress<TransportServiceCCSegmentCompleteOptions>,\n\t) {\n\t\tsuper(options);\n\t\tthis.sessionId = options.sessionId;\n\t}\n\n\tpublic static from(\n\t\traw: CCRaw,\n\t\tctx: CCParsingContext,\n\t): TransportServiceCCSegmentComplete {\n\t\tvalidatePayload(raw.payload.length >= 2);\n\t\tconst sessionId = raw.payload[1] >>> 4;\n\n\t\treturn new this({\n\t\t\tnodeId: ctx.sourceNodeId,\n\t\t\tsessionId,\n\t\t});\n\t}\n\n\tpublic sessionId: number;\n\n\tpublic serialize(ctx: CCEncodingContext): Promise<Bytes> {\n\t\tthis.payload = Bytes.from([(this.sessionId & 0b1111) << 4]);\n\t\treturn super.serialize(ctx);\n\t}\n\n\tpublic toLogEntry(ctx?: GetValueDB): MessageOrCCLogEntry {\n\t\treturn {\n\t\t\t...super.toLogEntry(ctx),\n\t\t\tmessage: { \"session ID\": this.sessionId },\n\t\t};\n\t}\n}\n\n// @publicAPI\nexport interface TransportServiceCCSegmentWaitOptions {\n\tpendingSegments: number;\n}\n\n@CCCommand(TransportServiceCommand.SegmentWait)\nexport class TransportServiceCCSegmentWait extends TransportServiceCC {\n\tpublic constructor(\n\t\toptions: WithAddress<TransportServiceCCSegmentWaitOptions>,\n\t) {\n\t\tsuper(options);\n\t\tthis.pendingSegments = options.pendingSegments;\n\t}\n\n\tpublic static from(\n\t\traw: CCRaw,\n\t\tctx: CCParsingContext,\n\t): TransportServiceCCSegmentWait {\n\t\tvalidatePayload(raw.payload.length >= 2);\n\t\tconst pendingSegments = raw.payload[1];\n\n\t\treturn new this({\n\t\t\tnodeId: ctx.sourceNodeId,\n\t\t\tpendingSegments,\n\t\t});\n\t}\n\n\tpublic pendingSegments: number;\n\n\tpublic serialize(ctx: CCEncodingContext): Promise<Bytes> {\n\t\tthis.payload = Bytes.from([this.pendingSegments]);\n\t\treturn super.serialize(ctx);\n\t}\n\n\tpublic toLogEntry(ctx?: GetValueDB): MessageOrCCLogEntry {\n\t\treturn {\n\t\t\t...super.toLogEntry(ctx),\n\t\t\tmessage: { \"pending segments\": this.pendingSegments },\n\t\t};\n\t}\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,kBAUO;AACP,oBAAkD;AAClD,0BAAyC;AACzC,oCAIO;AACP,mBAAwC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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,WAAK,UAAU,oBAAM,KAAK,CAAC,KAAK,eAAe,CAAC;AAChD,aAAO,MAAM,UAAU,GAAG;IAC3B;IAEO,WAAW,KAAgB;AACjC,aAAO;QACN,GAAG,MAAM,WAAW,GAAG;QACvB,SAAS,EAAE,oBAAoB,KAAK,gBAAe;;IAErD;;;;",
6
6
  "names": []
7
7
  }
@@ -495,6 +495,14 @@ export declare class UserCodeCC extends CommandClass {
495
495
  * This only works AFTER the user IDs have been queried.
496
496
  */
497
497
  static getUserCodeCached(ctx: GetValueDB, endpoint: EndpointId, userId: number): MaybeNotKnown<string | BytesView>;
498
+ /**
499
+ * Sets the status of a user ID in the cache.
500
+ */
501
+ static setUserIdStatusCached(ctx: GetValueDB, endpoint: EndpointId, userId: number, status: UserIDStatus): void;
502
+ /**
503
+ * Sets the code belonging to a user ID in the cache.
504
+ */
505
+ static setUserCodeCached(ctx: GetValueDB, endpoint: EndpointId, userId: number, code: string | BytesView): void;
498
506
  }
499
507
  export type UserCodeCCSetOptions = {
500
508
  userId: 0;
@@ -651,7 +659,7 @@ export interface UserCode {
651
659
  }
652
660
  export declare class UserCodeCCExtendedUserCodeSet extends UserCodeCC {
653
661
  constructor(options: WithAddress<UserCodeCCExtendedUserCodeSetOptions>);
654
- static from(_raw: CCRaw, _ctx: CCParsingContext): UserCodeCCExtendedUserCodeSet;
662
+ static from(raw: CCRaw, ctx: CCParsingContext): UserCodeCCExtendedUserCodeSet;
655
663
  userCodes: UserCodeCCSetOptions[];
656
664
  serialize(ctx: CCEncodingContext): Promise<Bytes>;
657
665
  toLogEntry(ctx?: GetValueDB): MessageOrCCLogEntry;
@@ -123,7 +123,7 @@ __name(parseExtendedUserCode, "parseExtendedUserCode");
123
123
  function validateCode(code, supportedChars) {
124
124
  if (code.length < 4 || code.length > 10)
125
125
  return false;
126
- return [...code].every((char) => supportedChars.includes(char));
126
+ return code.split("").every((char) => supportedChars.includes(char));
127
127
  }
128
128
  __name(validateCode, "validateCode");
129
129
  function setUserCodeMetadata(ctx, userId, userCode) {
@@ -361,7 +361,7 @@ let UserCodeCCAPI = (() => {
361
361
  }
362
362
  /** Configures a single user code */
363
363
  async set(userId, userIdStatus, userCode) {
364
- if (userId > 255) {
364
+ if (this.version >= 2 || userId > 255) {
365
365
  return this.setMany([{ userId, userIdStatus, userCode }]);
366
366
  }
367
367
  this.assertSupportsCommand(import_Types.UserCodeCommand, import_Types.UserCodeCommand.Set);
@@ -425,7 +425,7 @@ let UserCodeCCAPI = (() => {
425
425
  * @param userId The user code to clear. If none or 0 is given, all codes are cleared
426
426
  */
427
427
  async clear(userId = 0) {
428
- if (this.version > 1 || userId > 255) {
428
+ if (this.version >= 2 || userId > 255) {
429
429
  return this.setMany([
430
430
  { userId, userIdStatus: import_Types.UserIDStatus.Available }
431
431
  ]);
@@ -444,7 +444,7 @@ let UserCodeCCAPI = (() => {
444
444
  return this.host.sendCommand(cc, this.commandOptions);
445
445
  }
446
446
  }
447
- // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
447
+ // oxlint-disable-next-line typescript/explicit-module-boundary-types
448
448
  async getCapabilities() {
449
449
  this.assertSupportsCommand(import_Types.UserCodeCommand, import_Types.UserCodeCommand.CapabilitiesGet);
450
450
  const cc = new UserCodeCCCapabilitiesGet({
@@ -738,6 +738,18 @@ let UserCodeCC = (() => {
738
738
  static getUserCodeCached(ctx, endpoint, userId) {
739
739
  return ctx.getValueDB(endpoint.nodeId).getValue(import_CCValues_generated.UserCodeCCValues.userCode(userId).endpoint(endpoint.index));
740
740
  }
741
+ /**
742
+ * Sets the status of a user ID in the cache.
743
+ */
744
+ static setUserIdStatusCached(ctx, endpoint, userId, status) {
745
+ ctx.getValueDB(endpoint.nodeId).setValue(import_CCValues_generated.UserCodeCCValues.userIdStatus(userId).endpoint(endpoint.index), status);
746
+ }
747
+ /**
748
+ * Sets the code belonging to a user ID in the cache.
749
+ */
750
+ static setUserCodeCached(ctx, endpoint, userId, code) {
751
+ ctx.getValueDB(endpoint.nodeId).setValue(import_CCValues_generated.UserCodeCCValues.userCode(userId).endpoint(endpoint.index), code);
752
+ }
741
753
  };
742
754
  return UserCodeCC2 = _classThis;
743
755
  })();
@@ -910,7 +922,7 @@ let UserCodeCCReport = (() => {
910
922
  }
911
923
  };
912
924
  }
913
- // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
925
+ // oxlint-disable-next-line typescript/explicit-module-boundary-types
914
926
  toNotificationEventParameters() {
915
927
  return { userId: this.userId };
916
928
  }
@@ -1117,7 +1129,7 @@ let UserCodeCCCapabilitiesReport = (() => {
1117
1129
  const controlByte1 = (this.supportsAdminCode ? 128 : 0) | (this.supportsAdminCodeDeactivation ? 64 : 0) | supportedStatusesBitmask.length & 31;
1118
1130
  const supportedKeypadModesBitmask = (0, import_core.encodeBitMask)(this.supportedKeypadModes, void 0, import_Types.KeypadMode.Normal);
1119
1131
  const controlByte2 = (this.supportsUserCodeChecksum ? 128 : 0) | (this.supportsMultipleUserCodeReport ? 64 : 0) | (this.supportsMultipleUserCodeSet ? 32 : 0) | supportedKeypadModesBitmask.length & 31;
1120
- const keysAsNumbers = [...this.supportedASCIIChars].map((char) => char.charCodeAt(0));
1132
+ const keysAsNumbers = this.supportedASCIIChars.split("").map((char) => char.charCodeAt(0));
1121
1133
  const supportedKeysBitmask = (0, import_core.encodeBitMask)(keysAsNumbers, void 0, 0);
1122
1134
  const controlByte3 = supportedKeysBitmask.length & 31;
1123
1135
  this.payload = import_shared.Bytes.concat([
@@ -1520,8 +1532,38 @@ let UserCodeCCExtendedUserCodeSet = (() => {
1520
1532
  super(options);
1521
1533
  this.userCodes = options.userCodes;
1522
1534
  }
1523
- static from(_raw, _ctx) {
1524
- throw new import_core.ZWaveError(`${this.name}: deserialization not implemented`, import_core.ZWaveErrorCodes.Deserialization_NotImplemented);
1535
+ static from(raw, ctx) {
1536
+ (0, import_core.validatePayload)(raw.payload.length >= 1);
1537
+ const numCodes = raw.payload[0];
1538
+ let offset = 1;
1539
+ const userCodes = [];
1540
+ for (let i = 0; i < numCodes; i++) {
1541
+ (0, import_core.validatePayload)(raw.payload.length >= offset + 4);
1542
+ const userId = raw.payload.readUInt16BE(offset);
1543
+ const userIdStatus = raw.payload[offset + 2];
1544
+ const codeLength = raw.payload[offset + 3];
1545
+ (0, import_core.validatePayload)(raw.payload.length >= offset + 4 + codeLength);
1546
+ if (userIdStatus === import_Types.UserIDStatus.Available) {
1547
+ userCodes.push({
1548
+ userId,
1549
+ userIdStatus
1550
+ });
1551
+ } else {
1552
+ const userCodeBuffer = raw.payload.subarray(offset + 4, offset + 4 + codeLength);
1553
+ const userCodeString = userCodeBuffer.toString("utf8");
1554
+ const userCode = (0, import_shared.isPrintableASCII)(userCodeString) ? userCodeString : userCodeBuffer;
1555
+ userCodes.push({
1556
+ userId,
1557
+ userIdStatus,
1558
+ userCode
1559
+ });
1560
+ }
1561
+ offset += 4 + codeLength;
1562
+ }
1563
+ return new this({
1564
+ nodeId: ctx.sourceNodeId,
1565
+ userCodes
1566
+ });
1525
1567
  }
1526
1568
  userCodes;
1527
1569
  serialize(ctx) {