tsvesync 1.0.39 → 1.0.41

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.
@@ -76,6 +76,10 @@ export declare class VeSyncAirBypass extends VeSyncFan {
76
76
  * Turn on display
77
77
  */
78
78
  turnOnDisplay(): Promise<boolean>;
79
+ /**
80
+ * Display device info
81
+ */
82
+ display(): void;
79
83
  }
80
84
  /**
81
85
  * VeSync Humidifier Base Class
@@ -153,6 +157,10 @@ export declare class VeSyncHumidifier extends VeSyncFan {
153
157
  * Set manual mode
154
158
  */
155
159
  setManualMode(): Promise<boolean>;
160
+ /**
161
+ * Set sleep mode
162
+ */
163
+ sleepMode(): Promise<boolean>;
156
164
  /**
157
165
  * Turn off display
158
166
  */
@@ -235,7 +243,23 @@ export declare class VeSyncAirBaseV2 extends VeSyncAirBypass {
235
243
  /**
236
244
  * Set mode
237
245
  */
238
- protected mode_toggle(mode: string): Promise<boolean>;
246
+ mode_toggle(mode: string): Promise<boolean>;
247
+ /**
248
+ * Set manual mode
249
+ */
250
+ manual_mode(): Promise<boolean>;
251
+ /**
252
+ * Set sleep mode
253
+ */
254
+ sleep_mode(): Promise<boolean>;
255
+ /**
256
+ * Set auto mode
257
+ */
258
+ auto_mode(): Promise<boolean>;
259
+ /**
260
+ * Set turbo mode
261
+ */
262
+ turbo_mode(): Promise<boolean>;
239
263
  }
240
264
  /**
241
265
  * VeSync Tower Fan Implementation
@@ -336,6 +360,18 @@ export declare class VeSyncTowerFan extends VeSyncAirBaseV2 {
336
360
  * Get error code
337
361
  */
338
362
  get errorCode(): number;
363
+ /**
364
+ * Set oscillation state
365
+ */
366
+ setOscillation(toggle: boolean): Promise<boolean>;
367
+ /**
368
+ * Turn oscillation on
369
+ */
370
+ setOscillationOn(): Promise<boolean>;
371
+ /**
372
+ * Turn oscillation off
373
+ */
374
+ setOscillationOff(): Promise<boolean>;
339
375
  /**
340
376
  * Display device info
341
377
  */
@@ -460,6 +460,24 @@ class VeSyncAirBypass extends vesyncFan_1.VeSyncFan {
460
460
  }
461
461
  return success;
462
462
  }
463
+ /**
464
+ * Display device info
465
+ */
466
+ display() {
467
+ super.display();
468
+ const info = [
469
+ ['Mode: ', this.details.mode || ''],
470
+ ['Speed: ', this.speed],
471
+ ['Filter Life: ', this.filterLife || 0, '%'],
472
+ ['Air Quality: ', this.details.air_quality || ''],
473
+ ['Display: ', this.details.display || false],
474
+ ['Child Lock: ', this.details.child_lock || false],
475
+ ['Night Light: ', this.details.night_light || 'off']
476
+ ];
477
+ for (const [key, value, unit = ''] of info) {
478
+ logger_1.logger.info(`${key.toString().padEnd(30, '.')} ${value}${unit}`);
479
+ }
480
+ }
463
481
  }
464
482
  exports.VeSyncAirBypass = VeSyncAirBypass;
465
483
  /**
@@ -837,6 +855,17 @@ class VeSyncHumidifier extends vesyncFan_1.VeSyncFan {
837
855
  }
838
856
  return success;
839
857
  }
858
+ /**
859
+ * Set sleep mode
860
+ */
861
+ async sleepMode() {
862
+ logger_1.logger.debug(`Setting sleep mode for device: ${this.deviceName}`);
863
+ const success = await this.setMode('sleep');
864
+ if (!success) {
865
+ logger_1.logger.error(`Failed to set sleep mode for device: ${this.deviceName}`);
866
+ }
867
+ return success;
868
+ }
840
869
  /**
841
870
  * Turn off display
842
871
  */
@@ -1122,6 +1151,30 @@ class VeSyncAirBaseV2 extends VeSyncAirBypass {
1122
1151
  }
1123
1152
  return success;
1124
1153
  }
1154
+ /**
1155
+ * Set manual mode
1156
+ */
1157
+ async manual_mode() {
1158
+ return this.mode_toggle('manual');
1159
+ }
1160
+ /**
1161
+ * Set sleep mode
1162
+ */
1163
+ async sleep_mode() {
1164
+ return this.mode_toggle('sleep');
1165
+ }
1166
+ /**
1167
+ * Set auto mode
1168
+ */
1169
+ async auto_mode() {
1170
+ return this.mode_toggle('auto');
1171
+ }
1172
+ /**
1173
+ * Set turbo mode
1174
+ */
1175
+ async turbo_mode() {
1176
+ return this.mode_toggle('turbo');
1177
+ }
1125
1178
  }
1126
1179
  exports.VeSyncAirBaseV2 = VeSyncAirBaseV2;
1127
1180
  /**
@@ -1382,6 +1435,30 @@ class VeSyncTowerFan extends VeSyncAirBaseV2 {
1382
1435
  get errorCode() {
1383
1436
  return this.details.errorCode || 0;
1384
1437
  }
1438
+ /**
1439
+ * Set oscillation state
1440
+ */
1441
+ async setOscillation(toggle) {
1442
+ logger_1.logger.debug(`Setting oscillation to ${toggle ? 'on' : 'off'} for device: ${this.deviceName}`);
1443
+ const [head, body] = this.buildApiDict('setSwitch');
1444
+ body.payload.data = {
1445
+ oscillationSwitch: toggle ? 1 : 0
1446
+ };
1447
+ const [response, status] = await this.callApi('/cloud/v2/deviceManaged/bypassV2', 'post', body, head);
1448
+ return this.checkResponse([response, status], 'setOscillation');
1449
+ }
1450
+ /**
1451
+ * Turn oscillation on
1452
+ */
1453
+ async setOscillationOn() {
1454
+ return this.setOscillation(true);
1455
+ }
1456
+ /**
1457
+ * Turn oscillation off
1458
+ */
1459
+ async setOscillationOff() {
1460
+ return this.setOscillation(false);
1461
+ }
1385
1462
  /**
1386
1463
  * Display device info
1387
1464
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tsvesync",
3
- "version": "1.0.39",
3
+ "version": "1.0.41",
4
4
  "description": "A TypeScript library for interacting with VeSync smart home devices",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -573,6 +573,26 @@ export class VeSyncAirBypass extends VeSyncFan {
573
573
  }
574
574
  return success;
575
575
  }
576
+
577
+ /**
578
+ * Display device info
579
+ */
580
+ override display(): void {
581
+ super.display();
582
+ const info = [
583
+ ['Mode: ', this.details.mode || ''],
584
+ ['Speed: ', this.speed],
585
+ ['Filter Life: ', this.filterLife || 0, '%'],
586
+ ['Air Quality: ', this.details.air_quality || ''],
587
+ ['Display: ', this.details.display || false],
588
+ ['Child Lock: ', this.details.child_lock || false],
589
+ ['Night Light: ', this.details.night_light || 'off']
590
+ ];
591
+
592
+ for (const [key, value, unit = ''] of info) {
593
+ logger.info(`${key.toString().padEnd(30, '.')} ${value}${unit}`);
594
+ }
595
+ }
576
596
  }
577
597
 
578
598
  /**
@@ -1033,6 +1053,18 @@ export class VeSyncHumidifier extends VeSyncFan {
1033
1053
  return success;
1034
1054
  }
1035
1055
 
1056
+ /**
1057
+ * Set sleep mode
1058
+ */
1059
+ async sleepMode(): Promise<boolean> {
1060
+ logger.debug(`Setting sleep mode for device: ${this.deviceName}`);
1061
+ const success = await this.setMode('sleep');
1062
+ if (!success) {
1063
+ logger.error(`Failed to set sleep mode for device: ${this.deviceName}`);
1064
+ }
1065
+ return success;
1066
+ }
1067
+
1036
1068
  /**
1037
1069
  * Turn off display
1038
1070
  */
@@ -1346,7 +1378,7 @@ export class VeSyncAirBaseV2 extends VeSyncAirBypass {
1346
1378
  /**
1347
1379
  * Set mode
1348
1380
  */
1349
- protected async mode_toggle(mode: string): Promise<boolean> {
1381
+ public async mode_toggle(mode: string): Promise<boolean> {
1350
1382
  const validModes = this.modes.map(m => m.toLowerCase());
1351
1383
  if (!validModes.includes(mode.toLowerCase())) {
1352
1384
  logger.debug(`Invalid mode used - ${mode}`);
@@ -1377,6 +1409,34 @@ export class VeSyncAirBaseV2 extends VeSyncAirBypass {
1377
1409
  }
1378
1410
  return success;
1379
1411
  }
1412
+
1413
+ /**
1414
+ * Set manual mode
1415
+ */
1416
+ async manual_mode(): Promise<boolean> {
1417
+ return this.mode_toggle('manual');
1418
+ }
1419
+
1420
+ /**
1421
+ * Set sleep mode
1422
+ */
1423
+ async sleep_mode(): Promise<boolean> {
1424
+ return this.mode_toggle('sleep');
1425
+ }
1426
+
1427
+ /**
1428
+ * Set auto mode
1429
+ */
1430
+ async auto_mode(): Promise<boolean> {
1431
+ return this.mode_toggle('auto');
1432
+ }
1433
+
1434
+ /**
1435
+ * Set turbo mode
1436
+ */
1437
+ async turbo_mode(): Promise<boolean> {
1438
+ return this.mode_toggle('turbo');
1439
+ }
1380
1440
  }
1381
1441
 
1382
1442
  /**
@@ -1694,6 +1754,41 @@ export class VeSyncTowerFan extends VeSyncAirBaseV2 {
1694
1754
  return this.details.errorCode || 0;
1695
1755
  }
1696
1756
 
1757
+ /**
1758
+ * Set oscillation state
1759
+ */
1760
+ async setOscillation(toggle: boolean): Promise<boolean> {
1761
+ logger.debug(`Setting oscillation to ${toggle ? 'on' : 'off'} for device: ${this.deviceName}`);
1762
+
1763
+ const [head, body] = this.buildApiDict('setSwitch');
1764
+ body.payload.data = {
1765
+ oscillationSwitch: toggle ? 1 : 0
1766
+ };
1767
+
1768
+ const [response, status] = await this.callApi(
1769
+ '/cloud/v2/deviceManaged/bypassV2',
1770
+ 'post',
1771
+ body,
1772
+ head
1773
+ );
1774
+
1775
+ return this.checkResponse([response, status], 'setOscillation');
1776
+ }
1777
+
1778
+ /**
1779
+ * Turn oscillation on
1780
+ */
1781
+ async setOscillationOn(): Promise<boolean> {
1782
+ return this.setOscillation(true);
1783
+ }
1784
+
1785
+ /**
1786
+ * Turn oscillation off
1787
+ */
1788
+ async setOscillationOff(): Promise<boolean> {
1789
+ return this.setOscillation(false);
1790
+ }
1791
+
1697
1792
  /**
1698
1793
  * Display device info
1699
1794
  */