tsvesync 1.0.72 → 1.0.74

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.
@@ -40,50 +40,6 @@ export class VeSyncAirBypass extends VeSyncFan {
40
40
  async getDetails(): Promise<Boolean> {
41
41
  logger.debug(`Getting details for device: ${this.deviceName}`);
42
42
 
43
- // Special handling for LV series
44
- if (this.deviceType.startsWith('LV-')) {
45
- const [response, status] = await this.callApi(
46
- '/131airPurifier/v1/device/devicedetail',
47
- 'post',
48
- {
49
- acceptLanguage: 'en',
50
- accountID: this.manager.accountId!,
51
- appVersion: '2.8.6',
52
- method: 'devicedetail',
53
- mobileId: '1234567890123456',
54
- phoneBrand: 'SM N9005',
55
- phoneOS: 'Android',
56
- timeZone: this.manager.timeZone!,
57
- token: this.manager.token!,
58
- uuid: this.uuid
59
- },
60
- {
61
- 'accept-language': 'en',
62
- 'accountId': this.manager.accountId!,
63
- 'appVersion': '2.8.6',
64
- 'content-type': 'application/json',
65
- 'tk': this.manager.token!,
66
- 'tz': this.manager.timeZone!
67
- }
68
- );
69
-
70
- const success = this.checkResponse([response, status], 'getDetails');
71
- if (success && response) {
72
- this.deviceStatus = response.result?.result?.deviceStatus === 'on' ? 'on' : 'off';
73
- this.details = {
74
- mode: response.result?.result?.mode || '',
75
- speed: response.result?.result?.level || 0,
76
- filterLife: response.result?.result?.filterLife || 0,
77
- screenStatus: response.result?.result?.display ? 'on' : 'off',
78
- childLock: response.result?.result?.childLock || false,
79
- airQuality: response.result?.result?.airQuality || 0
80
- };
81
- return true;
82
- }
83
- return false;
84
- }
85
-
86
- // Original implementation for other devices
87
43
  const [response, status] = await this.callApi(
88
44
  '/cloud/v2/deviceManaged/bypassV2',
89
45
  'post',
@@ -130,37 +86,6 @@ export class VeSyncAirBypass extends VeSyncFan {
130
86
  async turnOn(): Promise<boolean> {
131
87
  logger.info(`Turning on device: ${this.deviceName}`);
132
88
 
133
- // Special handling for LV series
134
- if (this.deviceType.startsWith('LV-')) {
135
- const [response, status] = await this.callApi(
136
- '/131airPurifier/v1/device/deviceStatus',
137
- 'put',
138
- {
139
- acceptLanguage: 'en',
140
- accountID: this.manager.accountId!,
141
- status: 'on',
142
- timeZone: this.manager.timeZone!,
143
- token: this.manager.token!,
144
- uuid: this.uuid
145
- },
146
- {
147
- 'accept-language': 'en',
148
- 'accountId': this.manager.accountId!,
149
- 'appVersion': '2.8.6',
150
- 'content-type': 'application/json',
151
- 'tk': this.manager.token!,
152
- 'tz': this.manager.timeZone!
153
- }
154
- );
155
-
156
- const success = this.checkResponse([response, status], 'turnOn');
157
- if (!success) {
158
- logger.error(`Failed to turn on device: ${this.deviceName}`);
159
- }
160
- return success;
161
- }
162
-
163
- // Original implementation for other devices
164
89
  const [response, status] = await this.callApi(
165
90
  '/cloud/v2/deviceManaged/bypassV2',
166
91
  'post',
@@ -193,37 +118,6 @@ export class VeSyncAirBypass extends VeSyncFan {
193
118
  async turnOff(): Promise<boolean> {
194
119
  logger.info(`Turning off device: ${this.deviceName}`);
195
120
 
196
- // Special handling for LV series
197
- if (this.deviceType.startsWith('LV-')) {
198
- const [response, status] = await this.callApi(
199
- '/131airPurifier/v1/device/deviceStatus',
200
- 'put',
201
- {
202
- acceptLanguage: 'en',
203
- accountID: this.manager.accountId!,
204
- status: 'off',
205
- timeZone: this.manager.timeZone!,
206
- token: this.manager.token!,
207
- uuid: this.uuid
208
- },
209
- {
210
- 'accept-language': 'en',
211
- 'accountId': this.manager.accountId!,
212
- 'appVersion': '2.8.6',
213
- 'content-type': 'application/json',
214
- 'tk': this.manager.token!,
215
- 'tz': this.manager.timeZone!
216
- }
217
- );
218
-
219
- const success = this.checkResponse([response, status], 'turnOff');
220
- if (!success) {
221
- logger.error(`Failed to turn off device: ${this.deviceName}`);
222
- }
223
- return success;
224
- }
225
-
226
- // Original implementation for other devices
227
121
  const [response, status] = await this.callApi(
228
122
  '/cloud/v2/deviceManaged/bypassV2',
229
123
  'post',
@@ -262,52 +156,6 @@ export class VeSyncAirBypass extends VeSyncFan {
262
156
 
263
157
  logger.info(`Changing fan speed to ${speed} for device: ${this.deviceName}`);
264
158
 
265
- // Special handling for LV series
266
- if (this.deviceType.startsWith('LV-')) {
267
- // Check if device is in manual mode
268
- if (this.details.mode !== 'manual') {
269
- logger.debug(`${this.deviceName} not in manual mode, cannot change speed`);
270
- return false;
271
- }
272
-
273
- // Validate speed for LV series (1-3)
274
- if (speed < 1 || speed > 3) {
275
- logger.error(`Invalid fan speed: ${speed}. Must be between 1 and 3 for device: ${this.deviceName}`);
276
- return false;
277
- }
278
-
279
- const [response, status] = await this.callApi(
280
- '/131airPurifier/v1/device/updateSpeed',
281
- 'put',
282
- {
283
- acceptLanguage: 'en',
284
- accountID: this.manager.accountId!,
285
- level: speed,
286
- timeZone: this.manager.timeZone!,
287
- token: this.manager.token!,
288
- uuid: this.uuid
289
- },
290
- {
291
- 'accept-language': 'en',
292
- 'accountId': this.manager.accountId!,
293
- 'appVersion': '2.8.6',
294
- 'content-type': 'application/json',
295
- 'tk': this.manager.token!,
296
- 'tz': this.manager.timeZone!
297
- }
298
- );
299
-
300
- const success = this.checkResponse([response, status], 'changeFanSpeed');
301
- if (success) {
302
- this.details.speed = speed;
303
- return true;
304
- } else {
305
- logger.error(`Failed to change fan speed to ${speed} for device: ${this.deviceName}`);
306
- return false;
307
- }
308
- }
309
-
310
- // Standard implementation for other devices
311
159
  const [response, status] = await this.callApi(
312
160
  '/cloud/v2/deviceManaged/bypassV2',
313
161
  'post',
@@ -348,44 +196,11 @@ export class VeSyncAirBypass extends VeSyncFan {
348
196
 
349
197
  logger.debug(`Setting mode to ${mode} for device: ${this.deviceName}`);
350
198
 
351
- // Special handling for LV series
352
- if (this.deviceType.startsWith('LV-')) {
353
- const payload: Record<string, any> = {
354
- acceptLanguage: 'en',
355
- accountID: this.manager.accountId!,
356
- mode: mode,
357
- timeZone: this.manager.timeZone!,
358
- token: this.manager.token!,
359
- uuid: this.uuid
360
- };
361
-
362
- // For manual mode, we need to set the level
363
- if (mode === 'manual') {
364
- payload.level = this.details.speed || 1;
365
- }
366
-
367
- const [response, status] = await this.callApi(
368
- '/131airPurifier/v1/device/updateMode',
369
- 'put',
370
- payload,
371
- {
372
- 'accept-language': 'en',
373
- 'accountId': this.manager.accountId!,
374
- 'appVersion': '2.8.6',
375
- 'content-type': 'application/json',
376
- 'tk': this.manager.token!,
377
- 'tz': this.manager.timeZone!
378
- }
379
- );
380
-
381
- const success = this.checkResponse([response, status], 'setMode');
382
- if (success) {
383
- this.details.mode = mode;
384
- return true;
385
- } else {
386
- logger.error(`Failed to set mode to ${mode} for device: ${this.deviceName}`);
387
- return false;
388
- }
199
+ // Special handling for Core200S auto mode
200
+ if (this.deviceType.includes('Core200S') && mode === 'auto') {
201
+ // Core200S doesn't support auto mode, so we'll set it to manual mode
202
+ logger.warn(`Auto mode not supported for ${this.deviceType}, using manual mode instead`);
203
+ return this.setMode('manual');
389
204
  }
390
205
 
391
206
  // Standard implementation for other devices
@@ -408,10 +223,13 @@ export class VeSyncAirBypass extends VeSyncFan {
408
223
  );
409
224
 
410
225
  const success = this.checkResponse([response, status], 'setMode');
411
- if (!success) {
226
+ if (success) {
227
+ this.details.mode = mode;
228
+ return true;
229
+ } else {
412
230
  logger.error(`Failed to set mode to ${mode} for device: ${this.deviceName}`);
231
+ return false;
413
232
  }
414
- return success;
415
233
  }
416
234
 
417
235
  /**
@@ -424,42 +242,13 @@ export class VeSyncAirBypass extends VeSyncFan {
424
242
  throw new Error(error);
425
243
  }
426
244
 
427
- logger.debug(`Setting display to ${enabled ? 'on' : 'off'} for device: ${this.deviceName}`);
428
-
429
- // Special handling for LV series
430
- if (this.deviceType.startsWith('LV-')) {
431
- const [response, status] = await this.callApi(
432
- '/131airPurifier/v1/device/updateScreen',
433
- 'put',
434
- {
435
- acceptLanguage: 'en',
436
- accountID: this.manager.accountId!,
437
- status: enabled ? 'on' : 'off',
438
- timeZone: this.manager.timeZone!,
439
- token: this.manager.token!,
440
- uuid: this.uuid
441
- },
442
- {
443
- 'accept-language': 'en',
444
- 'accountId': this.manager.accountId!,
445
- 'appVersion': '2.8.6',
446
- 'content-type': 'application/json',
447
- 'tk': this.manager.token!,
448
- 'tz': this.manager.timeZone!
449
- }
450
- );
451
-
452
- const success = this.checkResponse([response, status], 'setDisplay');
453
- if (success) {
454
- this.details.screenStatus = enabled ? 'on' : 'off';
455
- return true;
456
- } else {
457
- logger.error(`Failed to set display to ${enabled ? 'on' : 'off'} for device: ${this.deviceName}`);
458
- return false;
459
- }
245
+ // Check if device is in sleep mode - display control may not work in sleep mode
246
+ if (this.details.mode === 'sleep') {
247
+ logger.warn(`Device ${this.deviceName} is in sleep mode, display control may not work`);
460
248
  }
461
249
 
462
- // Standard implementation for other devices
250
+ logger.debug(`Setting display to ${enabled ? 'on' : 'off'} for device: ${this.deviceName}`);
251
+
463
252
  const [response, status] = await this.callApi(
464
253
  '/cloud/v2/deviceManaged/bypassV2',
465
254
  'post',
@@ -479,12 +268,20 @@ export class VeSyncAirBypass extends VeSyncFan {
479
268
  );
480
269
 
481
270
  const success = this.checkResponse([response, status], 'setDisplay');
271
+
272
+ // Check for error code 11018000 (operation not supported in current mode)
273
+ if (response?.result?.code === 11018000) {
274
+ logger.warn(`Display control not supported in current mode for device: ${this.deviceName}`);
275
+ return false;
276
+ }
277
+
482
278
  if (success) {
483
279
  this.details.screenStatus = enabled ? 'on' : 'off';
280
+ return true;
484
281
  } else {
485
282
  logger.error(`Failed to set display to ${enabled ? 'on' : 'off'} for device: ${this.deviceName}`);
283
+ return false;
486
284
  }
487
- return success;
488
285
  }
489
286
 
490
287
  /**
@@ -497,42 +294,13 @@ export class VeSyncAirBypass extends VeSyncFan {
497
294
  throw new Error(error);
498
295
  }
499
296
 
500
- logger.debug(`Setting child lock to ${enabled ? 'on' : 'off'} for device: ${this.deviceName}`);
501
-
502
- // Special handling for LV series
503
- if (this.deviceType.startsWith('LV-')) {
504
- const [response, status] = await this.callApi(
505
- '/131airPurifier/v1/device/updateChildLock',
506
- 'put',
507
- {
508
- acceptLanguage: 'en',
509
- accountID: this.manager.accountId!,
510
- status: enabled ? 'on' : 'off',
511
- timeZone: this.manager.timeZone!,
512
- token: this.manager.token!,
513
- uuid: this.uuid
514
- },
515
- {
516
- 'accept-language': 'en',
517
- 'accountId': this.manager.accountId!,
518
- 'appVersion': '2.8.6',
519
- 'content-type': 'application/json',
520
- 'tk': this.manager.token!,
521
- 'tz': this.manager.timeZone!
522
- }
523
- );
524
-
525
- const success = this.checkResponse([response, status], 'setChildLock');
526
- if (success) {
527
- this.details.childLock = enabled;
528
- return true;
529
- } else {
530
- logger.error(`Failed to set child lock to ${enabled ? 'on' : 'off'} for device: ${this.deviceName}`);
531
- return false;
532
- }
297
+ // Check if device is in sleep mode - child lock may not work in sleep mode
298
+ if (this.details.mode === 'sleep') {
299
+ logger.warn(`Device ${this.deviceName} is in sleep mode, child lock control may not work`);
533
300
  }
534
301
 
535
- // Standard implementation for other devices
302
+ logger.debug(`Setting child lock to ${enabled ? 'on' : 'off'} for device: ${this.deviceName}`);
303
+
536
304
  const [response, status] = await this.callApi(
537
305
  '/cloud/v2/deviceManaged/bypassV2',
538
306
  'post',
@@ -552,12 +320,20 @@ export class VeSyncAirBypass extends VeSyncFan {
552
320
  );
553
321
 
554
322
  const success = this.checkResponse([response, status], 'setChildLock');
323
+
324
+ // Check for error code 11000000 (feature not supported)
325
+ if (response?.code === 11000000 || (response?.result?.code === 11000000)) {
326
+ logger.warn(`Child lock control not supported via API for device: ${this.deviceName}`);
327
+ return false;
328
+ }
329
+
555
330
  if (success) {
556
- this.details.child_lock = enabled;
331
+ this.details.childLock = enabled;
332
+ return true;
557
333
  } else {
558
334
  logger.error(`Failed to set child lock to ${enabled ? 'on' : 'off'} for device: ${this.deviceName}`);
335
+ return false;
559
336
  }
560
- return success;
561
337
  }
562
338
 
563
339
  /**
@@ -572,38 +348,6 @@ export class VeSyncAirBypass extends VeSyncFan {
572
348
 
573
349
  logger.debug(`Setting timer to ${hours} hours for device: ${this.deviceName}`);
574
350
 
575
- // Special handling for LV series
576
- if (this.deviceType.startsWith('LV-')) {
577
- const [response, status] = await this.callApi(
578
- '/131airPurifier/v1/device/updateTimer',
579
- 'put',
580
- {
581
- acceptLanguage: 'en',
582
- accountID: this.manager.accountId!,
583
- action: 'off',
584
- duration: hours,
585
- timeZone: this.manager.timeZone!,
586
- token: this.manager.token!,
587
- uuid: this.uuid
588
- },
589
- {
590
- 'accept-language': 'en',
591
- 'accountId': this.manager.accountId!,
592
- 'appVersion': '2.8.6',
593
- 'content-type': 'application/json',
594
- 'tk': this.manager.token!,
595
- 'tz': this.manager.timeZone!
596
- }
597
- );
598
-
599
- const success = this.checkResponse([response, status], 'setTimer');
600
- if (!success) {
601
- logger.error(`Failed to set timer to ${hours} hours for device: ${this.deviceName}`);
602
- }
603
- return success;
604
- }
605
-
606
- // Standard implementation for other devices
607
351
  const [response, status] = await this.callApi(
608
352
  '/cloud/v2/deviceManaged/bypassV2',
609
353
  'post',
@@ -624,10 +368,20 @@ export class VeSyncAirBypass extends VeSyncFan {
624
368
  );
625
369
 
626
370
  const success = this.checkResponse([response, status], 'setTimer');
627
- if (!success) {
371
+
372
+ // Check for successful response with timer ID
373
+ if (success && response?.result?.result?.id) {
374
+ this.timer = { duration: hours * 3600, action: 'off' };
375
+ return true;
376
+ } else if (success) {
377
+ // API call succeeded but no timer ID returned
378
+ logger.warn(`Timer API call succeeded but no timer ID returned for device: ${this.deviceName}`);
379
+ this.timer = { duration: hours * 3600, action: 'off' };
380
+ return true;
381
+ } else {
628
382
  logger.error(`Failed to set timer to ${hours} hours for device: ${this.deviceName}`);
383
+ return false;
629
384
  }
630
- return success;
631
385
  }
632
386
 
633
387
  /**
@@ -640,38 +394,14 @@ export class VeSyncAirBypass extends VeSyncFan {
640
394
  throw new Error(error);
641
395
  }
642
396
 
643
- logger.debug(`Clearing timer for device: ${this.deviceName}`);
644
-
645
- // Special handling for LV series
646
- if (this.deviceType.startsWith('LV-')) {
647
- const [response, status] = await this.callApi(
648
- '/131airPurifier/v1/device/cancelTimer',
649
- 'put',
650
- {
651
- acceptLanguage: 'en',
652
- accountID: this.manager.accountId!,
653
- timeZone: this.manager.timeZone!,
654
- token: this.manager.token!,
655
- uuid: this.uuid
656
- },
657
- {
658
- 'accept-language': 'en',
659
- 'accountId': this.manager.accountId!,
660
- 'appVersion': '2.8.6',
661
- 'content-type': 'application/json',
662
- 'tk': this.manager.token!,
663
- 'tz': this.manager.timeZone!
664
- }
665
- );
666
-
667
- const success = this.checkResponse([response, status], 'clearTimer');
668
- if (!success) {
669
- logger.error(`Failed to clear timer for device: ${this.deviceName}`);
670
- }
671
- return success;
397
+ // If no timer is set, return success
398
+ if (!this.timer) {
399
+ logger.debug(`No timer to clear for device: ${this.deviceName}`);
400
+ return true;
672
401
  }
673
402
 
674
- // Standard implementation for other devices
403
+ logger.debug(`Clearing timer for device: ${this.deviceName}`);
404
+
675
405
  const [response, status] = await this.callApi(
676
406
  '/cloud/v2/deviceManaged/bypassV2',
677
407
  'post',
@@ -689,10 +419,21 @@ export class VeSyncAirBypass extends VeSyncFan {
689
419
  );
690
420
 
691
421
  const success = this.checkResponse([response, status], 'clearTimer');
692
- if (!success) {
422
+
423
+ // Check for error code 11000000 (feature not supported or no timer to clear)
424
+ if (response?.code === 11000000 || (response?.result?.code === 11000000)) {
425
+ logger.warn(`No timer to clear or timer control not supported via API for device: ${this.deviceName}`);
426
+ this.timer = null;
427
+ return true;
428
+ }
429
+
430
+ if (success) {
431
+ this.timer = null;
432
+ return true;
433
+ } else {
693
434
  logger.error(`Failed to clear timer for device: ${this.deviceName}`);
435
+ return false;
694
436
  }
695
- return success;
696
437
  }
697
438
 
698
439
  /**