tsvesync 1.0.43 → 1.0.45
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/vesync.js +25 -8
- package/dist/lib/vesyncFan.d.ts +13 -2
- package/dist/lib/vesyncFan.js +48 -33
- package/dist/lib/vesyncFanImpl.d.ts +99 -14
- package/dist/lib/vesyncFanImpl.js +408 -69
- package/package.json +1 -1
- package/src/lib/vesync.ts +26 -7
- package/src/lib/vesyncFan.ts +49 -34
- package/src/lib/vesyncFanImpl.ts +491 -70
package/dist/lib/vesync.js
CHANGED
|
@@ -340,9 +340,21 @@ class VeSync {
|
|
|
340
340
|
let success = false;
|
|
341
341
|
try {
|
|
342
342
|
const [response] = await helpers_1.Helpers.callApi('/cloud/v2/deviceManaged/devices', 'post', helpers_1.Helpers.reqBody(this, 'devicelist'), helpers_1.Helpers.reqHeaders(this), this);
|
|
343
|
-
if (
|
|
344
|
-
|
|
345
|
-
|
|
343
|
+
if (!response) {
|
|
344
|
+
logger_1.logger.error('No response received from VeSync API');
|
|
345
|
+
return false;
|
|
346
|
+
}
|
|
347
|
+
if (response.error) {
|
|
348
|
+
logger_1.logger.error('API error:', response.msg || 'Unknown error');
|
|
349
|
+
return false;
|
|
350
|
+
}
|
|
351
|
+
if (!((_a = response.result) === null || _a === void 0 ? void 0 : _a.list)) {
|
|
352
|
+
logger_1.logger.error('No device list found in response');
|
|
353
|
+
return false;
|
|
354
|
+
}
|
|
355
|
+
const deviceList = response.result.list;
|
|
356
|
+
success = this.processDevices(deviceList);
|
|
357
|
+
if (success) {
|
|
346
358
|
// Log device discovery results
|
|
347
359
|
logger_1.logger.debug('\n=== Device Discovery Summary ===');
|
|
348
360
|
logger_1.logger.debug(`Total devices processed: ${deviceList.length}`);
|
|
@@ -372,14 +384,19 @@ class VeSync {
|
|
|
372
384
|
}
|
|
373
385
|
logger_1.logger.debug('\n=== End of Device Discovery ===\n');
|
|
374
386
|
}
|
|
387
|
+
}
|
|
388
|
+
catch (err) {
|
|
389
|
+
const error = err;
|
|
390
|
+
if (error.code === 'ECONNABORTED') {
|
|
391
|
+
logger_1.logger.error('VeSync API request timed out');
|
|
392
|
+
}
|
|
393
|
+
else if (error.code === 'ECONNREFUSED') {
|
|
394
|
+
logger_1.logger.error('Unable to connect to VeSync API');
|
|
395
|
+
}
|
|
375
396
|
else {
|
|
376
|
-
logger_1.logger.error('
|
|
377
|
-
logger_1.logger.error(response.code, response.msg);
|
|
397
|
+
logger_1.logger.error('Error getting device list:', error.message || 'Unknown error');
|
|
378
398
|
}
|
|
379
399
|
}
|
|
380
|
-
catch (error) {
|
|
381
|
-
logger_1.logger.error('Unable to get device list:', error);
|
|
382
|
-
}
|
|
383
400
|
this._inProcess = false;
|
|
384
401
|
return success;
|
|
385
402
|
}
|
package/dist/lib/vesyncFan.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ import { VeSyncBaseDevice } from './vesyncBaseDevice';
|
|
|
5
5
|
import { VeSync } from './vesync';
|
|
6
6
|
interface FanConfig {
|
|
7
7
|
[key: string]: {
|
|
8
|
-
module: 'VeSyncAirBypass' | 'VeSyncHumidifier' | 'VeSyncWarmHumidifier' | 'VeSyncTowerFan';
|
|
8
|
+
module: 'VeSyncAirBypass' | 'VeSyncHumidifier' | 'VeSyncWarmHumidifier' | 'VeSyncTowerFan' | 'VeSyncAirBaseV2';
|
|
9
9
|
features: string[];
|
|
10
10
|
};
|
|
11
11
|
}
|
|
@@ -18,6 +18,10 @@ export declare abstract class VeSyncFan extends VeSyncBaseDevice {
|
|
|
18
18
|
protected mode_dict: Record<string, any>;
|
|
19
19
|
protected speed_dict: Record<string, any>;
|
|
20
20
|
protected features: string[];
|
|
21
|
+
protected _timer: number | {
|
|
22
|
+
duration: number;
|
|
23
|
+
action: string;
|
|
24
|
+
} | null;
|
|
21
25
|
constructor(details: Record<string, any>, manager: VeSync);
|
|
22
26
|
/**
|
|
23
27
|
* Check if feature is supported
|
|
@@ -62,7 +66,14 @@ export declare abstract class VeSyncFan extends VeSyncBaseDevice {
|
|
|
62
66
|
/**
|
|
63
67
|
* Get timer status
|
|
64
68
|
*/
|
|
65
|
-
get timer(): number
|
|
69
|
+
get timer(): number | {
|
|
70
|
+
duration: number;
|
|
71
|
+
action: string;
|
|
72
|
+
} | null;
|
|
73
|
+
set timer(value: number | {
|
|
74
|
+
duration: number;
|
|
75
|
+
action: string;
|
|
76
|
+
} | null);
|
|
66
77
|
/**
|
|
67
78
|
* Return formatted device info to stdout
|
|
68
79
|
*/
|
package/dist/lib/vesyncFan.js
CHANGED
|
@@ -71,68 +71,68 @@ exports.fanConfig = {
|
|
|
71
71
|
features: ['display', 'child_lock', 'night_light', 'air_quality', 'timer']
|
|
72
72
|
},
|
|
73
73
|
'LAP-V102S-AASR': {
|
|
74
|
-
module: '
|
|
74
|
+
module: 'VeSyncAirBaseV2',
|
|
75
75
|
features: ['display', 'child_lock', 'night_light', 'air_quality', 'timer']
|
|
76
76
|
},
|
|
77
77
|
'LAP-V102S-WUS': {
|
|
78
|
-
module: '
|
|
78
|
+
module: 'VeSyncAirBaseV2',
|
|
79
79
|
features: ['display', 'child_lock', 'night_light', 'air_quality', 'timer']
|
|
80
80
|
},
|
|
81
81
|
'LAP-V102S-WEU': {
|
|
82
|
-
module: '
|
|
82
|
+
module: 'VeSyncAirBaseV2',
|
|
83
83
|
features: ['display', 'child_lock', 'night_light', 'air_quality', 'timer']
|
|
84
84
|
},
|
|
85
85
|
'LAP-V102S-AUSR': {
|
|
86
|
-
module: '
|
|
86
|
+
module: 'VeSyncAirBaseV2',
|
|
87
87
|
features: ['display', 'child_lock', 'night_light', 'air_quality', 'timer']
|
|
88
88
|
},
|
|
89
89
|
'LAP-V102S-WJP': {
|
|
90
|
-
module: '
|
|
90
|
+
module: 'VeSyncAirBaseV2',
|
|
91
91
|
features: ['display', 'child_lock', 'night_light', 'air_quality', 'timer']
|
|
92
92
|
},
|
|
93
93
|
'LAP-V201S-AASR': {
|
|
94
|
-
module: '
|
|
95
|
-
features: ['display', 'child_lock', 'night_light', 'air_quality', 'timer']
|
|
94
|
+
module: 'VeSyncAirBaseV2',
|
|
95
|
+
features: ['display', 'child_lock', 'night_light', 'air_quality', 'timer', 'light_detection']
|
|
96
96
|
},
|
|
97
97
|
'LAP-V201S-WJP': {
|
|
98
|
-
module: '
|
|
99
|
-
features: ['display', 'child_lock', 'night_light', 'air_quality', 'timer']
|
|
98
|
+
module: 'VeSyncAirBaseV2',
|
|
99
|
+
features: ['display', 'child_lock', 'night_light', 'air_quality', 'timer', 'light_detection']
|
|
100
100
|
},
|
|
101
101
|
'LAP-V201S-WEU': {
|
|
102
|
-
module: '
|
|
103
|
-
features: ['display', 'child_lock', 'night_light', 'air_quality', 'timer']
|
|
102
|
+
module: 'VeSyncAirBaseV2',
|
|
103
|
+
features: ['display', 'child_lock', 'night_light', 'air_quality', 'timer', 'light_detection']
|
|
104
104
|
},
|
|
105
105
|
'LAP-V201S-WUS': {
|
|
106
|
-
module: '
|
|
107
|
-
features: ['display', 'child_lock', 'night_light', 'air_quality', 'timer']
|
|
106
|
+
module: 'VeSyncAirBaseV2',
|
|
107
|
+
features: ['display', 'child_lock', 'night_light', 'air_quality', 'timer', 'light_detection']
|
|
108
108
|
},
|
|
109
109
|
'LAP-V201-AUSR': {
|
|
110
|
-
module: '
|
|
111
|
-
features: ['display', 'child_lock', 'night_light', 'air_quality', 'timer']
|
|
110
|
+
module: 'VeSyncAirBaseV2',
|
|
111
|
+
features: ['display', 'child_lock', 'night_light', 'air_quality', 'timer', 'light_detection']
|
|
112
112
|
},
|
|
113
113
|
'LAP-V201S-AUSR': {
|
|
114
|
-
module: '
|
|
115
|
-
features: ['display', 'child_lock', 'night_light', 'air_quality', 'timer']
|
|
114
|
+
module: 'VeSyncAirBaseV2',
|
|
115
|
+
features: ['display', 'child_lock', 'night_light', 'air_quality', 'timer', 'light_detection']
|
|
116
116
|
},
|
|
117
117
|
'LAP-V201S-AEUR': {
|
|
118
|
-
module: '
|
|
119
|
-
features: ['display', 'child_lock', 'night_light', 'air_quality', 'timer']
|
|
118
|
+
module: 'VeSyncAirBaseV2',
|
|
119
|
+
features: ['display', 'child_lock', 'night_light', 'air_quality', 'timer', 'light_detection']
|
|
120
120
|
},
|
|
121
121
|
'LAP-EL551S-AUS': {
|
|
122
|
-
module: '
|
|
123
|
-
features: ['display', 'child_lock', 'night_light', 'air_quality', 'timer']
|
|
122
|
+
module: 'VeSyncAirBaseV2',
|
|
123
|
+
features: ['display', 'child_lock', 'night_light', 'air_quality', 'timer', 'fan_rotate']
|
|
124
124
|
},
|
|
125
125
|
'LAP-EL551S-AEUR': {
|
|
126
|
-
module: '
|
|
127
|
-
features: ['display', 'child_lock', 'night_light', 'air_quality', 'timer']
|
|
126
|
+
module: 'VeSyncAirBaseV2',
|
|
127
|
+
features: ['display', 'child_lock', 'night_light', 'air_quality', 'timer', 'fan_rotate']
|
|
128
128
|
},
|
|
129
129
|
'LAP-EL551S-WEU': {
|
|
130
|
-
module: '
|
|
131
|
-
features: ['display', 'child_lock', 'night_light', 'air_quality', 'timer']
|
|
130
|
+
module: 'VeSyncAirBaseV2',
|
|
131
|
+
features: ['display', 'child_lock', 'night_light', 'air_quality', 'timer', 'fan_rotate']
|
|
132
132
|
},
|
|
133
133
|
'LAP-EL551S-WUS': {
|
|
134
|
-
module: '
|
|
135
|
-
features: ['display', 'child_lock', 'night_light', 'air_quality', 'timer']
|
|
134
|
+
module: 'VeSyncAirBaseV2',
|
|
135
|
+
features: ['display', 'child_lock', 'night_light', 'air_quality', 'timer', 'fan_rotate']
|
|
136
136
|
},
|
|
137
137
|
// LTF Series
|
|
138
138
|
'LTF-F422S-KEU': {
|
|
@@ -268,6 +268,7 @@ class VeSyncFan extends vesyncBaseDevice_1.VeSyncBaseDevice {
|
|
|
268
268
|
this.mode_dict = {};
|
|
269
269
|
this.speed_dict = {};
|
|
270
270
|
this.features = [];
|
|
271
|
+
this._timer = null;
|
|
271
272
|
this.details = details;
|
|
272
273
|
this.features = ((_a = exports.fanConfig[this.deviceType]) === null || _a === void 0 ? void 0 : _a.features) || [];
|
|
273
274
|
}
|
|
@@ -344,8 +345,10 @@ class VeSyncFan extends vesyncBaseDevice_1.VeSyncBaseDevice {
|
|
|
344
345
|
* Get timer status
|
|
345
346
|
*/
|
|
346
347
|
get timer() {
|
|
347
|
-
|
|
348
|
-
|
|
348
|
+
return this._timer;
|
|
349
|
+
}
|
|
350
|
+
set timer(value) {
|
|
351
|
+
this._timer = value;
|
|
349
352
|
}
|
|
350
353
|
/**
|
|
351
354
|
* Return formatted device info to stdout
|
|
@@ -375,8 +378,14 @@ class VeSyncFan extends vesyncBaseDevice_1.VeSyncBaseDevice {
|
|
|
375
378
|
if (this.hasFeature('warm')) {
|
|
376
379
|
info.push(['Warm Level: ', this.warmLevel]);
|
|
377
380
|
}
|
|
378
|
-
if (this.hasFeature('timer')) {
|
|
379
|
-
|
|
381
|
+
if (this.hasFeature('timer') && this.timer) {
|
|
382
|
+
if (typeof this.timer === 'number') {
|
|
383
|
+
info.push(['Timer: ', this.timer, 'hours']);
|
|
384
|
+
}
|
|
385
|
+
else {
|
|
386
|
+
info.push(['Timer: ', this.timer.duration, 'seconds']);
|
|
387
|
+
info.push(['Timer Action: ', this.timer.action]);
|
|
388
|
+
}
|
|
380
389
|
}
|
|
381
390
|
for (const [key, value, unit = ''] of info) {
|
|
382
391
|
logger_1.logger.info(`${key.toString().padEnd(30, '.')} ${value}${unit}`);
|
|
@@ -410,8 +419,14 @@ class VeSyncFan extends vesyncBaseDevice_1.VeSyncBaseDevice {
|
|
|
410
419
|
if (this.hasFeature('warm')) {
|
|
411
420
|
details['Warm Level'] = this.warmLevel.toString();
|
|
412
421
|
}
|
|
413
|
-
if (this.hasFeature('timer')) {
|
|
414
|
-
|
|
422
|
+
if (this.hasFeature('timer') && this.timer) {
|
|
423
|
+
if (typeof this.timer === 'number') {
|
|
424
|
+
details['Timer'] = this.timer.toString();
|
|
425
|
+
}
|
|
426
|
+
else {
|
|
427
|
+
details['Timer'] = this.timer.duration.toString();
|
|
428
|
+
details['Timer Action'] = this.timer.action;
|
|
429
|
+
}
|
|
415
430
|
}
|
|
416
431
|
return JSON.stringify({
|
|
417
432
|
...baseInfo,
|
|
@@ -12,6 +12,10 @@ export declare class VeSyncAirBypass extends VeSyncFan {
|
|
|
12
12
|
protected readonly displayModes: readonly ["on", "off"];
|
|
13
13
|
protected readonly childLockModes: readonly ["on", "off"];
|
|
14
14
|
constructor(details: Record<string, any>, manager: VeSync);
|
|
15
|
+
/**
|
|
16
|
+
* Build API dictionary
|
|
17
|
+
*/
|
|
18
|
+
protected buildApiDict(method: string): [Record<string, any>, Record<string, any>];
|
|
15
19
|
/**
|
|
16
20
|
* Get device details
|
|
17
21
|
*/
|
|
@@ -215,27 +219,101 @@ export declare class VeSyncWarmHumidifier extends VeSyncHumidifier {
|
|
|
215
219
|
export declare class VeSyncAirBaseV2 extends VeSyncAirBypass {
|
|
216
220
|
protected _lightDetection: boolean;
|
|
217
221
|
protected _lightDetectionState: boolean;
|
|
222
|
+
protected setSpeedLevel: number | null;
|
|
223
|
+
protected autoPreferences: string[];
|
|
224
|
+
protected enabled: boolean;
|
|
225
|
+
protected _mode: string;
|
|
226
|
+
protected _speed: number;
|
|
227
|
+
protected _timer: {
|
|
228
|
+
duration: number;
|
|
229
|
+
action: string;
|
|
230
|
+
} | null;
|
|
218
231
|
constructor(details: Record<string, any>, manager: VeSync);
|
|
232
|
+
protected buildConfigDict(configDict: Record<string, any>): void;
|
|
233
|
+
get mode(): string;
|
|
234
|
+
set mode(value: string);
|
|
235
|
+
get speed(): number;
|
|
236
|
+
set speed(value: number);
|
|
237
|
+
get timer(): {
|
|
238
|
+
duration: number;
|
|
239
|
+
action: string;
|
|
240
|
+
} | null;
|
|
241
|
+
set timer(value: {
|
|
242
|
+
duration: number;
|
|
243
|
+
action: string;
|
|
244
|
+
} | null);
|
|
219
245
|
/**
|
|
220
246
|
* Build API dictionary
|
|
221
247
|
*/
|
|
222
248
|
protected buildApiDict(method: string): [Record<string, any>, Record<string, any>];
|
|
249
|
+
/**
|
|
250
|
+
* Get device details
|
|
251
|
+
*/
|
|
252
|
+
getDetails(): Promise<Boolean>;
|
|
253
|
+
/**
|
|
254
|
+
* Build purifier dictionary
|
|
255
|
+
*/
|
|
256
|
+
protected buildPurifierDict(devDict: Record<string, any>): void;
|
|
257
|
+
/**
|
|
258
|
+
* Toggle device power
|
|
259
|
+
*/
|
|
260
|
+
toggleSwitch(toggle: boolean): Promise<boolean>;
|
|
261
|
+
/**
|
|
262
|
+
* Turn device on - compatibility method that proxies to toggleSwitch
|
|
263
|
+
*/
|
|
264
|
+
turnOn(): Promise<boolean>;
|
|
265
|
+
/**
|
|
266
|
+
* Turn device off - compatibility method that proxies to toggleSwitch
|
|
267
|
+
*/
|
|
268
|
+
turnOff(): Promise<boolean>;
|
|
269
|
+
/**
|
|
270
|
+
* Change fan speed
|
|
271
|
+
*/
|
|
272
|
+
changeFanSpeed(speed: number): Promise<boolean>;
|
|
273
|
+
/**
|
|
274
|
+
* Set mode
|
|
275
|
+
*/
|
|
276
|
+
setMode(mode: string): Promise<boolean>;
|
|
277
|
+
/**
|
|
278
|
+
* Set display status
|
|
279
|
+
*/
|
|
280
|
+
setDisplay(enabled: boolean): Promise<boolean>;
|
|
281
|
+
/**
|
|
282
|
+
* Set child lock
|
|
283
|
+
*/
|
|
284
|
+
setChildLock(enabled: boolean): Promise<boolean>;
|
|
285
|
+
/**
|
|
286
|
+
* Set timer
|
|
287
|
+
*/
|
|
288
|
+
setTimer(timerDuration: number, action?: 'on' | 'off', method?: string): Promise<boolean>;
|
|
289
|
+
/**
|
|
290
|
+
* Clear timer
|
|
291
|
+
*/
|
|
292
|
+
clearTimer(): Promise<boolean>;
|
|
293
|
+
/**
|
|
294
|
+
* Set auto preference
|
|
295
|
+
*/
|
|
296
|
+
setAutoPreference(preference?: string, roomSize?: number): Promise<boolean>;
|
|
297
|
+
/**
|
|
298
|
+
* Set light detection
|
|
299
|
+
*/
|
|
300
|
+
setLightDetection(enabled: boolean): Promise<boolean>;
|
|
301
|
+
/**
|
|
302
|
+
* Get light detection status
|
|
303
|
+
*/
|
|
223
304
|
get lightDetection(): boolean;
|
|
224
|
-
|
|
305
|
+
/**
|
|
306
|
+
* Get light detection state
|
|
307
|
+
*/
|
|
225
308
|
get lightDetectionState(): boolean;
|
|
226
|
-
setLightDetection(toggle: boolean): Promise<boolean>;
|
|
227
|
-
setLightDetectionOn(): Promise<boolean>;
|
|
228
|
-
setLightDetectionOff(): Promise<boolean>;
|
|
229
|
-
turboMode(): Promise<boolean>;
|
|
230
|
-
petMode(): Promise<boolean>;
|
|
231
309
|
/**
|
|
232
|
-
*
|
|
310
|
+
* Get auto preference type
|
|
233
311
|
*/
|
|
234
|
-
|
|
312
|
+
get autoPreferenceType(): string | null;
|
|
235
313
|
/**
|
|
236
|
-
*
|
|
314
|
+
* Display JSON details
|
|
237
315
|
*/
|
|
238
|
-
|
|
316
|
+
displayJSON(): string;
|
|
239
317
|
}
|
|
240
318
|
/**
|
|
241
319
|
* VeSync Tower Fan Implementation
|
|
@@ -244,6 +322,17 @@ export declare class VeSyncTowerFan extends VeSyncAirBaseV2 {
|
|
|
244
322
|
protected readonly towerModes: readonly ["normal", "advancedSleep", "off"];
|
|
245
323
|
protected readonly speeds: number[];
|
|
246
324
|
constructor(details: Record<string, any>, manager: VeSync);
|
|
325
|
+
/**
|
|
326
|
+
* Get timer status (in seconds)
|
|
327
|
+
*/
|
|
328
|
+
get timer(): {
|
|
329
|
+
duration: number;
|
|
330
|
+
action: string;
|
|
331
|
+
} | null;
|
|
332
|
+
set timer(value: {
|
|
333
|
+
duration: number;
|
|
334
|
+
action: string;
|
|
335
|
+
} | null);
|
|
247
336
|
/**
|
|
248
337
|
* Build API dictionary
|
|
249
338
|
*/
|
|
@@ -308,10 +397,6 @@ export declare class VeSyncTowerFan extends VeSyncAirBaseV2 {
|
|
|
308
397
|
* Get mute status
|
|
309
398
|
*/
|
|
310
399
|
get muteState(): boolean;
|
|
311
|
-
/**
|
|
312
|
-
* Get timer status (in seconds)
|
|
313
|
-
*/
|
|
314
|
-
get timer(): number;
|
|
315
400
|
/**
|
|
316
401
|
* Get temperature (in tenths of a degree)
|
|
317
402
|
*/
|