tsvesync 1.0.11 → 1.0.13

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