tsvesync 1.0.22 → 1.0.24

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.
@@ -26,7 +26,7 @@ export class VeSyncAirBypass extends VeSyncFan {
26
26
  */
27
27
  async getDetails(): Promise<void> {
28
28
  logger.debug(`Getting details for device: ${this.deviceName}`);
29
- const [response, status] = await Helpers.callApi(
29
+ const [response, status] = await this.callApi(
30
30
  '/cloud/v2/deviceManaged/bypassV2',
31
31
  'post',
32
32
  {
@@ -74,7 +74,7 @@ export class VeSyncAirBypass extends VeSyncFan {
74
74
  */
75
75
  async turnOn(): Promise<boolean> {
76
76
  logger.debug(`Turning on device: ${this.deviceName}`);
77
- const [response, status] = await Helpers.callApi(
77
+ const [response, status] = await this.callApi(
78
78
  '/cloud/v2/deviceManaged/bypassV2',
79
79
  'post',
80
80
  {
@@ -105,7 +105,7 @@ export class VeSyncAirBypass extends VeSyncFan {
105
105
  */
106
106
  async turnOff(): Promise<boolean> {
107
107
  logger.debug(`Turning off device: ${this.deviceName}`);
108
- const [response, status] = await Helpers.callApi(
108
+ const [response, status] = await this.callApi(
109
109
  '/cloud/v2/deviceManaged/bypassV2',
110
110
  'post',
111
111
  {
@@ -142,7 +142,7 @@ export class VeSyncAirBypass extends VeSyncFan {
142
142
  }
143
143
 
144
144
  logger.debug(`Changing fan speed to ${speed} for device: ${this.deviceName}`);
145
- const [response, status] = await Helpers.callApi(
145
+ const [response, status] = await this.callApi(
146
146
  '/cloud/v2/deviceManaged/bypassV2',
147
147
  'post',
148
148
  {
@@ -181,7 +181,7 @@ export class VeSyncAirBypass extends VeSyncFan {
181
181
  }
182
182
 
183
183
  logger.debug(`Setting mode to ${mode} for device: ${this.deviceName}`);
184
- const [response, status] = await Helpers.callApi(
184
+ const [response, status] = await this.callApi(
185
185
  '/cloud/v2/deviceManaged/bypassV2',
186
186
  'post',
187
187
  {
@@ -217,7 +217,7 @@ export class VeSyncAirBypass extends VeSyncFan {
217
217
  }
218
218
 
219
219
  logger.debug(`Setting display to ${enabled ? 'on' : 'off'} for device: ${this.deviceName}`);
220
- const [response, status] = await Helpers.callApi(
220
+ const [response, status] = await this.callApi(
221
221
  '/cloud/v2/deviceManaged/bypassV2',
222
222
  'post',
223
223
  {
@@ -253,7 +253,7 @@ export class VeSyncAirBypass extends VeSyncFan {
253
253
  }
254
254
 
255
255
  logger.debug(`Setting child lock to ${enabled ? 'on' : 'off'} for device: ${this.deviceName}`);
256
- const [response, status] = await Helpers.callApi(
256
+ const [response, status] = await this.callApi(
257
257
  '/cloud/v2/deviceManaged/bypassV2',
258
258
  'post',
259
259
  {
@@ -289,7 +289,7 @@ export class VeSyncAirBypass extends VeSyncFan {
289
289
  }
290
290
 
291
291
  logger.debug(`Setting timer to ${hours} hours for device: ${this.deviceName}`);
292
- const [response, status] = await Helpers.callApi(
292
+ const [response, status] = await this.callApi(
293
293
  '/cloud/v2/deviceManaged/bypassV2',
294
294
  'post',
295
295
  {
@@ -326,7 +326,7 @@ export class VeSyncAirBypass extends VeSyncFan {
326
326
  }
327
327
 
328
328
  logger.debug(`Clearing timer for device: ${this.deviceName}`);
329
- const [response, status] = await Helpers.callApi(
329
+ const [response, status] = await this.callApi(
330
330
  '/cloud/v2/deviceManaged/bypassV2',
331
331
  'post',
332
332
  {
@@ -354,7 +354,7 @@ export class VeSyncAirBypass extends VeSyncFan {
354
354
  */
355
355
  async automaticStopOn(): Promise<boolean> {
356
356
  logger.debug(`Setting automatic stop on for device: ${this.deviceName}`);
357
- const [response, status] = await Helpers.callApi(
357
+ const [response, status] = await this.callApi(
358
358
  '/cloud/v2/deviceManaged/bypassV2',
359
359
  'post',
360
360
  {
@@ -384,7 +384,7 @@ export class VeSyncAirBypass extends VeSyncFan {
384
384
  */
385
385
  async automaticStopOff(): Promise<boolean> {
386
386
  logger.debug(`Setting automatic stop off for device: ${this.deviceName}`);
387
- const [response, status] = await Helpers.callApi(
387
+ const [response, status] = await this.callApi(
388
388
  '/cloud/v2/deviceManaged/bypassV2',
389
389
  'post',
390
390
  {
@@ -490,7 +490,7 @@ export class VeSyncHumidifier extends VeSyncFan {
490
490
  */
491
491
  async getDetails(): Promise<void> {
492
492
  logger.debug(`Getting details for device: ${this.deviceName}`);
493
- const [response, status] = await Helpers.callApi(
493
+ const [response, status] = await this.callApi(
494
494
  '/cloud/v2/deviceManaged/bypassV2',
495
495
  'post',
496
496
  {
@@ -520,7 +520,7 @@ export class VeSyncHumidifier extends VeSyncFan {
520
520
  */
521
521
  async turnOn(): Promise<boolean> {
522
522
  logger.debug(`Turning on device: ${this.deviceName}`);
523
- const [response, status] = await Helpers.callApi(
523
+ const [response, status] = await this.callApi(
524
524
  '/cloud/v2/deviceManaged/bypassV2',
525
525
  'post',
526
526
  {
@@ -551,7 +551,7 @@ export class VeSyncHumidifier extends VeSyncFan {
551
551
  */
552
552
  async turnOff(): Promise<boolean> {
553
553
  logger.debug(`Turning off device: ${this.deviceName}`);
554
- const [response, status] = await Helpers.callApi(
554
+ const [response, status] = await this.callApi(
555
555
  '/cloud/v2/deviceManaged/bypassV2',
556
556
  'post',
557
557
  {
@@ -588,7 +588,7 @@ export class VeSyncHumidifier extends VeSyncFan {
588
588
  }
589
589
 
590
590
  logger.debug(`Changing fan speed to ${speed} for device: ${this.deviceName}`);
591
- const [response, status] = await Helpers.callApi(
591
+ const [response, status] = await this.callApi(
592
592
  '/cloud/v2/deviceManaged/bypassV2',
593
593
  'post',
594
594
  {
@@ -626,7 +626,7 @@ export class VeSyncHumidifier extends VeSyncFan {
626
626
  }
627
627
 
628
628
  logger.debug(`Setting mode to ${mode} for device: ${this.deviceName}`);
629
- const [response, status] = await Helpers.callApi(
629
+ const [response, status] = await this.callApi(
630
630
  '/cloud/v2/deviceManaged/bypassV2',
631
631
  'post',
632
632
  {
@@ -668,7 +668,7 @@ export class VeSyncHumidifier extends VeSyncFan {
668
668
  }
669
669
 
670
670
  logger.debug(`Setting mist level to ${level} for device: ${this.deviceName}`);
671
- const [response, status] = await Helpers.callApi(
671
+ const [response, status] = await this.callApi(
672
672
  '/cloud/v2/deviceManaged/bypassV2',
673
673
  'post',
674
674
  {
@@ -710,7 +710,7 @@ export class VeSyncHumidifier extends VeSyncFan {
710
710
  }
711
711
 
712
712
  logger.debug(`Setting target humidity to ${humidity}% for device: ${this.deviceName}`);
713
- const [response, status] = await Helpers.callApi(
713
+ const [response, status] = await this.callApi(
714
714
  '/cloud/v2/deviceManaged/bypassV2',
715
715
  'post',
716
716
  {
@@ -746,7 +746,7 @@ export class VeSyncHumidifier extends VeSyncFan {
746
746
  }
747
747
 
748
748
  logger.debug(`Setting display to ${enabled ? 'on' : 'off'} for device: ${this.deviceName}`);
749
- const [response, status] = await Helpers.callApi(
749
+ const [response, status] = await this.callApi(
750
750
  '/cloud/v2/deviceManaged/bypassV2',
751
751
  'post',
752
752
  {
@@ -782,7 +782,7 @@ export class VeSyncHumidifier extends VeSyncFan {
782
782
  }
783
783
 
784
784
  logger.debug(`Setting timer to ${hours} hours for device: ${this.deviceName}`);
785
- const [response, status] = await Helpers.callApi(
785
+ const [response, status] = await this.callApi(
786
786
  '/cloud/v2/deviceManaged/bypassV2',
787
787
  'post',
788
788
  {
@@ -819,7 +819,7 @@ export class VeSyncHumidifier extends VeSyncFan {
819
819
  }
820
820
 
821
821
  logger.debug(`Clearing timer for device: ${this.deviceName}`);
822
- const [response, status] = await Helpers.callApi(
822
+ const [response, status] = await this.callApi(
823
823
  '/cloud/v2/deviceManaged/bypassV2',
824
824
  'post',
825
825
  {
@@ -847,7 +847,7 @@ export class VeSyncHumidifier extends VeSyncFan {
847
847
  */
848
848
  async automaticStopOn(): Promise<boolean> {
849
849
  logger.debug(`Setting automatic stop on for device: ${this.deviceName}`);
850
- const [response, status] = await Helpers.callApi(
850
+ const [response, status] = await this.callApi(
851
851
  '/cloud/v2/deviceManaged/bypassV2',
852
852
  'post',
853
853
  {
@@ -877,7 +877,7 @@ export class VeSyncHumidifier extends VeSyncFan {
877
877
  */
878
878
  async automaticStopOff(): Promise<boolean> {
879
879
  logger.debug(`Setting automatic stop off for device: ${this.deviceName}`);
880
- const [response, status] = await Helpers.callApi(
880
+ const [response, status] = await this.callApi(
881
881
  '/cloud/v2/deviceManaged/bypassV2',
882
882
  'post',
883
883
  {
@@ -979,7 +979,7 @@ export class VeSyncWarmHumidifier extends VeSyncHumidifier {
979
979
  }
980
980
 
981
981
  logger.debug(`Setting warm level to ${level} for device: ${this.deviceName}`);
982
- const [response, status] = await Helpers.callApi(
982
+ const [response, status] = await this.callApi(
983
983
  '/cloud/v2/deviceManaged/bypassV2',
984
984
  'post',
985
985
  {
@@ -1015,7 +1015,7 @@ export class VeSyncWarmHumidifier extends VeSyncHumidifier {
1015
1015
  }
1016
1016
 
1017
1017
  logger.debug(`Setting drying mode to ${enabled} for device: ${this.deviceName}`);
1018
- const [response, status] = await Helpers.callApi(
1018
+ const [response, status] = await this.callApi(
1019
1019
  '/cloud/v2/deviceManaged/bypassV2',
1020
1020
  'post',
1021
1021
  {
@@ -77,7 +77,7 @@ export abstract class VeSyncOutlet extends VeSyncBaseDevice {
77
77
  url = '/v1/device/devicedetail';
78
78
  }
79
79
 
80
- const [response] = await Helpers.callApi(
80
+ const [response] = await this.callApi(
81
81
  url,
82
82
  this.deviceType === 'wifi-switch-1.3' ? 'get' : 'post',
83
83
  this.deviceType === 'wifi-switch-1.3' ? null : body,
@@ -177,7 +177,7 @@ export abstract class VeSyncOutlet extends VeSyncBaseDevice {
177
177
  uuid: this.uuid
178
178
  };
179
179
 
180
- const [response] = await Helpers.callApi(
180
+ const [response] = await this.callApi(
181
181
  url,
182
182
  this.deviceType === 'wifi-switch-1.3' ? 'get' : 'post',
183
183
  body,
@@ -281,7 +281,7 @@ export abstract class VeSyncOutlet extends VeSyncBaseDevice {
281
281
  uuid: this.uuid
282
282
  };
283
283
 
284
- const [response] = await Helpers.callApi(
284
+ const [response] = await this.callApi(
285
285
  isLegacyDevice ? `/${this.getApiPrefix()}/energy/week` : `/${this.getApiPrefix()}/energyweek`,
286
286
  isLegacyDevice ? 'get' : 'post',
287
287
  body,
@@ -313,7 +313,7 @@ export abstract class VeSyncOutlet extends VeSyncBaseDevice {
313
313
  uuid: this.uuid
314
314
  };
315
315
 
316
- const [response] = await Helpers.callApi(
316
+ const [response] = await this.callApi(
317
317
  isLegacyDevice ? `/${this.getApiPrefix()}/energy/month` : `/${this.getApiPrefix()}/energymonth`,
318
318
  isLegacyDevice ? 'get' : 'post',
319
319
  body,
@@ -345,7 +345,7 @@ export abstract class VeSyncOutlet extends VeSyncBaseDevice {
345
345
  uuid: this.uuid
346
346
  };
347
347
 
348
- const [response] = await Helpers.callApi(
348
+ const [response] = await this.callApi(
349
349
  isLegacyDevice ? `/${this.getApiPrefix()}/energy/year` : `/${this.getApiPrefix()}/energyyear`,
350
350
  isLegacyDevice ? 'get' : 'post',
351
351
  body,
@@ -21,7 +21,7 @@ export class VeSyncOutlet7A extends VeSyncOutlet {
21
21
  async turnOn(): Promise<boolean> {
22
22
  logger.debug(`[${this.deviceName}] Turning outlet on`);
23
23
  const url = `/v1/wifi-switch-1.3/${this.cid}/status/on`;
24
- const [response, statusCode] = await Helpers.callApi(
24
+ const [response, statusCode] = await this.callApi(
25
25
  url,
26
26
  'put',
27
27
  {},
@@ -43,7 +43,7 @@ export class VeSyncOutlet7A extends VeSyncOutlet {
43
43
  async turnOff(): Promise<boolean> {
44
44
  logger.debug(`[${this.deviceName}] Turning outlet off`);
45
45
  const url = `/v1/wifi-switch-1.3/${this.cid}/status/off`;
46
- const [response, statusCode] = await Helpers.callApi(
46
+ const [response, statusCode] = await this.callApi(
47
47
  url,
48
48
  'put',
49
49
  {},
@@ -79,7 +79,7 @@ export class VeSyncOutlet10A extends VeSyncOutlet {
79
79
  status: 'on'
80
80
  };
81
81
 
82
- const [response] = await Helpers.callApi(
82
+ const [response] = await this.callApi(
83
83
  '/10a/v1/device/devicestatus',
84
84
  'put',
85
85
  body,
@@ -106,7 +106,7 @@ export class VeSyncOutlet10A extends VeSyncOutlet {
106
106
  status: 'off'
107
107
  };
108
108
 
109
- const [response] = await Helpers.callApi(
109
+ const [response] = await this.callApi(
110
110
  '/10a/v1/device/devicestatus',
111
111
  'put',
112
112
  body,
@@ -142,7 +142,7 @@ export class VeSyncOutlet15A extends VeSyncOutlet {
142
142
  status: 'on'
143
143
  };
144
144
 
145
- const [response] = await Helpers.callApi(
145
+ const [response] = await this.callApi(
146
146
  '/15a/v1/device/devicestatus',
147
147
  'put',
148
148
  body,
@@ -169,7 +169,7 @@ export class VeSyncOutlet15A extends VeSyncOutlet {
169
169
  status: 'off'
170
170
  };
171
171
 
172
- const [response] = await Helpers.callApi(
172
+ const [response] = await this.callApi(
173
173
  '/15a/v1/device/devicestatus',
174
174
  'put',
175
175
  body,
@@ -201,7 +201,7 @@ export class VeSyncOutlet15A extends VeSyncOutlet {
201
201
  mode: 'auto'
202
202
  };
203
203
 
204
- const [response] = await Helpers.callApi(
204
+ const [response] = await this.callApi(
205
205
  '/15a/v1/device/nightlightstatus',
206
206
  'put',
207
207
  body,
@@ -233,7 +233,7 @@ export class VeSyncOutlet15A extends VeSyncOutlet {
233
233
  mode: 'manual'
234
234
  };
235
235
 
236
- const [response] = await Helpers.callApi(
236
+ const [response] = await this.callApi(
237
237
  '/15a/v1/device/nightlightstatus',
238
238
  'put',
239
239
  body,
@@ -254,26 +254,19 @@ export class VeSyncOutlet15A extends VeSyncOutlet {
254
254
  * VeSync Outdoor Plug
255
255
  */
256
256
  export class VeSyncOutdoorPlug extends VeSyncOutlet {
257
- protected subDeviceNo?: number;
258
- protected isSubDevice: boolean;
259
- protected parentCid?: string;
257
+ public subDeviceNo?: number;
258
+ public isSubDevice: boolean;
260
259
 
261
260
  constructor(details: Record<string, any>, manager: VeSync) {
262
261
  super(details, manager);
263
262
  this.isSubDevice = details.isSubDevice || false;
264
263
  this.subDeviceNo = details.subDeviceNo;
265
- this.parentCid = details.parentCid;
266
264
  }
267
265
 
268
266
  /**
269
267
  * Turn outlet on
270
268
  */
271
269
  async turnOn(): Promise<boolean> {
272
- if (!this.isSubDevice) {
273
- logger.error(`[${this.deviceName}] Cannot control parent device directly`);
274
- return false;
275
- }
276
-
277
270
  logger.debug(`[${this.deviceName}] Turning outlet on`);
278
271
  const body = {
279
272
  ...Helpers.reqBody(this.manager, 'devicestatus'),
@@ -282,7 +275,7 @@ export class VeSyncOutdoorPlug extends VeSyncOutlet {
282
275
  switchNo: this.subDeviceNo
283
276
  };
284
277
 
285
- const [response] = await Helpers.callApi(
278
+ const [response] = await this.callApi(
286
279
  '/outdoorsocket15a/v1/device/devicestatus',
287
280
  'put',
288
281
  body,
@@ -302,11 +295,6 @@ export class VeSyncOutdoorPlug extends VeSyncOutlet {
302
295
  * Turn outlet off
303
296
  */
304
297
  async turnOff(): Promise<boolean> {
305
- if (!this.isSubDevice) {
306
- logger.error(`[${this.deviceName}] Cannot control parent device directly`);
307
- return false;
308
- }
309
-
310
298
  logger.debug(`[${this.deviceName}] Turning outlet off`);
311
299
  const body = {
312
300
  ...Helpers.reqBody(this.manager, 'devicestatus'),
@@ -315,7 +303,7 @@ export class VeSyncOutdoorPlug extends VeSyncOutlet {
315
303
  switchNo: this.subDeviceNo
316
304
  };
317
305
 
318
- const [response] = await Helpers.callApi(
306
+ const [response] = await this.callApi(
319
307
  '/outdoorsocket15a/v1/device/devicestatus',
320
308
  'put',
321
309
  body,
@@ -27,7 +27,7 @@ export class VeSyncWallSwitch extends VeSyncSwitch {
27
27
  method: 'devicedetail'
28
28
  };
29
29
 
30
- const [response] = await Helpers.callApi(
30
+ const [response] = await this.callApi(
31
31
  '/inwallswitch/v1/device/devicedetail',
32
32
  'post',
33
33
  body,
@@ -56,7 +56,7 @@ export class VeSyncWallSwitch extends VeSyncSwitch {
56
56
  uuid: this.cid
57
57
  };
58
58
 
59
- const [response] = await Helpers.callApi(
59
+ const [response] = await this.callApi(
60
60
  '/inwallswitch/v1/device/configurations',
61
61
  'post',
62
62
  body,
@@ -82,7 +82,7 @@ export class VeSyncWallSwitch extends VeSyncSwitch {
82
82
  uuid: this.cid
83
83
  };
84
84
 
85
- const [response] = await Helpers.callApi(
85
+ const [response] = await this.callApi(
86
86
  '/inwallswitch/v1/device/devicestatus',
87
87
  'put',
88
88
  body,
@@ -109,7 +109,7 @@ export class VeSyncWallSwitch extends VeSyncSwitch {
109
109
  uuid: this.cid
110
110
  };
111
111
 
112
- const [response] = await Helpers.callApi(
112
+ const [response] = await this.callApi(
113
113
  '/inwallswitch/v1/device/devicestatus',
114
114
  'put',
115
115
  body,
@@ -151,7 +151,7 @@ export class VeSyncDimmerSwitch extends VeSyncSwitch {
151
151
  method: 'devicedetail'
152
152
  };
153
153
 
154
- const [response] = await Helpers.callApi(
154
+ const [response] = await this.callApi(
155
155
  '/dimmer/v1/device/devicedetail',
156
156
  'post',
157
157
  body,
@@ -190,7 +190,7 @@ export class VeSyncDimmerSwitch extends VeSyncSwitch {
190
190
  uuid: this.cid
191
191
  };
192
192
 
193
- const [response] = await Helpers.callApi(
193
+ const [response] = await this.callApi(
194
194
  '/dimmer/v1/device/configurations',
195
195
  'post',
196
196
  body,
@@ -216,7 +216,7 @@ export class VeSyncDimmerSwitch extends VeSyncSwitch {
216
216
  uuid: this.cid
217
217
  };
218
218
 
219
- const [response] = await Helpers.callApi(
219
+ const [response] = await this.callApi(
220
220
  '/dimmer/v1/device/devicestatus',
221
221
  'put',
222
222
  body,
@@ -243,7 +243,7 @@ export class VeSyncDimmerSwitch extends VeSyncSwitch {
243
243
  uuid: this.cid
244
244
  };
245
245
 
246
- const [response] = await Helpers.callApi(
246
+ const [response] = await this.callApi(
247
247
  '/dimmer/v1/device/devicestatus',
248
248
  'put',
249
249
  body,
@@ -275,7 +275,7 @@ export class VeSyncDimmerSwitch extends VeSyncSwitch {
275
275
  uuid: this.cid
276
276
  };
277
277
 
278
- const [response] = await Helpers.callApi(
278
+ const [response] = await this.callApi(
279
279
  '/dimmer/v1/device/updatebrightness',
280
280
  'put',
281
281
  body,
@@ -307,7 +307,7 @@ export class VeSyncDimmerSwitch extends VeSyncSwitch {
307
307
  uuid: this.cid
308
308
  };
309
309
 
310
- const [response] = await Helpers.callApi(
310
+ const [response] = await this.callApi(
311
311
  '/dimmer/v1/device/devicergbstatus',
312
312
  'put',
313
313
  body,
@@ -335,7 +335,7 @@ export class VeSyncDimmerSwitch extends VeSyncSwitch {
335
335
  uuid: this.cid
336
336
  };
337
337
 
338
- const [response] = await Helpers.callApi(
338
+ const [response] = await this.callApi(
339
339
  '/dimmer/v1/device/devicergbstatus',
340
340
  'put',
341
341
  body,
@@ -362,7 +362,7 @@ export class VeSyncDimmerSwitch extends VeSyncSwitch {
362
362
  status: 'on'
363
363
  };
364
364
 
365
- const [response] = await Helpers.callApi(
365
+ const [response] = await this.callApi(
366
366
  '/dimmer/v1/device/devicergbstatus',
367
367
  'put',
368
368
  body,
@@ -389,7 +389,7 @@ export class VeSyncDimmerSwitch extends VeSyncSwitch {
389
389
  status: 'on'
390
390
  };
391
391
 
392
- const [response] = await Helpers.callApi(
392
+ const [response] = await this.callApi(
393
393
  '/dimmer/v1/device/indicatorlightstatus',
394
394
  'put',
395
395
  body,
@@ -416,7 +416,7 @@ export class VeSyncDimmerSwitch extends VeSyncSwitch {
416
416
  status: 'off'
417
417
  };
418
418
 
419
- const [response] = await Helpers.callApi(
419
+ const [response] = await this.callApi(
420
420
  '/dimmer/v1/device/indicatorlightstatus',
421
421
  'put',
422
422
  body,