tsvesync 1.0.71 → 1.0.73

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.
@@ -314,6 +314,12 @@ class VeSyncAirBypass extends vesyncFan_1.VeSyncFan {
314
314
  return false;
315
315
  }
316
316
  }
317
+ // Special handling for Core200S auto mode
318
+ if (this.deviceType.includes('Core200S') && mode === 'auto') {
319
+ // Core200S doesn't support auto mode, so we'll set it to manual mode
320
+ logger_1.logger.warn(`Auto mode not supported for ${this.deviceType}, using manual mode instead`);
321
+ return this.setMode('manual');
322
+ }
317
323
  // Standard implementation for other devices
318
324
  const [response, status] = await this.callApi('/cloud/v2/deviceManaged/bypassV2', 'post', {
319
325
  ...helpers_1.Helpers.reqBody(this.manager, 'bypassV2'),
@@ -328,20 +334,29 @@ class VeSyncAirBypass extends vesyncFan_1.VeSyncFan {
328
334
  }
329
335
  }, helpers_1.Helpers.reqHeaderBypass());
330
336
  const success = this.checkResponse([response, status], 'setMode');
331
- if (!success) {
337
+ if (success) {
338
+ this.details.mode = mode;
339
+ return true;
340
+ }
341
+ else {
332
342
  logger_1.logger.error(`Failed to set mode to ${mode} for device: ${this.deviceName}`);
343
+ return false;
333
344
  }
334
- return success;
335
345
  }
336
346
  /**
337
347
  * Set display status
338
348
  */
339
349
  async setDisplay(enabled) {
350
+ var _a;
340
351
  if (!this.hasFeature('display')) {
341
352
  const error = 'Display control not supported';
342
353
  logger_1.logger.error(`${error} for device: ${this.deviceName}`);
343
354
  throw new Error(error);
344
355
  }
356
+ // Check if device is in sleep mode - display control may not work in sleep mode
357
+ if (this.details.mode === 'sleep') {
358
+ logger_1.logger.warn(`Device ${this.deviceName} is in sleep mode, display control may not work`);
359
+ }
345
360
  logger_1.logger.debug(`Setting display to ${enabled ? 'on' : 'off'} for device: ${this.deviceName}`);
346
361
  // Special handling for LV series
347
362
  if (this.deviceType.startsWith('LV-')) {
@@ -384,23 +399,34 @@ class VeSyncAirBypass extends vesyncFan_1.VeSyncFan {
384
399
  }
385
400
  }, helpers_1.Helpers.reqHeaderBypass());
386
401
  const success = this.checkResponse([response, status], 'setDisplay');
402
+ // Check for error code 11018000 (operation not supported in current mode)
403
+ if (((_a = response === null || response === void 0 ? void 0 : response.result) === null || _a === void 0 ? void 0 : _a.code) === 11018000) {
404
+ logger_1.logger.warn(`Display control not supported in current mode for device: ${this.deviceName}`);
405
+ return false;
406
+ }
387
407
  if (success) {
388
408
  this.details.screenStatus = enabled ? 'on' : 'off';
409
+ return true;
389
410
  }
390
411
  else {
391
412
  logger_1.logger.error(`Failed to set display to ${enabled ? 'on' : 'off'} for device: ${this.deviceName}`);
413
+ return false;
392
414
  }
393
- return success;
394
415
  }
395
416
  /**
396
417
  * Set child lock
397
418
  */
398
419
  async setChildLock(enabled) {
420
+ var _a;
399
421
  if (!this.hasFeature('child_lock')) {
400
422
  const error = 'Child lock not supported';
401
423
  logger_1.logger.error(`${error} for device: ${this.deviceName}`);
402
424
  throw new Error(error);
403
425
  }
426
+ // Check if device is in sleep mode - child lock may not work in sleep mode
427
+ if (this.details.mode === 'sleep') {
428
+ logger_1.logger.warn(`Device ${this.deviceName} is in sleep mode, child lock control may not work`);
429
+ }
404
430
  logger_1.logger.debug(`Setting child lock to ${enabled ? 'on' : 'off'} for device: ${this.deviceName}`);
405
431
  // Special handling for LV series
406
432
  if (this.deviceType.startsWith('LV-')) {
@@ -425,6 +451,11 @@ class VeSyncAirBypass extends vesyncFan_1.VeSyncFan {
425
451
  return true;
426
452
  }
427
453
  else {
454
+ // Check for error code 11000000 (feature not supported)
455
+ if ((response === null || response === void 0 ? void 0 : response.code) === 11000000) {
456
+ logger_1.logger.warn(`Child lock control not supported via API for device: ${this.deviceName}`);
457
+ return false;
458
+ }
428
459
  logger_1.logger.error(`Failed to set child lock to ${enabled ? 'on' : 'off'} for device: ${this.deviceName}`);
429
460
  return false;
430
461
  }
@@ -443,18 +474,25 @@ class VeSyncAirBypass extends vesyncFan_1.VeSyncFan {
443
474
  }
444
475
  }, helpers_1.Helpers.reqHeaderBypass());
445
476
  const success = this.checkResponse([response, status], 'setChildLock');
477
+ // Check for error code 11000000 (feature not supported)
478
+ if ((response === null || response === void 0 ? void 0 : response.code) === 11000000 || (((_a = response === null || response === void 0 ? void 0 : response.result) === null || _a === void 0 ? void 0 : _a.code) === 11000000)) {
479
+ logger_1.logger.warn(`Child lock control not supported via API for device: ${this.deviceName}`);
480
+ return false;
481
+ }
446
482
  if (success) {
447
- this.details.child_lock = enabled;
483
+ this.details.childLock = enabled;
484
+ return true;
448
485
  }
449
486
  else {
450
487
  logger_1.logger.error(`Failed to set child lock to ${enabled ? 'on' : 'off'} for device: ${this.deviceName}`);
488
+ return false;
451
489
  }
452
- return success;
453
490
  }
454
491
  /**
455
492
  * Set timer
456
493
  */
457
494
  async setTimer(hours) {
495
+ var _a, _b;
458
496
  if (!this.hasFeature('timer')) {
459
497
  const error = 'Timer not supported';
460
498
  logger_1.logger.error(`${error} for device: ${this.deviceName}`);
@@ -480,10 +518,14 @@ class VeSyncAirBypass extends vesyncFan_1.VeSyncFan {
480
518
  'tz': this.manager.timeZone
481
519
  });
482
520
  const success = this.checkResponse([response, status], 'setTimer');
483
- if (!success) {
521
+ if (success) {
522
+ this.timer = { duration: hours * 3600, action: 'off' };
523
+ return true;
524
+ }
525
+ else {
484
526
  logger_1.logger.error(`Failed to set timer to ${hours} hours for device: ${this.deviceName}`);
527
+ return false;
485
528
  }
486
- return success;
487
529
  }
488
530
  // Standard implementation for other devices
489
531
  const [response, status] = await this.callApi('/cloud/v2/deviceManaged/bypassV2', 'post', {
@@ -500,20 +542,37 @@ class VeSyncAirBypass extends vesyncFan_1.VeSyncFan {
500
542
  }
501
543
  }, helpers_1.Helpers.reqHeaderBypass());
502
544
  const success = this.checkResponse([response, status], 'setTimer');
503
- if (!success) {
545
+ // Check for successful response with timer ID
546
+ if (success && ((_b = (_a = response === null || response === void 0 ? void 0 : response.result) === null || _a === void 0 ? void 0 : _a.result) === null || _b === void 0 ? void 0 : _b.id)) {
547
+ this.timer = { duration: hours * 3600, action: 'off' };
548
+ return true;
549
+ }
550
+ else if (success) {
551
+ // API call succeeded but no timer ID returned
552
+ logger_1.logger.warn(`Timer API call succeeded but no timer ID returned for device: ${this.deviceName}`);
553
+ this.timer = { duration: hours * 3600, action: 'off' };
554
+ return true;
555
+ }
556
+ else {
504
557
  logger_1.logger.error(`Failed to set timer to ${hours} hours for device: ${this.deviceName}`);
558
+ return false;
505
559
  }
506
- return success;
507
560
  }
508
561
  /**
509
562
  * Clear timer
510
563
  */
511
564
  async clearTimer() {
565
+ var _a;
512
566
  if (!this.hasFeature('timer')) {
513
567
  const error = 'Timer not supported';
514
568
  logger_1.logger.error(`${error} for device: ${this.deviceName}`);
515
569
  throw new Error(error);
516
570
  }
571
+ // If no timer is set, return success
572
+ if (!this.timer) {
573
+ logger_1.logger.debug(`No timer to clear for device: ${this.deviceName}`);
574
+ return true;
575
+ }
517
576
  logger_1.logger.debug(`Clearing timer for device: ${this.deviceName}`);
518
577
  // Special handling for LV series
519
578
  if (this.deviceType.startsWith('LV-')) {
@@ -532,10 +591,14 @@ class VeSyncAirBypass extends vesyncFan_1.VeSyncFan {
532
591
  'tz': this.manager.timeZone
533
592
  });
534
593
  const success = this.checkResponse([response, status], 'clearTimer');
535
- if (!success) {
594
+ if (success) {
595
+ this.timer = null;
596
+ return true;
597
+ }
598
+ else {
536
599
  logger_1.logger.error(`Failed to clear timer for device: ${this.deviceName}`);
600
+ return false;
537
601
  }
538
- return success;
539
602
  }
540
603
  // Standard implementation for other devices
541
604
  const [response, status] = await this.callApi('/cloud/v2/deviceManaged/bypassV2', 'post', {
@@ -549,10 +612,20 @@ class VeSyncAirBypass extends vesyncFan_1.VeSyncFan {
549
612
  }
550
613
  }, helpers_1.Helpers.reqHeaderBypass());
551
614
  const success = this.checkResponse([response, status], 'clearTimer');
552
- if (!success) {
615
+ // Check for error code 11000000 (feature not supported or no timer to clear)
616
+ if ((response === null || response === void 0 ? void 0 : response.code) === 11000000 || (((_a = response === null || response === void 0 ? void 0 : response.result) === null || _a === void 0 ? void 0 : _a.code) === 11000000)) {
617
+ logger_1.logger.warn(`No timer to clear or timer control not supported via API for device: ${this.deviceName}`);
618
+ this.timer = null;
619
+ return true;
620
+ }
621
+ if (success) {
622
+ this.timer = null;
623
+ return true;
624
+ }
625
+ else {
553
626
  logger_1.logger.error(`Failed to clear timer for device: ${this.deviceName}`);
627
+ return false;
554
628
  }
555
- return success;
556
629
  }
557
630
  /**
558
631
  * Turn automatic stop on
@@ -0,0 +1,70 @@
1
+ import { VeSyncHumid200300S } from './humid200300S';
2
+ import { VeSync } from '../vesync';
3
+ /**
4
+ * VeSync Humid1000S Humidifier Class
5
+ * Implementation based on PyVeSync's VeSyncHumid1000S class
6
+ * For OASISMIST1000S models (LUH-M101S-WUS and LUH-M101S-WEUR)
7
+ */
8
+ export declare class VeSyncHumid1000S extends VeSyncHumid200300S {
9
+ protected readonly _apiModes: string[];
10
+ constructor(details: Record<string, any>, manager: VeSync);
11
+ /**
12
+ * Build API dictionary for humidifier
13
+ */
14
+ protected buildApiDict(method: string): [Record<string, any>, Record<string, any>];
15
+ /**
16
+ * Get device details
17
+ */
18
+ getDetails(): Promise<Boolean>;
19
+ /**
20
+ * Turn device on
21
+ */
22
+ turnOn(): Promise<boolean>;
23
+ /**
24
+ * Turn device off
25
+ */
26
+ turnOff(): Promise<boolean>;
27
+ /**
28
+ * Toggle device power
29
+ */
30
+ toggleSwitch(enabled: boolean): Promise<boolean>;
31
+ /**
32
+ * Set night light
33
+ */
34
+ setNightLight(enabled: boolean, brightness?: number): Promise<boolean>;
35
+ /**
36
+ * Get night light status
37
+ * Returns the night light status (on/off)
38
+ */
39
+ get nightLightStatus(): string;
40
+ /**
41
+ * Get night light brightness
42
+ * Returns the night light brightness (0-100)
43
+ */
44
+ get nightLightBrightness(): number;
45
+ /**
46
+ * Set automatic stop
47
+ * Enable or disable automatic stop when target humidity is reached
48
+ */
49
+ setAutomaticStop(enabled: boolean): Promise<boolean>;
50
+ /**
51
+ * Turn automatic stop on
52
+ * Enable automatic stop when target humidity is reached
53
+ */
54
+ automaticStopOn(): Promise<boolean>;
55
+ /**
56
+ * Turn automatic stop off
57
+ * Disable automatic stop when target humidity is reached
58
+ */
59
+ automaticStopOff(): Promise<boolean>;
60
+ /**
61
+ * Get target humidity
62
+ * Returns the target humidity setting
63
+ */
64
+ get targetHumidity(): number;
65
+ /**
66
+ * Get automatic stop setting
67
+ * Returns whether automatic stop is enabled
68
+ */
69
+ get automaticStop(): boolean;
70
+ }
@@ -0,0 +1,222 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.VeSyncHumid1000S = void 0;
4
+ const humid200300S_1 = require("./humid200300S");
5
+ const helpers_1 = require("../helpers");
6
+ const logger_1 = require("../logger");
7
+ /**
8
+ * VeSync Humid1000S Humidifier Class
9
+ * Implementation based on PyVeSync's VeSyncHumid1000S class
10
+ * For OASISMIST1000S models (LUH-M101S-WUS and LUH-M101S-WEUR)
11
+ */
12
+ class VeSyncHumid1000S extends humid200300S_1.VeSyncHumid200300S {
13
+ constructor(details, manager) {
14
+ super(details, manager);
15
+ this._apiModes = [
16
+ 'getHumidifierStatus',
17
+ 'setSwitch',
18
+ 'setVirtualLevel',
19
+ 'setTargetHumidity',
20
+ 'setHumidityMode',
21
+ 'setDisplay',
22
+ 'setNightLight',
23
+ 'setAutoStopSwitch',
24
+ ];
25
+ // Update config for Humid1000S
26
+ this.config = {
27
+ module: 'VeSyncHumid1000S',
28
+ features: ['display', 'humidity', 'mist', 'timer', 'auto_mode', 'night_light'],
29
+ levels: [1, 2, 3, 4, 5, 6, 7, 8, 9]
30
+ };
31
+ logger_1.logger.debug(`Initialized VeSyncHumid1000S device: ${this.deviceName}`);
32
+ }
33
+ /**
34
+ * Build API dictionary for humidifier
35
+ */
36
+ buildApiDict(method) {
37
+ if (!this._apiModes.includes(method)) {
38
+ logger_1.logger.debug(`Invalid mode - ${method}`);
39
+ throw new Error(`Invalid mode - ${method}`);
40
+ }
41
+ const head = helpers_1.Helpers.reqHeaderBypass();
42
+ const body = {
43
+ ...helpers_1.Helpers.reqBody(this.manager, 'bypassV2'),
44
+ cid: this.cid,
45
+ configModule: this.configModule,
46
+ payload: {
47
+ method: method,
48
+ source: 'APP',
49
+ data: {}
50
+ }
51
+ };
52
+ return [head, body];
53
+ }
54
+ /**
55
+ * Get device details
56
+ */
57
+ async getDetails() {
58
+ var _a;
59
+ logger_1.logger.debug(`Getting details for device: ${this.deviceName}`);
60
+ const [head, body] = this.buildApiDict('getHumidifierStatus');
61
+ const [response, status] = await this.callApi('/cloud/v2/deviceManaged/bypassV2', 'post', body, head);
62
+ const success = this.checkResponse([response, status], 'getDetails');
63
+ if (success && ((_a = response === null || response === void 0 ? void 0 : response.result) === null || _a === void 0 ? void 0 : _a.result)) {
64
+ const result = response.result.result;
65
+ // Update device status based on powerSwitch field
66
+ this.deviceStatus = result.powerSwitch === 1 ? 'on' : 'off';
67
+ // Build details object with Humid1000S specific fields
68
+ this.details = {
69
+ mode: result.workMode || '',
70
+ humidity: result.humidity || 0,
71
+ target_humidity: result.targetHumidity || 0,
72
+ mist_level: result.mistLevel || 0,
73
+ mist_virtual_level: result.virtualLevel || 0,
74
+ water_lacks: result.waterLacksState || false,
75
+ water_tank_lifted: result.waterTankLifted || false,
76
+ display: result.screenSwitch === 1,
77
+ night_light_status: result.nightLightStatus || 'off',
78
+ night_light_brightness: result.nightLightBrightness || 0,
79
+ connection_status: result.connectionStatus || null,
80
+ configuration: result.configuration || {}
81
+ };
82
+ logger_1.logger.debug(`Successfully got details for device: ${this.deviceName}`);
83
+ }
84
+ return success;
85
+ }
86
+ /**
87
+ * Turn device on
88
+ */
89
+ async turnOn() {
90
+ return this.toggleSwitch(true);
91
+ }
92
+ /**
93
+ * Turn device off
94
+ */
95
+ async turnOff() {
96
+ return this.toggleSwitch(false);
97
+ }
98
+ /**
99
+ * Toggle device power
100
+ */
101
+ async toggleSwitch(enabled) {
102
+ logger_1.logger.info(`Setting device power to ${enabled ? 'on' : 'off'}: ${this.deviceName}`);
103
+ const [head, body] = this.buildApiDict('setSwitch');
104
+ body.payload.data = {
105
+ powerSwitch: enabled ? 1 : 0,
106
+ switchIdx: 0
107
+ };
108
+ const [response, status] = await this.callApi('/cloud/v2/deviceManaged/bypassV2', 'post', body, head);
109
+ const success = this.checkResponse([response, status], 'toggleSwitch');
110
+ if (success) {
111
+ this.deviceStatus = enabled ? 'on' : 'off';
112
+ return true;
113
+ }
114
+ logger_1.logger.error(`Failed to set device power to ${enabled ? 'on' : 'off'} for device: ${this.deviceName}`);
115
+ return false;
116
+ }
117
+ /**
118
+ * Set night light
119
+ */
120
+ async setNightLight(enabled, brightness) {
121
+ if (!this.hasFeature('night_light')) {
122
+ logger_1.logger.error(`Night light feature not supported for device: ${this.deviceName}`);
123
+ return false;
124
+ }
125
+ logger_1.logger.debug(`Setting night light to ${enabled ? 'on' : 'off'} for device: ${this.deviceName}`);
126
+ const [head, body] = this.buildApiDict('setNightLight');
127
+ body.payload.data = {
128
+ nightLightSwitch: enabled ? 1 : 0
129
+ };
130
+ // Add brightness if provided
131
+ if (enabled && brightness !== undefined) {
132
+ if (brightness < 1 || brightness > 100) {
133
+ logger_1.logger.error(`Invalid night light brightness: ${brightness}. Must be between 1 and 100.`);
134
+ return false;
135
+ }
136
+ body.payload.data.nightLightBrightness = brightness;
137
+ }
138
+ const [response, status] = await this.callApi('/cloud/v2/deviceManaged/bypassV2', 'post', body, head);
139
+ const success = this.checkResponse([response, status], 'setNightLight');
140
+ if (success) {
141
+ this.details.night_light_status = enabled ? 'on' : 'off';
142
+ if (enabled && brightness !== undefined) {
143
+ this.details.night_light_brightness = brightness;
144
+ }
145
+ return true;
146
+ }
147
+ // Check for API error code 11000000 (feature not supported)
148
+ if ((response === null || response === void 0 ? void 0 : response.code) === 11000000) {
149
+ logger_1.logger.warn(`Night light control not supported via API for device: ${this.deviceName}`);
150
+ return false;
151
+ }
152
+ logger_1.logger.error(`Failed to set night light for device: ${this.deviceName}`);
153
+ return false;
154
+ }
155
+ // Connection status is available in details.connection_status
156
+ /**
157
+ * Get night light status
158
+ * Returns the night light status (on/off)
159
+ */
160
+ get nightLightStatus() {
161
+ return this.details.night_light_status || 'off';
162
+ }
163
+ /**
164
+ * Get night light brightness
165
+ * Returns the night light brightness (0-100)
166
+ */
167
+ get nightLightBrightness() {
168
+ return this.details.night_light_brightness || 0;
169
+ }
170
+ /**
171
+ * Set automatic stop
172
+ * Enable or disable automatic stop when target humidity is reached
173
+ */
174
+ async setAutomaticStop(enabled) {
175
+ logger_1.logger.debug(`Setting automatic stop to ${enabled ? 'enabled' : 'disabled'} for device: ${this.deviceName}`);
176
+ const [head, body] = this.buildApiDict('setAutoStopSwitch');
177
+ body.payload.data = {
178
+ autoStopSwitch: enabled ? 1 : 0
179
+ };
180
+ const [response, status] = await this.callApi('/cloud/v2/deviceManaged/bypassV2', 'post', body, head);
181
+ const success = this.checkResponse([response, status], 'setAutomaticStop');
182
+ if (success) {
183
+ if (!this.details.configuration) {
184
+ this.details.configuration = {};
185
+ }
186
+ this.details.configuration.automatic_stop = enabled;
187
+ return true;
188
+ }
189
+ logger_1.logger.error(`Failed to set automatic stop for device: ${this.deviceName}`);
190
+ return false;
191
+ }
192
+ /**
193
+ * Turn automatic stop on
194
+ * Enable automatic stop when target humidity is reached
195
+ */
196
+ async automaticStopOn() {
197
+ return this.setAutomaticStop(true);
198
+ }
199
+ /**
200
+ * Turn automatic stop off
201
+ * Disable automatic stop when target humidity is reached
202
+ */
203
+ async automaticStopOff() {
204
+ return this.setAutomaticStop(false);
205
+ }
206
+ /**
207
+ * Get target humidity
208
+ * Returns the target humidity setting
209
+ */
210
+ get targetHumidity() {
211
+ return this.details.target_humidity || 0;
212
+ }
213
+ /**
214
+ * Get automatic stop setting
215
+ * Returns whether automatic stop is enabled
216
+ */
217
+ get automaticStop() {
218
+ var _a;
219
+ return ((_a = this.details.configuration) === null || _a === void 0 ? void 0 : _a.automatic_stop) || false;
220
+ }
221
+ }
222
+ exports.VeSyncHumid1000S = VeSyncHumid1000S;
@@ -0,0 +1,52 @@
1
+ import { VeSyncHumidifier } from './humidifier';
2
+ import { VeSync } from '../vesync';
3
+ /**
4
+ * VeSync Humid200S Humidifier Class
5
+ * Implementation based on PyVeSync's VeSyncHumid200S class
6
+ * For Classic200S models
7
+ */
8
+ export declare class VeSyncHumid200S extends VeSyncHumidifier {
9
+ protected readonly modes: readonly ["auto", "manual", "sleep"];
10
+ protected readonly features: string[];
11
+ protected readonly mistLevels: number[];
12
+ protected readonly humidityRange: {
13
+ min: number;
14
+ max: number;
15
+ };
16
+ constructor(details: Record<string, any>, manager: VeSync);
17
+ /**
18
+ * Get device details
19
+ */
20
+ getDetails(): Promise<Boolean>;
21
+ /**
22
+ * Set display
23
+ * Override to use setIndicatorLightSwitch method
24
+ */
25
+ setDisplay(enabled: boolean): Promise<boolean>;
26
+ /**
27
+ * Set mist level
28
+ */
29
+ setMistLevel(level: number): Promise<boolean>;
30
+ /**
31
+ * Get current humidity
32
+ * Provides access to the current humidity reading
33
+ */
34
+ get currentHumidity(): number;
35
+ /**
36
+ * Get target humidity
37
+ */
38
+ get targetHumidity(): number;
39
+ /**
40
+ * Get water lacks status
41
+ */
42
+ get waterLacks(): boolean;
43
+ /**
44
+ * Get water tank lifted status
45
+ */
46
+ get waterTankLifted(): boolean;
47
+ /**
48
+ * Return JSON details for humidifier
49
+ * Override to include current humidity and target humidity
50
+ */
51
+ displayJSON(): string;
52
+ }