tsvesync 1.0.28 → 1.0.29
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.
- package/dist/lib/vesyncFanImpl.d.ts +18 -11
- package/dist/lib/vesyncFanImpl.js +90 -71
- package/package.json +1 -1
- package/src/lib/vesyncFanImpl.ts +101 -80
|
@@ -82,9 +82,8 @@ export declare class VeSyncAirBypass extends VeSyncFan {
|
|
|
82
82
|
*/
|
|
83
83
|
export declare class VeSyncHumidifier extends VeSyncFan {
|
|
84
84
|
protected readonly modes: readonly ["auto", "manual", "sleep"];
|
|
85
|
-
protected readonly speeds: number[];
|
|
86
|
-
protected readonly displayModes: readonly ["on", "off"];
|
|
87
85
|
protected readonly mistLevels: number[];
|
|
86
|
+
protected readonly displayModes: readonly ["on", "off"];
|
|
88
87
|
protected readonly humidityRange: {
|
|
89
88
|
min: number;
|
|
90
89
|
max: number;
|
|
@@ -95,15 +94,11 @@ export declare class VeSyncHumidifier extends VeSyncFan {
|
|
|
95
94
|
*/
|
|
96
95
|
getDetails(): Promise<Boolean>;
|
|
97
96
|
/**
|
|
98
|
-
*
|
|
99
|
-
*/
|
|
100
|
-
turnOn(): Promise<boolean>;
|
|
101
|
-
/**
|
|
102
|
-
* Turn device off
|
|
97
|
+
* Set mist level
|
|
103
98
|
*/
|
|
104
|
-
|
|
99
|
+
setMistLevel(level: number): Promise<boolean>;
|
|
105
100
|
/**
|
|
106
|
-
* Change fan speed
|
|
101
|
+
* Change fan speed - Implemented to satisfy interface but redirects to setMistLevel
|
|
107
102
|
*/
|
|
108
103
|
changeFanSpeed(speed: number): Promise<boolean>;
|
|
109
104
|
/**
|
|
@@ -111,9 +106,13 @@ export declare class VeSyncHumidifier extends VeSyncFan {
|
|
|
111
106
|
*/
|
|
112
107
|
setMode(mode: string): Promise<boolean>;
|
|
113
108
|
/**
|
|
114
|
-
*
|
|
109
|
+
* Turn device on
|
|
115
110
|
*/
|
|
116
|
-
|
|
111
|
+
turnOn(): Promise<boolean>;
|
|
112
|
+
/**
|
|
113
|
+
* Turn device off
|
|
114
|
+
*/
|
|
115
|
+
turnOff(): Promise<boolean>;
|
|
117
116
|
/**
|
|
118
117
|
* Set target humidity
|
|
119
118
|
*/
|
|
@@ -161,6 +160,14 @@ export declare class VeSyncHumidifier extends VeSyncFan {
|
|
|
161
160
|
export declare class VeSyncWarmHumidifier extends VeSyncHumidifier {
|
|
162
161
|
protected readonly warmLevels: number[];
|
|
163
162
|
constructor(details: Record<string, any>, manager: VeSync);
|
|
163
|
+
/**
|
|
164
|
+
* Change fan speed - Implemented to satisfy interface but redirects to setMistLevel
|
|
165
|
+
*/
|
|
166
|
+
changeFanSpeed(speed: number): Promise<boolean>;
|
|
167
|
+
/**
|
|
168
|
+
* Set device mode
|
|
169
|
+
*/
|
|
170
|
+
setMode(mode: string): Promise<boolean>;
|
|
164
171
|
/**
|
|
165
172
|
* Set warm mist level
|
|
166
173
|
*/
|
|
@@ -387,10 +387,20 @@ class VeSyncHumidifier extends vesyncFan_1.VeSyncFan {
|
|
|
387
387
|
constructor(details, manager) {
|
|
388
388
|
super(details, manager);
|
|
389
389
|
this.modes = ['auto', 'manual', 'sleep'];
|
|
390
|
-
this.speeds = [1, 2, 3];
|
|
391
390
|
this.displayModes = ['on', 'off'];
|
|
392
|
-
this.mistLevels = [1, 2, 3];
|
|
393
391
|
this.humidityRange = { min: 30, max: 80 };
|
|
392
|
+
// Set mist levels based on model
|
|
393
|
+
switch (this.deviceType) {
|
|
394
|
+
case 'Dual200S':
|
|
395
|
+
case 'LUH-D301S-WUSR':
|
|
396
|
+
case 'LUH-D301S-WJP':
|
|
397
|
+
case 'LUH-D301S-WEU':
|
|
398
|
+
this.mistLevels = [1, 2];
|
|
399
|
+
break;
|
|
400
|
+
default:
|
|
401
|
+
// All other models support levels 1-9
|
|
402
|
+
this.mistLevels = [1, 2, 3, 4, 5, 6, 7, 8, 9];
|
|
403
|
+
}
|
|
394
404
|
logger_1.logger.debug(`Initialized VeSyncHumidifier device: ${this.deviceName}`);
|
|
395
405
|
}
|
|
396
406
|
/**
|
|
@@ -417,141 +427,115 @@ class VeSyncHumidifier extends vesyncFan_1.VeSyncFan {
|
|
|
417
427
|
return success;
|
|
418
428
|
}
|
|
419
429
|
/**
|
|
420
|
-
*
|
|
430
|
+
* Set mist level
|
|
421
431
|
*/
|
|
422
|
-
async
|
|
423
|
-
|
|
432
|
+
async setMistLevel(level) {
|
|
433
|
+
if (!this.mistLevels.includes(level)) {
|
|
434
|
+
const error = `Invalid mist level: ${level}. Must be one of: ${this.mistLevels.join(', ')}`;
|
|
435
|
+
logger_1.logger.error(`${error} for device: ${this.deviceName}`);
|
|
436
|
+
throw new Error(error);
|
|
437
|
+
}
|
|
438
|
+
logger_1.logger.info(`Setting mist level to ${level} for device: ${this.deviceName}`);
|
|
424
439
|
const [response, status] = await this.callApi('/cloud/v2/deviceManaged/bypassV2', 'post', {
|
|
425
440
|
...helpers_1.Helpers.reqBody(this.manager, 'bypassV2'),
|
|
426
441
|
cid: this.cid,
|
|
427
442
|
configModule: this.configModule,
|
|
428
443
|
payload: {
|
|
429
444
|
data: {
|
|
430
|
-
|
|
431
|
-
|
|
445
|
+
id: 0,
|
|
446
|
+
level: level,
|
|
447
|
+
type: 'mist'
|
|
432
448
|
},
|
|
433
|
-
method: '
|
|
449
|
+
method: 'setVirtualLevel',
|
|
434
450
|
source: 'APP'
|
|
435
451
|
}
|
|
436
452
|
}, helpers_1.Helpers.reqHeaderBypass());
|
|
437
|
-
const success = this.checkResponse([response, status], '
|
|
453
|
+
const success = this.checkResponse([response, status], 'setMistLevel');
|
|
438
454
|
if (!success) {
|
|
439
|
-
logger_1.logger.error(`Failed to
|
|
455
|
+
logger_1.logger.error(`Failed to set mist level to ${level} for device: ${this.deviceName}`);
|
|
440
456
|
}
|
|
441
457
|
return success;
|
|
442
458
|
}
|
|
443
459
|
/**
|
|
444
|
-
*
|
|
460
|
+
* Change fan speed - Implemented to satisfy interface but redirects to setMistLevel
|
|
445
461
|
*/
|
|
446
|
-
async
|
|
447
|
-
logger_1.logger.
|
|
448
|
-
|
|
449
|
-
...helpers_1.Helpers.reqBody(this.manager, 'bypassV2'),
|
|
450
|
-
cid: this.cid,
|
|
451
|
-
configModule: this.configModule,
|
|
452
|
-
payload: {
|
|
453
|
-
data: {
|
|
454
|
-
enabled: false,
|
|
455
|
-
id: 0
|
|
456
|
-
},
|
|
457
|
-
method: 'setSwitch',
|
|
458
|
-
source: 'APP'
|
|
459
|
-
}
|
|
460
|
-
}, helpers_1.Helpers.reqHeaderBypass());
|
|
461
|
-
const success = this.checkResponse([response, status], 'turnOff');
|
|
462
|
-
if (!success) {
|
|
463
|
-
logger_1.logger.error(`Failed to turn off device: ${this.deviceName}`);
|
|
464
|
-
}
|
|
465
|
-
return success;
|
|
462
|
+
async changeFanSpeed(speed) {
|
|
463
|
+
logger_1.logger.debug(`Redirecting fan speed change to mist level for device: ${this.deviceName}`);
|
|
464
|
+
return this.setMistLevel(speed);
|
|
466
465
|
}
|
|
467
466
|
/**
|
|
468
|
-
*
|
|
467
|
+
* Set device mode
|
|
469
468
|
*/
|
|
470
|
-
async
|
|
471
|
-
if (!this.
|
|
472
|
-
const error = `Invalid
|
|
469
|
+
async setMode(mode) {
|
|
470
|
+
if (!this.modes.includes(mode)) {
|
|
471
|
+
const error = `Invalid mode: ${mode}. Must be one of: ${this.modes.join(', ')}`;
|
|
473
472
|
logger_1.logger.error(`${error} for device: ${this.deviceName}`);
|
|
474
473
|
throw new Error(error);
|
|
475
474
|
}
|
|
476
|
-
logger_1.logger.
|
|
475
|
+
logger_1.logger.debug(`Setting mode to ${mode} for device: ${this.deviceName}`);
|
|
477
476
|
const [response, status] = await this.callApi('/cloud/v2/deviceManaged/bypassV2', 'post', {
|
|
478
477
|
...helpers_1.Helpers.reqBody(this.manager, 'bypassV2'),
|
|
479
478
|
cid: this.cid,
|
|
480
479
|
configModule: this.configModule,
|
|
481
480
|
payload: {
|
|
482
481
|
data: {
|
|
483
|
-
|
|
484
|
-
level: speed,
|
|
485
|
-
type: 'wind'
|
|
482
|
+
mode
|
|
486
483
|
},
|
|
487
|
-
method: '
|
|
484
|
+
method: 'setHumidifierMode',
|
|
488
485
|
source: 'APP'
|
|
489
486
|
}
|
|
490
487
|
}, helpers_1.Helpers.reqHeaderBypass());
|
|
491
|
-
const success = this.checkResponse([response, status], '
|
|
488
|
+
const success = this.checkResponse([response, status], 'setMode');
|
|
492
489
|
if (!success) {
|
|
493
|
-
logger_1.logger.error(`Failed to
|
|
490
|
+
logger_1.logger.error(`Failed to set mode to ${mode} for device: ${this.deviceName}`);
|
|
494
491
|
}
|
|
495
492
|
return success;
|
|
496
493
|
}
|
|
497
494
|
/**
|
|
498
|
-
*
|
|
495
|
+
* Turn device on
|
|
499
496
|
*/
|
|
500
|
-
async
|
|
501
|
-
|
|
502
|
-
const error = `Invalid mode: ${mode}. Must be one of: ${this.modes.join(', ')}`;
|
|
503
|
-
logger_1.logger.error(`${error} for device: ${this.deviceName}`);
|
|
504
|
-
throw new Error(error);
|
|
505
|
-
}
|
|
506
|
-
logger_1.logger.debug(`Setting mode to ${mode} for device: ${this.deviceName}`);
|
|
497
|
+
async turnOn() {
|
|
498
|
+
logger_1.logger.info(`Turning on device: ${this.deviceName}`);
|
|
507
499
|
const [response, status] = await this.callApi('/cloud/v2/deviceManaged/bypassV2', 'post', {
|
|
508
500
|
...helpers_1.Helpers.reqBody(this.manager, 'bypassV2'),
|
|
509
501
|
cid: this.cid,
|
|
510
502
|
configModule: this.configModule,
|
|
511
503
|
payload: {
|
|
512
504
|
data: {
|
|
513
|
-
|
|
505
|
+
enabled: true,
|
|
506
|
+
id: 0
|
|
514
507
|
},
|
|
515
|
-
method: '
|
|
508
|
+
method: 'setSwitch',
|
|
516
509
|
source: 'APP'
|
|
517
510
|
}
|
|
518
511
|
}, helpers_1.Helpers.reqHeaderBypass());
|
|
519
|
-
const success = this.checkResponse([response, status], '
|
|
512
|
+
const success = this.checkResponse([response, status], 'turnOn');
|
|
520
513
|
if (!success) {
|
|
521
|
-
logger_1.logger.error(`Failed to
|
|
514
|
+
logger_1.logger.error(`Failed to turn on device: ${this.deviceName}`);
|
|
522
515
|
}
|
|
523
516
|
return success;
|
|
524
517
|
}
|
|
525
518
|
/**
|
|
526
|
-
*
|
|
519
|
+
* Turn device off
|
|
527
520
|
*/
|
|
528
|
-
async
|
|
529
|
-
|
|
530
|
-
const error = 'Mist control not supported';
|
|
531
|
-
logger_1.logger.error(`${error} for device: ${this.deviceName}`);
|
|
532
|
-
throw new Error(error);
|
|
533
|
-
}
|
|
534
|
-
if (!this.mistLevels.includes(level)) {
|
|
535
|
-
const error = `Invalid mist level: ${level}. Must be one of: ${this.mistLevels.join(', ')}`;
|
|
536
|
-
logger_1.logger.error(`${error} for device: ${this.deviceName}`);
|
|
537
|
-
throw new Error(error);
|
|
538
|
-
}
|
|
539
|
-
logger_1.logger.debug(`Setting mist level to ${level} for device: ${this.deviceName}`);
|
|
521
|
+
async turnOff() {
|
|
522
|
+
logger_1.logger.info(`Turning off device: ${this.deviceName}`);
|
|
540
523
|
const [response, status] = await this.callApi('/cloud/v2/deviceManaged/bypassV2', 'post', {
|
|
541
524
|
...helpers_1.Helpers.reqBody(this.manager, 'bypassV2'),
|
|
542
525
|
cid: this.cid,
|
|
543
526
|
configModule: this.configModule,
|
|
544
527
|
payload: {
|
|
545
528
|
data: {
|
|
546
|
-
|
|
529
|
+
enabled: false,
|
|
530
|
+
id: 0
|
|
547
531
|
},
|
|
548
|
-
method: '
|
|
532
|
+
method: 'setSwitch',
|
|
549
533
|
source: 'APP'
|
|
550
534
|
}
|
|
551
535
|
}, helpers_1.Helpers.reqHeaderBypass());
|
|
552
|
-
const success = this.checkResponse([response, status], '
|
|
536
|
+
const success = this.checkResponse([response, status], 'turnOff');
|
|
553
537
|
if (!success) {
|
|
554
|
-
logger_1.logger.error(`Failed to
|
|
538
|
+
logger_1.logger.error(`Failed to turn off device: ${this.deviceName}`);
|
|
555
539
|
}
|
|
556
540
|
return success;
|
|
557
541
|
}
|
|
@@ -772,6 +756,41 @@ class VeSyncWarmHumidifier extends VeSyncHumidifier {
|
|
|
772
756
|
this.warmLevels = [1, 2, 3];
|
|
773
757
|
logger_1.logger.debug(`Initialized VeSyncWarmHumidifier device: ${this.deviceName}`);
|
|
774
758
|
}
|
|
759
|
+
/**
|
|
760
|
+
* Change fan speed - Implemented to satisfy interface but redirects to setMistLevel
|
|
761
|
+
*/
|
|
762
|
+
async changeFanSpeed(speed) {
|
|
763
|
+
logger_1.logger.debug(`Redirecting fan speed change to mist level for device: ${this.deviceName}`);
|
|
764
|
+
return this.setMistLevel(speed);
|
|
765
|
+
}
|
|
766
|
+
/**
|
|
767
|
+
* Set device mode
|
|
768
|
+
*/
|
|
769
|
+
async setMode(mode) {
|
|
770
|
+
if (!this.modes.includes(mode)) {
|
|
771
|
+
const error = `Invalid mode: ${mode}. Must be one of: ${this.modes.join(', ')}`;
|
|
772
|
+
logger_1.logger.error(`${error} for device: ${this.deviceName}`);
|
|
773
|
+
throw new Error(error);
|
|
774
|
+
}
|
|
775
|
+
logger_1.logger.debug(`Setting mode to ${mode} for device: ${this.deviceName}`);
|
|
776
|
+
const [response, status] = await this.callApi('/cloud/v2/deviceManaged/bypassV2', 'post', {
|
|
777
|
+
...helpers_1.Helpers.reqBody(this.manager, 'bypassV2'),
|
|
778
|
+
cid: this.cid,
|
|
779
|
+
configModule: this.configModule,
|
|
780
|
+
payload: {
|
|
781
|
+
data: {
|
|
782
|
+
mode
|
|
783
|
+
},
|
|
784
|
+
method: 'setHumidifierMode',
|
|
785
|
+
source: 'APP'
|
|
786
|
+
}
|
|
787
|
+
}, helpers_1.Helpers.reqHeaderBypass());
|
|
788
|
+
const success = this.checkResponse([response, status], 'setMode');
|
|
789
|
+
if (!success) {
|
|
790
|
+
logger_1.logger.error(`Failed to set mode to ${mode} for device: ${this.deviceName}`);
|
|
791
|
+
}
|
|
792
|
+
return success;
|
|
793
|
+
}
|
|
775
794
|
/**
|
|
776
795
|
* Set warm mist level
|
|
777
796
|
*/
|
package/package.json
CHANGED
package/src/lib/vesyncFanImpl.ts
CHANGED
|
@@ -475,13 +475,24 @@ export class VeSyncAirBypass extends VeSyncFan {
|
|
|
475
475
|
*/
|
|
476
476
|
export class VeSyncHumidifier extends VeSyncFan {
|
|
477
477
|
protected readonly modes = ['auto', 'manual', 'sleep'] as const;
|
|
478
|
-
protected readonly
|
|
478
|
+
protected readonly mistLevels: number[];
|
|
479
479
|
protected readonly displayModes = ['on', 'off'] as const;
|
|
480
|
-
protected readonly mistLevels = [1, 2, 3];
|
|
481
480
|
protected readonly humidityRange = { min: 30, max: 80 };
|
|
482
481
|
|
|
483
482
|
constructor(details: Record<string, any>, manager: VeSync) {
|
|
484
483
|
super(details, manager);
|
|
484
|
+
// Set mist levels based on model
|
|
485
|
+
switch (this.deviceType) {
|
|
486
|
+
case 'Dual200S':
|
|
487
|
+
case 'LUH-D301S-WUSR':
|
|
488
|
+
case 'LUH-D301S-WJP':
|
|
489
|
+
case 'LUH-D301S-WEU':
|
|
490
|
+
this.mistLevels = [1, 2];
|
|
491
|
+
break;
|
|
492
|
+
default:
|
|
493
|
+
// All other models support levels 1-9
|
|
494
|
+
this.mistLevels = [1, 2, 3, 4, 5, 6, 7, 8, 9];
|
|
495
|
+
}
|
|
485
496
|
logger.debug(`Initialized VeSyncHumidifier device: ${this.deviceName}`);
|
|
486
497
|
}
|
|
487
498
|
|
|
@@ -515,10 +526,16 @@ export class VeSyncHumidifier extends VeSyncFan {
|
|
|
515
526
|
}
|
|
516
527
|
|
|
517
528
|
/**
|
|
518
|
-
*
|
|
529
|
+
* Set mist level
|
|
519
530
|
*/
|
|
520
|
-
async
|
|
521
|
-
|
|
531
|
+
async setMistLevel(level: number): Promise<boolean> {
|
|
532
|
+
if (!this.mistLevels.includes(level)) {
|
|
533
|
+
const error = `Invalid mist level: ${level}. Must be one of: ${this.mistLevels.join(', ')}`;
|
|
534
|
+
logger.error(`${error} for device: ${this.deviceName}`);
|
|
535
|
+
throw new Error(error);
|
|
536
|
+
}
|
|
537
|
+
|
|
538
|
+
logger.info(`Setting mist level to ${level} for device: ${this.deviceName}`);
|
|
522
539
|
const [response, status] = await this.callApi(
|
|
523
540
|
'/cloud/v2/deviceManaged/bypassV2',
|
|
524
541
|
'post',
|
|
@@ -528,65 +545,43 @@ export class VeSyncHumidifier extends VeSyncFan {
|
|
|
528
545
|
configModule: this.configModule,
|
|
529
546
|
payload: {
|
|
530
547
|
data: {
|
|
531
|
-
|
|
532
|
-
|
|
548
|
+
id: 0,
|
|
549
|
+
level: level,
|
|
550
|
+
type: 'mist'
|
|
533
551
|
},
|
|
534
|
-
method: '
|
|
552
|
+
method: 'setVirtualLevel',
|
|
535
553
|
source: 'APP'
|
|
536
554
|
}
|
|
537
555
|
},
|
|
538
556
|
Helpers.reqHeaderBypass()
|
|
539
557
|
);
|
|
540
558
|
|
|
541
|
-
const success = this.checkResponse([response, status], '
|
|
559
|
+
const success = this.checkResponse([response, status], 'setMistLevel');
|
|
542
560
|
if (!success) {
|
|
543
|
-
logger.error(`Failed to
|
|
561
|
+
logger.error(`Failed to set mist level to ${level} for device: ${this.deviceName}`);
|
|
544
562
|
}
|
|
545
563
|
return success;
|
|
546
564
|
}
|
|
547
565
|
|
|
548
566
|
/**
|
|
549
|
-
*
|
|
567
|
+
* Change fan speed - Implemented to satisfy interface but redirects to setMistLevel
|
|
550
568
|
*/
|
|
551
|
-
async
|
|
552
|
-
logger.
|
|
553
|
-
|
|
554
|
-
'/cloud/v2/deviceManaged/bypassV2',
|
|
555
|
-
'post',
|
|
556
|
-
{
|
|
557
|
-
...Helpers.reqBody(this.manager, 'bypassV2'),
|
|
558
|
-
cid: this.cid,
|
|
559
|
-
configModule: this.configModule,
|
|
560
|
-
payload: {
|
|
561
|
-
data: {
|
|
562
|
-
enabled: false,
|
|
563
|
-
id: 0
|
|
564
|
-
},
|
|
565
|
-
method: 'setSwitch',
|
|
566
|
-
source: 'APP'
|
|
567
|
-
}
|
|
568
|
-
},
|
|
569
|
-
Helpers.reqHeaderBypass()
|
|
570
|
-
);
|
|
571
|
-
|
|
572
|
-
const success = this.checkResponse([response, status], 'turnOff');
|
|
573
|
-
if (!success) {
|
|
574
|
-
logger.error(`Failed to turn off device: ${this.deviceName}`);
|
|
575
|
-
}
|
|
576
|
-
return success;
|
|
569
|
+
async changeFanSpeed(speed: number): Promise<boolean> {
|
|
570
|
+
logger.debug(`Redirecting fan speed change to mist level for device: ${this.deviceName}`);
|
|
571
|
+
return this.setMistLevel(speed);
|
|
577
572
|
}
|
|
578
573
|
|
|
579
574
|
/**
|
|
580
|
-
*
|
|
575
|
+
* Set device mode
|
|
581
576
|
*/
|
|
582
|
-
async
|
|
583
|
-
if (!this.
|
|
584
|
-
const error = `Invalid
|
|
577
|
+
async setMode(mode: string): Promise<boolean> {
|
|
578
|
+
if (!this.modes.includes(mode as any)) {
|
|
579
|
+
const error = `Invalid mode: ${mode}. Must be one of: ${this.modes.join(', ')}`;
|
|
585
580
|
logger.error(`${error} for device: ${this.deviceName}`);
|
|
586
581
|
throw new Error(error);
|
|
587
582
|
}
|
|
588
583
|
|
|
589
|
-
logger.
|
|
584
|
+
logger.debug(`Setting mode to ${mode} for device: ${this.deviceName}`);
|
|
590
585
|
const [response, status] = await this.callApi(
|
|
591
586
|
'/cloud/v2/deviceManaged/bypassV2',
|
|
592
587
|
'post',
|
|
@@ -596,35 +591,27 @@ export class VeSyncHumidifier extends VeSyncFan {
|
|
|
596
591
|
configModule: this.configModule,
|
|
597
592
|
payload: {
|
|
598
593
|
data: {
|
|
599
|
-
|
|
600
|
-
level: speed,
|
|
601
|
-
type: 'wind'
|
|
594
|
+
mode
|
|
602
595
|
},
|
|
603
|
-
method: '
|
|
596
|
+
method: 'setHumidifierMode',
|
|
604
597
|
source: 'APP'
|
|
605
598
|
}
|
|
606
599
|
},
|
|
607
600
|
Helpers.reqHeaderBypass()
|
|
608
601
|
);
|
|
609
602
|
|
|
610
|
-
const success = this.checkResponse([response, status], '
|
|
603
|
+
const success = this.checkResponse([response, status], 'setMode');
|
|
611
604
|
if (!success) {
|
|
612
|
-
logger.error(`Failed to
|
|
605
|
+
logger.error(`Failed to set mode to ${mode} for device: ${this.deviceName}`);
|
|
613
606
|
}
|
|
614
607
|
return success;
|
|
615
608
|
}
|
|
616
609
|
|
|
617
610
|
/**
|
|
618
|
-
*
|
|
611
|
+
* Turn device on
|
|
619
612
|
*/
|
|
620
|
-
async
|
|
621
|
-
|
|
622
|
-
const error = `Invalid mode: ${mode}. Must be one of: ${this.modes.join(', ')}`;
|
|
623
|
-
logger.error(`${error} for device: ${this.deviceName}`);
|
|
624
|
-
throw new Error(error);
|
|
625
|
-
}
|
|
626
|
-
|
|
627
|
-
logger.debug(`Setting mode to ${mode} for device: ${this.deviceName}`);
|
|
613
|
+
async turnOn(): Promise<boolean> {
|
|
614
|
+
logger.info(`Turning on device: ${this.deviceName}`);
|
|
628
615
|
const [response, status] = await this.callApi(
|
|
629
616
|
'/cloud/v2/deviceManaged/bypassV2',
|
|
630
617
|
'post',
|
|
@@ -634,39 +621,28 @@ export class VeSyncHumidifier extends VeSyncFan {
|
|
|
634
621
|
configModule: this.configModule,
|
|
635
622
|
payload: {
|
|
636
623
|
data: {
|
|
637
|
-
|
|
624
|
+
enabled: true,
|
|
625
|
+
id: 0
|
|
638
626
|
},
|
|
639
|
-
method: '
|
|
627
|
+
method: 'setSwitch',
|
|
640
628
|
source: 'APP'
|
|
641
629
|
}
|
|
642
630
|
},
|
|
643
631
|
Helpers.reqHeaderBypass()
|
|
644
632
|
);
|
|
645
633
|
|
|
646
|
-
const success = this.checkResponse([response, status], '
|
|
634
|
+
const success = this.checkResponse([response, status], 'turnOn');
|
|
647
635
|
if (!success) {
|
|
648
|
-
logger.error(`Failed to
|
|
636
|
+
logger.error(`Failed to turn on device: ${this.deviceName}`);
|
|
649
637
|
}
|
|
650
638
|
return success;
|
|
651
639
|
}
|
|
652
640
|
|
|
653
641
|
/**
|
|
654
|
-
*
|
|
642
|
+
* Turn device off
|
|
655
643
|
*/
|
|
656
|
-
async
|
|
657
|
-
|
|
658
|
-
const error = 'Mist control not supported';
|
|
659
|
-
logger.error(`${error} for device: ${this.deviceName}`);
|
|
660
|
-
throw new Error(error);
|
|
661
|
-
}
|
|
662
|
-
|
|
663
|
-
if (!this.mistLevels.includes(level)) {
|
|
664
|
-
const error = `Invalid mist level: ${level}. Must be one of: ${this.mistLevels.join(', ')}`;
|
|
665
|
-
logger.error(`${error} for device: ${this.deviceName}`);
|
|
666
|
-
throw new Error(error);
|
|
667
|
-
}
|
|
668
|
-
|
|
669
|
-
logger.debug(`Setting mist level to ${level} for device: ${this.deviceName}`);
|
|
644
|
+
async turnOff(): Promise<boolean> {
|
|
645
|
+
logger.info(`Turning off device: ${this.deviceName}`);
|
|
670
646
|
const [response, status] = await this.callApi(
|
|
671
647
|
'/cloud/v2/deviceManaged/bypassV2',
|
|
672
648
|
'post',
|
|
@@ -676,18 +652,19 @@ export class VeSyncHumidifier extends VeSyncFan {
|
|
|
676
652
|
configModule: this.configModule,
|
|
677
653
|
payload: {
|
|
678
654
|
data: {
|
|
679
|
-
|
|
655
|
+
enabled: false,
|
|
656
|
+
id: 0
|
|
680
657
|
},
|
|
681
|
-
method: '
|
|
658
|
+
method: 'setSwitch',
|
|
682
659
|
source: 'APP'
|
|
683
660
|
}
|
|
684
661
|
},
|
|
685
662
|
Helpers.reqHeaderBypass()
|
|
686
663
|
);
|
|
687
664
|
|
|
688
|
-
const success = this.checkResponse([response, status], '
|
|
665
|
+
const success = this.checkResponse([response, status], 'turnOff');
|
|
689
666
|
if (!success) {
|
|
690
|
-
logger.error(`Failed to
|
|
667
|
+
logger.error(`Failed to turn off device: ${this.deviceName}`);
|
|
691
668
|
}
|
|
692
669
|
return success;
|
|
693
670
|
}
|
|
@@ -961,6 +938,50 @@ export class VeSyncWarmHumidifier extends VeSyncHumidifier {
|
|
|
961
938
|
logger.debug(`Initialized VeSyncWarmHumidifier device: ${this.deviceName}`);
|
|
962
939
|
}
|
|
963
940
|
|
|
941
|
+
/**
|
|
942
|
+
* Change fan speed - Implemented to satisfy interface but redirects to setMistLevel
|
|
943
|
+
*/
|
|
944
|
+
async changeFanSpeed(speed: number): Promise<boolean> {
|
|
945
|
+
logger.debug(`Redirecting fan speed change to mist level for device: ${this.deviceName}`);
|
|
946
|
+
return this.setMistLevel(speed);
|
|
947
|
+
}
|
|
948
|
+
|
|
949
|
+
/**
|
|
950
|
+
* Set device mode
|
|
951
|
+
*/
|
|
952
|
+
async setMode(mode: string): Promise<boolean> {
|
|
953
|
+
if (!this.modes.includes(mode as any)) {
|
|
954
|
+
const error = `Invalid mode: ${mode}. Must be one of: ${this.modes.join(', ')}`;
|
|
955
|
+
logger.error(`${error} for device: ${this.deviceName}`);
|
|
956
|
+
throw new Error(error);
|
|
957
|
+
}
|
|
958
|
+
|
|
959
|
+
logger.debug(`Setting mode to ${mode} for device: ${this.deviceName}`);
|
|
960
|
+
const [response, status] = await this.callApi(
|
|
961
|
+
'/cloud/v2/deviceManaged/bypassV2',
|
|
962
|
+
'post',
|
|
963
|
+
{
|
|
964
|
+
...Helpers.reqBody(this.manager, 'bypassV2'),
|
|
965
|
+
cid: this.cid,
|
|
966
|
+
configModule: this.configModule,
|
|
967
|
+
payload: {
|
|
968
|
+
data: {
|
|
969
|
+
mode
|
|
970
|
+
},
|
|
971
|
+
method: 'setHumidifierMode',
|
|
972
|
+
source: 'APP'
|
|
973
|
+
}
|
|
974
|
+
},
|
|
975
|
+
Helpers.reqHeaderBypass()
|
|
976
|
+
);
|
|
977
|
+
|
|
978
|
+
const success = this.checkResponse([response, status], 'setMode');
|
|
979
|
+
if (!success) {
|
|
980
|
+
logger.error(`Failed to set mode to ${mode} for device: ${this.deviceName}`);
|
|
981
|
+
}
|
|
982
|
+
return success;
|
|
983
|
+
}
|
|
984
|
+
|
|
964
985
|
/**
|
|
965
986
|
* Set warm mist level
|
|
966
987
|
*/
|