@zwave-js/cc 10.15.0 → 10.17.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 (114) hide show
  1. package/build/cc/AlarmSensorCC.d.ts +34 -34
  2. package/build/cc/AssociationCC.d.ts +18 -18
  3. package/build/cc/AssociationGroupInfoCC.d.ts +27 -27
  4. package/build/cc/BarrierOperatorCC.d.ts +11 -11
  5. package/build/cc/BasicCC.d.ts +1 -1
  6. package/build/cc/BatteryCC.d.ts +10 -10
  7. package/build/cc/BinarySensorCC.d.ts +9 -9
  8. package/build/cc/BinarySwitchCC.d.ts +1 -1
  9. package/build/cc/BinarySwitchCC.d.ts.map +1 -1
  10. package/build/cc/BinarySwitchCC.js +1 -1
  11. package/build/cc/BinarySwitchCC.js.map +1 -1
  12. package/build/cc/CentralSceneCC.d.ts +11 -11
  13. package/build/cc/ClimateControlScheduleCC.d.ts +10 -10
  14. package/build/cc/ClimateControlScheduleCC.js +6 -6
  15. package/build/cc/ClockCC.d.ts +1 -1
  16. package/build/cc/ColorSwitchCC.d.ts +22 -22
  17. package/build/cc/ColorSwitchCC.js +5 -5
  18. package/build/cc/ConfigurationCC.d.ts +21 -18
  19. package/build/cc/ConfigurationCC.d.ts.map +1 -1
  20. package/build/cc/ConfigurationCC.js +32 -26
  21. package/build/cc/ConfigurationCC.js.map +1 -1
  22. package/build/cc/DoorLockCC.d.ts +8 -8
  23. package/build/cc/EnergyProductionCC.d.ts +67 -0
  24. package/build/cc/EnergyProductionCC.d.ts.map +1 -0
  25. package/build/cc/EnergyProductionCC.js +179 -0
  26. package/build/cc/EnergyProductionCC.js.map +1 -0
  27. package/build/cc/HumidityControlSetpointCC.d.ts +22 -22
  28. package/build/cc/IndicatorCC.d.ts +30 -30
  29. package/build/cc/IrrigationCC.d.ts +177 -177
  30. package/build/cc/ManufacturerSpecificCC.d.ts +14 -14
  31. package/build/cc/MeterCC.d.ts +22 -22
  32. package/build/cc/MeterCC.d.ts.map +1 -1
  33. package/build/cc/MeterCC.js +6 -1
  34. package/build/cc/MeterCC.js.map +1 -1
  35. package/build/cc/MultiChannelAssociationCC.d.ts +28 -28
  36. package/build/cc/MultiChannelCC.d.ts +9 -9
  37. package/build/cc/MultilevelSensorCC.d.ts +18 -18
  38. package/build/cc/MultilevelSwitchCC.d.ts +19 -19
  39. package/build/cc/MultilevelSwitchCC.js +2 -2
  40. package/build/cc/MultilevelSwitchCC.js.map +1 -1
  41. package/build/cc/NodeNamingCC.d.ts +2 -2
  42. package/build/cc/NotificationCC.d.ts +54 -53
  43. package/build/cc/NotificationCC.d.ts.map +1 -1
  44. package/build/cc/NotificationCC.js +21 -0
  45. package/build/cc/NotificationCC.js.map +1 -1
  46. package/build/cc/ProtectionCC.d.ts +3 -3
  47. package/build/cc/SceneActivationCC.d.ts +1 -1
  48. package/build/cc/SceneActuatorConfigurationCC.d.ts +21 -21
  49. package/build/cc/SceneActuatorConfigurationCC.d.ts.map +1 -1
  50. package/build/cc/SceneActuatorConfigurationCC.js +1 -2
  51. package/build/cc/SceneActuatorConfigurationCC.js.map +1 -1
  52. package/build/cc/SceneControllerConfigurationCC.d.ts +21 -21
  53. package/build/cc/SceneControllerConfigurationCC.d.ts.map +1 -1
  54. package/build/cc/SceneControllerConfigurationCC.js +3 -4
  55. package/build/cc/SceneControllerConfigurationCC.js.map +1 -1
  56. package/build/cc/ScheduleEntryLockCC.d.ts.map +1 -1
  57. package/build/cc/ScheduleEntryLockCC.js +2 -1
  58. package/build/cc/ScheduleEntryLockCC.js.map +1 -1
  59. package/build/cc/Security2CC.d.ts +1 -0
  60. package/build/cc/Security2CC.d.ts.map +1 -1
  61. package/build/cc/Security2CC.js +37 -10
  62. package/build/cc/Security2CC.js.map +1 -1
  63. package/build/cc/SecurityCC.d.ts +9 -5
  64. package/build/cc/SecurityCC.d.ts.map +1 -1
  65. package/build/cc/SecurityCC.js +70 -28
  66. package/build/cc/SecurityCC.js.map +1 -1
  67. package/build/cc/SoundSwitchCC.d.ts +1 -1
  68. package/build/cc/SupervisionCC.d.ts +9 -9
  69. package/build/cc/ThermostatFanModeCC.d.ts +2 -2
  70. package/build/cc/ThermostatSetbackCC.js +3 -3
  71. package/build/cc/ThermostatSetpointCC.d.ts +20 -20
  72. package/build/cc/TimeCC.d.ts +1 -1
  73. package/build/cc/TransportServiceCC.d.ts.map +1 -1
  74. package/build/cc/TransportServiceCC.js +5 -4
  75. package/build/cc/TransportServiceCC.js.map +1 -1
  76. package/build/cc/UserCodeCC.d.ts +22 -22
  77. package/build/cc/VersionCC.d.ts +24 -15
  78. package/build/cc/VersionCC.d.ts.map +1 -1
  79. package/build/cc/VersionCC.js +133 -10
  80. package/build/cc/VersionCC.js.map +1 -1
  81. package/build/cc/WakeUpCC.d.ts +2 -2
  82. package/build/cc/WindowCoveringCC.d.ts +353 -0
  83. package/build/cc/WindowCoveringCC.d.ts.map +1 -0
  84. package/build/cc/WindowCoveringCC.js +760 -0
  85. package/build/cc/WindowCoveringCC.js.map +1 -0
  86. package/build/cc/ZWavePlusCC.d.ts +1 -1
  87. package/build/cc/ZWavePlusCC.d.ts.map +1 -1
  88. package/build/cc/ZWavePlusCC.js +34 -0
  89. package/build/cc/ZWavePlusCC.js.map +1 -1
  90. package/build/cc/index.d.ts +2 -0
  91. package/build/cc/index.d.ts.map +1 -1
  92. package/build/cc/index.js +24 -9
  93. package/build/cc/index.js.map +1 -1
  94. package/build/lib/API.d.ts +4 -0
  95. package/build/lib/API.d.ts.map +1 -1
  96. package/build/lib/API.js.map +1 -1
  97. package/build/lib/CommandClass.d.ts.map +1 -1
  98. package/build/lib/CommandClass.js +17 -4
  99. package/build/lib/CommandClass.js.map +1 -1
  100. package/build/lib/EncapsulatingCommandClass.d.ts +1 -0
  101. package/build/lib/EncapsulatingCommandClass.d.ts.map +1 -1
  102. package/build/lib/EncapsulatingCommandClass.js +10 -1
  103. package/build/lib/EncapsulatingCommandClass.js.map +1 -1
  104. package/build/lib/Security2/Extension.d.ts +2 -0
  105. package/build/lib/Security2/Extension.d.ts.map +1 -1
  106. package/build/lib/Security2/Extension.js +9 -1
  107. package/build/lib/Security2/Extension.js.map +1 -1
  108. package/build/lib/Values.d.ts +3 -1
  109. package/build/lib/Values.d.ts.map +1 -1
  110. package/build/lib/_Types.d.ts +50 -0
  111. package/build/lib/_Types.d.ts.map +1 -1
  112. package/build/lib/_Types.js +93 -4
  113. package/build/lib/_Types.js.map +1 -1
  114. package/package.json +12 -24
@@ -0,0 +1,760 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var _a, _b;
9
+ Object.defineProperty(exports, "__esModule", { value: true });
10
+ exports.WindowCoveringCCStopLevelChange = exports.WindowCoveringCCStartLevelChange = exports.WindowCoveringCCSet = exports.WindowCoveringCCGet = exports.WindowCoveringCCReport = exports.WindowCoveringCCSupportedGet = exports.WindowCoveringCCSupportedReport = exports.WindowCoveringCC = exports.WindowCoveringCCAPI = exports.WindowCoveringCCValues = void 0;
11
+ function __assertType(argName, typeName, boundHasError) {
12
+ const { ZWaveError, ZWaveErrorCodes } = require("@zwave-js/core");
13
+ if (boundHasError()) {
14
+ throw new ZWaveError(typeName ? `${argName} is not a ${typeName}` : `${argName} has the wrong type`, ZWaveErrorCodes.Argument_Invalid);
15
+ }
16
+ }
17
+ const __assertType__WindowCoveringParameter = $o => {
18
+ function su__1__2__3__4__5__6__7__8__9__10__11__12__13__14__15__16__17__18__19__20__21__22__23__24_eu($o) {
19
+ return ![0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23].includes($o) ? {} : null;
20
+ }
21
+ return su__1__2__3__4__5__6__7__8__9__10__11__12__13__14__15__16__17__18__19__20__21__22__23__24_eu($o);
22
+ };
23
+ const __assertType__sa__2_ea_2 = $o => {
24
+ function su__4__5__6__7__8__9__10__11__12__13__14__15__16__17__18__19__20__21__22__23__24__25__26__27_eu($o) {
25
+ return ![0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23].includes($o) ? {} : null;
26
+ }
27
+ function _number($o) {
28
+ return typeof $o !== "number" ? {} : null;
29
+ }
30
+ function _2($o) {
31
+ if (typeof $o !== "object" || $o === null || Array.isArray($o))
32
+ return {};
33
+ if ("parameter" in $o && $o["parameter"] !== undefined) {
34
+ const error = su__4__5__6__7__8__9__10__11__12__13__14__15__16__17__18__19__20__21__22__23__24__25__26__27_eu($o["parameter"]);
35
+ if (error)
36
+ return error;
37
+ }
38
+ else
39
+ return {};
40
+ if ("value" in $o && $o["value"] !== undefined) {
41
+ const error = _number($o["value"]);
42
+ if (error)
43
+ return error;
44
+ }
45
+ else
46
+ return {};
47
+ return null;
48
+ }
49
+ function sa__2_ea_2($o) {
50
+ if (!Array.isArray($o))
51
+ return {};
52
+ for (let i = 0; i < $o.length; i++) {
53
+ const error = _2($o[i]);
54
+ if (error)
55
+ return error;
56
+ }
57
+ return null;
58
+ }
59
+ return sa__2_ea_2($o);
60
+ };
61
+ const __assertType__optional_su__string__2_eu = $o => {
62
+ function _string($o) {
63
+ return typeof $o !== "string" ? {} : null;
64
+ }
65
+ function _2($o) {
66
+ return !($o instanceof require("@zwave-js/core").Duration) ? {} : null;
67
+ }
68
+ function su__string__2_eu($o) {
69
+ const conditions = [_string, _2];
70
+ for (const condition of conditions) {
71
+ const error = condition($o);
72
+ if (!error)
73
+ return null;
74
+ }
75
+ return {};
76
+ }
77
+ function optional_su__string__2_eu($o) {
78
+ if ($o !== undefined) {
79
+ const error = su__string__2_eu($o);
80
+ if (error)
81
+ return error;
82
+ }
83
+ return null;
84
+ }
85
+ return optional_su__string__2_eu($o);
86
+ };
87
+ const __assertType__su__1__2_eu = $o => {
88
+ function _1($o) {
89
+ return $o !== "up" ? {} : null;
90
+ }
91
+ function _2($o) {
92
+ return $o !== "down" ? {} : null;
93
+ }
94
+ function su__1__2_eu($o) {
95
+ const conditions = [_1, _2];
96
+ for (const condition of conditions) {
97
+ const error = condition($o);
98
+ if (!error)
99
+ return null;
100
+ }
101
+ return {};
102
+ }
103
+ return su__1__2_eu($o);
104
+ };
105
+ const core_1 = require("@zwave-js/core");
106
+ const safe_1 = require("@zwave-js/shared/safe");
107
+ const API_1 = require("../lib/API");
108
+ const CommandClass_1 = require("../lib/CommandClass");
109
+ const CommandClassDecorators_1 = require("../lib/CommandClassDecorators");
110
+ const Values_1 = require("../lib/Values");
111
+ const _Types_1 = require("../lib/_Types");
112
+ function parameterToMetadataStates(parameter, isTargetValue) {
113
+ switch (parameter) {
114
+ case _Types_1.WindowCoveringParameter["Vertical Slats Angle (no position)"]:
115
+ if (isTargetValue)
116
+ return undefined;
117
+ return {
118
+ 0: "Closing (right)",
119
+ 50: "Opening",
120
+ 99: "Closing (left)",
121
+ };
122
+ case _Types_1.WindowCoveringParameter["Vertical Slats Angle"]:
123
+ return {
124
+ 0: "Closed (right)",
125
+ 50: "Open",
126
+ 99: "Closed (left)",
127
+ };
128
+ case _Types_1.WindowCoveringParameter["Horizontal Slats Angle (no position)"]:
129
+ if (isTargetValue)
130
+ return undefined;
131
+ return {
132
+ 0: "Closing (up)",
133
+ 50: "Opening",
134
+ 99: "Closing (down)",
135
+ };
136
+ case _Types_1.WindowCoveringParameter["Horizontal Slats Angle"]:
137
+ return {
138
+ 0: "Closed (up)",
139
+ 50: "Open",
140
+ 99: "Closed (down)",
141
+ };
142
+ }
143
+ if (parameter % 2 === 1) {
144
+ // Odd-numbered parameters have position support
145
+ return {
146
+ 0: "Closed",
147
+ 99: "Open",
148
+ };
149
+ }
150
+ else {
151
+ if (isTargetValue)
152
+ return undefined;
153
+ return {
154
+ 0: "Closing",
155
+ 99: "Opening",
156
+ };
157
+ }
158
+ }
159
+ function isTiltParameter(parameter) {
160
+ return (parameter === _Types_1.WindowCoveringParameter["Vertical Slats Angle"] ||
161
+ parameter ===
162
+ _Types_1.WindowCoveringParameter["Vertical Slats Angle (no position)"] ||
163
+ parameter === _Types_1.WindowCoveringParameter["Horizontal Slats Angle"] ||
164
+ parameter ===
165
+ _Types_1.WindowCoveringParameter["Horizontal Slats Angle (no position)"]);
166
+ }
167
+ exports.WindowCoveringCCValues = Object.freeze({
168
+ ...Values_1.V.defineStaticCCValues(core_1.CommandClasses["Window Covering"], {
169
+ ...Values_1.V.staticProperty("supportedParameters", undefined, // meta
170
+ { internal: true }),
171
+ }),
172
+ ...Values_1.V.defineDynamicCCValues(core_1.CommandClasses["Window Covering"], {
173
+ ...Values_1.V.dynamicPropertyAndKeyWithName("currentValue", "currentValue", (parameter) => parameter, ({ property, propertyKey }) => property === "currentValue" && typeof propertyKey === "number", (parameter) => {
174
+ const states = parameterToMetadataStates(parameter, false);
175
+ return {
176
+ ...core_1.ValueMetadata.ReadOnlyLevel,
177
+ label: `Current value - ${(0, safe_1.getEnumMemberName)(_Types_1.WindowCoveringParameter, parameter)}`,
178
+ ...(states ? { states } : {}),
179
+ ccSpecific: {
180
+ parameter,
181
+ },
182
+ };
183
+ }),
184
+ ...Values_1.V.dynamicPropertyAndKeyWithName("targetValue", "targetValue", (parameter) => parameter, ({ property, propertyKey }) => property === "targetValue" && typeof propertyKey === "number", (parameter) => {
185
+ const states = parameterToMetadataStates(parameter, false);
186
+ return {
187
+ ...core_1.ValueMetadata.Level,
188
+ label: `Target value - ${(0, safe_1.getEnumMemberName)(_Types_1.WindowCoveringParameter, parameter)}`,
189
+ // Only odd-numbered parameters have position support and are writable
190
+ writeable: parameter % 2 === 1,
191
+ ...(states ? { states } : {}),
192
+ ccSpecific: {
193
+ parameter,
194
+ },
195
+ valueChangeOptions: ["transitionDuration"],
196
+ };
197
+ }),
198
+ ...Values_1.V.dynamicPropertyAndKeyWithName("duration", "duration", (parameter) => parameter, ({ property, propertyKey }) => property === "duration" && typeof propertyKey === "number", (parameter) => ({
199
+ ...core_1.ValueMetadata.ReadOnlyDuration,
200
+ label: `Remaining duration - ${(0, safe_1.getEnumMemberName)(_Types_1.WindowCoveringParameter, parameter)}`,
201
+ ccSpecific: {
202
+ parameter,
203
+ },
204
+ })),
205
+ // Convenience values to control the different parameters
206
+ // Open all parameters
207
+ ...Values_1.V.dynamicPropertyAndKeyWithName("open", "open", (parameter) => parameter, ({ property, propertyKey }) => property === "open" && typeof propertyKey === "number", (parameter) => ({
208
+ ...core_1.ValueMetadata.WriteOnlyBoolean,
209
+ label: `Open - ${(0, safe_1.getEnumMemberName)(_Types_1.WindowCoveringParameter, parameter)}`,
210
+ ccSpecific: {
211
+ parameter,
212
+ },
213
+ valueChangeOptions: ["transitionDuration"],
214
+ })),
215
+ // Close positional parameters
216
+ ...Values_1.V.dynamicPropertyAndKeyWithName("positionClose", "close", (parameter) => parameter, ({ property, propertyKey }) => property === "close" &&
217
+ typeof propertyKey === "number" &&
218
+ !isTiltParameter(propertyKey), (parameter) => ({
219
+ ...core_1.ValueMetadata.WriteOnlyBoolean,
220
+ label: `Close - ${(0, safe_1.getEnumMemberName)(_Types_1.WindowCoveringParameter, parameter)}`,
221
+ ccSpecific: {
222
+ parameter,
223
+ },
224
+ valueChangeOptions: ["transitionDuration"],
225
+ })),
226
+ // Close vertical slats to the right, horizontal to the top
227
+ ...Values_1.V.dynamicPropertyAndKeyWithName("tiltClose0", "close0", (parameter) => parameter, ({ property, propertyKey }) => property === "close0" &&
228
+ typeof propertyKey === "number" &&
229
+ isTiltParameter(propertyKey), (parameter) => {
230
+ const direction = parameter ===
231
+ _Types_1.WindowCoveringParameter["Vertical Slats Angle"] ||
232
+ parameter ===
233
+ _Types_1.WindowCoveringParameter["Vertical Slats Angle (no position)"]
234
+ ? "Right"
235
+ : "Up";
236
+ return {
237
+ ...core_1.ValueMetadata.WriteOnlyBoolean,
238
+ label: `Close ${direction} - ${(0, safe_1.getEnumMemberName)(_Types_1.WindowCoveringParameter, parameter)}`,
239
+ ccSpecific: {
240
+ parameter,
241
+ },
242
+ valueChangeOptions: ["transitionDuration"],
243
+ };
244
+ }),
245
+ // Close vertical slats to the left, horizontal to the bottom
246
+ ...Values_1.V.dynamicPropertyAndKeyWithName("tiltClose99", "close99", (parameter) => parameter, ({ property, propertyKey }) => property === "close99" &&
247
+ typeof propertyKey === "number" &&
248
+ isTiltParameter(propertyKey), (parameter) => {
249
+ const direction = parameter ===
250
+ _Types_1.WindowCoveringParameter["Vertical Slats Angle"] ||
251
+ parameter ===
252
+ _Types_1.WindowCoveringParameter["Vertical Slats Angle (no position)"]
253
+ ? "Left"
254
+ : "Down";
255
+ return {
256
+ ...core_1.ValueMetadata.WriteOnlyBoolean,
257
+ label: `Close ${direction} - ${(0, safe_1.getEnumMemberName)(_Types_1.WindowCoveringParameter, parameter)}`,
258
+ ccSpecific: {
259
+ parameter,
260
+ },
261
+ valueChangeOptions: ["transitionDuration"],
262
+ };
263
+ }),
264
+ }),
265
+ });
266
+ let WindowCoveringCCAPI = class WindowCoveringCCAPI extends API_1.CCAPI {
267
+ constructor() {
268
+ super(...arguments);
269
+ this[_a] = async ({ property, propertyKey }, value, options) => {
270
+ const valueId = {
271
+ commandClass: this.ccId,
272
+ property,
273
+ propertyKey,
274
+ };
275
+ let targetValue;
276
+ if (exports.WindowCoveringCCValues.targetValue.is(valueId)) {
277
+ if (typeof propertyKey !== "number" ||
278
+ // Only odd-numbered parameters have position support and are writable
279
+ propertyKey % 2 === 0) {
280
+ (0, API_1.throwUnsupportedPropertyKey)(this.ccId, property, propertyKey);
281
+ }
282
+ if (typeof value !== "number") {
283
+ (0, API_1.throwWrongValueType)(this.ccId, property, "number", typeof value);
284
+ }
285
+ targetValue = value;
286
+ }
287
+ else if (
288
+ // Opening a positional parameter is the same as closing a tilt parameter to one side (99)
289
+ (exports.WindowCoveringCCValues.open.is(valueId) &&
290
+ !isTiltParameter(propertyKey)) ||
291
+ exports.WindowCoveringCCValues.tiltClose99.is(valueId)) {
292
+ if (!value) {
293
+ (0, API_1.throwWrongValueType)(this.ccId, property, "true", typeof value);
294
+ }
295
+ targetValue = 99;
296
+ }
297
+ else if (
298
+ // Opening a tilt parameter means setting it to 50
299
+ exports.WindowCoveringCCValues.open.is(valueId) &&
300
+ isTiltParameter(propertyKey)) {
301
+ if (!value) {
302
+ (0, API_1.throwWrongValueType)(this.ccId, property, "true", typeof value);
303
+ }
304
+ targetValue = 50;
305
+ }
306
+ else if (exports.WindowCoveringCCValues.positionClose.is(valueId) ||
307
+ exports.WindowCoveringCCValues.tiltClose0.is(valueId)) {
308
+ if (!value) {
309
+ (0, API_1.throwWrongValueType)(this.ccId, property, "true", typeof value);
310
+ }
311
+ // Closing a positional parameter is the same as closing a tilt parameter to the other side
312
+ targetValue = 0;
313
+ }
314
+ else {
315
+ (0, API_1.throwUnsupportedProperty)(this.ccId, property);
316
+ }
317
+ const parameter = propertyKey;
318
+ const currentValueValueId = exports.WindowCoveringCCValues.currentValue(parameter).endpoint(this.endpoint.index);
319
+ const targetValueValueId = exports.WindowCoveringCCValues.targetValue(parameter).endpoint(this.endpoint.index);
320
+ // If we have set the value via one of the convenience properties,
321
+ // we need to update the targetValue value ID
322
+ if (targetValue !== value) {
323
+ this.tryGetValueDB()?.setValue(targetValueValueId, targetValue);
324
+ }
325
+ const duration = core_1.Duration.from(options?.transitionDuration);
326
+ // Window Covering commands may take some time to be executed.
327
+ // Therefore we try to supervise the command execution and delay the
328
+ // optimistic update until the final result is received.
329
+ const result = await this.withOptions({
330
+ requestStatusUpdates: true,
331
+ onUpdate: (update) => {
332
+ if (update.status === core_1.SupervisionStatus.Success) {
333
+ this.tryGetValueDB()?.setValue(currentValueValueId, targetValue);
334
+ }
335
+ else if (update.status === core_1.SupervisionStatus.Fail) {
336
+ // The transition failed, so now we don't know the status
337
+ // Refresh the current value
338
+ // eslint-disable-next-line @typescript-eslint/no-empty-function
339
+ void this.get(parameter).catch(() => { });
340
+ }
341
+ },
342
+ }).set([{ parameter: propertyKey, value: targetValue }], duration);
343
+ // If the command did not fail, assume that it succeeded and update the currentValue accordingly
344
+ // so UIs have immediate feedback
345
+ const shouldUpdateOptimistically =
346
+ // For unsupervised commands, make the choice to update optimistically dependent on the driver options
347
+ (!this.applHost.options.disableOptimisticValueUpdate &&
348
+ result == undefined) ||
349
+ ((0, core_1.isSupervisionResult)(result) &&
350
+ result.status === core_1.SupervisionStatus.Success);
351
+ if (this.isSinglecast()) {
352
+ // Only update currentValue for valid target values
353
+ if (shouldUpdateOptimistically &&
354
+ targetValue >= 0 &&
355
+ targetValue <= 99) {
356
+ this.tryGetValueDB()?.setValue(currentValueValueId, targetValue);
357
+ }
358
+ // Verify the current value after a delay, unless...
359
+ // ...the command was supervised and successful
360
+ // ...and we know the actual value
361
+ if (!(0, core_1.supervisedCommandSucceeded)(result)) {
362
+ this.schedulePoll({
363
+ property: currentValueValueId.property,
364
+ propertyKey: currentValueValueId.propertyKey,
365
+ }, targetValue, { duration });
366
+ }
367
+ }
368
+ return result;
369
+ };
370
+ this[_b] = async ({ property, propertyKey, }) => {
371
+ switch (property) {
372
+ case "currentValue":
373
+ case "targetValue":
374
+ case "duration":
375
+ if (propertyKey == undefined) {
376
+ (0, API_1.throwMissingPropertyKey)(this.ccId, property);
377
+ }
378
+ else if (typeof propertyKey !== "number") {
379
+ (0, API_1.throwUnsupportedPropertyKey)(this.ccId, property, propertyKey);
380
+ }
381
+ return (await this.get(propertyKey))?.[property];
382
+ default:
383
+ (0, API_1.throwUnsupportedProperty)(this.ccId, property);
384
+ }
385
+ };
386
+ }
387
+ supportsCommand(cmd) {
388
+ switch (cmd) {
389
+ case _Types_1.WindowCoveringCommand.Get:
390
+ case _Types_1.WindowCoveringCommand.Set:
391
+ case _Types_1.WindowCoveringCommand.SupportedGet:
392
+ case _Types_1.WindowCoveringCommand.StartLevelChange:
393
+ case _Types_1.WindowCoveringCommand.StopLevelChange:
394
+ return true; // This is mandatory
395
+ }
396
+ return super.supportsCommand(cmd);
397
+ }
398
+ async getSupported() {
399
+ this.assertSupportsCommand(_Types_1.WindowCoveringCommand, _Types_1.WindowCoveringCommand.SupportedGet);
400
+ const cc = new WindowCoveringCCSupportedGet(this.applHost, {
401
+ nodeId: this.endpoint.nodeId,
402
+ endpoint: this.endpoint.index,
403
+ });
404
+ const response = await this.applHost.sendCommand(cc, this.commandOptions);
405
+ return response?.supportedParameters;
406
+ }
407
+ async get(parameter) {
408
+ __assertType("parameter", "WindowCoveringParameter", __assertType__WindowCoveringParameter.bind(void 0, parameter));
409
+ this.assertSupportsCommand(_Types_1.WindowCoveringCommand, _Types_1.WindowCoveringCommand.Get);
410
+ const cc = new WindowCoveringCCGet(this.applHost, {
411
+ nodeId: this.endpoint.nodeId,
412
+ endpoint: this.endpoint.index,
413
+ parameter,
414
+ });
415
+ const response = await this.applHost.sendCommand(cc, this.commandOptions);
416
+ if (response) {
417
+ return (0, safe_1.pick)(response, ["currentValue", "targetValue", "duration"]);
418
+ }
419
+ }
420
+ async set(targetValues, duration) {
421
+ __assertType("targetValues", undefined, __assertType__sa__2_ea_2.bind(void 0, targetValues));
422
+ __assertType("duration", undefined, __assertType__optional_su__string__2_eu.bind(void 0, duration));
423
+ this.assertSupportsCommand(_Types_1.WindowCoveringCommand, _Types_1.WindowCoveringCommand.StartLevelChange);
424
+ const cc = new WindowCoveringCCSet(this.applHost, {
425
+ nodeId: this.endpoint.nodeId,
426
+ endpoint: this.endpoint.index,
427
+ targetValues,
428
+ duration,
429
+ });
430
+ return this.applHost.sendCommand(cc, this.commandOptions);
431
+ }
432
+ async startLevelChange(parameter, direction, duration) {
433
+ __assertType("parameter", "WindowCoveringParameter", __assertType__WindowCoveringParameter.bind(void 0, parameter));
434
+ __assertType("direction", undefined, __assertType__su__1__2_eu.bind(void 0, direction));
435
+ __assertType("duration", undefined, __assertType__optional_su__string__2_eu.bind(void 0, duration));
436
+ this.assertSupportsCommand(_Types_1.WindowCoveringCommand, _Types_1.WindowCoveringCommand.StartLevelChange);
437
+ const cc = new WindowCoveringCCStartLevelChange(this.applHost, {
438
+ nodeId: this.endpoint.nodeId,
439
+ endpoint: this.endpoint.index,
440
+ parameter,
441
+ direction,
442
+ duration,
443
+ });
444
+ return this.applHost.sendCommand(cc, this.commandOptions);
445
+ }
446
+ async stopLevelChange(parameter) {
447
+ __assertType("parameter", "WindowCoveringParameter", __assertType__WindowCoveringParameter.bind(void 0, parameter));
448
+ this.assertSupportsCommand(_Types_1.WindowCoveringCommand, _Types_1.WindowCoveringCommand.StopLevelChange);
449
+ const cc = new WindowCoveringCCStopLevelChange(this.applHost, {
450
+ nodeId: this.endpoint.nodeId,
451
+ endpoint: this.endpoint.index,
452
+ parameter,
453
+ });
454
+ return this.applHost.sendCommand(cc, this.commandOptions);
455
+ }
456
+ };
457
+ _a = API_1.SET_VALUE, _b = API_1.POLL_VALUE;
458
+ WindowCoveringCCAPI = __decorate([
459
+ (0, CommandClassDecorators_1.API)(core_1.CommandClasses["Window Covering"])
460
+ ], WindowCoveringCCAPI);
461
+ exports.WindowCoveringCCAPI = WindowCoveringCCAPI;
462
+ let WindowCoveringCC = class WindowCoveringCC extends CommandClass_1.CommandClass {
463
+ async interview(applHost) {
464
+ const node = this.getNode(applHost);
465
+ const endpoint = this.getEndpoint(applHost);
466
+ const api = API_1.CCAPI.create(core_1.CommandClasses["Window Covering"], applHost, endpoint).withOptions({
467
+ priority: core_1.MessagePriority.NodeQuery,
468
+ });
469
+ applHost.controllerLog.logNode(node.id, {
470
+ endpoint: this.endpointIndex,
471
+ message: `Interviewing ${this.ccName}...`,
472
+ direction: "none",
473
+ });
474
+ applHost.controllerLog.logNode(node.id, {
475
+ endpoint: this.endpointIndex,
476
+ message: "querying supported window covering parameters...",
477
+ direction: "outbound",
478
+ });
479
+ const supported = await api.getSupported();
480
+ if (supported?.length) {
481
+ const logMessage = `supported window covering parameters:
482
+ ${supported
483
+ .map((p) => `· ${(0, safe_1.getEnumMemberName)(_Types_1.WindowCoveringParameter, p)}`)
484
+ .join("\n")}`;
485
+ applHost.controllerLog.logNode(node.id, {
486
+ endpoint: this.endpointIndex,
487
+ message: logMessage,
488
+ direction: "inbound",
489
+ });
490
+ // Create metadata for all supported parameters
491
+ for (const param of supported) {
492
+ // Default values
493
+ this.setMetadata(applHost, exports.WindowCoveringCCValues.currentValue(param));
494
+ this.setMetadata(applHost, exports.WindowCoveringCCValues.targetValue(param));
495
+ this.setMetadata(applHost, exports.WindowCoveringCCValues.duration(param));
496
+ // Convenience values
497
+ this.setMetadata(applHost, exports.WindowCoveringCCValues.open(param));
498
+ if (isTiltParameter(param)) {
499
+ this.setMetadata(applHost, exports.WindowCoveringCCValues.tiltClose0(param));
500
+ this.setMetadata(applHost, exports.WindowCoveringCCValues.tiltClose99(param));
501
+ }
502
+ else {
503
+ this.setMetadata(applHost, exports.WindowCoveringCCValues.positionClose(param));
504
+ }
505
+ // And for the odd parameters (with position support), query the position
506
+ if (param % 2 === 1) {
507
+ applHost.controllerLog.logNode(node.id, {
508
+ endpoint: this.endpointIndex,
509
+ message: `querying position for parameter ${(0, safe_1.getEnumMemberName)(_Types_1.WindowCoveringParameter, param)}...`,
510
+ direction: "outbound",
511
+ });
512
+ await api.get(param);
513
+ }
514
+ }
515
+ }
516
+ // Remember that the interview is complete
517
+ this.setInterviewComplete(applHost, true);
518
+ }
519
+ translatePropertyKey(_applHost, _property, propertyKey) {
520
+ if (typeof propertyKey === "number") {
521
+ return (0, safe_1.getEnumMemberName)(_Types_1.WindowCoveringParameter, propertyKey);
522
+ }
523
+ return super.translatePropertyKey(_applHost, _property, propertyKey);
524
+ }
525
+ };
526
+ WindowCoveringCC = __decorate([
527
+ (0, CommandClassDecorators_1.commandClass)(core_1.CommandClasses["Window Covering"]),
528
+ (0, CommandClassDecorators_1.implementedVersion)(1),
529
+ (0, CommandClassDecorators_1.ccValues)(exports.WindowCoveringCCValues)
530
+ ], WindowCoveringCC);
531
+ exports.WindowCoveringCC = WindowCoveringCC;
532
+ let WindowCoveringCCSupportedReport = class WindowCoveringCCSupportedReport extends WindowCoveringCC {
533
+ constructor(host, options) {
534
+ super(host, options);
535
+ if ((0, CommandClass_1.gotDeserializationOptions)(options)) {
536
+ (0, core_1.validatePayload)(this.payload.length >= 1);
537
+ const numBitmaskBytes = this.payload[0] & 0b1111;
538
+ (0, core_1.validatePayload)(this.payload.length >= 1 + numBitmaskBytes);
539
+ const bitmask = this.payload.slice(1, 1 + numBitmaskBytes);
540
+ this.supportedParameters = (0, core_1.parseBitMask)(bitmask, _Types_1.WindowCoveringParameter["Outbound Left (no position)"]);
541
+ }
542
+ else {
543
+ this.supportedParameters = options.supportedParameters;
544
+ }
545
+ }
546
+ serialize() {
547
+ const bitmask = (0, core_1.encodeBitMask)(this.supportedParameters, undefined, _Types_1.WindowCoveringParameter["Outbound Left (no position)"]).slice(0, 15);
548
+ const numBitmaskBytes = bitmask.length & 0b1111;
549
+ this.payload = Buffer.concat([
550
+ Buffer.from([numBitmaskBytes]),
551
+ bitmask.slice(0, numBitmaskBytes),
552
+ ]);
553
+ return super.serialize();
554
+ }
555
+ toLogEntry(applHost) {
556
+ return {
557
+ ...super.toLogEntry(applHost),
558
+ message: {
559
+ "supported parameters": this.supportedParameters
560
+ .map((p) => `\n· ${(0, safe_1.getEnumMemberName)(_Types_1.WindowCoveringParameter, p)}`)
561
+ .join(""),
562
+ },
563
+ };
564
+ }
565
+ };
566
+ __decorate([
567
+ (0, CommandClassDecorators_1.ccValue)(exports.WindowCoveringCCValues.supportedParameters)
568
+ ], WindowCoveringCCSupportedReport.prototype, "supportedParameters", void 0);
569
+ WindowCoveringCCSupportedReport = __decorate([
570
+ (0, CommandClassDecorators_1.CCCommand)(_Types_1.WindowCoveringCommand.SupportedReport)
571
+ ], WindowCoveringCCSupportedReport);
572
+ exports.WindowCoveringCCSupportedReport = WindowCoveringCCSupportedReport;
573
+ let WindowCoveringCCSupportedGet = class WindowCoveringCCSupportedGet extends WindowCoveringCC {
574
+ };
575
+ WindowCoveringCCSupportedGet = __decorate([
576
+ (0, CommandClassDecorators_1.CCCommand)(_Types_1.WindowCoveringCommand.SupportedGet),
577
+ (0, CommandClassDecorators_1.expectedCCResponse)(WindowCoveringCCSupportedReport)
578
+ ], WindowCoveringCCSupportedGet);
579
+ exports.WindowCoveringCCSupportedGet = WindowCoveringCCSupportedGet;
580
+ let WindowCoveringCCReport = class WindowCoveringCCReport extends WindowCoveringCC {
581
+ constructor(host, options) {
582
+ super(host, options);
583
+ (0, core_1.validatePayload)(this.payload.length >= 4);
584
+ this.parameter = this.payload[0];
585
+ this.currentValue = this.payload[1];
586
+ this.targetValue = this.payload[2];
587
+ this.duration =
588
+ core_1.Duration.parseReport(this.payload[3]) ?? core_1.Duration.unknown();
589
+ }
590
+ toLogEntry(applHost) {
591
+ return {
592
+ ...super.toLogEntry(applHost),
593
+ message: {
594
+ parameter: (0, safe_1.getEnumMemberName)(_Types_1.WindowCoveringParameter, this.parameter),
595
+ "current value": this.currentValue,
596
+ "target value": this.targetValue,
597
+ duration: this.duration.toString(),
598
+ },
599
+ };
600
+ }
601
+ };
602
+ __decorate([
603
+ (0, CommandClassDecorators_1.ccValue)(exports.WindowCoveringCCValues.currentValue, (self) => [self.parameter])
604
+ ], WindowCoveringCCReport.prototype, "currentValue", void 0);
605
+ __decorate([
606
+ (0, CommandClassDecorators_1.ccValue)(exports.WindowCoveringCCValues.targetValue, (self) => [self.parameter])
607
+ ], WindowCoveringCCReport.prototype, "targetValue", void 0);
608
+ __decorate([
609
+ (0, CommandClassDecorators_1.ccValue)(exports.WindowCoveringCCValues.duration, (self) => [self.parameter])
610
+ ], WindowCoveringCCReport.prototype, "duration", void 0);
611
+ WindowCoveringCCReport = __decorate([
612
+ (0, CommandClassDecorators_1.CCCommand)(_Types_1.WindowCoveringCommand.Report)
613
+ ], WindowCoveringCCReport);
614
+ exports.WindowCoveringCCReport = WindowCoveringCCReport;
615
+ function testResponseForWindowCoveringGet(sent, received) {
616
+ return received.parameter === sent.parameter;
617
+ }
618
+ let WindowCoveringCCGet = class WindowCoveringCCGet extends WindowCoveringCC {
619
+ constructor(host, options) {
620
+ super(host, options);
621
+ if ((0, CommandClass_1.gotDeserializationOptions)(options)) {
622
+ (0, core_1.validatePayload)(this.payload.length >= 1);
623
+ this.parameter = this.payload[0];
624
+ }
625
+ else {
626
+ this.parameter = options.parameter;
627
+ }
628
+ }
629
+ serialize() {
630
+ this.payload = Buffer.from([this.parameter]);
631
+ return super.serialize();
632
+ }
633
+ toLogEntry(applHost) {
634
+ return {
635
+ ...super.toLogEntry(applHost),
636
+ message: {
637
+ parameter: (0, safe_1.getEnumMemberName)(_Types_1.WindowCoveringParameter, this.parameter),
638
+ },
639
+ };
640
+ }
641
+ };
642
+ WindowCoveringCCGet = __decorate([
643
+ (0, CommandClassDecorators_1.CCCommand)(_Types_1.WindowCoveringCommand.Get),
644
+ (0, CommandClassDecorators_1.expectedCCResponse)(WindowCoveringCCReport, testResponseForWindowCoveringGet)
645
+ ], WindowCoveringCCGet);
646
+ exports.WindowCoveringCCGet = WindowCoveringCCGet;
647
+ let WindowCoveringCCSet = class WindowCoveringCCSet extends WindowCoveringCC {
648
+ constructor(host, options) {
649
+ super(host, options);
650
+ if ((0, CommandClass_1.gotDeserializationOptions)(options)) {
651
+ // TODO: Deserialize payload
652
+ throw new core_1.ZWaveError(`${this.constructor.name}: deserialization not implemented`, core_1.ZWaveErrorCodes.Deserialization_NotImplemented);
653
+ }
654
+ else {
655
+ this.targetValues = options.targetValues;
656
+ this.duration = core_1.Duration.from(options.duration);
657
+ }
658
+ }
659
+ serialize() {
660
+ const numEntries = this.targetValues.length & 0b11111;
661
+ this.payload = Buffer.allocUnsafe(2 + numEntries * 2);
662
+ this.payload[0] = numEntries;
663
+ for (let i = 0; i < numEntries; i++) {
664
+ const offset = 1 + i * 2;
665
+ this.payload[offset] = this.targetValues[i].parameter;
666
+ this.payload[offset + 1] = this.targetValues[i].value;
667
+ }
668
+ this.payload[this.payload.length - 1] = (this.duration ?? core_1.Duration.default()).serializeSet();
669
+ return super.serialize();
670
+ }
671
+ toLogEntry(applHost) {
672
+ const message = {};
673
+ for (const { parameter, value } of this.targetValues) {
674
+ message[(0, safe_1.getEnumMemberName)(_Types_1.WindowCoveringParameter, parameter)] =
675
+ value;
676
+ }
677
+ if (this.duration) {
678
+ message.duration = this.duration.toString();
679
+ }
680
+ return {
681
+ ...super.toLogEntry(applHost),
682
+ message,
683
+ };
684
+ }
685
+ };
686
+ WindowCoveringCCSet = __decorate([
687
+ (0, CommandClassDecorators_1.CCCommand)(_Types_1.WindowCoveringCommand.Set),
688
+ (0, CommandClassDecorators_1.useSupervision)()
689
+ ], WindowCoveringCCSet);
690
+ exports.WindowCoveringCCSet = WindowCoveringCCSet;
691
+ let WindowCoveringCCStartLevelChange = class WindowCoveringCCStartLevelChange extends WindowCoveringCC {
692
+ constructor(host, options) {
693
+ super(host, options);
694
+ if ((0, CommandClass_1.gotDeserializationOptions)(options)) {
695
+ // TODO: Deserialize payload
696
+ throw new core_1.ZWaveError(`${this.constructor.name}: deserialization not implemented`, core_1.ZWaveErrorCodes.Deserialization_NotImplemented);
697
+ }
698
+ else {
699
+ this.parameter = options.parameter;
700
+ this.direction = options.direction;
701
+ this.duration = core_1.Duration.from(options.duration);
702
+ }
703
+ }
704
+ serialize() {
705
+ this.payload = Buffer.from([
706
+ this.direction === "up" ? 64 : 0,
707
+ this.parameter,
708
+ (this.duration ?? core_1.Duration.default()).serializeSet(),
709
+ ]);
710
+ return super.serialize();
711
+ }
712
+ toLogEntry(applHost) {
713
+ const message = {
714
+ parameter: (0, safe_1.getEnumMemberName)(_Types_1.WindowCoveringParameter, this.parameter),
715
+ direction: this.direction,
716
+ };
717
+ if (this.duration) {
718
+ message.duration = this.duration.toString();
719
+ }
720
+ return {
721
+ ...super.toLogEntry(applHost),
722
+ message,
723
+ };
724
+ }
725
+ };
726
+ WindowCoveringCCStartLevelChange = __decorate([
727
+ (0, CommandClassDecorators_1.CCCommand)(_Types_1.WindowCoveringCommand.StartLevelChange),
728
+ (0, CommandClassDecorators_1.useSupervision)()
729
+ ], WindowCoveringCCStartLevelChange);
730
+ exports.WindowCoveringCCStartLevelChange = WindowCoveringCCStartLevelChange;
731
+ let WindowCoveringCCStopLevelChange = class WindowCoveringCCStopLevelChange extends WindowCoveringCC {
732
+ constructor(host, options) {
733
+ super(host, options);
734
+ if ((0, CommandClass_1.gotDeserializationOptions)(options)) {
735
+ // TODO: Deserialize payload
736
+ throw new core_1.ZWaveError(`${this.constructor.name}: deserialization not implemented`, core_1.ZWaveErrorCodes.Deserialization_NotImplemented);
737
+ }
738
+ else {
739
+ this.parameter = options.parameter;
740
+ }
741
+ }
742
+ serialize() {
743
+ this.payload = Buffer.from([this.parameter]);
744
+ return super.serialize();
745
+ }
746
+ toLogEntry(applHost) {
747
+ return {
748
+ ...super.toLogEntry(applHost),
749
+ message: {
750
+ parameter: (0, safe_1.getEnumMemberName)(_Types_1.WindowCoveringParameter, this.parameter),
751
+ },
752
+ };
753
+ }
754
+ };
755
+ WindowCoveringCCStopLevelChange = __decorate([
756
+ (0, CommandClassDecorators_1.CCCommand)(_Types_1.WindowCoveringCommand.StopLevelChange),
757
+ (0, CommandClassDecorators_1.useSupervision)()
758
+ ], WindowCoveringCCStopLevelChange);
759
+ exports.WindowCoveringCCStopLevelChange = WindowCoveringCCStopLevelChange;
760
+ //# sourceMappingURL=WindowCoveringCC.js.map