tsvesync 1.0.72 → 1.0.74
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/fans/air131.d.ts +68 -0
- package/dist/lib/fans/air131.js +404 -0
- package/dist/lib/fans/airBypass.js +70 -269
- package/dist/lib/fans/index.d.ts +1 -0
- package/dist/lib/fans/index.js +6 -3
- package/dist/lib/vesyncFan.d.ts +10 -2
- package/dist/lib/vesyncFan.js +68 -34
- package/package.json +3 -1
- package/src/lib/fans/air131.ts +486 -0
- package/src/lib/fans/airBypass.ts +70 -329
- package/src/lib/fans/airBypass.ts.bak +890 -0
- package/src/lib/fans/index.ts +4 -2
- package/src/lib/vesyncFan.ts +77 -36
|
@@ -36,45 +36,8 @@ class VeSyncAirBypass extends vesyncFan_1.VeSyncFan {
|
|
|
36
36
|
* Get device details
|
|
37
37
|
*/
|
|
38
38
|
async getDetails() {
|
|
39
|
-
var _a
|
|
39
|
+
var _a;
|
|
40
40
|
logger_1.logger.debug(`Getting details for device: ${this.deviceName}`);
|
|
41
|
-
// Special handling for LV series
|
|
42
|
-
if (this.deviceType.startsWith('LV-')) {
|
|
43
|
-
const [response, status] = await this.callApi('/131airPurifier/v1/device/devicedetail', 'post', {
|
|
44
|
-
acceptLanguage: 'en',
|
|
45
|
-
accountID: this.manager.accountId,
|
|
46
|
-
appVersion: '2.8.6',
|
|
47
|
-
method: 'devicedetail',
|
|
48
|
-
mobileId: '1234567890123456',
|
|
49
|
-
phoneBrand: 'SM N9005',
|
|
50
|
-
phoneOS: 'Android',
|
|
51
|
-
timeZone: this.manager.timeZone,
|
|
52
|
-
token: this.manager.token,
|
|
53
|
-
uuid: this.uuid
|
|
54
|
-
}, {
|
|
55
|
-
'accept-language': 'en',
|
|
56
|
-
'accountId': this.manager.accountId,
|
|
57
|
-
'appVersion': '2.8.6',
|
|
58
|
-
'content-type': 'application/json',
|
|
59
|
-
'tk': this.manager.token,
|
|
60
|
-
'tz': this.manager.timeZone
|
|
61
|
-
});
|
|
62
|
-
const success = this.checkResponse([response, status], 'getDetails');
|
|
63
|
-
if (success && response) {
|
|
64
|
-
this.deviceStatus = ((_b = (_a = response.result) === null || _a === void 0 ? void 0 : _a.result) === null || _b === void 0 ? void 0 : _b.deviceStatus) === 'on' ? 'on' : 'off';
|
|
65
|
-
this.details = {
|
|
66
|
-
mode: ((_d = (_c = response.result) === null || _c === void 0 ? void 0 : _c.result) === null || _d === void 0 ? void 0 : _d.mode) || '',
|
|
67
|
-
speed: ((_f = (_e = response.result) === null || _e === void 0 ? void 0 : _e.result) === null || _f === void 0 ? void 0 : _f.level) || 0,
|
|
68
|
-
filterLife: ((_h = (_g = response.result) === null || _g === void 0 ? void 0 : _g.result) === null || _h === void 0 ? void 0 : _h.filterLife) || 0,
|
|
69
|
-
screenStatus: ((_k = (_j = response.result) === null || _j === void 0 ? void 0 : _j.result) === null || _k === void 0 ? void 0 : _k.display) ? 'on' : 'off',
|
|
70
|
-
childLock: ((_m = (_l = response.result) === null || _l === void 0 ? void 0 : _l.result) === null || _m === void 0 ? void 0 : _m.childLock) || false,
|
|
71
|
-
airQuality: ((_p = (_o = response.result) === null || _o === void 0 ? void 0 : _o.result) === null || _p === void 0 ? void 0 : _p.airQuality) || 0
|
|
72
|
-
};
|
|
73
|
-
return true;
|
|
74
|
-
}
|
|
75
|
-
return false;
|
|
76
|
-
}
|
|
77
|
-
// Original implementation for other devices
|
|
78
41
|
const [response, status] = await this.callApi('/cloud/v2/deviceManaged/bypassV2', 'post', {
|
|
79
42
|
...helpers_1.Helpers.reqBody(this.manager, 'bypassV2'),
|
|
80
43
|
cid: this.cid,
|
|
@@ -87,7 +50,7 @@ class VeSyncAirBypass extends vesyncFan_1.VeSyncFan {
|
|
|
87
50
|
}, helpers_1.Helpers.reqHeaderBypass());
|
|
88
51
|
const success = this.checkResponse([response, status], 'getDetails');
|
|
89
52
|
if (success) {
|
|
90
|
-
const result = (
|
|
53
|
+
const result = (_a = response === null || response === void 0 ? void 0 : response.result) === null || _a === void 0 ? void 0 : _a.result;
|
|
91
54
|
if (result) {
|
|
92
55
|
this.deviceStatus = result.enabled ? 'on' : 'off';
|
|
93
56
|
this.details = {
|
|
@@ -112,30 +75,6 @@ class VeSyncAirBypass extends vesyncFan_1.VeSyncFan {
|
|
|
112
75
|
*/
|
|
113
76
|
async turnOn() {
|
|
114
77
|
logger_1.logger.info(`Turning on device: ${this.deviceName}`);
|
|
115
|
-
// Special handling for LV series
|
|
116
|
-
if (this.deviceType.startsWith('LV-')) {
|
|
117
|
-
const [response, status] = await this.callApi('/131airPurifier/v1/device/deviceStatus', 'put', {
|
|
118
|
-
acceptLanguage: 'en',
|
|
119
|
-
accountID: this.manager.accountId,
|
|
120
|
-
status: 'on',
|
|
121
|
-
timeZone: this.manager.timeZone,
|
|
122
|
-
token: this.manager.token,
|
|
123
|
-
uuid: this.uuid
|
|
124
|
-
}, {
|
|
125
|
-
'accept-language': 'en',
|
|
126
|
-
'accountId': this.manager.accountId,
|
|
127
|
-
'appVersion': '2.8.6',
|
|
128
|
-
'content-type': 'application/json',
|
|
129
|
-
'tk': this.manager.token,
|
|
130
|
-
'tz': this.manager.timeZone
|
|
131
|
-
});
|
|
132
|
-
const success = this.checkResponse([response, status], 'turnOn');
|
|
133
|
-
if (!success) {
|
|
134
|
-
logger_1.logger.error(`Failed to turn on device: ${this.deviceName}`);
|
|
135
|
-
}
|
|
136
|
-
return success;
|
|
137
|
-
}
|
|
138
|
-
// Original implementation for other devices
|
|
139
78
|
const [response, status] = await this.callApi('/cloud/v2/deviceManaged/bypassV2', 'post', {
|
|
140
79
|
...helpers_1.Helpers.reqBody(this.manager, 'bypassV2'),
|
|
141
80
|
cid: this.cid,
|
|
@@ -160,30 +99,6 @@ class VeSyncAirBypass extends vesyncFan_1.VeSyncFan {
|
|
|
160
99
|
*/
|
|
161
100
|
async turnOff() {
|
|
162
101
|
logger_1.logger.info(`Turning off device: ${this.deviceName}`);
|
|
163
|
-
// Special handling for LV series
|
|
164
|
-
if (this.deviceType.startsWith('LV-')) {
|
|
165
|
-
const [response, status] = await this.callApi('/131airPurifier/v1/device/deviceStatus', 'put', {
|
|
166
|
-
acceptLanguage: 'en',
|
|
167
|
-
accountID: this.manager.accountId,
|
|
168
|
-
status: 'off',
|
|
169
|
-
timeZone: this.manager.timeZone,
|
|
170
|
-
token: this.manager.token,
|
|
171
|
-
uuid: this.uuid
|
|
172
|
-
}, {
|
|
173
|
-
'accept-language': 'en',
|
|
174
|
-
'accountId': this.manager.accountId,
|
|
175
|
-
'appVersion': '2.8.6',
|
|
176
|
-
'content-type': 'application/json',
|
|
177
|
-
'tk': this.manager.token,
|
|
178
|
-
'tz': this.manager.timeZone
|
|
179
|
-
});
|
|
180
|
-
const success = this.checkResponse([response, status], 'turnOff');
|
|
181
|
-
if (!success) {
|
|
182
|
-
logger_1.logger.error(`Failed to turn off device: ${this.deviceName}`);
|
|
183
|
-
}
|
|
184
|
-
return success;
|
|
185
|
-
}
|
|
186
|
-
// Original implementation for other devices
|
|
187
102
|
const [response, status] = await this.callApi('/cloud/v2/deviceManaged/bypassV2', 'post', {
|
|
188
103
|
...helpers_1.Helpers.reqBody(this.manager, 'bypassV2'),
|
|
189
104
|
cid: this.cid,
|
|
@@ -213,44 +128,6 @@ class VeSyncAirBypass extends vesyncFan_1.VeSyncFan {
|
|
|
213
128
|
// return false;
|
|
214
129
|
// }
|
|
215
130
|
logger_1.logger.info(`Changing fan speed to ${speed} for device: ${this.deviceName}`);
|
|
216
|
-
// Special handling for LV series
|
|
217
|
-
if (this.deviceType.startsWith('LV-')) {
|
|
218
|
-
// Check if device is in manual mode
|
|
219
|
-
if (this.details.mode !== 'manual') {
|
|
220
|
-
logger_1.logger.debug(`${this.deviceName} not in manual mode, cannot change speed`);
|
|
221
|
-
return false;
|
|
222
|
-
}
|
|
223
|
-
// Validate speed for LV series (1-3)
|
|
224
|
-
if (speed < 1 || speed > 3) {
|
|
225
|
-
logger_1.logger.error(`Invalid fan speed: ${speed}. Must be between 1 and 3 for device: ${this.deviceName}`);
|
|
226
|
-
return false;
|
|
227
|
-
}
|
|
228
|
-
const [response, status] = await this.callApi('/131airPurifier/v1/device/updateSpeed', 'put', {
|
|
229
|
-
acceptLanguage: 'en',
|
|
230
|
-
accountID: this.manager.accountId,
|
|
231
|
-
level: speed,
|
|
232
|
-
timeZone: this.manager.timeZone,
|
|
233
|
-
token: this.manager.token,
|
|
234
|
-
uuid: this.uuid
|
|
235
|
-
}, {
|
|
236
|
-
'accept-language': 'en',
|
|
237
|
-
'accountId': this.manager.accountId,
|
|
238
|
-
'appVersion': '2.8.6',
|
|
239
|
-
'content-type': 'application/json',
|
|
240
|
-
'tk': this.manager.token,
|
|
241
|
-
'tz': this.manager.timeZone
|
|
242
|
-
});
|
|
243
|
-
const success = this.checkResponse([response, status], 'changeFanSpeed');
|
|
244
|
-
if (success) {
|
|
245
|
-
this.details.speed = speed;
|
|
246
|
-
return true;
|
|
247
|
-
}
|
|
248
|
-
else {
|
|
249
|
-
logger_1.logger.error(`Failed to change fan speed to ${speed} for device: ${this.deviceName}`);
|
|
250
|
-
return false;
|
|
251
|
-
}
|
|
252
|
-
}
|
|
253
|
-
// Standard implementation for other devices
|
|
254
131
|
const [response, status] = await this.callApi('/cloud/v2/deviceManaged/bypassV2', 'post', {
|
|
255
132
|
...helpers_1.Helpers.reqBody(this.manager, 'bypassV2'),
|
|
256
133
|
cid: this.cid,
|
|
@@ -282,37 +159,11 @@ class VeSyncAirBypass extends vesyncFan_1.VeSyncFan {
|
|
|
282
159
|
throw new Error(error);
|
|
283
160
|
}
|
|
284
161
|
logger_1.logger.debug(`Setting mode to ${mode} for device: ${this.deviceName}`);
|
|
285
|
-
// Special handling for
|
|
286
|
-
if (this.deviceType.
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
mode: mode,
|
|
291
|
-
timeZone: this.manager.timeZone,
|
|
292
|
-
token: this.manager.token,
|
|
293
|
-
uuid: this.uuid
|
|
294
|
-
};
|
|
295
|
-
// For manual mode, we need to set the level
|
|
296
|
-
if (mode === 'manual') {
|
|
297
|
-
payload.level = this.details.speed || 1;
|
|
298
|
-
}
|
|
299
|
-
const [response, status] = await this.callApi('/131airPurifier/v1/device/updateMode', 'put', payload, {
|
|
300
|
-
'accept-language': 'en',
|
|
301
|
-
'accountId': this.manager.accountId,
|
|
302
|
-
'appVersion': '2.8.6',
|
|
303
|
-
'content-type': 'application/json',
|
|
304
|
-
'tk': this.manager.token,
|
|
305
|
-
'tz': this.manager.timeZone
|
|
306
|
-
});
|
|
307
|
-
const success = this.checkResponse([response, status], 'setMode');
|
|
308
|
-
if (success) {
|
|
309
|
-
this.details.mode = mode;
|
|
310
|
-
return true;
|
|
311
|
-
}
|
|
312
|
-
else {
|
|
313
|
-
logger_1.logger.error(`Failed to set mode to ${mode} for device: ${this.deviceName}`);
|
|
314
|
-
return false;
|
|
315
|
-
}
|
|
162
|
+
// Special handling for Core200S auto mode
|
|
163
|
+
if (this.deviceType.includes('Core200S') && mode === 'auto') {
|
|
164
|
+
// Core200S doesn't support auto mode, so we'll set it to manual mode
|
|
165
|
+
logger_1.logger.warn(`Auto mode not supported for ${this.deviceType}, using manual mode instead`);
|
|
166
|
+
return this.setMode('manual');
|
|
316
167
|
}
|
|
317
168
|
// Standard implementation for other devices
|
|
318
169
|
const [response, status] = await this.callApi('/cloud/v2/deviceManaged/bypassV2', 'post', {
|
|
@@ -328,49 +179,30 @@ class VeSyncAirBypass extends vesyncFan_1.VeSyncFan {
|
|
|
328
179
|
}
|
|
329
180
|
}, helpers_1.Helpers.reqHeaderBypass());
|
|
330
181
|
const success = this.checkResponse([response, status], 'setMode');
|
|
331
|
-
if (
|
|
182
|
+
if (success) {
|
|
183
|
+
this.details.mode = mode;
|
|
184
|
+
return true;
|
|
185
|
+
}
|
|
186
|
+
else {
|
|
332
187
|
logger_1.logger.error(`Failed to set mode to ${mode} for device: ${this.deviceName}`);
|
|
188
|
+
return false;
|
|
333
189
|
}
|
|
334
|
-
return success;
|
|
335
190
|
}
|
|
336
191
|
/**
|
|
337
192
|
* Set display status
|
|
338
193
|
*/
|
|
339
194
|
async setDisplay(enabled) {
|
|
195
|
+
var _a;
|
|
340
196
|
if (!this.hasFeature('display')) {
|
|
341
197
|
const error = 'Display control not supported';
|
|
342
198
|
logger_1.logger.error(`${error} for device: ${this.deviceName}`);
|
|
343
199
|
throw new Error(error);
|
|
344
200
|
}
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
const [response, status] = await this.callApi('/131airPurifier/v1/device/updateScreen', 'put', {
|
|
349
|
-
acceptLanguage: 'en',
|
|
350
|
-
accountID: this.manager.accountId,
|
|
351
|
-
status: enabled ? 'on' : 'off',
|
|
352
|
-
timeZone: this.manager.timeZone,
|
|
353
|
-
token: this.manager.token,
|
|
354
|
-
uuid: this.uuid
|
|
355
|
-
}, {
|
|
356
|
-
'accept-language': 'en',
|
|
357
|
-
'accountId': this.manager.accountId,
|
|
358
|
-
'appVersion': '2.8.6',
|
|
359
|
-
'content-type': 'application/json',
|
|
360
|
-
'tk': this.manager.token,
|
|
361
|
-
'tz': this.manager.timeZone
|
|
362
|
-
});
|
|
363
|
-
const success = this.checkResponse([response, status], 'setDisplay');
|
|
364
|
-
if (success) {
|
|
365
|
-
this.details.screenStatus = enabled ? 'on' : 'off';
|
|
366
|
-
return true;
|
|
367
|
-
}
|
|
368
|
-
else {
|
|
369
|
-
logger_1.logger.error(`Failed to set display to ${enabled ? 'on' : 'off'} for device: ${this.deviceName}`);
|
|
370
|
-
return false;
|
|
371
|
-
}
|
|
201
|
+
// Check if device is in sleep mode - display control may not work in sleep mode
|
|
202
|
+
if (this.details.mode === 'sleep') {
|
|
203
|
+
logger_1.logger.warn(`Device ${this.deviceName} is in sleep mode, display control may not work`);
|
|
372
204
|
}
|
|
373
|
-
|
|
205
|
+
logger_1.logger.debug(`Setting display to ${enabled ? 'on' : 'off'} for device: ${this.deviceName}`);
|
|
374
206
|
const [response, status] = await this.callApi('/cloud/v2/deviceManaged/bypassV2', 'post', {
|
|
375
207
|
...helpers_1.Helpers.reqBody(this.manager, 'bypassV2'),
|
|
376
208
|
cid: this.cid,
|
|
@@ -384,52 +216,35 @@ class VeSyncAirBypass extends vesyncFan_1.VeSyncFan {
|
|
|
384
216
|
}
|
|
385
217
|
}, helpers_1.Helpers.reqHeaderBypass());
|
|
386
218
|
const success = this.checkResponse([response, status], 'setDisplay');
|
|
219
|
+
// Check for error code 11018000 (operation not supported in current mode)
|
|
220
|
+
if (((_a = response === null || response === void 0 ? void 0 : response.result) === null || _a === void 0 ? void 0 : _a.code) === 11018000) {
|
|
221
|
+
logger_1.logger.warn(`Display control not supported in current mode for device: ${this.deviceName}`);
|
|
222
|
+
return false;
|
|
223
|
+
}
|
|
387
224
|
if (success) {
|
|
388
225
|
this.details.screenStatus = enabled ? 'on' : 'off';
|
|
226
|
+
return true;
|
|
389
227
|
}
|
|
390
228
|
else {
|
|
391
229
|
logger_1.logger.error(`Failed to set display to ${enabled ? 'on' : 'off'} for device: ${this.deviceName}`);
|
|
230
|
+
return false;
|
|
392
231
|
}
|
|
393
|
-
return success;
|
|
394
232
|
}
|
|
395
233
|
/**
|
|
396
234
|
* Set child lock
|
|
397
235
|
*/
|
|
398
236
|
async setChildLock(enabled) {
|
|
237
|
+
var _a;
|
|
399
238
|
if (!this.hasFeature('child_lock')) {
|
|
400
239
|
const error = 'Child lock not supported';
|
|
401
240
|
logger_1.logger.error(`${error} for device: ${this.deviceName}`);
|
|
402
241
|
throw new Error(error);
|
|
403
242
|
}
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
const [response, status] = await this.callApi('/131airPurifier/v1/device/updateChildLock', 'put', {
|
|
408
|
-
acceptLanguage: 'en',
|
|
409
|
-
accountID: this.manager.accountId,
|
|
410
|
-
status: enabled ? 'on' : 'off',
|
|
411
|
-
timeZone: this.manager.timeZone,
|
|
412
|
-
token: this.manager.token,
|
|
413
|
-
uuid: this.uuid
|
|
414
|
-
}, {
|
|
415
|
-
'accept-language': 'en',
|
|
416
|
-
'accountId': this.manager.accountId,
|
|
417
|
-
'appVersion': '2.8.6',
|
|
418
|
-
'content-type': 'application/json',
|
|
419
|
-
'tk': this.manager.token,
|
|
420
|
-
'tz': this.manager.timeZone
|
|
421
|
-
});
|
|
422
|
-
const success = this.checkResponse([response, status], 'setChildLock');
|
|
423
|
-
if (success) {
|
|
424
|
-
this.details.childLock = enabled;
|
|
425
|
-
return true;
|
|
426
|
-
}
|
|
427
|
-
else {
|
|
428
|
-
logger_1.logger.error(`Failed to set child lock to ${enabled ? 'on' : 'off'} for device: ${this.deviceName}`);
|
|
429
|
-
return false;
|
|
430
|
-
}
|
|
243
|
+
// Check if device is in sleep mode - child lock may not work in sleep mode
|
|
244
|
+
if (this.details.mode === 'sleep') {
|
|
245
|
+
logger_1.logger.warn(`Device ${this.deviceName} is in sleep mode, child lock control may not work`);
|
|
431
246
|
}
|
|
432
|
-
|
|
247
|
+
logger_1.logger.debug(`Setting child lock to ${enabled ? 'on' : 'off'} for device: ${this.deviceName}`);
|
|
433
248
|
const [response, status] = await this.callApi('/cloud/v2/deviceManaged/bypassV2', 'post', {
|
|
434
249
|
...helpers_1.Helpers.reqBody(this.manager, 'bypassV2'),
|
|
435
250
|
cid: this.cid,
|
|
@@ -443,49 +258,31 @@ class VeSyncAirBypass extends vesyncFan_1.VeSyncFan {
|
|
|
443
258
|
}
|
|
444
259
|
}, helpers_1.Helpers.reqHeaderBypass());
|
|
445
260
|
const success = this.checkResponse([response, status], 'setChildLock');
|
|
261
|
+
// Check for error code 11000000 (feature not supported)
|
|
262
|
+
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)) {
|
|
263
|
+
logger_1.logger.warn(`Child lock control not supported via API for device: ${this.deviceName}`);
|
|
264
|
+
return false;
|
|
265
|
+
}
|
|
446
266
|
if (success) {
|
|
447
|
-
this.details.
|
|
267
|
+
this.details.childLock = enabled;
|
|
268
|
+
return true;
|
|
448
269
|
}
|
|
449
270
|
else {
|
|
450
271
|
logger_1.logger.error(`Failed to set child lock to ${enabled ? 'on' : 'off'} for device: ${this.deviceName}`);
|
|
272
|
+
return false;
|
|
451
273
|
}
|
|
452
|
-
return success;
|
|
453
274
|
}
|
|
454
275
|
/**
|
|
455
276
|
* Set timer
|
|
456
277
|
*/
|
|
457
278
|
async setTimer(hours) {
|
|
279
|
+
var _a, _b;
|
|
458
280
|
if (!this.hasFeature('timer')) {
|
|
459
281
|
const error = 'Timer not supported';
|
|
460
282
|
logger_1.logger.error(`${error} for device: ${this.deviceName}`);
|
|
461
283
|
throw new Error(error);
|
|
462
284
|
}
|
|
463
285
|
logger_1.logger.debug(`Setting timer to ${hours} hours for device: ${this.deviceName}`);
|
|
464
|
-
// Special handling for LV series
|
|
465
|
-
if (this.deviceType.startsWith('LV-')) {
|
|
466
|
-
const [response, status] = await this.callApi('/131airPurifier/v1/device/updateTimer', 'put', {
|
|
467
|
-
acceptLanguage: 'en',
|
|
468
|
-
accountID: this.manager.accountId,
|
|
469
|
-
action: 'off',
|
|
470
|
-
duration: hours,
|
|
471
|
-
timeZone: this.manager.timeZone,
|
|
472
|
-
token: this.manager.token,
|
|
473
|
-
uuid: this.uuid
|
|
474
|
-
}, {
|
|
475
|
-
'accept-language': 'en',
|
|
476
|
-
'accountId': this.manager.accountId,
|
|
477
|
-
'appVersion': '2.8.6',
|
|
478
|
-
'content-type': 'application/json',
|
|
479
|
-
'tk': this.manager.token,
|
|
480
|
-
'tz': this.manager.timeZone
|
|
481
|
-
});
|
|
482
|
-
const success = this.checkResponse([response, status], 'setTimer');
|
|
483
|
-
if (!success) {
|
|
484
|
-
logger_1.logger.error(`Failed to set timer to ${hours} hours for device: ${this.deviceName}`);
|
|
485
|
-
}
|
|
486
|
-
return success;
|
|
487
|
-
}
|
|
488
|
-
// Standard implementation for other devices
|
|
489
286
|
const [response, status] = await this.callApi('/cloud/v2/deviceManaged/bypassV2', 'post', {
|
|
490
287
|
...helpers_1.Helpers.reqBody(this.manager, 'bypassV2'),
|
|
491
288
|
cid: this.cid,
|
|
@@ -500,44 +297,38 @@ class VeSyncAirBypass extends vesyncFan_1.VeSyncFan {
|
|
|
500
297
|
}
|
|
501
298
|
}, helpers_1.Helpers.reqHeaderBypass());
|
|
502
299
|
const success = this.checkResponse([response, status], 'setTimer');
|
|
503
|
-
|
|
300
|
+
// Check for successful response with timer ID
|
|
301
|
+
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)) {
|
|
302
|
+
this.timer = { duration: hours * 3600, action: 'off' };
|
|
303
|
+
return true;
|
|
304
|
+
}
|
|
305
|
+
else if (success) {
|
|
306
|
+
// API call succeeded but no timer ID returned
|
|
307
|
+
logger_1.logger.warn(`Timer API call succeeded but no timer ID returned for device: ${this.deviceName}`);
|
|
308
|
+
this.timer = { duration: hours * 3600, action: 'off' };
|
|
309
|
+
return true;
|
|
310
|
+
}
|
|
311
|
+
else {
|
|
504
312
|
logger_1.logger.error(`Failed to set timer to ${hours} hours for device: ${this.deviceName}`);
|
|
313
|
+
return false;
|
|
505
314
|
}
|
|
506
|
-
return success;
|
|
507
315
|
}
|
|
508
316
|
/**
|
|
509
317
|
* Clear timer
|
|
510
318
|
*/
|
|
511
319
|
async clearTimer() {
|
|
320
|
+
var _a;
|
|
512
321
|
if (!this.hasFeature('timer')) {
|
|
513
322
|
const error = 'Timer not supported';
|
|
514
323
|
logger_1.logger.error(`${error} for device: ${this.deviceName}`);
|
|
515
324
|
throw new Error(error);
|
|
516
325
|
}
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
acceptLanguage: 'en',
|
|
522
|
-
accountID: this.manager.accountId,
|
|
523
|
-
timeZone: this.manager.timeZone,
|
|
524
|
-
token: this.manager.token,
|
|
525
|
-
uuid: this.uuid
|
|
526
|
-
}, {
|
|
527
|
-
'accept-language': 'en',
|
|
528
|
-
'accountId': this.manager.accountId,
|
|
529
|
-
'appVersion': '2.8.6',
|
|
530
|
-
'content-type': 'application/json',
|
|
531
|
-
'tk': this.manager.token,
|
|
532
|
-
'tz': this.manager.timeZone
|
|
533
|
-
});
|
|
534
|
-
const success = this.checkResponse([response, status], 'clearTimer');
|
|
535
|
-
if (!success) {
|
|
536
|
-
logger_1.logger.error(`Failed to clear timer for device: ${this.deviceName}`);
|
|
537
|
-
}
|
|
538
|
-
return success;
|
|
326
|
+
// If no timer is set, return success
|
|
327
|
+
if (!this.timer) {
|
|
328
|
+
logger_1.logger.debug(`No timer to clear for device: ${this.deviceName}`);
|
|
329
|
+
return true;
|
|
539
330
|
}
|
|
540
|
-
|
|
331
|
+
logger_1.logger.debug(`Clearing timer for device: ${this.deviceName}`);
|
|
541
332
|
const [response, status] = await this.callApi('/cloud/v2/deviceManaged/bypassV2', 'post', {
|
|
542
333
|
...helpers_1.Helpers.reqBody(this.manager, 'bypassV2'),
|
|
543
334
|
cid: this.cid,
|
|
@@ -549,10 +340,20 @@ class VeSyncAirBypass extends vesyncFan_1.VeSyncFan {
|
|
|
549
340
|
}
|
|
550
341
|
}, helpers_1.Helpers.reqHeaderBypass());
|
|
551
342
|
const success = this.checkResponse([response, status], 'clearTimer');
|
|
552
|
-
|
|
343
|
+
// Check for error code 11000000 (feature not supported or no timer to clear)
|
|
344
|
+
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)) {
|
|
345
|
+
logger_1.logger.warn(`No timer to clear or timer control not supported via API for device: ${this.deviceName}`);
|
|
346
|
+
this.timer = null;
|
|
347
|
+
return true;
|
|
348
|
+
}
|
|
349
|
+
if (success) {
|
|
350
|
+
this.timer = null;
|
|
351
|
+
return true;
|
|
352
|
+
}
|
|
353
|
+
else {
|
|
553
354
|
logger_1.logger.error(`Failed to clear timer for device: ${this.deviceName}`);
|
|
355
|
+
return false;
|
|
554
356
|
}
|
|
555
|
-
return success;
|
|
556
357
|
}
|
|
557
358
|
/**
|
|
558
359
|
* Turn automatic stop on
|
package/dist/lib/fans/index.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ import { VeSyncFan } from '../vesyncFan';
|
|
|
2
2
|
import { VeSync } from '../vesync';
|
|
3
3
|
export { VeSyncAirBypass } from './airBypass';
|
|
4
4
|
export { VeSyncAirBaseV2 } from './airBaseV2';
|
|
5
|
+
export { VeSyncAir131 } from './air131';
|
|
5
6
|
export { VeSyncTowerFan } from './towerFan';
|
|
6
7
|
export { VeSyncHumidifier } from './humidifier';
|
|
7
8
|
export { VeSyncWarmHumidifier } from './warmHumidifier';
|
package/dist/lib/fans/index.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.fanModules = exports.VeSyncHumid200S = exports.VeSyncHumid1000S = exports.VeSyncSuperior6000S = exports.VeSyncHumid200300S = exports.VeSyncWarmHumidifier = exports.VeSyncHumidifier = exports.VeSyncTowerFan = exports.VeSyncAirBaseV2 = exports.VeSyncAirBypass = void 0;
|
|
3
|
+
exports.fanModules = exports.VeSyncHumid200S = exports.VeSyncHumid1000S = exports.VeSyncSuperior6000S = exports.VeSyncHumid200300S = exports.VeSyncWarmHumidifier = exports.VeSyncHumidifier = exports.VeSyncTowerFan = exports.VeSyncAir131 = exports.VeSyncAirBaseV2 = exports.VeSyncAirBypass = void 0;
|
|
4
4
|
const airBypass_1 = require("./airBypass");
|
|
5
5
|
const airBaseV2_1 = require("./airBaseV2");
|
|
6
|
+
const air131_1 = require("./air131");
|
|
6
7
|
const towerFan_1 = require("./towerFan");
|
|
7
8
|
const humidifier_1 = require("./humidifier");
|
|
8
9
|
const humid200300S_1 = require("./humid200300S");
|
|
@@ -14,6 +15,8 @@ var airBypass_2 = require("./airBypass");
|
|
|
14
15
|
Object.defineProperty(exports, "VeSyncAirBypass", { enumerable: true, get: function () { return airBypass_2.VeSyncAirBypass; } });
|
|
15
16
|
var airBaseV2_2 = require("./airBaseV2");
|
|
16
17
|
Object.defineProperty(exports, "VeSyncAirBaseV2", { enumerable: true, get: function () { return airBaseV2_2.VeSyncAirBaseV2; } });
|
|
18
|
+
var air131_2 = require("./air131");
|
|
19
|
+
Object.defineProperty(exports, "VeSyncAir131", { enumerable: true, get: function () { return air131_2.VeSyncAir131; } });
|
|
17
20
|
var towerFan_2 = require("./towerFan");
|
|
18
21
|
Object.defineProperty(exports, "VeSyncTowerFan", { enumerable: true, get: function () { return towerFan_2.VeSyncTowerFan; } });
|
|
19
22
|
var humidifier_2 = require("./humidifier");
|
|
@@ -99,6 +102,6 @@ exports.fanModules = {
|
|
|
99
102
|
'LEH-S601S-WUS': superior6000S_1.VeSyncSuperior6000S,
|
|
100
103
|
'LEH-S601S-WUSR': superior6000S_1.VeSyncSuperior6000S,
|
|
101
104
|
// LV Series
|
|
102
|
-
'LV-PUR131S':
|
|
103
|
-
'LV-RH131S':
|
|
105
|
+
'LV-PUR131S': air131_1.VeSyncAir131,
|
|
106
|
+
'LV-RH131S': air131_1.VeSyncAir131
|
|
104
107
|
};
|
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' | 'VeSyncAirBaseV2' | 'VeSyncSuperior6000S' | 'VeSyncHumid1000S' | 'VeSyncHumid200S';
|
|
8
|
+
module: 'VeSyncAirBypass' | 'VeSyncHumidifier' | 'VeSyncWarmHumidifier' | 'VeSyncTowerFan' | 'VeSyncAirBaseV2' | 'VeSyncSuperior6000S' | 'VeSyncHumid1000S' | 'VeSyncHumid200S' | 'VeSyncAir131';
|
|
9
9
|
features: string[];
|
|
10
10
|
levels?: number[];
|
|
11
11
|
};
|
|
@@ -35,7 +35,7 @@ export declare abstract class VeSyncFan extends VeSyncBaseDevice {
|
|
|
35
35
|
action: string;
|
|
36
36
|
} | null;
|
|
37
37
|
protected config: {
|
|
38
|
-
module: 'VeSyncAirBypass' | 'VeSyncHumidifier' | 'VeSyncWarmHumidifier' | 'VeSyncTowerFan' | 'VeSyncAirBaseV2' | 'VeSyncSuperior6000S' | 'VeSyncHumid1000S' | 'VeSyncHumid200S';
|
|
38
|
+
module: 'VeSyncAirBypass' | 'VeSyncHumidifier' | 'VeSyncWarmHumidifier' | 'VeSyncTowerFan' | 'VeSyncAirBaseV2' | 'VeSyncSuperior6000S' | 'VeSyncHumid1000S' | 'VeSyncHumid200S' | 'VeSyncAir131';
|
|
39
39
|
features: string[];
|
|
40
40
|
levels?: number[];
|
|
41
41
|
};
|
|
@@ -44,6 +44,14 @@ export declare abstract class VeSyncFan extends VeSyncBaseDevice {
|
|
|
44
44
|
* Check if feature is supported
|
|
45
45
|
*/
|
|
46
46
|
hasFeature(feature: string): boolean;
|
|
47
|
+
/**
|
|
48
|
+
* Check if feature is supported in current mode
|
|
49
|
+
*/
|
|
50
|
+
isFeatureSupportedInCurrentMode(feature: string): boolean;
|
|
51
|
+
/**
|
|
52
|
+
* Get maximum fan speed level
|
|
53
|
+
*/
|
|
54
|
+
getMaxFanSpeed(): number;
|
|
47
55
|
/**
|
|
48
56
|
* Get current mode
|
|
49
57
|
*/
|