tsvesync 1.0.12 → 1.0.13

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.
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.fanModules = exports.VeSyncWarmHumidifier = exports.VeSyncHumidifier = exports.VeSyncAirBypass = void 0;
7
7
  const vesyncFan_1 = require("./vesyncFan");
8
8
  const helpers_1 = require("./helpers");
9
+ const logger_1 = require("./logger");
9
10
  /**
10
11
  * VeSync Air Purifier with Bypass
11
12
  */
@@ -16,12 +17,14 @@ class VeSyncAirBypass extends vesyncFan_1.VeSyncFan {
16
17
  this.speeds = [1, 2, 3, 4, 5];
17
18
  this.displayModes = ['on', 'off'];
18
19
  this.childLockModes = ['on', 'off'];
20
+ logger_1.logger.debug(`Initialized VeSyncAirBypass device: ${this.deviceName}`);
19
21
  }
20
22
  /**
21
23
  * Get device details
22
24
  */
23
25
  async getDetails() {
24
26
  var _a;
27
+ logger_1.logger.debug(`Getting details for device: ${this.deviceName}`);
25
28
  const [response, status] = await helpers_1.Helpers.callApi('/cloud/v2/deviceManaged/bypassV2', 'post', {
26
29
  ...helpers_1.Helpers.reqBody(this.manager, 'bypassV2'),
27
30
  cid: this.cid,
@@ -50,13 +53,18 @@ class VeSyncAirBypass extends vesyncFan_1.VeSyncFan {
50
53
  if (result.configuration) {
51
54
  this.config = result.configuration;
52
55
  }
56
+ logger_1.logger.debug(`Successfully got details for device: ${this.deviceName}`);
53
57
  }
54
58
  }
59
+ else {
60
+ logger_1.logger.error(`Failed to get details for device: ${this.deviceName}`);
61
+ }
55
62
  }
56
63
  /**
57
64
  * Turn device on
58
65
  */
59
66
  async turnOn() {
67
+ logger_1.logger.debug(`Turning on device: ${this.deviceName}`);
60
68
  const [response, status] = await helpers_1.Helpers.callApi('/cloud/v2/deviceManaged/bypassV2', 'post', {
61
69
  ...helpers_1.Helpers.reqBody(this.manager, 'bypassV2'),
62
70
  cid: this.cid,
@@ -70,12 +78,17 @@ class VeSyncAirBypass extends vesyncFan_1.VeSyncFan {
70
78
  source: 'APP'
71
79
  }
72
80
  }, helpers_1.Helpers.reqHeaderBypass());
73
- return this.checkResponse([response, status], 'turnOn');
81
+ const success = this.checkResponse([response, status], 'turnOn');
82
+ if (!success) {
83
+ logger_1.logger.error(`Failed to turn on device: ${this.deviceName}`);
84
+ }
85
+ return success;
74
86
  }
75
87
  /**
76
88
  * Turn device off
77
89
  */
78
90
  async turnOff() {
91
+ logger_1.logger.debug(`Turning off device: ${this.deviceName}`);
79
92
  const [response, status] = await helpers_1.Helpers.callApi('/cloud/v2/deviceManaged/bypassV2', 'post', {
80
93
  ...helpers_1.Helpers.reqBody(this.manager, 'bypassV2'),
81
94
  cid: this.cid,
@@ -89,15 +102,22 @@ class VeSyncAirBypass extends vesyncFan_1.VeSyncFan {
89
102
  source: 'APP'
90
103
  }
91
104
  }, helpers_1.Helpers.reqHeaderBypass());
92
- return this.checkResponse([response, status], 'turnOff');
105
+ const success = this.checkResponse([response, status], 'turnOff');
106
+ if (!success) {
107
+ logger_1.logger.error(`Failed to turn off device: ${this.deviceName}`);
108
+ }
109
+ return success;
93
110
  }
94
111
  /**
95
112
  * Change fan speed
96
113
  */
97
114
  async changeFanSpeed(speed) {
98
115
  if (!this.speeds.includes(speed)) {
99
- throw new Error(`Invalid speed: ${speed}. Must be one of: ${this.speeds.join(', ')}`);
116
+ const error = `Invalid speed: ${speed}. Must be one of: ${this.speeds.join(', ')}`;
117
+ logger_1.logger.error(`${error} for device: ${this.deviceName}`);
118
+ throw new Error(error);
100
119
  }
120
+ logger_1.logger.debug(`Changing fan speed to ${speed} for device: ${this.deviceName}`);
101
121
  const [response, status] = await helpers_1.Helpers.callApi('/cloud/v2/deviceManaged/bypassV2', 'post', {
102
122
  ...helpers_1.Helpers.reqBody(this.manager, 'bypassV2'),
103
123
  cid: this.cid,
@@ -113,15 +133,22 @@ class VeSyncAirBypass extends vesyncFan_1.VeSyncFan {
113
133
  source: 'APP'
114
134
  }
115
135
  }, helpers_1.Helpers.reqHeaderBypass());
116
- return this.checkResponse([response, status], 'changeFanSpeed');
136
+ const success = this.checkResponse([response, status], 'changeFanSpeed');
137
+ if (!success) {
138
+ logger_1.logger.error(`Failed to change fan speed to ${speed} for device: ${this.deviceName}`);
139
+ }
140
+ return success;
117
141
  }
118
142
  /**
119
143
  * Set device mode
120
144
  */
121
145
  async setMode(mode) {
122
146
  if (!this.modes.includes(mode)) {
123
- throw new Error(`Invalid mode: ${mode}. Must be one of: ${this.modes.join(', ')}`);
147
+ const error = `Invalid mode: ${mode}. Must be one of: ${this.modes.join(', ')}`;
148
+ logger_1.logger.error(`${error} for device: ${this.deviceName}`);
149
+ throw new Error(error);
124
150
  }
151
+ logger_1.logger.debug(`Setting mode to ${mode} for device: ${this.deviceName}`);
125
152
  const [response, status] = await helpers_1.Helpers.callApi('/cloud/v2/deviceManaged/bypassV2', 'post', {
126
153
  ...helpers_1.Helpers.reqBody(this.manager, 'bypassV2'),
127
154
  cid: this.cid,
@@ -134,15 +161,22 @@ class VeSyncAirBypass extends vesyncFan_1.VeSyncFan {
134
161
  source: 'APP'
135
162
  }
136
163
  }, helpers_1.Helpers.reqHeaderBypass());
137
- return this.checkResponse([response, status], 'setMode');
164
+ const success = this.checkResponse([response, status], 'setMode');
165
+ if (!success) {
166
+ logger_1.logger.error(`Failed to set mode to ${mode} for device: ${this.deviceName}`);
167
+ }
168
+ return success;
138
169
  }
139
170
  /**
140
171
  * Set display status
141
172
  */
142
173
  async setDisplay(enabled) {
143
174
  if (!this.hasFeature('display')) {
144
- throw new Error('Display control not supported');
175
+ const error = 'Display control not supported';
176
+ logger_1.logger.error(`${error} for device: ${this.deviceName}`);
177
+ throw new Error(error);
145
178
  }
179
+ logger_1.logger.debug(`Setting display to ${enabled ? 'on' : 'off'} for device: ${this.deviceName}`);
146
180
  const [response, status] = await helpers_1.Helpers.callApi('/cloud/v2/deviceManaged/bypassV2', 'post', {
147
181
  ...helpers_1.Helpers.reqBody(this.manager, 'bypassV2'),
148
182
  cid: this.cid,
@@ -155,15 +189,22 @@ class VeSyncAirBypass extends vesyncFan_1.VeSyncFan {
155
189
  source: 'APP'
156
190
  }
157
191
  }, helpers_1.Helpers.reqHeaderBypass());
158
- return this.checkResponse([response, status], 'setDisplay');
192
+ const success = this.checkResponse([response, status], 'setDisplay');
193
+ if (!success) {
194
+ logger_1.logger.error(`Failed to set display to ${enabled ? 'on' : 'off'} for device: ${this.deviceName}`);
195
+ }
196
+ return success;
159
197
  }
160
198
  /**
161
199
  * Set child lock
162
200
  */
163
201
  async setChildLock(enabled) {
164
202
  if (!this.hasFeature('child_lock')) {
165
- throw new Error('Child lock not supported');
203
+ const error = 'Child lock not supported';
204
+ logger_1.logger.error(`${error} for device: ${this.deviceName}`);
205
+ throw new Error(error);
166
206
  }
207
+ logger_1.logger.debug(`Setting child lock to ${enabled ? 'on' : 'off'} for device: ${this.deviceName}`);
167
208
  const [response, status] = await helpers_1.Helpers.callApi('/cloud/v2/deviceManaged/bypassV2', 'post', {
168
209
  ...helpers_1.Helpers.reqBody(this.manager, 'bypassV2'),
169
210
  cid: this.cid,
@@ -176,15 +217,22 @@ class VeSyncAirBypass extends vesyncFan_1.VeSyncFan {
176
217
  source: 'APP'
177
218
  }
178
219
  }, helpers_1.Helpers.reqHeaderBypass());
179
- return this.checkResponse([response, status], 'setChildLock');
220
+ const success = this.checkResponse([response, status], 'setChildLock');
221
+ if (!success) {
222
+ logger_1.logger.error(`Failed to set child lock to ${enabled ? 'on' : 'off'} for device: ${this.deviceName}`);
223
+ }
224
+ return success;
180
225
  }
181
226
  /**
182
227
  * Set timer
183
228
  */
184
229
  async setTimer(hours) {
185
230
  if (!this.hasFeature('timer')) {
186
- throw new Error('Timer not supported');
231
+ const error = 'Timer not supported';
232
+ logger_1.logger.error(`${error} for device: ${this.deviceName}`);
233
+ throw new Error(error);
187
234
  }
235
+ logger_1.logger.debug(`Setting timer to ${hours} hours for device: ${this.deviceName}`);
188
236
  const [response, status] = await helpers_1.Helpers.callApi('/cloud/v2/deviceManaged/bypassV2', 'post', {
189
237
  ...helpers_1.Helpers.reqBody(this.manager, 'bypassV2'),
190
238
  cid: this.cid,
@@ -198,15 +246,22 @@ class VeSyncAirBypass extends vesyncFan_1.VeSyncFan {
198
246
  source: 'APP'
199
247
  }
200
248
  }, helpers_1.Helpers.reqHeaderBypass());
201
- return this.checkResponse([response, status], 'setTimer');
249
+ const success = this.checkResponse([response, status], 'setTimer');
250
+ if (!success) {
251
+ logger_1.logger.error(`Failed to set timer to ${hours} hours for device: ${this.deviceName}`);
252
+ }
253
+ return success;
202
254
  }
203
255
  /**
204
256
  * Clear timer
205
257
  */
206
258
  async clearTimer() {
207
259
  if (!this.hasFeature('timer')) {
208
- throw new Error('Timer not supported');
260
+ const error = 'Timer not supported';
261
+ logger_1.logger.error(`${error} for device: ${this.deviceName}`);
262
+ throw new Error(error);
209
263
  }
264
+ logger_1.logger.debug(`Clearing timer for device: ${this.deviceName}`);
210
265
  const [response, status] = await helpers_1.Helpers.callApi('/cloud/v2/deviceManaged/bypassV2', 'post', {
211
266
  ...helpers_1.Helpers.reqBody(this.manager, 'bypassV2'),
212
267
  cid: this.cid,
@@ -217,12 +272,17 @@ class VeSyncAirBypass extends vesyncFan_1.VeSyncFan {
217
272
  source: 'APP'
218
273
  }
219
274
  }, helpers_1.Helpers.reqHeaderBypass());
220
- return this.checkResponse([response, status], 'clearTimer');
275
+ const success = this.checkResponse([response, status], 'clearTimer');
276
+ if (!success) {
277
+ logger_1.logger.error(`Failed to clear timer for device: ${this.deviceName}`);
278
+ }
279
+ return success;
221
280
  }
222
281
  /**
223
282
  * Turn automatic stop on
224
283
  */
225
284
  async automaticStopOn() {
285
+ logger_1.logger.debug(`Setting automatic stop on for device: ${this.deviceName}`);
226
286
  const [response, status] = await helpers_1.Helpers.callApi('/cloud/v2/deviceManaged/bypassV2', 'post', {
227
287
  ...helpers_1.Helpers.reqBody(this.manager, 'bypassV2'),
228
288
  cid: this.cid,
@@ -235,12 +295,17 @@ class VeSyncAirBypass extends vesyncFan_1.VeSyncFan {
235
295
  source: 'APP'
236
296
  }
237
297
  }, helpers_1.Helpers.reqHeaderBypass());
238
- return this.checkResponse([response, status], 'automaticStopOn');
298
+ const success = this.checkResponse([response, status], 'automaticStopOn');
299
+ if (!success) {
300
+ logger_1.logger.error(`Failed to set automatic stop on for device: ${this.deviceName}`);
301
+ }
302
+ return success;
239
303
  }
240
304
  /**
241
305
  * Turn automatic stop off
242
306
  */
243
307
  async automaticStopOff() {
308
+ logger_1.logger.debug(`Setting automatic stop off for device: ${this.deviceName}`);
244
309
  const [response, status] = await helpers_1.Helpers.callApi('/cloud/v2/deviceManaged/bypassV2', 'post', {
245
310
  ...helpers_1.Helpers.reqBody(this.manager, 'bypassV2'),
246
311
  cid: this.cid,
@@ -253,7 +318,66 @@ class VeSyncAirBypass extends vesyncFan_1.VeSyncFan {
253
318
  source: 'APP'
254
319
  }
255
320
  }, helpers_1.Helpers.reqHeaderBypass());
256
- return this.checkResponse([response, status], 'automaticStopOff');
321
+ const success = this.checkResponse([response, status], 'automaticStopOff');
322
+ if (!success) {
323
+ logger_1.logger.error(`Failed to set automatic stop off for device: ${this.deviceName}`);
324
+ }
325
+ return success;
326
+ }
327
+ /**
328
+ * Set auto mode
329
+ */
330
+ async autoMode() {
331
+ logger_1.logger.debug(`Setting auto mode for device: ${this.deviceName}`);
332
+ const success = await this.setMode('auto');
333
+ if (!success) {
334
+ logger_1.logger.error(`Failed to set auto mode for device: ${this.deviceName}`);
335
+ }
336
+ return success;
337
+ }
338
+ /**
339
+ * Set manual mode
340
+ */
341
+ async manualMode() {
342
+ logger_1.logger.debug(`Setting manual mode for device: ${this.deviceName}`);
343
+ const success = await this.setMode('manual');
344
+ if (!success) {
345
+ logger_1.logger.error(`Failed to set manual mode for device: ${this.deviceName}`);
346
+ }
347
+ return success;
348
+ }
349
+ /**
350
+ * Set sleep mode
351
+ */
352
+ async sleepMode() {
353
+ logger_1.logger.debug(`Setting sleep mode for device: ${this.deviceName}`);
354
+ const success = await this.setMode('sleep');
355
+ if (!success) {
356
+ logger_1.logger.error(`Failed to set sleep mode for device: ${this.deviceName}`);
357
+ }
358
+ return success;
359
+ }
360
+ /**
361
+ * Turn off display
362
+ */
363
+ async turnOffDisplay() {
364
+ logger_1.logger.debug(`Turning off display for device: ${this.deviceName}`);
365
+ const success = await this.setDisplay(false);
366
+ if (!success) {
367
+ logger_1.logger.error(`Failed to turn off display for device: ${this.deviceName}`);
368
+ }
369
+ return success;
370
+ }
371
+ /**
372
+ * Turn on display
373
+ */
374
+ async turnOnDisplay() {
375
+ logger_1.logger.debug(`Turning on display for device: ${this.deviceName}`);
376
+ const success = await this.setDisplay(true);
377
+ if (!success) {
378
+ logger_1.logger.error(`Failed to turn on display for device: ${this.deviceName}`);
379
+ }
380
+ return success;
257
381
  }
258
382
  }
259
383
  exports.VeSyncAirBypass = VeSyncAirBypass;
@@ -268,11 +392,13 @@ class VeSyncHumidifier extends vesyncFan_1.VeSyncFan {
268
392
  this.displayModes = ['on', 'off'];
269
393
  this.mistLevels = [1, 2, 3];
270
394
  this.humidityRange = { min: 30, max: 80 };
395
+ logger_1.logger.debug(`Initialized VeSyncHumidifier device: ${this.deviceName}`);
271
396
  }
272
397
  /**
273
398
  * Get device details
274
399
  */
275
400
  async getDetails() {
401
+ logger_1.logger.debug(`Getting details for device: ${this.deviceName}`);
276
402
  const [response, status] = await helpers_1.Helpers.callApi('/cloud/v2/deviceManaged/bypassV2', 'post', {
277
403
  ...helpers_1.Helpers.reqBody(this.manager, 'bypassV2'),
278
404
  cid: this.cid,
@@ -283,14 +409,20 @@ class VeSyncHumidifier extends vesyncFan_1.VeSyncFan {
283
409
  source: 'APP'
284
410
  }
285
411
  }, helpers_1.Helpers.reqHeaderBypass());
286
- if (this.checkResponse([response, status], 'getDetails')) {
412
+ const success = this.checkResponse([response, status], 'getDetails');
413
+ if (success) {
287
414
  this.details = response.result.result;
415
+ logger_1.logger.debug(`Successfully got details for device: ${this.deviceName}`);
416
+ }
417
+ else {
418
+ logger_1.logger.error(`Failed to get details for device: ${this.deviceName}`);
288
419
  }
289
420
  }
290
421
  /**
291
422
  * Turn device on
292
423
  */
293
424
  async turnOn() {
425
+ logger_1.logger.debug(`Turning on device: ${this.deviceName}`);
294
426
  const [response, status] = await helpers_1.Helpers.callApi('/cloud/v2/deviceManaged/bypassV2', 'post', {
295
427
  ...helpers_1.Helpers.reqBody(this.manager, 'bypassV2'),
296
428
  cid: this.cid,
@@ -304,12 +436,17 @@ class VeSyncHumidifier extends vesyncFan_1.VeSyncFan {
304
436
  source: 'APP'
305
437
  }
306
438
  }, helpers_1.Helpers.reqHeaderBypass());
307
- return this.checkResponse([response, status], 'turnOn');
439
+ const success = this.checkResponse([response, status], 'turnOn');
440
+ if (!success) {
441
+ logger_1.logger.error(`Failed to turn on device: ${this.deviceName}`);
442
+ }
443
+ return success;
308
444
  }
309
445
  /**
310
446
  * Turn device off
311
447
  */
312
448
  async turnOff() {
449
+ logger_1.logger.debug(`Turning off device: ${this.deviceName}`);
313
450
  const [response, status] = await helpers_1.Helpers.callApi('/cloud/v2/deviceManaged/bypassV2', 'post', {
314
451
  ...helpers_1.Helpers.reqBody(this.manager, 'bypassV2'),
315
452
  cid: this.cid,
@@ -323,15 +460,22 @@ class VeSyncHumidifier extends vesyncFan_1.VeSyncFan {
323
460
  source: 'APP'
324
461
  }
325
462
  }, helpers_1.Helpers.reqHeaderBypass());
326
- return this.checkResponse([response, status], 'turnOff');
463
+ const success = this.checkResponse([response, status], 'turnOff');
464
+ if (!success) {
465
+ logger_1.logger.error(`Failed to turn off device: ${this.deviceName}`);
466
+ }
467
+ return success;
327
468
  }
328
469
  /**
329
470
  * Change fan speed
330
471
  */
331
472
  async changeFanSpeed(speed) {
332
473
  if (!this.speeds.includes(speed)) {
333
- throw new Error(`Invalid speed: ${speed}. Must be one of: ${this.speeds.join(', ')}`);
474
+ const error = `Invalid speed: ${speed}. Must be one of: ${this.speeds.join(', ')}`;
475
+ logger_1.logger.error(`${error} for device: ${this.deviceName}`);
476
+ throw new Error(error);
334
477
  }
478
+ logger_1.logger.debug(`Changing fan speed to ${speed} for device: ${this.deviceName}`);
335
479
  const [response, status] = await helpers_1.Helpers.callApi('/cloud/v2/deviceManaged/bypassV2', 'post', {
336
480
  ...helpers_1.Helpers.reqBody(this.manager, 'bypassV2'),
337
481
  cid: this.cid,
@@ -346,15 +490,22 @@ class VeSyncHumidifier extends vesyncFan_1.VeSyncFan {
346
490
  source: 'APP'
347
491
  }
348
492
  }, helpers_1.Helpers.reqHeaderBypass());
349
- return this.checkResponse([response, status], 'changeFanSpeed');
493
+ const success = this.checkResponse([response, status], 'changeFanSpeed');
494
+ if (!success) {
495
+ logger_1.logger.error(`Failed to change fan speed to ${speed} for device: ${this.deviceName}`);
496
+ }
497
+ return success;
350
498
  }
351
499
  /**
352
500
  * Set device mode
353
501
  */
354
502
  async setMode(mode) {
355
503
  if (!this.modes.includes(mode)) {
356
- throw new Error(`Invalid mode: ${mode}. Must be one of: ${this.modes.join(', ')}`);
504
+ const error = `Invalid mode: ${mode}. Must be one of: ${this.modes.join(', ')}`;
505
+ logger_1.logger.error(`${error} for device: ${this.deviceName}`);
506
+ throw new Error(error);
357
507
  }
508
+ logger_1.logger.debug(`Setting mode to ${mode} for device: ${this.deviceName}`);
358
509
  const [response, status] = await helpers_1.Helpers.callApi('/cloud/v2/deviceManaged/bypassV2', 'post', {
359
510
  ...helpers_1.Helpers.reqBody(this.manager, 'bypassV2'),
360
511
  cid: this.cid,
@@ -367,18 +518,27 @@ class VeSyncHumidifier extends vesyncFan_1.VeSyncFan {
367
518
  source: 'APP'
368
519
  }
369
520
  }, helpers_1.Helpers.reqHeaderBypass());
370
- return this.checkResponse([response, status], 'setMode');
521
+ const success = this.checkResponse([response, status], 'setMode');
522
+ if (!success) {
523
+ logger_1.logger.error(`Failed to set mode to ${mode} for device: ${this.deviceName}`);
524
+ }
525
+ return success;
371
526
  }
372
527
  /**
373
528
  * Set mist level
374
529
  */
375
530
  async setMistLevel(level) {
376
531
  if (!this.hasFeature('mist')) {
377
- throw new Error('Mist control not supported');
532
+ const error = 'Mist control not supported';
533
+ logger_1.logger.error(`${error} for device: ${this.deviceName}`);
534
+ throw new Error(error);
378
535
  }
379
536
  if (!this.mistLevels.includes(level)) {
380
- throw new Error(`Invalid mist level: ${level}. Must be one of: ${this.mistLevels.join(', ')}`);
537
+ const error = `Invalid mist level: ${level}. Must be one of: ${this.mistLevels.join(', ')}`;
538
+ logger_1.logger.error(`${error} for device: ${this.deviceName}`);
539
+ throw new Error(error);
381
540
  }
541
+ logger_1.logger.debug(`Setting mist level to ${level} for device: ${this.deviceName}`);
382
542
  const [response, status] = await helpers_1.Helpers.callApi('/cloud/v2/deviceManaged/bypassV2', 'post', {
383
543
  ...helpers_1.Helpers.reqBody(this.manager, 'bypassV2'),
384
544
  cid: this.cid,
@@ -391,18 +551,27 @@ class VeSyncHumidifier extends vesyncFan_1.VeSyncFan {
391
551
  source: 'APP'
392
552
  }
393
553
  }, helpers_1.Helpers.reqHeaderBypass());
394
- return this.checkResponse([response, status], 'setMistLevel');
554
+ const success = this.checkResponse([response, status], 'setMistLevel');
555
+ if (!success) {
556
+ logger_1.logger.error(`Failed to set mist level to ${level} for device: ${this.deviceName}`);
557
+ }
558
+ return success;
395
559
  }
396
560
  /**
397
561
  * Set target humidity
398
562
  */
399
563
  async setHumidity(humidity) {
400
564
  if (!this.hasFeature('humidity')) {
401
- throw new Error('Humidity control not supported');
565
+ const error = 'Humidity control not supported';
566
+ logger_1.logger.error(`${error} for device: ${this.deviceName}`);
567
+ throw new Error(error);
402
568
  }
403
569
  if (humidity < this.humidityRange.min || humidity > this.humidityRange.max) {
404
- throw new Error(`Invalid humidity: ${humidity}. Must be between ${this.humidityRange.min} and ${this.humidityRange.max}`);
570
+ const error = `Invalid humidity: ${humidity}. Must be between ${this.humidityRange.min} and ${this.humidityRange.max}`;
571
+ logger_1.logger.error(`${error} for device: ${this.deviceName}`);
572
+ throw new Error(error);
405
573
  }
574
+ logger_1.logger.debug(`Setting target humidity to ${humidity}% for device: ${this.deviceName}`);
406
575
  const [response, status] = await helpers_1.Helpers.callApi('/cloud/v2/deviceManaged/bypassV2', 'post', {
407
576
  ...helpers_1.Helpers.reqBody(this.manager, 'bypassV2'),
408
577
  cid: this.cid,
@@ -415,15 +584,22 @@ class VeSyncHumidifier extends vesyncFan_1.VeSyncFan {
415
584
  source: 'APP'
416
585
  }
417
586
  }, helpers_1.Helpers.reqHeaderBypass());
418
- return this.checkResponse([response, status], 'setHumidity');
587
+ const success = this.checkResponse([response, status], 'setHumidity');
588
+ if (!success) {
589
+ logger_1.logger.error(`Failed to set target humidity to ${humidity}% for device: ${this.deviceName}`);
590
+ }
591
+ return success;
419
592
  }
420
593
  /**
421
594
  * Set display status
422
595
  */
423
596
  async setDisplay(enabled) {
424
597
  if (!this.hasFeature('display')) {
425
- throw new Error('Display control not supported');
598
+ const error = 'Display control not supported';
599
+ logger_1.logger.error(`${error} for device: ${this.deviceName}`);
600
+ throw new Error(error);
426
601
  }
602
+ logger_1.logger.debug(`Setting display to ${enabled ? 'on' : 'off'} for device: ${this.deviceName}`);
427
603
  const [response, status] = await helpers_1.Helpers.callApi('/cloud/v2/deviceManaged/bypassV2', 'post', {
428
604
  ...helpers_1.Helpers.reqBody(this.manager, 'bypassV2'),
429
605
  cid: this.cid,
@@ -436,15 +612,22 @@ class VeSyncHumidifier extends vesyncFan_1.VeSyncFan {
436
612
  source: 'APP'
437
613
  }
438
614
  }, helpers_1.Helpers.reqHeaderBypass());
439
- return this.checkResponse([response, status], 'setDisplay');
615
+ const success = this.checkResponse([response, status], 'setDisplay');
616
+ if (!success) {
617
+ logger_1.logger.error(`Failed to set display to ${enabled ? 'on' : 'off'} for device: ${this.deviceName}`);
618
+ }
619
+ return success;
440
620
  }
441
621
  /**
442
622
  * Set timer
443
623
  */
444
624
  async setTimer(hours) {
445
625
  if (!this.hasFeature('timer')) {
446
- throw new Error('Timer not supported');
626
+ const error = 'Timer not supported';
627
+ logger_1.logger.error(`${error} for device: ${this.deviceName}`);
628
+ throw new Error(error);
447
629
  }
630
+ logger_1.logger.debug(`Setting timer to ${hours} hours for device: ${this.deviceName}`);
448
631
  const [response, status] = await helpers_1.Helpers.callApi('/cloud/v2/deviceManaged/bypassV2', 'post', {
449
632
  ...helpers_1.Helpers.reqBody(this.manager, 'bypassV2'),
450
633
  cid: this.cid,
@@ -458,15 +641,22 @@ class VeSyncHumidifier extends vesyncFan_1.VeSyncFan {
458
641
  source: 'APP'
459
642
  }
460
643
  }, helpers_1.Helpers.reqHeaderBypass());
461
- return this.checkResponse([response, status], 'setTimer');
644
+ const success = this.checkResponse([response, status], 'setTimer');
645
+ if (!success) {
646
+ logger_1.logger.error(`Failed to set timer to ${hours} hours for device: ${this.deviceName}`);
647
+ }
648
+ return success;
462
649
  }
463
650
  /**
464
651
  * Clear timer
465
652
  */
466
653
  async clearTimer() {
467
654
  if (!this.hasFeature('timer')) {
468
- throw new Error('Timer not supported');
655
+ const error = 'Timer not supported';
656
+ logger_1.logger.error(`${error} for device: ${this.deviceName}`);
657
+ throw new Error(error);
469
658
  }
659
+ logger_1.logger.debug(`Clearing timer for device: ${this.deviceName}`);
470
660
  const [response, status] = await helpers_1.Helpers.callApi('/cloud/v2/deviceManaged/bypassV2', 'post', {
471
661
  ...helpers_1.Helpers.reqBody(this.manager, 'bypassV2'),
472
662
  cid: this.cid,
@@ -477,12 +667,17 @@ class VeSyncHumidifier extends vesyncFan_1.VeSyncFan {
477
667
  source: 'APP'
478
668
  }
479
669
  }, helpers_1.Helpers.reqHeaderBypass());
480
- return this.checkResponse([response, status], 'clearTimer');
670
+ const success = this.checkResponse([response, status], 'clearTimer');
671
+ if (!success) {
672
+ logger_1.logger.error(`Failed to clear timer for device: ${this.deviceName}`);
673
+ }
674
+ return success;
481
675
  }
482
676
  /**
483
677
  * Turn automatic stop on
484
678
  */
485
679
  async automaticStopOn() {
680
+ logger_1.logger.debug(`Setting automatic stop on for device: ${this.deviceName}`);
486
681
  const [response, status] = await helpers_1.Helpers.callApi('/cloud/v2/deviceManaged/bypassV2', 'post', {
487
682
  ...helpers_1.Helpers.reqBody(this.manager, 'bypassV2'),
488
683
  cid: this.cid,
@@ -495,12 +690,17 @@ class VeSyncHumidifier extends vesyncFan_1.VeSyncFan {
495
690
  source: 'APP'
496
691
  }
497
692
  }, helpers_1.Helpers.reqHeaderBypass());
498
- return this.checkResponse([response, status], 'automaticStopOn');
693
+ const success = this.checkResponse([response, status], 'automaticStopOn');
694
+ if (!success) {
695
+ logger_1.logger.error(`Failed to set automatic stop on for device: ${this.deviceName}`);
696
+ }
697
+ return success;
499
698
  }
500
699
  /**
501
700
  * Turn automatic stop off
502
701
  */
503
702
  async automaticStopOff() {
703
+ logger_1.logger.debug(`Setting automatic stop off for device: ${this.deviceName}`);
504
704
  const [response, status] = await helpers_1.Helpers.callApi('/cloud/v2/deviceManaged/bypassV2', 'post', {
505
705
  ...helpers_1.Helpers.reqBody(this.manager, 'bypassV2'),
506
706
  cid: this.cid,
@@ -513,7 +713,55 @@ class VeSyncHumidifier extends vesyncFan_1.VeSyncFan {
513
713
  source: 'APP'
514
714
  }
515
715
  }, helpers_1.Helpers.reqHeaderBypass());
516
- return this.checkResponse([response, status], 'automaticStopOff');
716
+ const success = this.checkResponse([response, status], 'automaticStopOff');
717
+ if (!success) {
718
+ logger_1.logger.error(`Failed to set automatic stop off for device: ${this.deviceName}`);
719
+ }
720
+ return success;
721
+ }
722
+ /**
723
+ * Set auto mode
724
+ */
725
+ async setAutoMode() {
726
+ logger_1.logger.debug(`Setting auto mode for device: ${this.deviceName}`);
727
+ const success = await this.setMode('auto');
728
+ if (!success) {
729
+ logger_1.logger.error(`Failed to set auto mode for device: ${this.deviceName}`);
730
+ }
731
+ return success;
732
+ }
733
+ /**
734
+ * Set manual mode
735
+ */
736
+ async setManualMode() {
737
+ logger_1.logger.debug(`Setting manual mode for device: ${this.deviceName}`);
738
+ const success = await this.setMode('manual');
739
+ if (!success) {
740
+ logger_1.logger.error(`Failed to set manual mode for device: ${this.deviceName}`);
741
+ }
742
+ return success;
743
+ }
744
+ /**
745
+ * Turn off display
746
+ */
747
+ async turnOffDisplay() {
748
+ logger_1.logger.debug(`Turning off display for device: ${this.deviceName}`);
749
+ const success = await this.setDisplay(false);
750
+ if (!success) {
751
+ logger_1.logger.error(`Failed to turn off display for device: ${this.deviceName}`);
752
+ }
753
+ return success;
754
+ }
755
+ /**
756
+ * Turn on display
757
+ */
758
+ async turnOnDisplay() {
759
+ logger_1.logger.debug(`Turning on display for device: ${this.deviceName}`);
760
+ const success = await this.setDisplay(true);
761
+ if (!success) {
762
+ logger_1.logger.error(`Failed to turn on display for device: ${this.deviceName}`);
763
+ }
764
+ return success;
517
765
  }
518
766
  }
519
767
  exports.VeSyncHumidifier = VeSyncHumidifier;
@@ -524,17 +772,23 @@ class VeSyncWarmHumidifier extends VeSyncHumidifier {
524
772
  constructor(details, manager) {
525
773
  super(details, manager);
526
774
  this.warmLevels = [1, 2, 3];
775
+ logger_1.logger.debug(`Initialized VeSyncWarmHumidifier device: ${this.deviceName}`);
527
776
  }
528
777
  /**
529
778
  * Set warm mist level
530
779
  */
531
780
  async setWarmLevel(level) {
532
781
  if (!this.hasFeature('warm')) {
533
- throw new Error('Warm mist control not supported');
782
+ const error = 'Warm mist control not supported';
783
+ logger_1.logger.error(`${error} for device: ${this.deviceName}`);
784
+ throw new Error(error);
534
785
  }
535
786
  if (!this.warmLevels.includes(level)) {
536
- throw new Error(`Invalid warm level: ${level}. Must be one of: ${this.warmLevels.join(', ')}`);
787
+ const error = `Invalid warm level: ${level}. Must be one of: ${this.warmLevels.join(', ')}`;
788
+ logger_1.logger.error(`${error} for device: ${this.deviceName}`);
789
+ throw new Error(error);
537
790
  }
791
+ logger_1.logger.debug(`Setting warm level to ${level} for device: ${this.deviceName}`);
538
792
  const [response, status] = await helpers_1.Helpers.callApi('/cloud/v2/deviceManaged/bypassV2', 'post', {
539
793
  ...helpers_1.Helpers.reqBody(this.manager, 'bypassV2'),
540
794
  cid: this.cid,
@@ -547,15 +801,22 @@ class VeSyncWarmHumidifier extends VeSyncHumidifier {
547
801
  source: 'APP'
548
802
  }
549
803
  }, helpers_1.Helpers.reqHeaderBypass());
550
- return this.checkResponse([response, status], 'setWarmLevel');
804
+ const success = this.checkResponse([response, status], 'setWarmLevel');
805
+ if (!success) {
806
+ logger_1.logger.error(`Failed to set warm level to ${level} for device: ${this.deviceName}`);
807
+ }
808
+ return success;
551
809
  }
552
810
  /**
553
811
  * Set drying mode enabled
554
812
  */
555
813
  async setDryingModeEnabled(enabled) {
556
814
  if (!this.hasFeature('drying')) {
557
- throw new Error('Drying mode not supported');
815
+ const error = 'Drying mode not supported';
816
+ logger_1.logger.error(`${error} for device: ${this.deviceName}`);
817
+ throw new Error(error);
558
818
  }
819
+ logger_1.logger.debug(`Setting drying mode to ${enabled} for device: ${this.deviceName}`);
559
820
  const [response, status] = await helpers_1.Helpers.callApi('/cloud/v2/deviceManaged/bypassV2', 'post', {
560
821
  ...helpers_1.Helpers.reqBody(this.manager, 'bypassV2'),
561
822
  cid: this.cid,
@@ -568,7 +829,11 @@ class VeSyncWarmHumidifier extends VeSyncHumidifier {
568
829
  source: 'APP'
569
830
  }
570
831
  }, helpers_1.Helpers.reqHeaderBypass());
571
- return this.checkResponse([response, status], 'setDryingModeEnabled');
832
+ const success = this.checkResponse([response, status], 'setDryingModeEnabled');
833
+ if (!success) {
834
+ logger_1.logger.error(`Failed to set drying mode to ${enabled} for device: ${this.deviceName}`);
835
+ }
836
+ return success;
572
837
  }
573
838
  }
574
839
  exports.VeSyncWarmHumidifier = VeSyncWarmHumidifier;