tsvesync 1.0.12 → 1.0.14
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/helpers.js +3 -2
- package/dist/lib/logger.d.ts +23 -0
- package/dist/lib/logger.js +54 -0
- package/dist/lib/vesync.js +42 -41
- package/dist/lib/vesyncBaseDevice.js +8 -7
- package/dist/lib/vesyncBulb.d.ts +9 -0
- package/dist/lib/vesyncBulb.js +125 -28
- package/dist/lib/vesyncBulbImpl.d.ts +1 -1
- package/dist/lib/vesyncBulbImpl.js +105 -36
- package/dist/lib/vesyncFan.js +2 -1
- package/dist/lib/vesyncFanImpl.d.ts +36 -0
- package/dist/lib/vesyncFanImpl.js +307 -42
- package/dist/lib/vesyncOutlet.d.ts +17 -0
- package/dist/lib/vesyncOutlet.js +124 -8
- package/dist/lib/vesyncOutletImpl.js +39 -0
- package/dist/lib/vesyncSwitch.d.ts +0 -124
- package/dist/lib/vesyncSwitch.js +3 -343
- package/dist/lib/vesyncSwitchImpl.d.ts +6 -6
- package/dist/lib/vesyncSwitchImpl.js +69 -15
- package/package.json +1 -1
- package/src/lib/helpers.ts +3 -2
- package/src/lib/logger.ts +60 -0
- package/src/lib/vesync.ts +42 -43
- package/src/lib/vesyncBaseDevice.ts +8 -7
- package/src/lib/vesyncBulb.ts +138 -30
- package/src/lib/vesyncBulbImpl.ts +113 -44
- package/src/lib/vesyncFan.ts +2 -4
- package/src/lib/vesyncFanImpl.ts +314 -42
- package/src/lib/vesyncOutlet.ts +140 -13
- package/src/lib/vesyncOutletImpl.ts +41 -0
- package/src/lib/vesyncSwitch.ts +3 -454
- package/src/lib/vesyncSwitchImpl.ts +66 -16
- package/dist/lib/helpers.js.map +0 -1
- package/dist/lib/vesync.js.map +0 -1
- package/dist/lib/vesyncBaseDevice.js.map +0 -1
- package/dist/lib/vesyncBulb.js.map +0 -1
- package/dist/lib/vesyncFan.js.map +0 -1
- package/dist/lib/vesyncKitchen.d.ts +0 -0
- package/dist/lib/vesyncKitchen.js +0 -2
- package/dist/lib/vesyncKitchen.js.map +0 -1
- package/dist/lib/vesyncOutlet.js.map +0 -1
- package/dist/lib/vesyncSwitch.js.map +0 -1
- package/dist/src/lib/helpers.d.ts +0 -88
- package/dist/src/lib/helpers.js +0 -244
- package/dist/src/lib/vesync.d.ts +0 -89
- package/dist/src/lib/vesync.js +0 -430
- package/dist/src/lib/vesyncBaseDevice.d.ts +0 -43
- package/dist/src/lib/vesyncBaseDevice.js +0 -87
- package/dist/src/lib/vesyncBulb.d.ts +0 -79
- package/dist/src/lib/vesyncBulb.js +0 -198
- package/dist/src/lib/vesyncBulbImpl.d.ts +0 -38
- package/dist/src/lib/vesyncBulbImpl.js +0 -161
- package/dist/src/lib/vesyncFan.d.ts +0 -80
- package/dist/src/lib/vesyncFan.js +0 -406
- package/dist/src/lib/vesyncFanImpl.d.ts +0 -137
- package/dist/src/lib/vesyncFanImpl.js +0 -643
- package/dist/src/lib/vesyncOutlet.d.ts +0 -53
- package/dist/src/lib/vesyncOutlet.js +0 -98
- package/dist/src/lib/vesyncOutletImpl.d.ts +0 -70
- package/dist/src/lib/vesyncOutletImpl.js +0 -206
- package/dist/src/lib/vesyncSwitch.d.ts +0 -169
- package/dist/src/lib/vesyncSwitch.js +0 -414
- package/dist/src/lib/vesyncSwitchImpl.d.ts +0 -82
- package/dist/src/lib/vesyncSwitchImpl.js +0 -290
- package/dist/test/testFeatures.d.ts +0 -4
- package/dist/test/testFeatures.js +0 -394
- package/dist/test/testService.d.ts +0 -62
- package/dist/test/testService.js +0 -540
- package/dist/test/testSpecial.d.ts +0 -5
- package/dist/test/testSpecial.js +0 -227
|
@@ -1,643 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* VeSync Fan Implementations
|
|
4
|
-
*/
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.fanModules = exports.VeSyncWarmHumidifier = exports.VeSyncHumidifier = exports.VeSyncAirBypass = void 0;
|
|
7
|
-
const vesyncFan_1 = require("./vesyncFan");
|
|
8
|
-
const helpers_1 = require("./helpers");
|
|
9
|
-
/**
|
|
10
|
-
* VeSync Air Purifier with Bypass
|
|
11
|
-
*/
|
|
12
|
-
class VeSyncAirBypass extends vesyncFan_1.VeSyncFan {
|
|
13
|
-
constructor(details, manager) {
|
|
14
|
-
super(details, manager);
|
|
15
|
-
this.modes = ['auto', 'manual', 'sleep'];
|
|
16
|
-
this.speeds = [1, 2, 3, 4, 5];
|
|
17
|
-
this.displayModes = ['on', 'off'];
|
|
18
|
-
this.childLockModes = ['on', 'off'];
|
|
19
|
-
}
|
|
20
|
-
/**
|
|
21
|
-
* Get device details
|
|
22
|
-
*/
|
|
23
|
-
async getDetails() {
|
|
24
|
-
const [response, status] = await helpers_1.Helpers.callApi('/cloud/v2/deviceManaged/bypassV2', 'post', {
|
|
25
|
-
...helpers_1.Helpers.reqBody(this.manager, 'bypassV2'),
|
|
26
|
-
cid: this.cid,
|
|
27
|
-
configModule: this.configModule,
|
|
28
|
-
payload: {
|
|
29
|
-
data: {},
|
|
30
|
-
method: 'getPurifierStatus',
|
|
31
|
-
source: 'APP'
|
|
32
|
-
}
|
|
33
|
-
}, helpers_1.Helpers.reqHeaderBypass());
|
|
34
|
-
if (this.checkResponse([response, status], 'getDetails')) {
|
|
35
|
-
const result = response?.result?.result;
|
|
36
|
-
if (result) {
|
|
37
|
-
// Update device status
|
|
38
|
-
this.deviceStatus = result.enabled ? 'on' : 'off';
|
|
39
|
-
// Store device settings
|
|
40
|
-
this.details = {
|
|
41
|
-
mode: result.mode || '',
|
|
42
|
-
speed: result.level || 0,
|
|
43
|
-
filterLife: result.filter_life || 0,
|
|
44
|
-
screenStatus: result.display || false,
|
|
45
|
-
childLock: result.child_lock || false,
|
|
46
|
-
airQuality: result.air_quality || 0
|
|
47
|
-
};
|
|
48
|
-
// Store configuration if available
|
|
49
|
-
if (result.configuration) {
|
|
50
|
-
this.config = result.configuration;
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
/**
|
|
56
|
-
* Turn device on
|
|
57
|
-
*/
|
|
58
|
-
async turnOn() {
|
|
59
|
-
const [response, status] = await helpers_1.Helpers.callApi('/cloud/v2/deviceManaged/bypassV2', 'post', {
|
|
60
|
-
...helpers_1.Helpers.reqBody(this.manager, 'bypassV2'),
|
|
61
|
-
cid: this.cid,
|
|
62
|
-
configModule: this.configModule,
|
|
63
|
-
payload: {
|
|
64
|
-
data: {
|
|
65
|
-
enabled: true,
|
|
66
|
-
id: 0
|
|
67
|
-
},
|
|
68
|
-
method: 'setSwitch',
|
|
69
|
-
source: 'APP'
|
|
70
|
-
}
|
|
71
|
-
}, helpers_1.Helpers.reqHeaderBypass());
|
|
72
|
-
return this.checkResponse([response, status], 'turnOn');
|
|
73
|
-
}
|
|
74
|
-
/**
|
|
75
|
-
* Turn device off
|
|
76
|
-
*/
|
|
77
|
-
async turnOff() {
|
|
78
|
-
const [response, status] = await helpers_1.Helpers.callApi('/cloud/v2/deviceManaged/bypassV2', 'post', {
|
|
79
|
-
...helpers_1.Helpers.reqBody(this.manager, 'bypassV2'),
|
|
80
|
-
cid: this.cid,
|
|
81
|
-
configModule: this.configModule,
|
|
82
|
-
payload: {
|
|
83
|
-
data: {
|
|
84
|
-
enabled: false,
|
|
85
|
-
id: 0
|
|
86
|
-
},
|
|
87
|
-
method: 'setSwitch',
|
|
88
|
-
source: 'APP'
|
|
89
|
-
}
|
|
90
|
-
}, helpers_1.Helpers.reqHeaderBypass());
|
|
91
|
-
return this.checkResponse([response, status], 'turnOff');
|
|
92
|
-
}
|
|
93
|
-
/**
|
|
94
|
-
* Change fan speed
|
|
95
|
-
*/
|
|
96
|
-
async changeFanSpeed(speed) {
|
|
97
|
-
if (!this.speeds.includes(speed)) {
|
|
98
|
-
throw new Error(`Invalid speed: ${speed}. Must be one of: ${this.speeds.join(', ')}`);
|
|
99
|
-
}
|
|
100
|
-
const [response, status] = await helpers_1.Helpers.callApi('/cloud/v2/deviceManaged/bypassV2', 'post', {
|
|
101
|
-
...helpers_1.Helpers.reqBody(this.manager, 'bypassV2'),
|
|
102
|
-
cid: this.cid,
|
|
103
|
-
configModule: this.configModule,
|
|
104
|
-
payload: {
|
|
105
|
-
data: {
|
|
106
|
-
id: 0,
|
|
107
|
-
level: speed,
|
|
108
|
-
mode: 'manual',
|
|
109
|
-
type: 'wind'
|
|
110
|
-
},
|
|
111
|
-
method: 'setLevel',
|
|
112
|
-
source: 'APP'
|
|
113
|
-
}
|
|
114
|
-
}, helpers_1.Helpers.reqHeaderBypass());
|
|
115
|
-
return this.checkResponse([response, status], 'changeFanSpeed');
|
|
116
|
-
}
|
|
117
|
-
/**
|
|
118
|
-
* Set device mode
|
|
119
|
-
*/
|
|
120
|
-
async setMode(mode) {
|
|
121
|
-
if (!this.modes.includes(mode)) {
|
|
122
|
-
throw new Error(`Invalid mode: ${mode}. Must be one of: ${this.modes.join(', ')}`);
|
|
123
|
-
}
|
|
124
|
-
const [response, status] = await helpers_1.Helpers.callApi('/cloud/v2/deviceManaged/bypassV2', 'post', {
|
|
125
|
-
...helpers_1.Helpers.reqBody(this.manager, 'bypassV2'),
|
|
126
|
-
cid: this.cid,
|
|
127
|
-
configModule: this.configModule,
|
|
128
|
-
payload: {
|
|
129
|
-
data: {
|
|
130
|
-
mode
|
|
131
|
-
},
|
|
132
|
-
method: 'setPurifierMode',
|
|
133
|
-
source: 'APP'
|
|
134
|
-
}
|
|
135
|
-
}, helpers_1.Helpers.reqHeaderBypass());
|
|
136
|
-
return this.checkResponse([response, status], 'setMode');
|
|
137
|
-
}
|
|
138
|
-
/**
|
|
139
|
-
* Set display status
|
|
140
|
-
*/
|
|
141
|
-
async setDisplay(enabled) {
|
|
142
|
-
if (!this.hasFeature('display')) {
|
|
143
|
-
throw new Error('Display control not supported');
|
|
144
|
-
}
|
|
145
|
-
const [response, status] = await helpers_1.Helpers.callApi('/cloud/v2/deviceManaged/bypassV2', 'post', {
|
|
146
|
-
...helpers_1.Helpers.reqBody(this.manager, 'bypassV2'),
|
|
147
|
-
cid: this.cid,
|
|
148
|
-
configModule: this.configModule,
|
|
149
|
-
payload: {
|
|
150
|
-
data: {
|
|
151
|
-
state: enabled
|
|
152
|
-
},
|
|
153
|
-
method: 'setDisplay',
|
|
154
|
-
source: 'APP'
|
|
155
|
-
}
|
|
156
|
-
}, helpers_1.Helpers.reqHeaderBypass());
|
|
157
|
-
return this.checkResponse([response, status], 'setDisplay');
|
|
158
|
-
}
|
|
159
|
-
/**
|
|
160
|
-
* Set child lock
|
|
161
|
-
*/
|
|
162
|
-
async setChildLock(enabled) {
|
|
163
|
-
if (!this.hasFeature('child_lock')) {
|
|
164
|
-
throw new Error('Child lock not supported');
|
|
165
|
-
}
|
|
166
|
-
const [response, status] = await helpers_1.Helpers.callApi('/cloud/v2/deviceManaged/bypassV2', 'post', {
|
|
167
|
-
...helpers_1.Helpers.reqBody(this.manager, 'bypassV2'),
|
|
168
|
-
cid: this.cid,
|
|
169
|
-
configModule: this.configModule,
|
|
170
|
-
payload: {
|
|
171
|
-
data: {
|
|
172
|
-
state: enabled
|
|
173
|
-
},
|
|
174
|
-
method: 'setChildLock',
|
|
175
|
-
source: 'APP'
|
|
176
|
-
}
|
|
177
|
-
}, helpers_1.Helpers.reqHeaderBypass());
|
|
178
|
-
return this.checkResponse([response, status], 'setChildLock');
|
|
179
|
-
}
|
|
180
|
-
/**
|
|
181
|
-
* Set timer
|
|
182
|
-
*/
|
|
183
|
-
async setTimer(hours) {
|
|
184
|
-
if (!this.hasFeature('timer')) {
|
|
185
|
-
throw new Error('Timer not supported');
|
|
186
|
-
}
|
|
187
|
-
const [response, status] = await helpers_1.Helpers.callApi('/cloud/v2/deviceManaged/bypassV2', 'post', {
|
|
188
|
-
...helpers_1.Helpers.reqBody(this.manager, 'bypassV2'),
|
|
189
|
-
cid: this.cid,
|
|
190
|
-
configModule: this.configModule,
|
|
191
|
-
payload: {
|
|
192
|
-
data: {
|
|
193
|
-
action: 'off',
|
|
194
|
-
total: hours * 3600
|
|
195
|
-
},
|
|
196
|
-
method: 'addTimer',
|
|
197
|
-
source: 'APP'
|
|
198
|
-
}
|
|
199
|
-
}, helpers_1.Helpers.reqHeaderBypass());
|
|
200
|
-
return this.checkResponse([response, status], 'setTimer');
|
|
201
|
-
}
|
|
202
|
-
/**
|
|
203
|
-
* Clear timer
|
|
204
|
-
*/
|
|
205
|
-
async clearTimer() {
|
|
206
|
-
if (!this.hasFeature('timer')) {
|
|
207
|
-
throw new Error('Timer not supported');
|
|
208
|
-
}
|
|
209
|
-
const [response, status] = await helpers_1.Helpers.callApi('/cloud/v2/deviceManaged/bypassV2', 'post', {
|
|
210
|
-
...helpers_1.Helpers.reqBody(this.manager, 'bypassV2'),
|
|
211
|
-
cid: this.cid,
|
|
212
|
-
configModule: this.configModule,
|
|
213
|
-
payload: {
|
|
214
|
-
data: {},
|
|
215
|
-
method: 'deleteTimer',
|
|
216
|
-
source: 'APP'
|
|
217
|
-
}
|
|
218
|
-
}, helpers_1.Helpers.reqHeaderBypass());
|
|
219
|
-
return this.checkResponse([response, status], 'clearTimer');
|
|
220
|
-
}
|
|
221
|
-
/**
|
|
222
|
-
* Turn automatic stop on
|
|
223
|
-
*/
|
|
224
|
-
async automaticStopOn() {
|
|
225
|
-
const [response, status] = await helpers_1.Helpers.callApi('/cloud/v2/deviceManaged/bypassV2', 'post', {
|
|
226
|
-
...helpers_1.Helpers.reqBody(this.manager, 'bypassV2'),
|
|
227
|
-
cid: this.cid,
|
|
228
|
-
configModule: this.configModule,
|
|
229
|
-
payload: {
|
|
230
|
-
data: {
|
|
231
|
-
enabled: true
|
|
232
|
-
},
|
|
233
|
-
method: 'setAutomaticStop',
|
|
234
|
-
source: 'APP'
|
|
235
|
-
}
|
|
236
|
-
}, helpers_1.Helpers.reqHeaderBypass());
|
|
237
|
-
return this.checkResponse([response, status], 'automaticStopOn');
|
|
238
|
-
}
|
|
239
|
-
/**
|
|
240
|
-
* Turn automatic stop off
|
|
241
|
-
*/
|
|
242
|
-
async automaticStopOff() {
|
|
243
|
-
const [response, status] = await helpers_1.Helpers.callApi('/cloud/v2/deviceManaged/bypassV2', 'post', {
|
|
244
|
-
...helpers_1.Helpers.reqBody(this.manager, 'bypassV2'),
|
|
245
|
-
cid: this.cid,
|
|
246
|
-
configModule: this.configModule,
|
|
247
|
-
payload: {
|
|
248
|
-
data: {
|
|
249
|
-
enabled: false
|
|
250
|
-
},
|
|
251
|
-
method: 'setAutomaticStop',
|
|
252
|
-
source: 'APP'
|
|
253
|
-
}
|
|
254
|
-
}, helpers_1.Helpers.reqHeaderBypass());
|
|
255
|
-
return this.checkResponse([response, status], 'automaticStopOff');
|
|
256
|
-
}
|
|
257
|
-
}
|
|
258
|
-
exports.VeSyncAirBypass = VeSyncAirBypass;
|
|
259
|
-
/**
|
|
260
|
-
* VeSync Humidifier Base Class
|
|
261
|
-
*/
|
|
262
|
-
class VeSyncHumidifier extends vesyncFan_1.VeSyncFan {
|
|
263
|
-
constructor(details, manager) {
|
|
264
|
-
super(details, manager);
|
|
265
|
-
this.modes = ['auto', 'manual', 'sleep'];
|
|
266
|
-
this.speeds = [1, 2, 3];
|
|
267
|
-
this.displayModes = ['on', 'off'];
|
|
268
|
-
this.mistLevels = [1, 2, 3];
|
|
269
|
-
this.humidityRange = { min: 30, max: 80 };
|
|
270
|
-
}
|
|
271
|
-
/**
|
|
272
|
-
* Get device details
|
|
273
|
-
*/
|
|
274
|
-
async getDetails() {
|
|
275
|
-
const [response, status] = await helpers_1.Helpers.callApi('/cloud/v2/deviceManaged/bypassV2', 'post', {
|
|
276
|
-
...helpers_1.Helpers.reqBody(this.manager, 'bypassV2'),
|
|
277
|
-
cid: this.cid,
|
|
278
|
-
configModule: this.configModule,
|
|
279
|
-
payload: {
|
|
280
|
-
data: {},
|
|
281
|
-
method: 'getHumidifierStatus',
|
|
282
|
-
source: 'APP'
|
|
283
|
-
}
|
|
284
|
-
}, helpers_1.Helpers.reqHeaderBypass());
|
|
285
|
-
if (this.checkResponse([response, status], 'getDetails')) {
|
|
286
|
-
this.details = response.result.result;
|
|
287
|
-
}
|
|
288
|
-
}
|
|
289
|
-
/**
|
|
290
|
-
* Turn device on
|
|
291
|
-
*/
|
|
292
|
-
async turnOn() {
|
|
293
|
-
const [response, status] = await helpers_1.Helpers.callApi('/cloud/v2/deviceManaged/bypassV2', 'post', {
|
|
294
|
-
...helpers_1.Helpers.reqBody(this.manager, 'bypassV2'),
|
|
295
|
-
cid: this.cid,
|
|
296
|
-
configModule: this.configModule,
|
|
297
|
-
payload: {
|
|
298
|
-
data: {
|
|
299
|
-
enabled: true,
|
|
300
|
-
id: 0
|
|
301
|
-
},
|
|
302
|
-
method: 'setSwitch',
|
|
303
|
-
source: 'APP'
|
|
304
|
-
}
|
|
305
|
-
}, helpers_1.Helpers.reqHeaderBypass());
|
|
306
|
-
return this.checkResponse([response, status], 'turnOn');
|
|
307
|
-
}
|
|
308
|
-
/**
|
|
309
|
-
* Turn device off
|
|
310
|
-
*/
|
|
311
|
-
async turnOff() {
|
|
312
|
-
const [response, status] = await helpers_1.Helpers.callApi('/cloud/v2/deviceManaged/bypassV2', 'post', {
|
|
313
|
-
...helpers_1.Helpers.reqBody(this.manager, 'bypassV2'),
|
|
314
|
-
cid: this.cid,
|
|
315
|
-
configModule: this.configModule,
|
|
316
|
-
payload: {
|
|
317
|
-
data: {
|
|
318
|
-
enabled: false,
|
|
319
|
-
id: 0
|
|
320
|
-
},
|
|
321
|
-
method: 'setSwitch',
|
|
322
|
-
source: 'APP'
|
|
323
|
-
}
|
|
324
|
-
}, helpers_1.Helpers.reqHeaderBypass());
|
|
325
|
-
return this.checkResponse([response, status], 'turnOff');
|
|
326
|
-
}
|
|
327
|
-
/**
|
|
328
|
-
* Change fan speed
|
|
329
|
-
*/
|
|
330
|
-
async changeFanSpeed(speed) {
|
|
331
|
-
if (!this.speeds.includes(speed)) {
|
|
332
|
-
throw new Error(`Invalid speed: ${speed}. Must be one of: ${this.speeds.join(', ')}`);
|
|
333
|
-
}
|
|
334
|
-
const [response, status] = await helpers_1.Helpers.callApi('/cloud/v2/deviceManaged/bypassV2', 'post', {
|
|
335
|
-
...helpers_1.Helpers.reqBody(this.manager, 'bypassV2'),
|
|
336
|
-
cid: this.cid,
|
|
337
|
-
configModule: this.configModule,
|
|
338
|
-
payload: {
|
|
339
|
-
data: {
|
|
340
|
-
id: 0,
|
|
341
|
-
level: speed,
|
|
342
|
-
type: 'wind'
|
|
343
|
-
},
|
|
344
|
-
method: 'setLevel',
|
|
345
|
-
source: 'APP'
|
|
346
|
-
}
|
|
347
|
-
}, helpers_1.Helpers.reqHeaderBypass());
|
|
348
|
-
return this.checkResponse([response, status], 'changeFanSpeed');
|
|
349
|
-
}
|
|
350
|
-
/**
|
|
351
|
-
* Set device mode
|
|
352
|
-
*/
|
|
353
|
-
async setMode(mode) {
|
|
354
|
-
if (!this.modes.includes(mode)) {
|
|
355
|
-
throw new Error(`Invalid mode: ${mode}. Must be one of: ${this.modes.join(', ')}`);
|
|
356
|
-
}
|
|
357
|
-
const [response, status] = await helpers_1.Helpers.callApi('/cloud/v2/deviceManaged/bypassV2', 'post', {
|
|
358
|
-
...helpers_1.Helpers.reqBody(this.manager, 'bypassV2'),
|
|
359
|
-
cid: this.cid,
|
|
360
|
-
configModule: this.configModule,
|
|
361
|
-
payload: {
|
|
362
|
-
data: {
|
|
363
|
-
mode
|
|
364
|
-
},
|
|
365
|
-
method: 'setHumidifierMode',
|
|
366
|
-
source: 'APP'
|
|
367
|
-
}
|
|
368
|
-
}, helpers_1.Helpers.reqHeaderBypass());
|
|
369
|
-
return this.checkResponse([response, status], 'setMode');
|
|
370
|
-
}
|
|
371
|
-
/**
|
|
372
|
-
* Set mist level
|
|
373
|
-
*/
|
|
374
|
-
async setMistLevel(level) {
|
|
375
|
-
if (!this.hasFeature('mist')) {
|
|
376
|
-
throw new Error('Mist control not supported');
|
|
377
|
-
}
|
|
378
|
-
if (!this.mistLevels.includes(level)) {
|
|
379
|
-
throw new Error(`Invalid mist level: ${level}. Must be one of: ${this.mistLevels.join(', ')}`);
|
|
380
|
-
}
|
|
381
|
-
const [response, status] = await helpers_1.Helpers.callApi('/cloud/v2/deviceManaged/bypassV2', 'post', {
|
|
382
|
-
...helpers_1.Helpers.reqBody(this.manager, 'bypassV2'),
|
|
383
|
-
cid: this.cid,
|
|
384
|
-
configModule: this.configModule,
|
|
385
|
-
payload: {
|
|
386
|
-
data: {
|
|
387
|
-
mistLevel: level
|
|
388
|
-
},
|
|
389
|
-
method: 'setMistLevel',
|
|
390
|
-
source: 'APP'
|
|
391
|
-
}
|
|
392
|
-
}, helpers_1.Helpers.reqHeaderBypass());
|
|
393
|
-
return this.checkResponse([response, status], 'setMistLevel');
|
|
394
|
-
}
|
|
395
|
-
/**
|
|
396
|
-
* Set target humidity
|
|
397
|
-
*/
|
|
398
|
-
async setHumidity(humidity) {
|
|
399
|
-
if (!this.hasFeature('humidity')) {
|
|
400
|
-
throw new Error('Humidity control not supported');
|
|
401
|
-
}
|
|
402
|
-
if (humidity < this.humidityRange.min || humidity > this.humidityRange.max) {
|
|
403
|
-
throw new Error(`Invalid humidity: ${humidity}. Must be between ${this.humidityRange.min} and ${this.humidityRange.max}`);
|
|
404
|
-
}
|
|
405
|
-
const [response, status] = await helpers_1.Helpers.callApi('/cloud/v2/deviceManaged/bypassV2', 'post', {
|
|
406
|
-
...helpers_1.Helpers.reqBody(this.manager, 'bypassV2'),
|
|
407
|
-
cid: this.cid,
|
|
408
|
-
configModule: this.configModule,
|
|
409
|
-
payload: {
|
|
410
|
-
data: {
|
|
411
|
-
targetHumidity: humidity
|
|
412
|
-
},
|
|
413
|
-
method: 'setTargetHumidity',
|
|
414
|
-
source: 'APP'
|
|
415
|
-
}
|
|
416
|
-
}, helpers_1.Helpers.reqHeaderBypass());
|
|
417
|
-
return this.checkResponse([response, status], 'setHumidity');
|
|
418
|
-
}
|
|
419
|
-
/**
|
|
420
|
-
* Set display status
|
|
421
|
-
*/
|
|
422
|
-
async setDisplay(enabled) {
|
|
423
|
-
if (!this.hasFeature('display')) {
|
|
424
|
-
throw new Error('Display control not supported');
|
|
425
|
-
}
|
|
426
|
-
const [response, status] = await helpers_1.Helpers.callApi('/cloud/v2/deviceManaged/bypassV2', 'post', {
|
|
427
|
-
...helpers_1.Helpers.reqBody(this.manager, 'bypassV2'),
|
|
428
|
-
cid: this.cid,
|
|
429
|
-
configModule: this.configModule,
|
|
430
|
-
payload: {
|
|
431
|
-
data: {
|
|
432
|
-
state: enabled
|
|
433
|
-
},
|
|
434
|
-
method: 'setDisplay',
|
|
435
|
-
source: 'APP'
|
|
436
|
-
}
|
|
437
|
-
}, helpers_1.Helpers.reqHeaderBypass());
|
|
438
|
-
return this.checkResponse([response, status], 'setDisplay');
|
|
439
|
-
}
|
|
440
|
-
/**
|
|
441
|
-
* Set timer
|
|
442
|
-
*/
|
|
443
|
-
async setTimer(hours) {
|
|
444
|
-
if (!this.hasFeature('timer')) {
|
|
445
|
-
throw new Error('Timer not supported');
|
|
446
|
-
}
|
|
447
|
-
const [response, status] = await helpers_1.Helpers.callApi('/cloud/v2/deviceManaged/bypassV2', 'post', {
|
|
448
|
-
...helpers_1.Helpers.reqBody(this.manager, 'bypassV2'),
|
|
449
|
-
cid: this.cid,
|
|
450
|
-
configModule: this.configModule,
|
|
451
|
-
payload: {
|
|
452
|
-
data: {
|
|
453
|
-
action: 'off',
|
|
454
|
-
total: hours * 3600
|
|
455
|
-
},
|
|
456
|
-
method: 'addTimer',
|
|
457
|
-
source: 'APP'
|
|
458
|
-
}
|
|
459
|
-
}, helpers_1.Helpers.reqHeaderBypass());
|
|
460
|
-
return this.checkResponse([response, status], 'setTimer');
|
|
461
|
-
}
|
|
462
|
-
/**
|
|
463
|
-
* Clear timer
|
|
464
|
-
*/
|
|
465
|
-
async clearTimer() {
|
|
466
|
-
if (!this.hasFeature('timer')) {
|
|
467
|
-
throw new Error('Timer not supported');
|
|
468
|
-
}
|
|
469
|
-
const [response, status] = await helpers_1.Helpers.callApi('/cloud/v2/deviceManaged/bypassV2', 'post', {
|
|
470
|
-
...helpers_1.Helpers.reqBody(this.manager, 'bypassV2'),
|
|
471
|
-
cid: this.cid,
|
|
472
|
-
configModule: this.configModule,
|
|
473
|
-
payload: {
|
|
474
|
-
data: {},
|
|
475
|
-
method: 'deleteTimer',
|
|
476
|
-
source: 'APP'
|
|
477
|
-
}
|
|
478
|
-
}, helpers_1.Helpers.reqHeaderBypass());
|
|
479
|
-
return this.checkResponse([response, status], 'clearTimer');
|
|
480
|
-
}
|
|
481
|
-
/**
|
|
482
|
-
* Turn automatic stop on
|
|
483
|
-
*/
|
|
484
|
-
async automaticStopOn() {
|
|
485
|
-
const [response, status] = await helpers_1.Helpers.callApi('/cloud/v2/deviceManaged/bypassV2', 'post', {
|
|
486
|
-
...helpers_1.Helpers.reqBody(this.manager, 'bypassV2'),
|
|
487
|
-
cid: this.cid,
|
|
488
|
-
configModule: this.configModule,
|
|
489
|
-
payload: {
|
|
490
|
-
data: {
|
|
491
|
-
enabled: true
|
|
492
|
-
},
|
|
493
|
-
method: 'setAutomaticStop',
|
|
494
|
-
source: 'APP'
|
|
495
|
-
}
|
|
496
|
-
}, helpers_1.Helpers.reqHeaderBypass());
|
|
497
|
-
return this.checkResponse([response, status], 'automaticStopOn');
|
|
498
|
-
}
|
|
499
|
-
/**
|
|
500
|
-
* Turn automatic stop off
|
|
501
|
-
*/
|
|
502
|
-
async automaticStopOff() {
|
|
503
|
-
const [response, status] = await helpers_1.Helpers.callApi('/cloud/v2/deviceManaged/bypassV2', 'post', {
|
|
504
|
-
...helpers_1.Helpers.reqBody(this.manager, 'bypassV2'),
|
|
505
|
-
cid: this.cid,
|
|
506
|
-
configModule: this.configModule,
|
|
507
|
-
payload: {
|
|
508
|
-
data: {
|
|
509
|
-
enabled: false
|
|
510
|
-
},
|
|
511
|
-
method: 'setAutomaticStop',
|
|
512
|
-
source: 'APP'
|
|
513
|
-
}
|
|
514
|
-
}, helpers_1.Helpers.reqHeaderBypass());
|
|
515
|
-
return this.checkResponse([response, status], 'automaticStopOff');
|
|
516
|
-
}
|
|
517
|
-
}
|
|
518
|
-
exports.VeSyncHumidifier = VeSyncHumidifier;
|
|
519
|
-
/**
|
|
520
|
-
* VeSync Warm Humidifier Class
|
|
521
|
-
*/
|
|
522
|
-
class VeSyncWarmHumidifier extends VeSyncHumidifier {
|
|
523
|
-
constructor(details, manager) {
|
|
524
|
-
super(details, manager);
|
|
525
|
-
this.warmLevels = [1, 2, 3];
|
|
526
|
-
}
|
|
527
|
-
/**
|
|
528
|
-
* Set warm mist level
|
|
529
|
-
*/
|
|
530
|
-
async setWarmLevel(level) {
|
|
531
|
-
if (!this.hasFeature('warm')) {
|
|
532
|
-
throw new Error('Warm mist control not supported');
|
|
533
|
-
}
|
|
534
|
-
if (!this.warmLevels.includes(level)) {
|
|
535
|
-
throw new Error(`Invalid warm level: ${level}. Must be one of: ${this.warmLevels.join(', ')}`);
|
|
536
|
-
}
|
|
537
|
-
const [response, status] = await helpers_1.Helpers.callApi('/cloud/v2/deviceManaged/bypassV2', 'post', {
|
|
538
|
-
...helpers_1.Helpers.reqBody(this.manager, 'bypassV2'),
|
|
539
|
-
cid: this.cid,
|
|
540
|
-
configModule: this.configModule,
|
|
541
|
-
payload: {
|
|
542
|
-
data: {
|
|
543
|
-
warmLevel: level
|
|
544
|
-
},
|
|
545
|
-
method: 'setWarmLevel',
|
|
546
|
-
source: 'APP'
|
|
547
|
-
}
|
|
548
|
-
}, helpers_1.Helpers.reqHeaderBypass());
|
|
549
|
-
return this.checkResponse([response, status], 'setWarmLevel');
|
|
550
|
-
}
|
|
551
|
-
/**
|
|
552
|
-
* Set drying mode enabled
|
|
553
|
-
*/
|
|
554
|
-
async setDryingModeEnabled(enabled) {
|
|
555
|
-
if (!this.hasFeature('drying')) {
|
|
556
|
-
throw new Error('Drying mode not supported');
|
|
557
|
-
}
|
|
558
|
-
const [response, status] = await helpers_1.Helpers.callApi('/cloud/v2/deviceManaged/bypassV2', 'post', {
|
|
559
|
-
...helpers_1.Helpers.reqBody(this.manager, 'bypassV2'),
|
|
560
|
-
cid: this.cid,
|
|
561
|
-
configModule: this.configModule,
|
|
562
|
-
payload: {
|
|
563
|
-
data: {
|
|
564
|
-
autoDryingSwitch: enabled ? 1 : 0
|
|
565
|
-
},
|
|
566
|
-
method: 'setDryingMode',
|
|
567
|
-
source: 'APP'
|
|
568
|
-
}
|
|
569
|
-
}, helpers_1.Helpers.reqHeaderBypass());
|
|
570
|
-
return this.checkResponse([response, status], 'setDryingModeEnabled');
|
|
571
|
-
}
|
|
572
|
-
}
|
|
573
|
-
exports.VeSyncWarmHumidifier = VeSyncWarmHumidifier;
|
|
574
|
-
// Export fan modules dictionary
|
|
575
|
-
exports.fanModules = {
|
|
576
|
-
// Core Series
|
|
577
|
-
'Core200S': VeSyncAirBypass,
|
|
578
|
-
'Core300S': VeSyncAirBypass,
|
|
579
|
-
'Core400S': VeSyncAirBypass,
|
|
580
|
-
'Core600S': VeSyncAirBypass,
|
|
581
|
-
// LAP Series
|
|
582
|
-
'LAP-C201S-AUSR': VeSyncAirBypass,
|
|
583
|
-
'LAP-C202S-WUSR': VeSyncAirBypass,
|
|
584
|
-
'LAP-C301S-WJP': VeSyncAirBypass,
|
|
585
|
-
'LAP-C302S-WUSB': VeSyncAirBypass,
|
|
586
|
-
'LAP-C301S-WAAA': VeSyncAirBypass,
|
|
587
|
-
'LAP-C401S-WJP': VeSyncAirBypass,
|
|
588
|
-
'LAP-C401S-WUSR': VeSyncAirBypass,
|
|
589
|
-
'LAP-C401S-WAAA': VeSyncAirBypass,
|
|
590
|
-
'LAP-C601S-WUS': VeSyncAirBypass,
|
|
591
|
-
'LAP-C601S-WUSR': VeSyncAirBypass,
|
|
592
|
-
'LAP-C601S-WEU': VeSyncAirBypass,
|
|
593
|
-
'LAP-V102S-AASR': VeSyncAirBypass,
|
|
594
|
-
'LAP-V102S-WUS': VeSyncAirBypass,
|
|
595
|
-
'LAP-V102S-WEU': VeSyncAirBypass,
|
|
596
|
-
'LAP-V102S-AUSR': VeSyncAirBypass,
|
|
597
|
-
'LAP-V102S-WJP': VeSyncAirBypass,
|
|
598
|
-
'LAP-V201S-AASR': VeSyncAirBypass,
|
|
599
|
-
'LAP-V201S-WJP': VeSyncAirBypass,
|
|
600
|
-
'LAP-V201S-WEU': VeSyncAirBypass,
|
|
601
|
-
'LAP-V201S-WUS': VeSyncAirBypass,
|
|
602
|
-
'LAP-V201-AUSR': VeSyncAirBypass,
|
|
603
|
-
'LAP-V201S-AUSR': VeSyncAirBypass,
|
|
604
|
-
'LAP-V201S-AEUR': VeSyncAirBypass,
|
|
605
|
-
'LAP-EL551S-AUS': VeSyncAirBypass,
|
|
606
|
-
'LAP-EL551S-AEUR': VeSyncAirBypass,
|
|
607
|
-
'LAP-EL551S-WEU': VeSyncAirBypass,
|
|
608
|
-
'LAP-EL551S-WUS': VeSyncAirBypass,
|
|
609
|
-
// LTF Series
|
|
610
|
-
'LTF-F422S-KEU': VeSyncAirBypass,
|
|
611
|
-
'LTF-F422S-WUSR': VeSyncAirBypass,
|
|
612
|
-
'LTF-F422_WJP': VeSyncAirBypass,
|
|
613
|
-
'LTF-F422S-WUS': VeSyncAirBypass,
|
|
614
|
-
// Classic Series
|
|
615
|
-
'Classic300S': VeSyncHumidifier,
|
|
616
|
-
'Classic200S': VeSyncHumidifier,
|
|
617
|
-
// Dual Series
|
|
618
|
-
'Dual200S': VeSyncHumidifier,
|
|
619
|
-
// LUH Series
|
|
620
|
-
'LUH-A601S-WUSB': VeSyncWarmHumidifier,
|
|
621
|
-
'LUH-A601S-AUSW': VeSyncWarmHumidifier,
|
|
622
|
-
'LUH-D301S-WUSR': VeSyncWarmHumidifier,
|
|
623
|
-
'LUH-D301S-WJP': VeSyncWarmHumidifier,
|
|
624
|
-
'LUH-D301S-WEU': VeSyncWarmHumidifier,
|
|
625
|
-
'LUH-A602S-WUSR': VeSyncWarmHumidifier,
|
|
626
|
-
'LUH-A602S-WUS': VeSyncWarmHumidifier,
|
|
627
|
-
'LUH-A602S-WEUR': VeSyncWarmHumidifier,
|
|
628
|
-
'LUH-A602S-WEU': VeSyncWarmHumidifier,
|
|
629
|
-
'LUH-A602S-WJP': VeSyncWarmHumidifier,
|
|
630
|
-
'LUH-A602S-WUSC': VeSyncWarmHumidifier,
|
|
631
|
-
'LUH-O451S-WEU': VeSyncWarmHumidifier,
|
|
632
|
-
'LUH-O451S-WUS': VeSyncWarmHumidifier,
|
|
633
|
-
'LUH-O451S-WUSR': VeSyncWarmHumidifier,
|
|
634
|
-
'LUH-O601S-WUS': VeSyncWarmHumidifier,
|
|
635
|
-
'LUH-O601S-KUS': VeSyncWarmHumidifier,
|
|
636
|
-
'LUH-M101S-WUS': VeSyncWarmHumidifier,
|
|
637
|
-
// LEH Series
|
|
638
|
-
'LEH-S601S-WUS': VeSyncWarmHumidifier,
|
|
639
|
-
'LEH-S601S-WUSR': VeSyncWarmHumidifier,
|
|
640
|
-
// LV Series
|
|
641
|
-
'LV-PUR131S': VeSyncAirBypass,
|
|
642
|
-
'LV-RH131S': VeSyncAirBypass
|
|
643
|
-
};
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* VeSync Outlets
|
|
3
|
-
*/
|
|
4
|
-
import { VeSyncBaseDevice } from './vesyncBaseDevice';
|
|
5
|
-
import { VeSync } from './vesync';
|
|
6
|
-
/**
|
|
7
|
-
* VeSync Outlet Base Class
|
|
8
|
-
*/
|
|
9
|
-
export declare abstract class VeSyncOutlet extends VeSyncBaseDevice {
|
|
10
|
-
protected energy: Record<string, any>;
|
|
11
|
-
protected details: Record<string, any>;
|
|
12
|
-
constructor(details: Record<string, any>, manager: VeSync);
|
|
13
|
-
/**
|
|
14
|
-
* Get outlet details
|
|
15
|
-
*/
|
|
16
|
-
getDetails(): Promise<void>;
|
|
17
|
-
/**
|
|
18
|
-
* Update outlet energy data
|
|
19
|
-
*/
|
|
20
|
-
updateEnergy(): Promise<void>;
|
|
21
|
-
/**
|
|
22
|
-
* Get outlet energy usage
|
|
23
|
-
*/
|
|
24
|
-
getEnergyUsage(): Promise<Record<string, any>>;
|
|
25
|
-
/**
|
|
26
|
-
* Get outlet status
|
|
27
|
-
*/
|
|
28
|
-
getStatus(): Promise<string>;
|
|
29
|
-
/**
|
|
30
|
-
* Get weekly energy data
|
|
31
|
-
*/
|
|
32
|
-
getWeeklyEnergy(): Promise<void>;
|
|
33
|
-
/**
|
|
34
|
-
* Get monthly energy data
|
|
35
|
-
*/
|
|
36
|
-
getMonthlyEnergy(): Promise<void>;
|
|
37
|
-
/**
|
|
38
|
-
* Get yearly energy data
|
|
39
|
-
*/
|
|
40
|
-
getYearlyEnergy(): Promise<void>;
|
|
41
|
-
/**
|
|
42
|
-
* Update outlet details and energy info
|
|
43
|
-
*/
|
|
44
|
-
update(): Promise<void>;
|
|
45
|
-
/**
|
|
46
|
-
* Turn outlet on
|
|
47
|
-
*/
|
|
48
|
-
abstract turnOn(): Promise<boolean>;
|
|
49
|
-
/**
|
|
50
|
-
* Turn outlet off
|
|
51
|
-
*/
|
|
52
|
-
abstract turnOff(): Promise<boolean>;
|
|
53
|
-
}
|