tsvesync 1.0.23 → 1.0.25

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.
@@ -25,7 +25,7 @@ class VeSyncWallSwitch extends vesyncSwitch_1.VeSyncSwitch {
25
25
  uuid: this.cid,
26
26
  method: 'devicedetail'
27
27
  };
28
- const [response] = await helpers_1.Helpers.callApi('/inwallswitch/v1/device/devicedetail', 'post', body, helpers_1.Helpers.reqHeaders(this.manager));
28
+ const [response] = await this.callApi('/inwallswitch/v1/device/devicedetail', 'post', body, helpers_1.Helpers.reqHeaders(this.manager));
29
29
  if ((response === null || response === void 0 ? void 0 : response.code) === 0 && (response === null || response === void 0 ? void 0 : response.result)) {
30
30
  const result = response.result;
31
31
  this.deviceStatus = result.deviceStatus || this.deviceStatus;
@@ -47,7 +47,7 @@ class VeSyncWallSwitch extends vesyncSwitch_1.VeSyncSwitch {
47
47
  method: 'configurations',
48
48
  uuid: this.cid
49
49
  };
50
- const [response] = await helpers_1.Helpers.callApi('/inwallswitch/v1/device/configurations', 'post', body, helpers_1.Helpers.reqHeaders(this.manager));
50
+ const [response] = await this.callApi('/inwallswitch/v1/device/configurations', 'post', body, helpers_1.Helpers.reqHeaders(this.manager));
51
51
  if ((response === null || response === void 0 ? void 0 : response.code) === 0) {
52
52
  this.config = helpers_1.Helpers.buildConfigDict(response);
53
53
  logger_1.logger.debug(`Successfully got configuration for device: ${this.deviceName}`);
@@ -66,7 +66,7 @@ class VeSyncWallSwitch extends vesyncSwitch_1.VeSyncSwitch {
66
66
  status: 'off',
67
67
  uuid: this.cid
68
68
  };
69
- const [response] = await helpers_1.Helpers.callApi('/inwallswitch/v1/device/devicestatus', 'put', body, helpers_1.Helpers.reqHeaders(this.manager));
69
+ const [response] = await this.callApi('/inwallswitch/v1/device/devicestatus', 'put', body, helpers_1.Helpers.reqHeaders(this.manager));
70
70
  if ((response === null || response === void 0 ? void 0 : response.code) === 0) {
71
71
  this.deviceStatus = 'off';
72
72
  logger_1.logger.debug(`Successfully turned off device: ${this.deviceName}`);
@@ -85,7 +85,7 @@ class VeSyncWallSwitch extends vesyncSwitch_1.VeSyncSwitch {
85
85
  status: 'on',
86
86
  uuid: this.cid
87
87
  };
88
- const [response] = await helpers_1.Helpers.callApi('/inwallswitch/v1/device/devicestatus', 'put', body, helpers_1.Helpers.reqHeaders(this.manager));
88
+ const [response] = await this.callApi('/inwallswitch/v1/device/devicestatus', 'put', body, helpers_1.Helpers.reqHeaders(this.manager));
89
89
  if ((response === null || response === void 0 ? void 0 : response.code) === 0) {
90
90
  this.deviceStatus = 'on';
91
91
  logger_1.logger.debug(`Successfully turned on device: ${this.deviceName}`);
@@ -118,7 +118,7 @@ class VeSyncDimmerSwitch extends vesyncSwitch_1.VeSyncSwitch {
118
118
  uuid: this.cid,
119
119
  method: 'devicedetail'
120
120
  };
121
- const [response] = await helpers_1.Helpers.callApi('/dimmer/v1/device/devicedetail', 'post', body, helpers_1.Helpers.reqHeaders(this.manager));
121
+ const [response] = await this.callApi('/dimmer/v1/device/devicedetail', 'post', body, helpers_1.Helpers.reqHeaders(this.manager));
122
122
  if ((response === null || response === void 0 ? void 0 : response.code) === 0 && (response === null || response === void 0 ? void 0 : response.result)) {
123
123
  const result = response.result;
124
124
  this.deviceStatus = result.deviceStatus || this.deviceStatus;
@@ -150,7 +150,7 @@ class VeSyncDimmerSwitch extends vesyncSwitch_1.VeSyncSwitch {
150
150
  method: 'configurations',
151
151
  uuid: this.cid
152
152
  };
153
- const [response] = await helpers_1.Helpers.callApi('/dimmer/v1/device/configurations', 'post', body, helpers_1.Helpers.reqHeaders(this.manager));
153
+ const [response] = await this.callApi('/dimmer/v1/device/configurations', 'post', body, helpers_1.Helpers.reqHeaders(this.manager));
154
154
  if ((response === null || response === void 0 ? void 0 : response.code) === 0) {
155
155
  this.config = helpers_1.Helpers.buildConfigDict(response);
156
156
  logger_1.logger.debug(`Successfully got configuration for device: ${this.deviceName}`);
@@ -169,7 +169,7 @@ class VeSyncDimmerSwitch extends vesyncSwitch_1.VeSyncSwitch {
169
169
  status: 'off',
170
170
  uuid: this.cid
171
171
  };
172
- const [response] = await helpers_1.Helpers.callApi('/dimmer/v1/device/devicestatus', 'put', body, helpers_1.Helpers.reqHeaders(this.manager));
172
+ const [response] = await this.callApi('/dimmer/v1/device/devicestatus', 'put', body, helpers_1.Helpers.reqHeaders(this.manager));
173
173
  if ((response === null || response === void 0 ? void 0 : response.code) === 0) {
174
174
  this.deviceStatus = 'off';
175
175
  logger_1.logger.debug(`Successfully turned off device: ${this.deviceName}`);
@@ -188,7 +188,7 @@ class VeSyncDimmerSwitch extends vesyncSwitch_1.VeSyncSwitch {
188
188
  status: 'on',
189
189
  uuid: this.cid
190
190
  };
191
- const [response] = await helpers_1.Helpers.callApi('/dimmer/v1/device/devicestatus', 'put', body, helpers_1.Helpers.reqHeaders(this.manager));
191
+ const [response] = await this.callApi('/dimmer/v1/device/devicestatus', 'put', body, helpers_1.Helpers.reqHeaders(this.manager));
192
192
  if ((response === null || response === void 0 ? void 0 : response.code) === 0) {
193
193
  this.deviceStatus = 'on';
194
194
  logger_1.logger.debug(`Successfully turned on device: ${this.deviceName}`);
@@ -211,7 +211,7 @@ class VeSyncDimmerSwitch extends vesyncSwitch_1.VeSyncSwitch {
211
211
  brightness: brightness.toString(),
212
212
  uuid: this.cid
213
213
  };
214
- const [response] = await helpers_1.Helpers.callApi('/dimmer/v1/device/updatebrightness', 'put', body, helpers_1.Helpers.reqHeaders(this.manager));
214
+ const [response] = await this.callApi('/dimmer/v1/device/updatebrightness', 'put', body, helpers_1.Helpers.reqHeaders(this.manager));
215
215
  if ((response === null || response === void 0 ? void 0 : response.code) === 0) {
216
216
  this._brightness = brightness;
217
217
  logger_1.logger.debug(`Successfully set brightness to ${brightness} for device: ${this.deviceName}`);
@@ -235,7 +235,7 @@ class VeSyncDimmerSwitch extends vesyncSwitch_1.VeSyncSwitch {
235
235
  status: 'on',
236
236
  uuid: this.cid
237
237
  };
238
- const [response] = await helpers_1.Helpers.callApi('/dimmer/v1/device/devicergbstatus', 'put', body, helpers_1.Helpers.reqHeaders(this.manager));
238
+ const [response] = await this.callApi('/dimmer/v1/device/devicergbstatus', 'put', body, helpers_1.Helpers.reqHeaders(this.manager));
239
239
  if ((response === null || response === void 0 ? void 0 : response.code) === 0) {
240
240
  this._rgbValue = { red, green, blue };
241
241
  this._rgbStatus = 'on';
@@ -255,7 +255,7 @@ class VeSyncDimmerSwitch extends vesyncSwitch_1.VeSyncSwitch {
255
255
  status: 'off',
256
256
  uuid: this.cid
257
257
  };
258
- const [response] = await helpers_1.Helpers.callApi('/dimmer/v1/device/devicergbstatus', 'put', body, helpers_1.Helpers.reqHeaders(this.manager));
258
+ const [response] = await this.callApi('/dimmer/v1/device/devicergbstatus', 'put', body, helpers_1.Helpers.reqHeaders(this.manager));
259
259
  if ((response === null || response === void 0 ? void 0 : response.code) === 0) {
260
260
  this._rgbStatus = 'off';
261
261
  logger_1.logger.debug(`Successfully turned off RGB color for device: ${this.deviceName}`);
@@ -274,7 +274,7 @@ class VeSyncDimmerSwitch extends vesyncSwitch_1.VeSyncSwitch {
274
274
  uuid: this.cid,
275
275
  status: 'on'
276
276
  };
277
- const [response] = await helpers_1.Helpers.callApi('/dimmer/v1/device/devicergbstatus', 'put', body, helpers_1.Helpers.reqHeaders(this.manager));
277
+ const [response] = await this.callApi('/dimmer/v1/device/devicergbstatus', 'put', body, helpers_1.Helpers.reqHeaders(this.manager));
278
278
  if ((response === null || response === void 0 ? void 0 : response.code) === 0) {
279
279
  this._rgbStatus = 'on';
280
280
  logger_1.logger.debug(`Successfully turned on RGB color for device: ${this.deviceName}`);
@@ -293,7 +293,7 @@ class VeSyncDimmerSwitch extends vesyncSwitch_1.VeSyncSwitch {
293
293
  uuid: this.cid,
294
294
  status: 'on'
295
295
  };
296
- const [response] = await helpers_1.Helpers.callApi('/dimmer/v1/device/indicatorlightstatus', 'put', body, helpers_1.Helpers.reqHeaders(this.manager));
296
+ const [response] = await this.callApi('/dimmer/v1/device/indicatorlightstatus', 'put', body, helpers_1.Helpers.reqHeaders(this.manager));
297
297
  if ((response === null || response === void 0 ? void 0 : response.code) === 0) {
298
298
  this._indicatorLight = 'on';
299
299
  logger_1.logger.debug(`Successfully turned on indicator light for device: ${this.deviceName}`);
@@ -312,7 +312,7 @@ class VeSyncDimmerSwitch extends vesyncSwitch_1.VeSyncSwitch {
312
312
  uuid: this.cid,
313
313
  status: 'off'
314
314
  };
315
- const [response] = await helpers_1.Helpers.callApi('/dimmer/v1/device/indicatorlightstatus', 'put', body, helpers_1.Helpers.reqHeaders(this.manager));
315
+ const [response] = await this.callApi('/dimmer/v1/device/indicatorlightstatus', 'put', body, helpers_1.Helpers.reqHeaders(this.manager));
316
316
  if ((response === null || response === void 0 ? void 0 : response.code) === 0) {
317
317
  this._indicatorLight = 'off';
318
318
  logger_1.logger.debug(`Successfully turned off indicator light for device: ${this.deviceName}`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tsvesync",
3
- "version": "1.0.23",
3
+ "version": "1.0.25",
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",
@@ -202,7 +202,8 @@ export class Helpers {
202
202
  endpoint: string,
203
203
  method: string,
204
204
  data: any = null,
205
- headers: Record<string, string> = {}
205
+ headers: Record<string, string> = {},
206
+ manager: VeSync
206
207
  ): Promise<[any, number]> {
207
208
  try {
208
209
  const url = _apiBaseUrl + endpoint;
@@ -217,7 +218,20 @@ export class Helpers {
217
218
  return [response.data, response.status];
218
219
  } catch (error: any) {
219
220
  if (error.response) {
220
- return [error.response.data, error.response.status];
221
+ const responseData = error.response.data;
222
+
223
+ // Check for token expiration
224
+ if (responseData?.code === 4001004 || responseData?.msg === "token expired") {
225
+ logger.debug('Token expired, attempting to re-login...');
226
+
227
+ // Re-login
228
+ if (await manager.login()) {
229
+ // Retry the original request
230
+ logger.debug('Re-login successful, retrying original request...');
231
+ return await this.callApi(endpoint, method, data, headers, manager);
232
+ }
233
+ }
234
+ return [responseData, error.response.status];
221
235
  }
222
236
  logger.error('API call failed:', error.message);
223
237
  return [null, 0];
package/src/lib/vesync.ts CHANGED
@@ -130,7 +130,7 @@ function objectFactory(details: Record<string, any>, manager: VeSync): [string,
130
130
  return [category, null];
131
131
  }
132
132
  } else {
133
- logger.warn(`No device class found for type: ${deviceType}`);
133
+ logger.debug(`No device class found for type: ${deviceType}`);
134
134
  return [category, null];
135
135
  }
136
136
  }
@@ -414,7 +414,8 @@ export class VeSync {
414
414
  '/cloud/v2/deviceManaged/devices',
415
415
  'post',
416
416
  Helpers.reqBody(this, 'devicelist'),
417
- Helpers.reqHeaders(this)
417
+ Helpers.reqHeaders(this),
418
+ this
418
419
  );
419
420
 
420
421
  if (response?.result?.list) {
@@ -478,7 +479,9 @@ export class VeSync {
478
479
  const [response, status] = await Helpers.callApi(
479
480
  '/cloud/v1/user/login',
480
481
  'post',
481
- body
482
+ body,
483
+ {},
484
+ this
482
485
  );
483
486
 
484
487
  logger.debug('Login response:', { status, response });
@@ -549,4 +552,16 @@ export class VeSync {
549
552
 
550
553
  return null;
551
554
  }
555
+
556
+ /**
557
+ * Call API with authentication
558
+ */
559
+ protected async callApi(
560
+ endpoint: string,
561
+ method: string,
562
+ data: any = null,
563
+ headers: Record<string, string> = {}
564
+ ): Promise<[any, number]> {
565
+ return await Helpers.callApi(endpoint, method, data, headers, this);
566
+ }
552
567
  }
@@ -4,6 +4,7 @@
4
4
 
5
5
  import { VeSync } from './vesync';
6
6
  import { logger } from './logger';
7
+ import { Helpers } from './helpers';
7
8
 
8
9
  export abstract class VeSyncBaseDevice {
9
10
  protected manager: VeSync;
@@ -112,4 +113,16 @@ export abstract class VeSyncBaseDevice {
112
113
  async update(): Promise<void> {
113
114
  await this.getDetails();
114
115
  }
116
+
117
+ /**
118
+ * Call API with proper headers
119
+ */
120
+ protected async callApi(
121
+ endpoint: string,
122
+ method: string,
123
+ data: any = null,
124
+ headers: Record<string, string> = {}
125
+ ): Promise<[any, number]> {
126
+ return await Helpers.callApi(endpoint, method, data, headers, this.manager);
127
+ }
115
128
  }
@@ -94,7 +94,7 @@ export abstract class VeSyncBulb extends VeSyncBaseDevice {
94
94
  }
95
95
  };
96
96
 
97
- const [response] = await Helpers.callApi(
97
+ const [response] = await this.callApi(
98
98
  endpoint,
99
99
  'post',
100
100
  body,
@@ -120,7 +120,7 @@ export abstract class VeSyncBulb extends VeSyncBaseDevice {
120
120
  this.colorValue = response.result.value || this.colorValue;
121
121
  }
122
122
  }
123
- logger.info(`[${this.deviceName}] Successfully retrieved bulb details`);
123
+ logger.debug(`[${this.deviceName}] Successfully retrieved bulb details`);
124
124
  } else {
125
125
  logger.error(`[${this.deviceName}] Failed to get bulb details: ${JSON.stringify(response)}`);
126
126
  }
@@ -166,7 +166,7 @@ export abstract class VeSyncBulb extends VeSyncBaseDevice {
166
166
  }
167
167
  };
168
168
 
169
- const [response] = await Helpers.callApi(
169
+ const [response] = await this.callApi(
170
170
  endpoint,
171
171
  'post',
172
172
  body,
@@ -213,7 +213,7 @@ export abstract class VeSyncBulb extends VeSyncBaseDevice {
213
213
  }
214
214
  };
215
215
 
216
- const [response] = await Helpers.callApi(
216
+ const [response] = await this.callApi(
217
217
  endpoint,
218
218
  'post',
219
219
  body,
@@ -270,7 +270,7 @@ export abstract class VeSyncBulb extends VeSyncBaseDevice {
270
270
  }
271
271
  };
272
272
 
273
- const [response] = await Helpers.callApi(
273
+ const [response] = await this.callApi(
274
274
  endpoint,
275
275
  'post',
276
276
  body,
@@ -47,7 +47,7 @@ export class VeSyncBulbESL100CW extends VeSyncBulb {
47
47
  }
48
48
  };
49
49
 
50
- const [response] = await Helpers.callApi(
50
+ const [response] = await this.callApi(
51
51
  '/cloud/v1/deviceManaged/bypass',
52
52
  'post',
53
53
  body,
@@ -98,7 +98,7 @@ export class VeSyncBulbXYD0001 extends VeSyncBulb {
98
98
  }
99
99
  };
100
100
 
101
- const [response] = await Helpers.callApi(
101
+ const [response] = await this.callApi(
102
102
  '/cloud/v2/deviceManaged/bypassV2',
103
103
  'post',
104
104
  body,
@@ -140,7 +140,7 @@ export class VeSyncBulbXYD0001 extends VeSyncBulb {
140
140
  }
141
141
  };
142
142
 
143
- const [response] = await Helpers.callApi(
143
+ const [response] = await this.callApi(
144
144
  '/cloud/v2/deviceManaged/bypassV2',
145
145
  'post',
146
146
  body,
@@ -179,7 +179,7 @@ export class VeSyncBulbXYD0001 extends VeSyncBulb {
179
179
  }
180
180
  };
181
181
 
182
- const [response] = await Helpers.callApi(
182
+ const [response] = await this.callApi(
183
183
  '/cloud/v2/deviceManaged/bypassV2',
184
184
  'post',
185
185
  body,
@@ -229,7 +229,7 @@ export class VeSyncBulbESL100MC extends VeSyncBulb {
229
229
  }
230
230
  };
231
231
 
232
- const [response] = await Helpers.callApi(
232
+ const [response] = await this.callApi(
233
233
  '/cloud/v1/deviceManaged/bypass',
234
234
  'post',
235
235
  body,
@@ -258,7 +258,7 @@ export class VeSyncBulbESL100MC extends VeSyncBulb {
258
258
  }
259
259
  };
260
260
 
261
- const [response] = await Helpers.callApi(
261
+ const [response] = await this.callApi(
262
262
  '/cloud/v1/deviceManaged/bypass',
263
263
  'post',
264
264
  body,
@@ -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,
@@ -125,7 +125,7 @@ export abstract class VeSyncOutlet extends VeSyncBaseDevice {
125
125
 
126
126
  if (subDevice) {
127
127
  this.deviceStatus = subDevice.subDeviceStatus;
128
- logger.info(`[${this.deviceName}] Successfully retrieved sub-device status: ${this.deviceStatus}`);
128
+ logger.debug(`[${this.deviceName}] Successfully retrieved sub-device status: ${this.deviceStatus}`);
129
129
  return;
130
130
  }
131
131
  }
@@ -141,7 +141,7 @@ export abstract class VeSyncOutlet extends VeSyncBaseDevice {
141
141
  logger.debug(`[${this.deviceName}] Device status not found in response: ${JSON.stringify(response)}`);
142
142
  return;
143
143
  }
144
- logger.info(`[${this.deviceName}] Successfully retrieved outlet details`);
144
+ logger.debug(`[${this.deviceName}] Successfully retrieved outlet details`);
145
145
  } else {
146
146
  logger.debug(`[${this.deviceName}] Failed to get outlet details: ${JSON.stringify(response)}`);
147
147
  }
@@ -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,
@@ -290,7 +290,7 @@ export abstract class VeSyncOutlet extends VeSyncBaseDevice {
290
290
 
291
291
  if (response?.code === 0) {
292
292
  this.energy.week = response.result || response.energyWeek || '0';
293
- logger.info(`[${this.deviceName}] Successfully retrieved weekly energy data`);
293
+ logger.debug(`[${this.deviceName}] Successfully retrieved weekly energy data`);
294
294
  } else {
295
295
  this.energy.week = '0';
296
296
  logger.debug(`[${this.deviceName}] Failed to get weekly energy data: ${JSON.stringify(response)}`);
@@ -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,
@@ -322,7 +322,7 @@ export abstract class VeSyncOutlet extends VeSyncBaseDevice {
322
322
 
323
323
  if (response?.code === 0) {
324
324
  this.energy.month = response.result || response.energyMonth || '0';
325
- logger.info(`[${this.deviceName}] Successfully retrieved monthly energy data`);
325
+ logger.debug(`[${this.deviceName}] Successfully retrieved monthly energy data`);
326
326
  } else {
327
327
  this.energy.month = '0';
328
328
  logger.debug(`[${this.deviceName}] Failed to get monthly energy data: ${JSON.stringify(response)}`);
@@ -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,
@@ -354,7 +354,7 @@ export abstract class VeSyncOutlet extends VeSyncBaseDevice {
354
354
 
355
355
  if (response?.code === 0) {
356
356
  this.energy.year = response.result || response.energyYear || '0';
357
- logger.info(`[${this.deviceName}] Successfully retrieved yearly energy data`);
357
+ logger.debug(`[${this.deviceName}] Successfully retrieved yearly energy data`);
358
358
  } else {
359
359
  this.energy.year = '0';
360
360
  logger.debug(`[${this.deviceName}] Failed to get yearly energy data: ${JSON.stringify(response)}`);