tsvesync 1.0.11 → 1.0.12
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/index.d.ts +7 -0
- package/dist/index.js +25 -0
- package/dist/lib/helpers.d.ts +52 -51
- package/dist/lib/helpers.js +134 -112
- package/dist/lib/vesync.d.ts +57 -15
- package/dist/lib/vesync.js +339 -216
- package/dist/lib/vesyncBaseDevice.d.ts +25 -50
- package/dist/lib/vesyncBaseDevice.js +62 -90
- package/dist/lib/vesyncBulb.d.ts +79 -0
- package/dist/lib/vesyncBulb.js +198 -1
- package/dist/lib/vesyncBulbImpl.d.ts +38 -0
- package/dist/lib/vesyncBulbImpl.js +161 -0
- package/dist/lib/vesyncFan.d.ts +55 -67
- package/dist/lib/vesyncFan.js +365 -213
- package/dist/lib/vesyncFanImpl.d.ts +137 -0
- package/dist/lib/vesyncFanImpl.js +644 -0
- package/dist/lib/vesyncOutlet.d.ts +53 -0
- package/dist/lib/vesyncOutlet.js +97 -1
- package/dist/lib/vesyncOutletImpl.d.ts +70 -0
- package/dist/lib/vesyncOutletImpl.js +206 -0
- package/dist/lib/vesyncSwitch.d.ts +169 -0
- package/dist/lib/vesyncSwitch.js +417 -1
- package/dist/lib/vesyncSwitchImpl.d.ts +82 -0
- package/dist/lib/vesyncSwitchImpl.js +290 -0
- package/package.json +1 -1
- package/src/index.ts +14 -0
package/dist/lib/vesyncFan.js
CHANGED
|
@@ -1,265 +1,417 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.VeSyncAirBypass = exports.fanModules = exports.fanClasses = exports.airFeatures = exports.humidFeatures = void 0;
|
|
4
|
-
exports.modelDict = modelDict;
|
|
5
|
-
exports.modelFeatures = modelFeatures;
|
|
6
2
|
/**
|
|
7
|
-
* VeSync
|
|
3
|
+
* VeSync Fan Classes
|
|
8
4
|
*/
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.VeSyncFan = exports.fanConfig = void 0;
|
|
9
7
|
const vesyncBaseDevice_1 = require("./vesyncBaseDevice");
|
|
10
|
-
|
|
11
|
-
exports.
|
|
8
|
+
// Fan configuration
|
|
9
|
+
exports.fanConfig = {
|
|
10
|
+
// Core Series
|
|
11
|
+
'Core200S': {
|
|
12
|
+
module: 'VeSyncAirBypass',
|
|
13
|
+
features: ['display', 'child_lock', 'night_light', 'air_quality', 'timer']
|
|
14
|
+
},
|
|
15
|
+
'Core300S': {
|
|
16
|
+
module: 'VeSyncAirBypass',
|
|
17
|
+
features: ['display', 'child_lock', 'night_light', 'air_quality', 'timer']
|
|
18
|
+
},
|
|
19
|
+
'Core400S': {
|
|
20
|
+
module: 'VeSyncAirBypass',
|
|
21
|
+
features: ['display', 'child_lock', 'night_light', 'air_quality', 'timer']
|
|
22
|
+
},
|
|
23
|
+
'Core600S': {
|
|
24
|
+
module: 'VeSyncAirBypass',
|
|
25
|
+
features: ['display', 'child_lock', 'night_light', 'air_quality', 'timer']
|
|
26
|
+
},
|
|
27
|
+
// LAP Series
|
|
28
|
+
'LAP-C201S-AUSR': {
|
|
29
|
+
module: 'VeSyncAirBypass',
|
|
30
|
+
features: ['display', 'child_lock', 'night_light', 'air_quality', 'timer']
|
|
31
|
+
},
|
|
32
|
+
'LAP-C202S-WUSR': {
|
|
33
|
+
module: 'VeSyncAirBypass',
|
|
34
|
+
features: ['display', 'child_lock', 'night_light', 'air_quality', 'timer']
|
|
35
|
+
},
|
|
36
|
+
'LAP-C301S-WJP': {
|
|
37
|
+
module: 'VeSyncAirBypass',
|
|
38
|
+
features: ['display', 'child_lock', 'night_light', 'air_quality', 'timer']
|
|
39
|
+
},
|
|
40
|
+
'LAP-C302S-WUSB': {
|
|
41
|
+
module: 'VeSyncAirBypass',
|
|
42
|
+
features: ['display', 'child_lock', 'night_light', 'air_quality', 'timer']
|
|
43
|
+
},
|
|
44
|
+
'LAP-C301S-WAAA': {
|
|
45
|
+
module: 'VeSyncAirBypass',
|
|
46
|
+
features: ['display', 'child_lock', 'night_light', 'air_quality', 'timer']
|
|
47
|
+
},
|
|
48
|
+
'LAP-C401S-WJP': {
|
|
49
|
+
module: 'VeSyncAirBypass',
|
|
50
|
+
features: ['display', 'child_lock', 'night_light', 'air_quality', 'timer']
|
|
51
|
+
},
|
|
52
|
+
'LAP-C401S-WUSR': {
|
|
53
|
+
module: 'VeSyncAirBypass',
|
|
54
|
+
features: ['display', 'child_lock', 'night_light', 'air_quality', 'timer']
|
|
55
|
+
},
|
|
56
|
+
'LAP-C401S-WAAA': {
|
|
57
|
+
module: 'VeSyncAirBypass',
|
|
58
|
+
features: ['display', 'child_lock', 'night_light', 'air_quality', 'timer']
|
|
59
|
+
},
|
|
60
|
+
'LAP-C601S-WUS': {
|
|
61
|
+
module: 'VeSyncAirBypass',
|
|
62
|
+
features: ['display', 'child_lock', 'night_light', 'air_quality', 'timer']
|
|
63
|
+
},
|
|
64
|
+
'LAP-C601S-WUSR': {
|
|
65
|
+
module: 'VeSyncAirBypass',
|
|
66
|
+
features: ['display', 'child_lock', 'night_light', 'air_quality', 'timer']
|
|
67
|
+
},
|
|
68
|
+
'LAP-C601S-WEU': {
|
|
69
|
+
module: 'VeSyncAirBypass',
|
|
70
|
+
features: ['display', 'child_lock', 'night_light', 'air_quality', 'timer']
|
|
71
|
+
},
|
|
72
|
+
'LAP-V102S-AASR': {
|
|
73
|
+
module: 'VeSyncAirBypass',
|
|
74
|
+
features: ['display', 'child_lock', 'night_light', 'air_quality', 'timer']
|
|
75
|
+
},
|
|
76
|
+
'LAP-V102S-WUS': {
|
|
77
|
+
module: 'VeSyncAirBypass',
|
|
78
|
+
features: ['display', 'child_lock', 'night_light', 'air_quality', 'timer']
|
|
79
|
+
},
|
|
80
|
+
'LAP-V102S-WEU': {
|
|
81
|
+
module: 'VeSyncAirBypass',
|
|
82
|
+
features: ['display', 'child_lock', 'night_light', 'air_quality', 'timer']
|
|
83
|
+
},
|
|
84
|
+
'LAP-V102S-AUSR': {
|
|
85
|
+
module: 'VeSyncAirBypass',
|
|
86
|
+
features: ['display', 'child_lock', 'night_light', 'air_quality', 'timer']
|
|
87
|
+
},
|
|
88
|
+
'LAP-V102S-WJP': {
|
|
89
|
+
module: 'VeSyncAirBypass',
|
|
90
|
+
features: ['display', 'child_lock', 'night_light', 'air_quality', 'timer']
|
|
91
|
+
},
|
|
92
|
+
'LAP-V201S-AASR': {
|
|
93
|
+
module: 'VeSyncAirBypass',
|
|
94
|
+
features: ['display', 'child_lock', 'night_light', 'air_quality', 'timer']
|
|
95
|
+
},
|
|
96
|
+
'LAP-V201S-WJP': {
|
|
97
|
+
module: 'VeSyncAirBypass',
|
|
98
|
+
features: ['display', 'child_lock', 'night_light', 'air_quality', 'timer']
|
|
99
|
+
},
|
|
100
|
+
'LAP-V201S-WEU': {
|
|
101
|
+
module: 'VeSyncAirBypass',
|
|
102
|
+
features: ['display', 'child_lock', 'night_light', 'air_quality', 'timer']
|
|
103
|
+
},
|
|
104
|
+
'LAP-V201S-WUS': {
|
|
105
|
+
module: 'VeSyncAirBypass',
|
|
106
|
+
features: ['display', 'child_lock', 'night_light', 'air_quality', 'timer']
|
|
107
|
+
},
|
|
108
|
+
'LAP-V201-AUSR': {
|
|
109
|
+
module: 'VeSyncAirBypass',
|
|
110
|
+
features: ['display', 'child_lock', 'night_light', 'air_quality', 'timer']
|
|
111
|
+
},
|
|
112
|
+
'LAP-V201S-AUSR': {
|
|
113
|
+
module: 'VeSyncAirBypass',
|
|
114
|
+
features: ['display', 'child_lock', 'night_light', 'air_quality', 'timer']
|
|
115
|
+
},
|
|
116
|
+
'LAP-V201S-AEUR': {
|
|
117
|
+
module: 'VeSyncAirBypass',
|
|
118
|
+
features: ['display', 'child_lock', 'night_light', 'air_quality', 'timer']
|
|
119
|
+
},
|
|
120
|
+
'LAP-EL551S-AUS': {
|
|
121
|
+
module: 'VeSyncAirBypass',
|
|
122
|
+
features: ['display', 'child_lock', 'night_light', 'air_quality', 'timer']
|
|
123
|
+
},
|
|
124
|
+
'LAP-EL551S-AEUR': {
|
|
125
|
+
module: 'VeSyncAirBypass',
|
|
126
|
+
features: ['display', 'child_lock', 'night_light', 'air_quality', 'timer']
|
|
127
|
+
},
|
|
128
|
+
'LAP-EL551S-WEU': {
|
|
129
|
+
module: 'VeSyncAirBypass',
|
|
130
|
+
features: ['display', 'child_lock', 'night_light', 'air_quality', 'timer']
|
|
131
|
+
},
|
|
132
|
+
'LAP-EL551S-WUS': {
|
|
133
|
+
module: 'VeSyncAirBypass',
|
|
134
|
+
features: ['display', 'child_lock', 'night_light', 'air_quality', 'timer']
|
|
135
|
+
},
|
|
136
|
+
// LTF Series
|
|
137
|
+
'LTF-F422S-KEU': {
|
|
138
|
+
module: 'VeSyncAirBypass',
|
|
139
|
+
features: ['display', 'child_lock', 'night_light', 'timer']
|
|
140
|
+
},
|
|
141
|
+
'LTF-F422S-WUSR': {
|
|
142
|
+
module: 'VeSyncAirBypass',
|
|
143
|
+
features: ['display', 'child_lock', 'night_light', 'timer']
|
|
144
|
+
},
|
|
145
|
+
'LTF-F422_WJP': {
|
|
146
|
+
module: 'VeSyncAirBypass',
|
|
147
|
+
features: ['display', 'child_lock', 'night_light', 'timer']
|
|
148
|
+
},
|
|
149
|
+
'LTF-F422S-WUS': {
|
|
150
|
+
module: 'VeSyncAirBypass',
|
|
151
|
+
features: ['display', 'child_lock', 'night_light', 'timer']
|
|
152
|
+
},
|
|
153
|
+
// Classic Series
|
|
12
154
|
'Classic300S': {
|
|
13
|
-
module: '
|
|
14
|
-
|
|
15
|
-
features: ['nightlight'],
|
|
16
|
-
mist_modes: ['auto', 'sleep', 'manual'],
|
|
17
|
-
mist_levels: Array.from({ length: 9 }, (_, i) => i + 1)
|
|
155
|
+
module: 'VeSyncHumidifier',
|
|
156
|
+
features: ['display', 'humidity', 'mist', 'timer', 'auto_mode']
|
|
18
157
|
},
|
|
19
158
|
'Classic200S': {
|
|
20
|
-
module: '
|
|
21
|
-
|
|
22
|
-
features: [],
|
|
23
|
-
mist_modes: ['auto', 'manual'],
|
|
24
|
-
mist_levels: Array.from({ length: 9 }, (_, i) => i + 1)
|
|
159
|
+
module: 'VeSyncHumidifier',
|
|
160
|
+
features: ['display', 'humidity', 'mist', 'timer', 'auto_mode']
|
|
25
161
|
},
|
|
162
|
+
// Dual Series
|
|
26
163
|
'Dual200S': {
|
|
27
|
-
module: '
|
|
28
|
-
|
|
29
|
-
features: [],
|
|
30
|
-
mist_modes: ['auto', 'manual'],
|
|
31
|
-
mist_levels: [1, 2]
|
|
32
|
-
},
|
|
33
|
-
'LV600S': {
|
|
34
|
-
module: 'VeSyncHumid200300S',
|
|
35
|
-
models: [
|
|
36
|
-
'LUH-A602S-WUSR',
|
|
37
|
-
'LUH-A602S-WUS',
|
|
38
|
-
'LUH-A602S-WEUR',
|
|
39
|
-
'LUH-A602S-WEU',
|
|
40
|
-
'LUH-A602S-WJP',
|
|
41
|
-
'LUH-A602S-WUSC'
|
|
42
|
-
],
|
|
43
|
-
features: ['warm_mist', 'nightlight'],
|
|
44
|
-
mist_modes: ['humidity', 'sleep', 'manual'],
|
|
45
|
-
mist_levels: Array.from({ length: 9 }, (_, i) => i + 1),
|
|
46
|
-
warm_mist_levels: [0, 1, 2, 3]
|
|
47
|
-
}
|
|
48
|
-
};
|
|
49
|
-
exports.airFeatures = {
|
|
50
|
-
'Core200S': {
|
|
51
|
-
module: 'VeSyncAirBypass',
|
|
52
|
-
models: ['Core200S', 'LAP-C201S-AUSR', 'LAP-C202S-WUSR'],
|
|
53
|
-
modes: ['sleep', 'off', 'manual'],
|
|
54
|
-
features: ['reset_filter'],
|
|
55
|
-
levels: [1, 2, 3]
|
|
164
|
+
module: 'VeSyncHumidifier',
|
|
165
|
+
features: ['display', 'humidity', 'mist', 'timer', 'auto_mode']
|
|
56
166
|
},
|
|
57
|
-
|
|
167
|
+
// LUH Series
|
|
168
|
+
'LUH-A601S-WUSB': {
|
|
169
|
+
module: 'VeSyncWarmHumidifier',
|
|
170
|
+
features: ['display', 'humidity', 'mist', 'warm', 'timer', 'auto_mode']
|
|
171
|
+
},
|
|
172
|
+
'LUH-A601S-AUSW': {
|
|
173
|
+
module: 'VeSyncWarmHumidifier',
|
|
174
|
+
features: ['display', 'humidity', 'mist', 'warm', 'timer', 'auto_mode']
|
|
175
|
+
},
|
|
176
|
+
'LUH-D301S-WUSR': {
|
|
177
|
+
module: 'VeSyncWarmHumidifier',
|
|
178
|
+
features: ['display', 'humidity', 'mist', 'warm', 'timer', 'auto_mode']
|
|
179
|
+
},
|
|
180
|
+
'LUH-D301S-WJP': {
|
|
181
|
+
module: 'VeSyncWarmHumidifier',
|
|
182
|
+
features: ['display', 'humidity', 'mist', 'warm', 'timer', 'auto_mode']
|
|
183
|
+
},
|
|
184
|
+
'LUH-D301S-WEU': {
|
|
185
|
+
module: 'VeSyncWarmHumidifier',
|
|
186
|
+
features: ['display', 'humidity', 'mist', 'warm', 'timer', 'auto_mode']
|
|
187
|
+
},
|
|
188
|
+
'LUH-A602S-WUSR': {
|
|
189
|
+
module: 'VeSyncWarmHumidifier',
|
|
190
|
+
features: ['display', 'humidity', 'mist', 'warm', 'timer', 'auto_mode']
|
|
191
|
+
},
|
|
192
|
+
'LUH-A602S-WUS': {
|
|
193
|
+
module: 'VeSyncWarmHumidifier',
|
|
194
|
+
features: ['display', 'humidity', 'mist', 'warm', 'timer', 'auto_mode']
|
|
195
|
+
},
|
|
196
|
+
'LUH-A602S-WEUR': {
|
|
197
|
+
module: 'VeSyncWarmHumidifier',
|
|
198
|
+
features: ['display', 'humidity', 'mist', 'warm', 'timer', 'auto_mode']
|
|
199
|
+
},
|
|
200
|
+
'LUH-A602S-WEU': {
|
|
201
|
+
module: 'VeSyncWarmHumidifier',
|
|
202
|
+
features: ['display', 'humidity', 'mist', 'warm', 'timer', 'auto_mode']
|
|
203
|
+
},
|
|
204
|
+
'LUH-A602S-WJP': {
|
|
205
|
+
module: 'VeSyncWarmHumidifier',
|
|
206
|
+
features: ['display', 'humidity', 'mist', 'warm', 'timer', 'auto_mode']
|
|
207
|
+
},
|
|
208
|
+
'LUH-A602S-WUSC': {
|
|
209
|
+
module: 'VeSyncWarmHumidifier',
|
|
210
|
+
features: ['display', 'humidity', 'mist', 'warm', 'timer', 'auto_mode']
|
|
211
|
+
},
|
|
212
|
+
'LUH-O451S-WEU': {
|
|
213
|
+
module: 'VeSyncWarmHumidifier',
|
|
214
|
+
features: ['display', 'humidity', 'mist', 'warm', 'timer', 'auto_mode']
|
|
215
|
+
},
|
|
216
|
+
'LUH-O451S-WUS': {
|
|
217
|
+
module: 'VeSyncWarmHumidifier',
|
|
218
|
+
features: ['display', 'humidity', 'mist', 'warm', 'timer', 'auto_mode']
|
|
219
|
+
},
|
|
220
|
+
'LUH-O451S-WUSR': {
|
|
221
|
+
module: 'VeSyncWarmHumidifier',
|
|
222
|
+
features: ['display', 'humidity', 'mist', 'warm', 'timer', 'auto_mode']
|
|
223
|
+
},
|
|
224
|
+
'LUH-O601S-WUS': {
|
|
225
|
+
module: 'VeSyncWarmHumidifier',
|
|
226
|
+
features: ['display', 'humidity', 'mist', 'warm', 'timer', 'auto_mode']
|
|
227
|
+
},
|
|
228
|
+
'LUH-O601S-KUS': {
|
|
229
|
+
module: 'VeSyncWarmHumidifier',
|
|
230
|
+
features: ['display', 'humidity', 'mist', 'warm', 'timer', 'auto_mode']
|
|
231
|
+
},
|
|
232
|
+
'LUH-M101S-WUS': {
|
|
233
|
+
module: 'VeSyncWarmHumidifier',
|
|
234
|
+
features: ['display', 'humidity', 'mist', 'warm', 'timer', 'auto_mode']
|
|
235
|
+
},
|
|
236
|
+
// LEH Series
|
|
237
|
+
'LEH-S601S-WUS': {
|
|
238
|
+
module: 'VeSyncWarmHumidifier',
|
|
239
|
+
features: ['display', 'humidity', 'mist', 'warm', 'timer', 'auto_mode', 'drying']
|
|
240
|
+
},
|
|
241
|
+
'LEH-S601S-WUSR': {
|
|
242
|
+
module: 'VeSyncWarmHumidifier',
|
|
243
|
+
features: ['display', 'humidity', 'mist', 'warm', 'timer', 'auto_mode', 'drying']
|
|
244
|
+
},
|
|
245
|
+
// LV Series
|
|
246
|
+
'LV-PUR131S': {
|
|
58
247
|
module: 'VeSyncAirBypass',
|
|
59
|
-
|
|
60
|
-
modes: ['sleep', 'off', 'auto', 'manual'],
|
|
61
|
-
features: ['air_quality'],
|
|
62
|
-
levels: [1, 2, 3, 4]
|
|
248
|
+
features: ['air_quality', 'display', 'child_lock', 'night_light', 'timer']
|
|
63
249
|
},
|
|
64
|
-
'
|
|
250
|
+
'LV-RH131S': {
|
|
65
251
|
module: 'VeSyncAirBypass',
|
|
66
|
-
|
|
67
|
-
'Core400S',
|
|
68
|
-
'LAP-C401S-WJP',
|
|
69
|
-
'LAP-C401S-WUSR',
|
|
70
|
-
'LAP-C401S-WAAA'
|
|
71
|
-
],
|
|
72
|
-
modes: ['sleep', 'off', 'auto', 'manual'],
|
|
73
|
-
features: ['air_quality'],
|
|
74
|
-
levels: [1, 2, 3, 4]
|
|
252
|
+
features: ['display', 'child_lock', 'night_light', 'timer']
|
|
75
253
|
}
|
|
76
254
|
};
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
for (const model of devDict.models) {
|
|
82
|
-
modelModules[model] = devDict.module;
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
return modelModules;
|
|
86
|
-
}
|
|
87
|
-
function modelFeatures(devType) {
|
|
88
|
-
const allFeatures = { ...exports.airFeatures, ...exports.humidFeatures };
|
|
89
|
-
for (const devDict of Object.values(allFeatures)) {
|
|
90
|
-
if (devDict.models.includes(devType)) {
|
|
91
|
-
return devDict;
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
throw new Error('Device not configured');
|
|
95
|
-
}
|
|
96
|
-
exports.fanClasses = new Set(Object.values({ ...exports.airFeatures, ...exports.humidFeatures })
|
|
97
|
-
.map(v => v.module));
|
|
98
|
-
exports.fanModules = modelDict();
|
|
99
|
-
class VeSyncAirBypass extends vesyncBaseDevice_1.VeSyncBaseDevice {
|
|
255
|
+
/**
|
|
256
|
+
* Base class for VeSync Fans
|
|
257
|
+
*/
|
|
258
|
+
class VeSyncFan extends vesyncBaseDevice_1.VeSyncBaseDevice {
|
|
100
259
|
constructor(details, manager) {
|
|
260
|
+
var _a;
|
|
101
261
|
super(details, manager);
|
|
102
|
-
this.
|
|
103
|
-
this.
|
|
104
|
-
this.
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
this.details = {
|
|
109
|
-
filter_life: 0,
|
|
110
|
-
mode: '',
|
|
111
|
-
level: 0,
|
|
112
|
-
display: false,
|
|
113
|
-
child_lock: false,
|
|
114
|
-
night_light: 'off'
|
|
115
|
-
};
|
|
116
|
-
this.timer = null;
|
|
262
|
+
this.details = {};
|
|
263
|
+
this.mode_dict = {};
|
|
264
|
+
this.speed_dict = {};
|
|
265
|
+
this.features = [];
|
|
266
|
+
this.details = details;
|
|
267
|
+
this.features = ((_a = exports.fanConfig[this.deviceType]) === null || _a === void 0 ? void 0 : _a.features) || [];
|
|
117
268
|
}
|
|
118
269
|
/**
|
|
119
|
-
*
|
|
270
|
+
* Check if feature is supported
|
|
120
271
|
*/
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
body.uuid = this.uuid;
|
|
124
|
-
body.method = 'getPurifierStatus';
|
|
125
|
-
const [response] = await helpers_1.Helpers.callApi('/cloud/v2/deviceManaged/bypassV2', 'post', body, helpers_1.Helpers.reqHeaders(this.manager));
|
|
126
|
-
if (!response || response.code !== 0) {
|
|
127
|
-
console.error('Error getting purifier config');
|
|
128
|
-
return;
|
|
129
|
-
}
|
|
130
|
-
if (response.result) {
|
|
131
|
-
const config = response.result;
|
|
132
|
-
this.details = {
|
|
133
|
-
filter_life: config.filter_life || 0,
|
|
134
|
-
mode: config.mode || '',
|
|
135
|
-
level: config.level || 0,
|
|
136
|
-
display: config.display || false,
|
|
137
|
-
child_lock: config.child_lock || false,
|
|
138
|
-
night_light: config.night_light || 'off',
|
|
139
|
-
air_quality: config.air_quality,
|
|
140
|
-
air_quality_value: config.air_quality_value,
|
|
141
|
-
display_forever: config.display_forever
|
|
142
|
-
};
|
|
143
|
-
this.config = config;
|
|
144
|
-
this.deviceStatus = config.enabled ? 'on' : 'off';
|
|
145
|
-
}
|
|
272
|
+
hasFeature(feature) {
|
|
273
|
+
return this.features.includes(feature);
|
|
146
274
|
}
|
|
147
275
|
/**
|
|
148
|
-
*
|
|
276
|
+
* Get current mode
|
|
149
277
|
*/
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
body.method = method;
|
|
154
|
-
return body;
|
|
278
|
+
get mode() {
|
|
279
|
+
var _a;
|
|
280
|
+
return (_a = this.details.mode) !== null && _a !== void 0 ? _a : '';
|
|
155
281
|
}
|
|
156
282
|
/**
|
|
157
|
-
*
|
|
283
|
+
* Get current speed
|
|
158
284
|
*/
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
const [response] = await helpers_1.Helpers.callApi('/cloud/v2/deviceManaged/bypassV2', 'post', body, helpers_1.Helpers.reqHeaders(this.manager));
|
|
163
|
-
if (!response || response.code !== 0) {
|
|
164
|
-
console.error('Error turning %s purifier', toggle ? 'on' : 'off');
|
|
165
|
-
return false;
|
|
166
|
-
}
|
|
167
|
-
this.deviceStatus = toggle ? 'on' : 'off';
|
|
168
|
-
return true;
|
|
285
|
+
get speed() {
|
|
286
|
+
var _a;
|
|
287
|
+
return (_a = this.details.speed) !== null && _a !== void 0 ? _a : 0;
|
|
169
288
|
}
|
|
170
|
-
|
|
171
|
-
|
|
289
|
+
/**
|
|
290
|
+
* Get filter life percentage
|
|
291
|
+
*/
|
|
292
|
+
get filterLife() {
|
|
293
|
+
var _a;
|
|
294
|
+
return (_a = this.details.filter_life) !== null && _a !== void 0 ? _a : 0;
|
|
172
295
|
}
|
|
173
296
|
/**
|
|
174
|
-
*
|
|
297
|
+
* Get screen status
|
|
175
298
|
*/
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
return false;
|
|
180
|
-
}
|
|
181
|
-
const body = this.buildBypassBody('setPurifierStatus');
|
|
182
|
-
body.mode = mode;
|
|
183
|
-
const [response] = await helpers_1.Helpers.callApi('/cloud/v2/deviceManaged/bypassV2', 'post', body, helpers_1.Helpers.reqHeaders(this.manager));
|
|
184
|
-
if (!response || response.code !== 0) {
|
|
185
|
-
console.error('Error setting mode');
|
|
186
|
-
return false;
|
|
187
|
-
}
|
|
188
|
-
this.details.mode = mode;
|
|
189
|
-
return true;
|
|
299
|
+
get screenStatus() {
|
|
300
|
+
var _a;
|
|
301
|
+
return (_a = this.details.screen_status) !== null && _a !== void 0 ? _a : '';
|
|
190
302
|
}
|
|
191
303
|
/**
|
|
192
|
-
*
|
|
304
|
+
* Get child lock status
|
|
193
305
|
*/
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
return false;
|
|
198
|
-
}
|
|
199
|
-
const body = this.buildBypassBody('setPurifierStatus');
|
|
200
|
-
body.level = level;
|
|
201
|
-
const [response] = await helpers_1.Helpers.callApi('/cloud/v2/deviceManaged/bypassV2', 'post', body, helpers_1.Helpers.reqHeaders(this.manager));
|
|
202
|
-
if (!response || response.code !== 0) {
|
|
203
|
-
console.error('Error setting fan level');
|
|
204
|
-
return false;
|
|
205
|
-
}
|
|
206
|
-
this.details.level = level;
|
|
207
|
-
return true;
|
|
306
|
+
get childLock() {
|
|
307
|
+
var _a;
|
|
308
|
+
return (_a = this.details.child_lock) !== null && _a !== void 0 ? _a : '';
|
|
208
309
|
}
|
|
209
310
|
/**
|
|
210
|
-
*
|
|
311
|
+
* Get air quality (if supported)
|
|
211
312
|
*/
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
const [response] = await helpers_1.Helpers.callApi('/cloud/v2/deviceManaged/bypassV2', 'post', body, helpers_1.Helpers.reqHeaders(this.manager));
|
|
216
|
-
if (!response || response.code !== 0) {
|
|
217
|
-
console.error('Error setting child lock');
|
|
218
|
-
return false;
|
|
219
|
-
}
|
|
220
|
-
this.details.child_lock = toggle;
|
|
221
|
-
return true;
|
|
313
|
+
get airQuality() {
|
|
314
|
+
var _a;
|
|
315
|
+
return (_a = this.details.air_quality) !== null && _a !== void 0 ? _a : '';
|
|
222
316
|
}
|
|
223
317
|
/**
|
|
224
|
-
*
|
|
318
|
+
* Get humidity level (if supported)
|
|
225
319
|
*/
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
return
|
|
320
|
+
get humidity() {
|
|
321
|
+
var _a;
|
|
322
|
+
return (_a = this.details.humidity) !== null && _a !== void 0 ? _a : 0;
|
|
323
|
+
}
|
|
324
|
+
/**
|
|
325
|
+
* Get mist level (if supported)
|
|
326
|
+
*/
|
|
327
|
+
get mistLevel() {
|
|
328
|
+
var _a;
|
|
329
|
+
return (_a = this.details.mist_level) !== null && _a !== void 0 ? _a : 0;
|
|
330
|
+
}
|
|
331
|
+
/**
|
|
332
|
+
* Get warm level (if supported)
|
|
333
|
+
*/
|
|
334
|
+
get warmLevel() {
|
|
335
|
+
var _a;
|
|
336
|
+
return (_a = this.details.warm_level) !== null && _a !== void 0 ? _a : 0;
|
|
236
337
|
}
|
|
237
338
|
/**
|
|
238
|
-
*
|
|
339
|
+
* Get timer status
|
|
239
340
|
*/
|
|
240
|
-
|
|
241
|
-
|
|
341
|
+
get timer() {
|
|
342
|
+
var _a;
|
|
343
|
+
return (_a = this.details.timer) !== null && _a !== void 0 ? _a : 0;
|
|
242
344
|
}
|
|
243
345
|
/**
|
|
244
|
-
*
|
|
346
|
+
* Return formatted device info to stdout
|
|
245
347
|
*/
|
|
246
348
|
display() {
|
|
247
349
|
super.display();
|
|
248
|
-
const
|
|
249
|
-
['Mode:', this.
|
|
250
|
-
['
|
|
251
|
-
['Filter Life:', this.
|
|
252
|
-
['Display:', this.details.display.toString()],
|
|
253
|
-
['Child Lock:', this.details.child_lock.toString()],
|
|
254
|
-
['Night Light:', this.details.night_light]
|
|
350
|
+
const info = [
|
|
351
|
+
['Mode: ', this.mode],
|
|
352
|
+
['Speed: ', this.speed],
|
|
353
|
+
['Filter Life: ', this.filterLife, '%']
|
|
255
354
|
];
|
|
256
|
-
if (this.
|
|
257
|
-
|
|
355
|
+
if (this.hasFeature('display')) {
|
|
356
|
+
info.push(['Screen Status: ', this.screenStatus]);
|
|
357
|
+
}
|
|
358
|
+
if (this.hasFeature('child_lock')) {
|
|
359
|
+
info.push(['Child Lock: ', this.childLock]);
|
|
360
|
+
}
|
|
361
|
+
if (this.hasFeature('air_quality')) {
|
|
362
|
+
info.push(['Air Quality: ', this.airQuality]);
|
|
363
|
+
}
|
|
364
|
+
if (this.hasFeature('humidity')) {
|
|
365
|
+
info.push(['Humidity: ', this.humidity, '%']);
|
|
366
|
+
}
|
|
367
|
+
if (this.hasFeature('mist')) {
|
|
368
|
+
info.push(['Mist Level: ', this.mistLevel]);
|
|
369
|
+
}
|
|
370
|
+
if (this.hasFeature('warm')) {
|
|
371
|
+
info.push(['Warm Level: ', this.warmLevel]);
|
|
372
|
+
}
|
|
373
|
+
if (this.hasFeature('timer')) {
|
|
374
|
+
info.push(['Timer: ', this.timer, 'hours']);
|
|
375
|
+
}
|
|
376
|
+
for (const [key, value, unit = ''] of info) {
|
|
377
|
+
console.log(`${key.toString().padEnd(30, '.')} ${value}${unit}`);
|
|
378
|
+
}
|
|
379
|
+
}
|
|
380
|
+
/**
|
|
381
|
+
* Return JSON details for fan
|
|
382
|
+
*/
|
|
383
|
+
displayJSON() {
|
|
384
|
+
const baseInfo = JSON.parse(super.displayJSON());
|
|
385
|
+
const details = {
|
|
386
|
+
'Mode': this.mode,
|
|
387
|
+
'Speed': this.speed.toString(),
|
|
388
|
+
'Filter Life': this.filterLife.toString()
|
|
389
|
+
};
|
|
390
|
+
if (this.hasFeature('display')) {
|
|
391
|
+
details['Screen Status'] = this.screenStatus;
|
|
392
|
+
}
|
|
393
|
+
if (this.hasFeature('child_lock')) {
|
|
394
|
+
details['Child Lock'] = this.childLock;
|
|
395
|
+
}
|
|
396
|
+
if (this.hasFeature('air_quality')) {
|
|
397
|
+
details['Air Quality'] = this.airQuality;
|
|
398
|
+
}
|
|
399
|
+
if (this.hasFeature('humidity')) {
|
|
400
|
+
details['Humidity'] = this.humidity.toString();
|
|
401
|
+
}
|
|
402
|
+
if (this.hasFeature('mist')) {
|
|
403
|
+
details['Mist Level'] = this.mistLevel.toString();
|
|
404
|
+
}
|
|
405
|
+
if (this.hasFeature('warm')) {
|
|
406
|
+
details['Warm Level'] = this.warmLevel.toString();
|
|
258
407
|
}
|
|
259
|
-
|
|
260
|
-
|
|
408
|
+
if (this.hasFeature('timer')) {
|
|
409
|
+
details['Timer'] = this.timer.toString();
|
|
261
410
|
}
|
|
411
|
+
return JSON.stringify({
|
|
412
|
+
...baseInfo,
|
|
413
|
+
...details
|
|
414
|
+
}, null, 4);
|
|
262
415
|
}
|
|
263
416
|
}
|
|
264
|
-
exports.
|
|
265
|
-
//# sourceMappingURL=vesyncFan.js.map
|
|
417
|
+
exports.VeSyncFan = VeSyncFan;
|