tsvesync 1.0.49 → 1.0.51
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/vesyncFan.d.ts +20 -3
- package/dist/lib/vesyncFan.js +129 -67
- package/dist/lib/vesyncFanImpl.d.ts +29 -2
- package/dist/lib/vesyncFanImpl.js +179 -88
- package/package.json +1 -1
- package/src/lib/vesyncFan.ts +149 -68
- package/src/lib/vesyncFanImpl.ts +187 -85
|
@@ -14,7 +14,6 @@ class VeSyncAirBypass extends vesyncFan_1.VeSyncFan {
|
|
|
14
14
|
constructor(details, manager) {
|
|
15
15
|
super(details, manager);
|
|
16
16
|
this.modes = ['auto', 'manual', 'sleep'];
|
|
17
|
-
this.speeds = [1, 2, 3, 4, 5];
|
|
18
17
|
this.displayModes = ['on', 'off'];
|
|
19
18
|
this.childLockModes = ['on', 'off'];
|
|
20
19
|
logger_1.logger.debug(`Initialized VeSyncAirBypass device: ${this.deviceName}`);
|
|
@@ -27,6 +26,7 @@ class VeSyncAirBypass extends vesyncFan_1.VeSyncFan {
|
|
|
27
26
|
const body = {
|
|
28
27
|
...helpers_1.Helpers.reqBody(this.manager, 'bypassV2'),
|
|
29
28
|
cid: this.cid,
|
|
29
|
+
deviceId: this.cid, // Add deviceId to match YAML spec
|
|
30
30
|
configModule: this.configModule,
|
|
31
31
|
payload: {
|
|
32
32
|
method,
|
|
@@ -210,10 +210,11 @@ class VeSyncAirBypass extends vesyncFan_1.VeSyncFan {
|
|
|
210
210
|
* Change fan speed
|
|
211
211
|
*/
|
|
212
212
|
async changeFanSpeed(speed) {
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
213
|
+
var _a;
|
|
214
|
+
const speeds = (_a = this.config.levels) !== null && _a !== void 0 ? _a : [];
|
|
215
|
+
if (!speeds.includes(speed)) {
|
|
216
|
+
logger_1.logger.error(`Invalid speed: ${speed}. Must be one of: ${speeds.join(', ')} for device: ${this.deviceName}`);
|
|
217
|
+
return false;
|
|
217
218
|
}
|
|
218
219
|
logger_1.logger.info(`Changing fan speed to ${speed} for device: ${this.deviceName}`);
|
|
219
220
|
const [response, status] = await this.callApi('/cloud/v2/deviceManaged/bypassV2', 'post', {
|
|
@@ -241,10 +242,11 @@ class VeSyncAirBypass extends vesyncFan_1.VeSyncFan {
|
|
|
241
242
|
* Set device mode
|
|
242
243
|
*/
|
|
243
244
|
async setMode(mode) {
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
logger_1.logger.
|
|
247
|
-
|
|
245
|
+
const modeStr = mode.toLowerCase();
|
|
246
|
+
if (!this.modes.includes(modeStr)) {
|
|
247
|
+
logger_1.logger.debug(`Invalid humidity mode used - ${mode}`);
|
|
248
|
+
logger_1.logger.debug(`Proper modes for this device are - ${this.modes.join(', ')}`);
|
|
249
|
+
return false;
|
|
248
250
|
}
|
|
249
251
|
logger_1.logger.debug(`Setting mode to ${mode} for device: ${this.deviceName}`);
|
|
250
252
|
const [response, status] = await this.callApi('/cloud/v2/deviceManaged/bypassV2', 'post', {
|
|
@@ -253,15 +255,15 @@ class VeSyncAirBypass extends vesyncFan_1.VeSyncFan {
|
|
|
253
255
|
configModule: this.configModule,
|
|
254
256
|
payload: {
|
|
255
257
|
data: {
|
|
256
|
-
|
|
258
|
+
workMode: this.deviceType.startsWith('Superior') && modeStr === 'auto' ? 'autoPro' : modeStr
|
|
257
259
|
},
|
|
258
|
-
method: '
|
|
260
|
+
method: 'setHumidifierMode',
|
|
259
261
|
source: 'APP'
|
|
260
262
|
}
|
|
261
263
|
}, helpers_1.Helpers.reqHeaderBypass());
|
|
262
264
|
const success = this.checkResponse([response, status], 'setMode');
|
|
263
265
|
if (!success) {
|
|
264
|
-
logger_1.logger.
|
|
266
|
+
logger_1.logger.debug('Error setting humidity mode');
|
|
265
267
|
}
|
|
266
268
|
return success;
|
|
267
269
|
}
|
|
@@ -488,6 +490,7 @@ class VeSyncHumidifier extends vesyncFan_1.VeSyncFan {
|
|
|
488
490
|
this.modes = ['auto', 'manual', 'sleep'];
|
|
489
491
|
this.displayModes = ['on', 'off'];
|
|
490
492
|
this.humidityRange = { min: 30, max: 80 };
|
|
493
|
+
this.states = ['inactive', 'idle', 'humidifying'];
|
|
491
494
|
// Set mist levels based on model
|
|
492
495
|
switch (this.deviceType) {
|
|
493
496
|
case 'Dual200S':
|
|
@@ -502,6 +505,66 @@ class VeSyncHumidifier extends vesyncFan_1.VeSyncFan {
|
|
|
502
505
|
}
|
|
503
506
|
logger_1.logger.debug(`Initialized VeSyncHumidifier device: ${this.deviceName}`);
|
|
504
507
|
}
|
|
508
|
+
/**
|
|
509
|
+
* Get current operational state
|
|
510
|
+
*/
|
|
511
|
+
get currentState() {
|
|
512
|
+
if (this.deviceStatus === 'off') {
|
|
513
|
+
return 'inactive';
|
|
514
|
+
}
|
|
515
|
+
if (this.details.water_lacks) {
|
|
516
|
+
return 'idle';
|
|
517
|
+
}
|
|
518
|
+
return 'humidifying';
|
|
519
|
+
}
|
|
520
|
+
/**
|
|
521
|
+
* Get water level percentage
|
|
522
|
+
*/
|
|
523
|
+
get waterLevel() {
|
|
524
|
+
var _a;
|
|
525
|
+
return (_a = this.details.water_level) !== null && _a !== void 0 ? _a : 0;
|
|
526
|
+
}
|
|
527
|
+
/**
|
|
528
|
+
* Get water tank status
|
|
529
|
+
*/
|
|
530
|
+
get waterTankLifted() {
|
|
531
|
+
var _a;
|
|
532
|
+
return (_a = this.details.water_tank_lifted) !== null && _a !== void 0 ? _a : false;
|
|
533
|
+
}
|
|
534
|
+
/**
|
|
535
|
+
* Get oscillation state
|
|
536
|
+
*/
|
|
537
|
+
get oscillationEnabled() {
|
|
538
|
+
var _a;
|
|
539
|
+
return (_a = this.details.oscillation_enabled) !== null && _a !== void 0 ? _a : false;
|
|
540
|
+
}
|
|
541
|
+
/**
|
|
542
|
+
* Set oscillation state
|
|
543
|
+
*/
|
|
544
|
+
async setOscillation(enabled) {
|
|
545
|
+
if (!this.hasFeature('oscillation')) {
|
|
546
|
+
logger_1.logger.debug('Oscillation not supported');
|
|
547
|
+
return false;
|
|
548
|
+
}
|
|
549
|
+
logger_1.logger.debug(`Setting oscillation to ${enabled ? 'on' : 'off'} for device: ${this.deviceName}`);
|
|
550
|
+
const [response, status] = await this.callApi('/cloud/v2/deviceManaged/bypassV2', 'post', {
|
|
551
|
+
...helpers_1.Helpers.reqBody(this.manager, 'bypassV2'),
|
|
552
|
+
cid: this.cid,
|
|
553
|
+
configModule: this.configModule,
|
|
554
|
+
payload: {
|
|
555
|
+
data: {
|
|
556
|
+
oscillationEnabled: enabled
|
|
557
|
+
},
|
|
558
|
+
method: 'setSwing',
|
|
559
|
+
source: 'APP'
|
|
560
|
+
}
|
|
561
|
+
}, helpers_1.Helpers.reqHeaderBypass());
|
|
562
|
+
const success = this.checkResponse([response, status], 'setOscillation');
|
|
563
|
+
if (!success) {
|
|
564
|
+
logger_1.logger.debug('Error setting oscillation');
|
|
565
|
+
}
|
|
566
|
+
return success;
|
|
567
|
+
}
|
|
505
568
|
/**
|
|
506
569
|
* Get device details
|
|
507
570
|
*/
|
|
@@ -533,12 +596,13 @@ class VeSyncHumidifier extends vesyncFan_1.VeSyncFan {
|
|
|
533
596
|
humidity: result.humidity || 0,
|
|
534
597
|
mist_level: result.mistLevel || 0,
|
|
535
598
|
mist_virtual_level: result.virtualLevel || 0,
|
|
536
|
-
warm_level: result.warmLevel || 0,
|
|
537
599
|
water_lacks: result.waterLacks || false,
|
|
538
|
-
|
|
600
|
+
water_level: result.waterLevel || 0,
|
|
539
601
|
water_tank_lifted: result.waterTankLifted || false,
|
|
602
|
+
humidity_high: result.humidityHigh || false,
|
|
540
603
|
display: result.display || false,
|
|
541
604
|
automatic_stop: result.automaticStop || false,
|
|
605
|
+
oscillation_enabled: result.oscillationEnabled || false,
|
|
542
606
|
configuration: result.configuration || {},
|
|
543
607
|
connection_status: result.connectionStatus || null
|
|
544
608
|
};
|
|
@@ -546,6 +610,34 @@ class VeSyncHumidifier extends vesyncFan_1.VeSyncFan {
|
|
|
546
610
|
}
|
|
547
611
|
return success;
|
|
548
612
|
}
|
|
613
|
+
/**
|
|
614
|
+
* Display device info
|
|
615
|
+
*/
|
|
616
|
+
display() {
|
|
617
|
+
super.display();
|
|
618
|
+
const info = [
|
|
619
|
+
['Current State: ', this.currentState],
|
|
620
|
+
['Water Level: ', this.waterLevel, '%'],
|
|
621
|
+
['Water Tank: ', this.waterTankLifted ? 'Lifted' : 'Seated'],
|
|
622
|
+
['Oscillation: ', this.oscillationEnabled ? 'On' : 'Off']
|
|
623
|
+
];
|
|
624
|
+
for (const [key, value, unit = ''] of info) {
|
|
625
|
+
logger_1.logger.info(`${key.toString().padEnd(30, '.')} ${value}${unit}`);
|
|
626
|
+
}
|
|
627
|
+
}
|
|
628
|
+
/**
|
|
629
|
+
* Return JSON details
|
|
630
|
+
*/
|
|
631
|
+
displayJSON() {
|
|
632
|
+
const baseInfo = JSON.parse(super.displayJSON());
|
|
633
|
+
return JSON.stringify({
|
|
634
|
+
...baseInfo,
|
|
635
|
+
'Current State': this.currentState,
|
|
636
|
+
'Water Level': this.waterLevel,
|
|
637
|
+
'Water Tank': this.waterTankLifted ? 'Lifted' : 'Seated',
|
|
638
|
+
'Oscillation': this.oscillationEnabled ? 'On' : 'Off'
|
|
639
|
+
}, null, 4);
|
|
640
|
+
}
|
|
549
641
|
/**
|
|
550
642
|
* Turn device on
|
|
551
643
|
*/
|
|
@@ -610,9 +702,9 @@ class VeSyncHumidifier extends vesyncFan_1.VeSyncFan {
|
|
|
610
702
|
*/
|
|
611
703
|
async setMistLevel(level) {
|
|
612
704
|
if (!this.mistLevels.includes(level)) {
|
|
613
|
-
|
|
614
|
-
logger_1.logger.
|
|
615
|
-
|
|
705
|
+
logger_1.logger.debug(`Invalid mist level: ${level} for device: ${this.deviceName}`);
|
|
706
|
+
logger_1.logger.debug(`Valid levels for ${this.deviceType}: ${this.mistLevels.join(', ')}`);
|
|
707
|
+
return false;
|
|
616
708
|
}
|
|
617
709
|
logger_1.logger.info(`Setting mist level to ${level} for device: ${this.deviceName}`);
|
|
618
710
|
const [response, status] = await this.callApi('/cloud/v2/deviceManaged/bypassV2', 'post', {
|
|
@@ -621,9 +713,9 @@ class VeSyncHumidifier extends vesyncFan_1.VeSyncFan {
|
|
|
621
713
|
configModule: this.configModule,
|
|
622
714
|
payload: {
|
|
623
715
|
data: {
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
716
|
+
levelIdx: 0,
|
|
717
|
+
virtualLevel: level,
|
|
718
|
+
levelType: 'mist'
|
|
627
719
|
},
|
|
628
720
|
method: 'setVirtualLevel',
|
|
629
721
|
source: 'APP'
|
|
@@ -631,7 +723,7 @@ class VeSyncHumidifier extends vesyncFan_1.VeSyncFan {
|
|
|
631
723
|
}, helpers_1.Helpers.reqHeaderBypass());
|
|
632
724
|
const success = this.checkResponse([response, status], 'setMistLevel');
|
|
633
725
|
if (!success) {
|
|
634
|
-
logger_1.logger.
|
|
726
|
+
logger_1.logger.debug('Error setting mist level');
|
|
635
727
|
}
|
|
636
728
|
return success;
|
|
637
729
|
}
|
|
@@ -646,10 +738,11 @@ class VeSyncHumidifier extends vesyncFan_1.VeSyncFan {
|
|
|
646
738
|
* Set device mode
|
|
647
739
|
*/
|
|
648
740
|
async setMode(mode) {
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
logger_1.logger.
|
|
652
|
-
|
|
741
|
+
const modeStr = mode.toLowerCase();
|
|
742
|
+
if (!this.modes.includes(modeStr)) {
|
|
743
|
+
logger_1.logger.debug(`Invalid humidity mode used - ${mode}`);
|
|
744
|
+
logger_1.logger.debug(`Proper modes for this device are - ${this.modes.join(', ')}`);
|
|
745
|
+
return false;
|
|
653
746
|
}
|
|
654
747
|
logger_1.logger.debug(`Setting mode to ${mode} for device: ${this.deviceName}`);
|
|
655
748
|
const [response, status] = await this.callApi('/cloud/v2/deviceManaged/bypassV2', 'post', {
|
|
@@ -658,7 +751,7 @@ class VeSyncHumidifier extends vesyncFan_1.VeSyncFan {
|
|
|
658
751
|
configModule: this.configModule,
|
|
659
752
|
payload: {
|
|
660
753
|
data: {
|
|
661
|
-
|
|
754
|
+
workMode: this.deviceType.startsWith('Superior') && modeStr === 'auto' ? 'autoPro' : modeStr
|
|
662
755
|
},
|
|
663
756
|
method: 'setHumidifierMode',
|
|
664
757
|
source: 'APP'
|
|
@@ -666,7 +759,7 @@ class VeSyncHumidifier extends vesyncFan_1.VeSyncFan {
|
|
|
666
759
|
}, helpers_1.Helpers.reqHeaderBypass());
|
|
667
760
|
const success = this.checkResponse([response, status], 'setMode');
|
|
668
761
|
if (!success) {
|
|
669
|
-
logger_1.logger.
|
|
762
|
+
logger_1.logger.debug('Error setting humidity mode');
|
|
670
763
|
}
|
|
671
764
|
return success;
|
|
672
765
|
}
|
|
@@ -896,7 +989,7 @@ class VeSyncWarmHumidifier extends VeSyncHumidifier {
|
|
|
896
989
|
// Add warm humidifier specific fields
|
|
897
990
|
this.details = {
|
|
898
991
|
...this.details,
|
|
899
|
-
warm_enabled: this.details.warm_level > 0,
|
|
992
|
+
warm_enabled: Boolean(this.details.warm_level && this.details.warm_level > 0),
|
|
900
993
|
drying_mode_enabled: this.details.autoDryingSwitch === 1,
|
|
901
994
|
drying_mode_state: this.details.dryingMode || '',
|
|
902
995
|
drying_mode_level: this.details.dryingLevel || 0,
|
|
@@ -916,10 +1009,11 @@ class VeSyncWarmHumidifier extends VeSyncHumidifier {
|
|
|
916
1009
|
* Set device mode
|
|
917
1010
|
*/
|
|
918
1011
|
async setMode(mode) {
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
logger_1.logger.
|
|
922
|
-
|
|
1012
|
+
const modeStr = mode.toLowerCase();
|
|
1013
|
+
if (!this.modes.includes(modeStr)) {
|
|
1014
|
+
logger_1.logger.debug(`Invalid humidity mode used - ${mode}`);
|
|
1015
|
+
logger_1.logger.debug(`Proper modes for this device are - ${this.modes.join(', ')}`);
|
|
1016
|
+
return false;
|
|
923
1017
|
}
|
|
924
1018
|
logger_1.logger.debug(`Setting mode to ${mode} for device: ${this.deviceName}`);
|
|
925
1019
|
const [response, status] = await this.callApi('/cloud/v2/deviceManaged/bypassV2', 'post', {
|
|
@@ -928,18 +1022,15 @@ class VeSyncWarmHumidifier extends VeSyncHumidifier {
|
|
|
928
1022
|
configModule: this.configModule,
|
|
929
1023
|
payload: {
|
|
930
1024
|
data: {
|
|
931
|
-
|
|
1025
|
+
workMode: this.deviceType.startsWith('Superior') && modeStr === 'auto' ? 'autoPro' : modeStr
|
|
932
1026
|
},
|
|
933
1027
|
method: 'setHumidifierMode',
|
|
934
1028
|
source: 'APP'
|
|
935
1029
|
}
|
|
936
1030
|
}, helpers_1.Helpers.reqHeaderBypass());
|
|
937
1031
|
const success = this.checkResponse([response, status], 'setMode');
|
|
938
|
-
if (success) {
|
|
939
|
-
|
|
940
|
-
}
|
|
941
|
-
else {
|
|
942
|
-
logger_1.logger.error(`Failed to set mode to ${mode} for device: ${this.deviceName}`);
|
|
1032
|
+
if (!success) {
|
|
1033
|
+
logger_1.logger.debug('Error setting humidity mode');
|
|
943
1034
|
}
|
|
944
1035
|
return success;
|
|
945
1036
|
}
|
|
@@ -948,14 +1039,13 @@ class VeSyncWarmHumidifier extends VeSyncHumidifier {
|
|
|
948
1039
|
*/
|
|
949
1040
|
async setWarmLevel(level) {
|
|
950
1041
|
if (!this.hasFeature('warm')) {
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
throw new Error(error);
|
|
1042
|
+
logger_1.logger.debug('Warm mist control not supported');
|
|
1043
|
+
return false;
|
|
954
1044
|
}
|
|
955
1045
|
if (!this.warmLevels.includes(level)) {
|
|
956
|
-
|
|
957
|
-
logger_1.logger.
|
|
958
|
-
|
|
1046
|
+
logger_1.logger.debug(`Invalid warm level: ${level} for device: ${this.deviceName}`);
|
|
1047
|
+
logger_1.logger.debug(`Valid levels for ${this.deviceType}: ${this.warmLevels.join(', ')}`);
|
|
1048
|
+
return false;
|
|
959
1049
|
}
|
|
960
1050
|
logger_1.logger.debug(`Setting warm level to ${level} for device: ${this.deviceName}`);
|
|
961
1051
|
const [response, status] = await this.callApi('/cloud/v2/deviceManaged/bypassV2', 'post', {
|
|
@@ -1062,7 +1152,10 @@ class VeSyncAirBaseV2 extends VeSyncAirBypass {
|
|
|
1062
1152
|
}
|
|
1063
1153
|
buildConfigDict(configDict) {
|
|
1064
1154
|
if (configDict) {
|
|
1065
|
-
this.config =
|
|
1155
|
+
this.config = {
|
|
1156
|
+
...this.config, // Preserve existing config
|
|
1157
|
+
...configDict // Merge in new config
|
|
1158
|
+
};
|
|
1066
1159
|
}
|
|
1067
1160
|
}
|
|
1068
1161
|
get mode() {
|
|
@@ -1091,6 +1184,7 @@ class VeSyncAirBaseV2 extends VeSyncAirBypass {
|
|
|
1091
1184
|
const body = {
|
|
1092
1185
|
...helpers_1.Helpers.reqBody(this.manager, 'bypassV2'),
|
|
1093
1186
|
cid: this.cid,
|
|
1187
|
+
deviceId: this.cid, // Add deviceId to match YAML spec
|
|
1094
1188
|
configModule: this.configModule,
|
|
1095
1189
|
payload: {
|
|
1096
1190
|
method,
|
|
@@ -1208,31 +1302,28 @@ class VeSyncAirBaseV2 extends VeSyncAirBypass {
|
|
|
1208
1302
|
* Change fan speed
|
|
1209
1303
|
*/
|
|
1210
1304
|
async changeFanSpeed(speed) {
|
|
1211
|
-
var _a
|
|
1212
|
-
const speeds = (
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
logger_1.logger.debug(`Invalid speed: ${speed}. Must be one of: ${speeds.join(', ')}`);
|
|
1217
|
-
return false;
|
|
1218
|
-
}
|
|
1305
|
+
var _a;
|
|
1306
|
+
const speeds = (_a = this.config.levels) !== null && _a !== void 0 ? _a : [];
|
|
1307
|
+
if (!speeds.includes(speed)) {
|
|
1308
|
+
logger_1.logger.error(`Invalid speed: ${speed}. Must be one of: ${speeds.join(', ')} for device: ${this.deviceName}`);
|
|
1309
|
+
return false;
|
|
1219
1310
|
}
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1311
|
+
logger_1.logger.info(`Changing fan speed to ${speed} for device: ${this.deviceName}`);
|
|
1312
|
+
const [response, status] = await this.callApi('/cloud/v2/deviceManaged/bypassV2', 'post', {
|
|
1313
|
+
...helpers_1.Helpers.reqBody(this.manager, 'bypassV2'),
|
|
1314
|
+
cid: this.cid,
|
|
1315
|
+
configModule: this.configModule,
|
|
1316
|
+
payload: {
|
|
1317
|
+
data: {
|
|
1318
|
+
id: 0,
|
|
1319
|
+
level: speed,
|
|
1320
|
+
mode: 'manual',
|
|
1321
|
+
type: 'wind'
|
|
1322
|
+
},
|
|
1323
|
+
method: 'setLevel',
|
|
1324
|
+
source: 'APP'
|
|
1227
1325
|
}
|
|
1228
|
-
}
|
|
1229
|
-
const [head, body] = this.buildApiDict('setLevel');
|
|
1230
|
-
body.payload.data = {
|
|
1231
|
-
levelIdx: 0,
|
|
1232
|
-
manualSpeedLevel: speed,
|
|
1233
|
-
levelType: 'wind'
|
|
1234
|
-
};
|
|
1235
|
-
const [response, status] = await this.callApi('/cloud/v2/deviceManaged/bypassV2', 'post', body, head);
|
|
1326
|
+
}, helpers_1.Helpers.reqHeaderBypass());
|
|
1236
1327
|
const success = this.checkResponse([response, status], 'changeFanSpeed');
|
|
1237
1328
|
if (success) {
|
|
1238
1329
|
this.setSpeedLevel = speed;
|
|
@@ -1419,22 +1510,23 @@ class VeSyncAirBaseV2 extends VeSyncAirBypass {
|
|
|
1419
1510
|
* Display JSON details
|
|
1420
1511
|
*/
|
|
1421
1512
|
displayJSON() {
|
|
1422
|
-
var _a, _b;
|
|
1513
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
|
|
1423
1514
|
const baseInfo = JSON.parse(super.displayJSON());
|
|
1424
1515
|
const details = {
|
|
1425
1516
|
...baseInfo,
|
|
1426
1517
|
'Mode': this.mode,
|
|
1427
|
-
'Filter Life': this.details.filter_life.toString(),
|
|
1518
|
+
'Filter Life': ((_a = this.details.filter_life) !== null && _a !== void 0 ? _a : 0).toString(),
|
|
1428
1519
|
'Fan Level': this.speed.toString(),
|
|
1429
|
-
'Display On': this.details.display.toString(),
|
|
1430
|
-
'Child Lock': this.details.child_lock.toString(),
|
|
1431
|
-
'
|
|
1432
|
-
'
|
|
1433
|
-
'
|
|
1520
|
+
'Display On': (_c = (_b = this.details.display) === null || _b === void 0 ? void 0 : _b.toString()) !== null && _c !== void 0 ? _c : 'false',
|
|
1521
|
+
'Child Lock': ((_d = this.details.child_lock) !== null && _d !== void 0 ? _d : false).toString(),
|
|
1522
|
+
'Night Light': ((_e = this.details.night_light) !== null && _e !== void 0 ? _e : '').toString(),
|
|
1523
|
+
'Display Set On': ((_f = this.details.screen_switch) !== null && _f !== void 0 ? _f : false).toString(),
|
|
1524
|
+
'Light Detection Enabled': ((_g = this.details.light_detection_switch) !== null && _g !== void 0 ? _g : false).toString(),
|
|
1525
|
+
'Environment Light State': ((_h = this.details.environment_light_state) !== null && _h !== void 0 ? _h : false).toString()
|
|
1434
1526
|
};
|
|
1435
1527
|
if (this.hasFeature('air_quality')) {
|
|
1436
|
-
details['Air Quality Level'] = ((
|
|
1437
|
-
details['Air Quality Value'] = ((
|
|
1528
|
+
details['Air Quality Level'] = ((_j = this.details.air_quality) !== null && _j !== void 0 ? _j : '').toString();
|
|
1529
|
+
details['Air Quality Value'] = ((_k = this.details.air_quality_value) !== null && _k !== void 0 ? _k : '').toString();
|
|
1438
1530
|
}
|
|
1439
1531
|
const everestKeys = {
|
|
1440
1532
|
'pm1': 'PM1',
|
|
@@ -1444,7 +1536,7 @@ class VeSyncAirBaseV2 extends VeSyncAirBypass {
|
|
|
1444
1536
|
};
|
|
1445
1537
|
for (const [key, value] of Object.entries(everestKeys)) {
|
|
1446
1538
|
if (key in this.details) {
|
|
1447
|
-
details[value] = this.details[key].toString();
|
|
1539
|
+
details[value] = (_m = (_l = this.details[key]) === null || _l === void 0 ? void 0 : _l.toString()) !== null && _m !== void 0 ? _m : '';
|
|
1448
1540
|
}
|
|
1449
1541
|
}
|
|
1450
1542
|
return JSON.stringify(details, null, 4);
|
|
@@ -1476,7 +1568,6 @@ class VeSyncTowerFan extends VeSyncAirBaseV2 {
|
|
|
1476
1568
|
constructor(details, manager) {
|
|
1477
1569
|
super(details, manager);
|
|
1478
1570
|
this.towerModes = ['normal', 'advancedSleep', 'off'];
|
|
1479
|
-
this.speeds = Array.from({ length: 12 }, (_, i) => i + 1);
|
|
1480
1571
|
logger_1.logger.debug(`Initialized VeSyncTowerFan device: ${this.deviceName}`);
|
|
1481
1572
|
}
|
|
1482
1573
|
/**
|
|
@@ -1502,6 +1593,7 @@ class VeSyncTowerFan extends VeSyncAirBaseV2 {
|
|
|
1502
1593
|
const body = {
|
|
1503
1594
|
...helpers_1.Helpers.reqBody(this.manager, 'bypassV2'),
|
|
1504
1595
|
cid: this.cid,
|
|
1596
|
+
deviceId: this.cid, // Add deviceId to match YAML spec
|
|
1505
1597
|
configModule: this.configModule,
|
|
1506
1598
|
payload: {
|
|
1507
1599
|
method,
|
|
@@ -1540,8 +1632,6 @@ class VeSyncTowerFan extends VeSyncAirBaseV2 {
|
|
|
1540
1632
|
screenSwitch: deviceData.screenSwitch,
|
|
1541
1633
|
oscillationState: deviceData.oscillationState,
|
|
1542
1634
|
oscillationSwitch: deviceData.oscillationSwitch,
|
|
1543
|
-
muteState: deviceData.muteState,
|
|
1544
|
-
muteSwitch: deviceData.muteSwitch,
|
|
1545
1635
|
timerRemain: deviceData.timerRemain,
|
|
1546
1636
|
temperature: deviceData.temperature || 0,
|
|
1547
1637
|
humidity: deviceData.humidity || 0,
|
|
@@ -1595,12 +1685,11 @@ class VeSyncTowerFan extends VeSyncAirBaseV2 {
|
|
|
1595
1685
|
* Set tower fan mode
|
|
1596
1686
|
*/
|
|
1597
1687
|
async mode_toggle(mode) {
|
|
1598
|
-
|
|
1599
|
-
|
|
1600
|
-
logger_1.logger.debug(`Invalid tower fan mode used - ${mode}`);
|
|
1688
|
+
if (!this.towerModes.includes(mode)) {
|
|
1689
|
+
logger_1.logger.debug(`Invalid mode: ${mode}. Must be one of: ${this.towerModes.join(', ')}`);
|
|
1601
1690
|
return false;
|
|
1602
1691
|
}
|
|
1603
|
-
if (mode
|
|
1692
|
+
if (mode === 'off') {
|
|
1604
1693
|
return this.turnOff();
|
|
1605
1694
|
}
|
|
1606
1695
|
const [head, body] = this.buildApiDict('setTowerFanMode');
|
|
@@ -1614,7 +1703,7 @@ class VeSyncTowerFan extends VeSyncAirBaseV2 {
|
|
|
1614
1703
|
this.details.workMode = mode;
|
|
1615
1704
|
}
|
|
1616
1705
|
else {
|
|
1617
|
-
logger_1.logger.
|
|
1706
|
+
logger_1.logger.error(`Failed to set ${mode} mode for device: ${this.deviceName}`);
|
|
1618
1707
|
}
|
|
1619
1708
|
return success;
|
|
1620
1709
|
}
|
|
@@ -1622,8 +1711,10 @@ class VeSyncTowerFan extends VeSyncAirBaseV2 {
|
|
|
1622
1711
|
* Change fan speed
|
|
1623
1712
|
*/
|
|
1624
1713
|
async changeFanSpeed(speed) {
|
|
1625
|
-
|
|
1626
|
-
|
|
1714
|
+
var _a;
|
|
1715
|
+
const speeds = (_a = this.config.levels) !== null && _a !== void 0 ? _a : [];
|
|
1716
|
+
if (!speeds.includes(speed)) {
|
|
1717
|
+
logger_1.logger.debug(`Invalid speed: ${speed}. Must be one of: ${speeds.join(', ')}`);
|
|
1627
1718
|
return false;
|
|
1628
1719
|
}
|
|
1629
1720
|
const [head, body] = this.buildApiDict('setLevel');
|