tsvesync 1.0.64 → 1.0.65
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/airBaseV2.d.ts +68 -0
- package/dist/lib/fans/airBaseV2.js +226 -0
- package/dist/lib/fans/airBypass.d.ts +79 -0
- package/dist/lib/fans/airBypass.js +484 -0
- package/dist/lib/fans/humid200300S.d.ts +50 -0
- package/dist/lib/fans/humid200300S.js +200 -0
- package/dist/lib/fans/humidifier.d.ts +83 -0
- package/dist/lib/fans/humidifier.js +388 -0
- package/dist/lib/fans/index.d.ts +9 -0
- package/dist/lib/fans/index.js +95 -0
- package/dist/lib/fans/towerFan.d.ts +105 -0
- package/dist/lib/fans/towerFan.js +279 -0
- package/dist/lib/fans/warmHumidifier.d.ts +49 -0
- package/dist/lib/fans/warmHumidifier.js +174 -0
- package/dist/lib/vesyncFan.d.ts +2 -2
- package/dist/lib/vesyncFan.js +2 -2
- package/dist/lib/vesyncFanImpl.d.ts +1 -436
- package/dist/lib/vesyncFanImpl.js +16 -1848
- package/package.json +1 -1
- package/src/lib/fans/airBaseV2.ts +276 -0
- package/src/lib/fans/airBypass.ts +594 -0
- package/src/lib/fans/humid200300S.ts +234 -0
- package/src/lib/fans/humidifier.ts +470 -0
- package/src/lib/fans/index.ts +101 -0
- package/src/lib/fans/towerFan.ts +335 -0
- package/src/lib/fans/warmHumidifier.ts +202 -0
- package/src/lib/vesyncFan.ts +5 -5
- package/src/lib/vesyncFanImpl.ts +2 -2262
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { VeSyncAirBypass } from './airBypass';
|
|
2
|
+
import { VeSync } from '../vesync';
|
|
3
|
+
/**
|
|
4
|
+
* VeSync Air Purifier with Bypass V2
|
|
5
|
+
*/
|
|
6
|
+
export declare class VeSyncAirBaseV2 extends VeSyncAirBypass {
|
|
7
|
+
protected _lightDetection: boolean;
|
|
8
|
+
protected _lightDetectionState: boolean;
|
|
9
|
+
protected setSpeedLevel: number | null;
|
|
10
|
+
protected autoPreferences: string[];
|
|
11
|
+
protected enabled: boolean;
|
|
12
|
+
protected _mode: string;
|
|
13
|
+
protected _speed: number;
|
|
14
|
+
protected _timer: {
|
|
15
|
+
duration: number;
|
|
16
|
+
action: string;
|
|
17
|
+
} | null;
|
|
18
|
+
constructor(details: Record<string, any>, manager: VeSync);
|
|
19
|
+
protected buildConfigDict(configDict: Record<string, any>): void;
|
|
20
|
+
get mode(): string;
|
|
21
|
+
set mode(value: string);
|
|
22
|
+
get speed(): number;
|
|
23
|
+
set speed(value: number);
|
|
24
|
+
get timer(): {
|
|
25
|
+
duration: number;
|
|
26
|
+
action: string;
|
|
27
|
+
} | null;
|
|
28
|
+
set timer(value: {
|
|
29
|
+
duration: number;
|
|
30
|
+
action: string;
|
|
31
|
+
} | null);
|
|
32
|
+
/**
|
|
33
|
+
* Get device details
|
|
34
|
+
*/
|
|
35
|
+
getDetails(): Promise<Boolean>;
|
|
36
|
+
/**
|
|
37
|
+
* Build purifier dictionary
|
|
38
|
+
*/
|
|
39
|
+
protected buildPurifierDict(devDict: Record<string, any>): void;
|
|
40
|
+
/**
|
|
41
|
+
* Set auto preference
|
|
42
|
+
*/
|
|
43
|
+
setAutoPreference(preference?: string, roomSize?: number): Promise<boolean>;
|
|
44
|
+
/**
|
|
45
|
+
* Set light detection
|
|
46
|
+
*/
|
|
47
|
+
setLightDetection(enabled: boolean): Promise<boolean>;
|
|
48
|
+
/**
|
|
49
|
+
* Get light detection status
|
|
50
|
+
*/
|
|
51
|
+
get lightDetection(): boolean;
|
|
52
|
+
/**
|
|
53
|
+
* Get light detection state
|
|
54
|
+
*/
|
|
55
|
+
get lightDetectionState(): boolean;
|
|
56
|
+
/**
|
|
57
|
+
* Get auto preference type
|
|
58
|
+
*/
|
|
59
|
+
get autoPreferenceType(): string | null;
|
|
60
|
+
/**
|
|
61
|
+
* Display JSON details
|
|
62
|
+
*/
|
|
63
|
+
displayJSON(): string;
|
|
64
|
+
/**
|
|
65
|
+
* Set oscillation state
|
|
66
|
+
*/
|
|
67
|
+
setOscillation(toggle: boolean): Promise<boolean>;
|
|
68
|
+
}
|
|
@@ -0,0 +1,226 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.VeSyncAirBaseV2 = void 0;
|
|
4
|
+
const airBypass_1 = require("./airBypass");
|
|
5
|
+
const logger_1 = require("../logger");
|
|
6
|
+
/**
|
|
7
|
+
* VeSync Air Purifier with Bypass V2
|
|
8
|
+
*/
|
|
9
|
+
class VeSyncAirBaseV2 extends airBypass_1.VeSyncAirBypass {
|
|
10
|
+
constructor(details, manager) {
|
|
11
|
+
super(details, manager);
|
|
12
|
+
this._lightDetection = false;
|
|
13
|
+
this._lightDetectionState = false;
|
|
14
|
+
this.setSpeedLevel = null;
|
|
15
|
+
this.autoPreferences = ['default', 'efficient', 'quiet'];
|
|
16
|
+
this.enabled = false;
|
|
17
|
+
this._mode = '';
|
|
18
|
+
this._speed = 0;
|
|
19
|
+
this._timer = null;
|
|
20
|
+
logger_1.logger.debug(`Initialized VeSyncAirBaseV2 device: ${this.deviceName}`);
|
|
21
|
+
}
|
|
22
|
+
buildConfigDict(configDict) {
|
|
23
|
+
if (configDict) {
|
|
24
|
+
this.config = {
|
|
25
|
+
...this.config, // Preserve existing config
|
|
26
|
+
...configDict // Merge in new config
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
get mode() {
|
|
31
|
+
return this._mode;
|
|
32
|
+
}
|
|
33
|
+
set mode(value) {
|
|
34
|
+
this._mode = value;
|
|
35
|
+
}
|
|
36
|
+
get speed() {
|
|
37
|
+
return this._speed;
|
|
38
|
+
}
|
|
39
|
+
set speed(value) {
|
|
40
|
+
this._speed = value;
|
|
41
|
+
}
|
|
42
|
+
get timer() {
|
|
43
|
+
return this._timer;
|
|
44
|
+
}
|
|
45
|
+
set timer(value) {
|
|
46
|
+
this._timer = value;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Get device details
|
|
50
|
+
*/
|
|
51
|
+
async getDetails() {
|
|
52
|
+
logger_1.logger.debug(`Getting details for device: ${this.deviceName}`);
|
|
53
|
+
const [head, body] = this.buildApiDict('getPurifierStatus');
|
|
54
|
+
const [response, status] = await this.callApi('/cloud/v2/deviceManaged/bypassV2', 'post', body, head);
|
|
55
|
+
if (!this.checkResponse([response, status], 'getDetails') || !(response === null || response === void 0 ? void 0 : response.result)) {
|
|
56
|
+
logger_1.logger.debug('Error getting purifier details');
|
|
57
|
+
this.connectionStatus = 'offline';
|
|
58
|
+
return false;
|
|
59
|
+
}
|
|
60
|
+
const innerResponse = response.result;
|
|
61
|
+
if (innerResponse.code !== 0 || !innerResponse.result) {
|
|
62
|
+
logger_1.logger.debug('Error in inner response from purifier');
|
|
63
|
+
this.connectionStatus = 'offline';
|
|
64
|
+
return false;
|
|
65
|
+
}
|
|
66
|
+
const deviceData = innerResponse.result;
|
|
67
|
+
this.buildPurifierDict(deviceData);
|
|
68
|
+
if (deviceData.configuration) {
|
|
69
|
+
this.buildConfigDict(deviceData.configuration);
|
|
70
|
+
}
|
|
71
|
+
return true;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Build purifier dictionary
|
|
75
|
+
*/
|
|
76
|
+
buildPurifierDict(devDict) {
|
|
77
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
|
|
78
|
+
this.connectionStatus = 'online';
|
|
79
|
+
const powerSwitch = Boolean((_a = devDict.powerSwitch) !== null && _a !== void 0 ? _a : 0);
|
|
80
|
+
this.enabled = powerSwitch;
|
|
81
|
+
this.deviceStatus = powerSwitch ? 'on' : 'off';
|
|
82
|
+
this.mode = (_b = devDict.workMode) !== null && _b !== void 0 ? _b : 'manual';
|
|
83
|
+
this.speed = (_c = devDict.fanSpeedLevel) !== null && _c !== void 0 ? _c : 0;
|
|
84
|
+
this.setSpeedLevel = (_d = devDict.manualSpeedLevel) !== null && _d !== void 0 ? _d : 1;
|
|
85
|
+
this.details = {
|
|
86
|
+
...this.details,
|
|
87
|
+
filter_life: (_e = devDict.filterLifePercent) !== null && _e !== void 0 ? _e : 0,
|
|
88
|
+
child_lock: Boolean((_f = devDict.childLockSwitch) !== null && _f !== void 0 ? _f : 0),
|
|
89
|
+
display: Boolean((_g = devDict.screenState) !== null && _g !== void 0 ? _g : 0),
|
|
90
|
+
light_detection_switch: Boolean((_h = devDict.lightDetectionSwitch) !== null && _h !== void 0 ? _h : 0),
|
|
91
|
+
environment_light_state: Boolean((_j = devDict.environmentLightState) !== null && _j !== void 0 ? _j : 0),
|
|
92
|
+
screen_switch: Boolean((_k = devDict.screenSwitch) !== null && _k !== void 0 ? _k : 0),
|
|
93
|
+
screenStatus: Boolean((_l = devDict.screenSwitch) !== null && _l !== void 0 ? _l : 0) ? 'on' : 'off'
|
|
94
|
+
};
|
|
95
|
+
if (this.hasFeature('air_quality')) {
|
|
96
|
+
this.details.air_quality_value = (_m = devDict.PM25) !== null && _m !== void 0 ? _m : 0;
|
|
97
|
+
this.details.air_quality = (_o = devDict.AQLevel) !== null && _o !== void 0 ? _o : 0;
|
|
98
|
+
}
|
|
99
|
+
if ('PM1' in devDict)
|
|
100
|
+
this.details.pm1 = devDict.PM1;
|
|
101
|
+
if ('PM10' in devDict)
|
|
102
|
+
this.details.pm10 = devDict.PM10;
|
|
103
|
+
if ('AQPercent' in devDict)
|
|
104
|
+
this.details.aq_percent = devDict.AQPercent;
|
|
105
|
+
if ('fanRotateAngle' in devDict)
|
|
106
|
+
this.details.fan_rotate_angle = devDict.fanRotateAngle;
|
|
107
|
+
if ('filterOpenState' in devDict)
|
|
108
|
+
this.details.filter_open_state = Boolean(devDict.filterOpenState);
|
|
109
|
+
if (((_p = devDict.timerRemain) !== null && _p !== void 0 ? _p : 0) > 0) {
|
|
110
|
+
this.timer = { duration: devDict.timerRemain, action: 'off' };
|
|
111
|
+
}
|
|
112
|
+
if (typeof devDict.autoPreference === 'object' && devDict.autoPreference) {
|
|
113
|
+
this.details.auto_preference_type = (_r = (_q = devDict.autoPreference) === null || _q === void 0 ? void 0 : _q.autoPreferenceType) !== null && _r !== void 0 ? _r : 'default';
|
|
114
|
+
}
|
|
115
|
+
else {
|
|
116
|
+
this.details.auto_preference_type = null;
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Set auto preference
|
|
121
|
+
*/
|
|
122
|
+
async setAutoPreference(preference = 'default', roomSize = 600) {
|
|
123
|
+
if (!this.autoPreferences.includes(preference)) {
|
|
124
|
+
logger_1.logger.debug(`Invalid preference: ${preference} - valid preferences are default, efficient, quiet`);
|
|
125
|
+
return false;
|
|
126
|
+
}
|
|
127
|
+
const [head, body] = this.buildApiDict('setAutoPreference');
|
|
128
|
+
body.payload.data = {
|
|
129
|
+
autoPreference: preference,
|
|
130
|
+
roomSize: roomSize
|
|
131
|
+
};
|
|
132
|
+
const [response, status] = await this.callApi('/cloud/v2/deviceManaged/bypassV2', 'post', body, head);
|
|
133
|
+
const success = this.checkResponse([response, status], 'setAutoPreference');
|
|
134
|
+
if (success) {
|
|
135
|
+
this.details.auto_preference = preference;
|
|
136
|
+
}
|
|
137
|
+
return success;
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* Set light detection
|
|
141
|
+
*/
|
|
142
|
+
async setLightDetection(enabled) {
|
|
143
|
+
const [head, body] = this.buildApiDict('setLightDetection');
|
|
144
|
+
body.payload.data = {
|
|
145
|
+
lightDetectionSwitch: enabled ? 1 : 0
|
|
146
|
+
};
|
|
147
|
+
const [response, status] = await this.callApi('/cloud/v2/deviceManaged/bypassV2', 'post', body, head);
|
|
148
|
+
const success = this.checkResponse([response, status], 'setLightDetection');
|
|
149
|
+
if (success) {
|
|
150
|
+
this.details.light_detection_switch = enabled;
|
|
151
|
+
}
|
|
152
|
+
return success;
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* Get light detection status
|
|
156
|
+
*/
|
|
157
|
+
get lightDetection() {
|
|
158
|
+
return Boolean(this.details.light_detection_switch);
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* Get light detection state
|
|
162
|
+
*/
|
|
163
|
+
get lightDetectionState() {
|
|
164
|
+
return Boolean(this.details.environment_light_state);
|
|
165
|
+
}
|
|
166
|
+
/**
|
|
167
|
+
* Get auto preference type
|
|
168
|
+
*/
|
|
169
|
+
get autoPreferenceType() {
|
|
170
|
+
return this.details.auto_preference_type;
|
|
171
|
+
}
|
|
172
|
+
/**
|
|
173
|
+
* Display JSON details
|
|
174
|
+
*/
|
|
175
|
+
displayJSON() {
|
|
176
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
|
|
177
|
+
const baseInfo = JSON.parse(super.displayJSON());
|
|
178
|
+
const details = {
|
|
179
|
+
...baseInfo,
|
|
180
|
+
'Mode': this.mode,
|
|
181
|
+
'Filter Life': ((_a = this.details.filter_life) !== null && _a !== void 0 ? _a : 0).toString(),
|
|
182
|
+
'Fan Level': this.speed.toString(),
|
|
183
|
+
'Display On': (_c = (_b = this.details.display) === null || _b === void 0 ? void 0 : _b.toString()) !== null && _c !== void 0 ? _c : 'false',
|
|
184
|
+
'Child Lock': ((_d = this.details.child_lock) !== null && _d !== void 0 ? _d : false).toString(),
|
|
185
|
+
'Night Light': ((_e = this.details.night_light) !== null && _e !== void 0 ? _e : '').toString(),
|
|
186
|
+
'Display Set On': ((_f = this.details.screen_switch) !== null && _f !== void 0 ? _f : false).toString(),
|
|
187
|
+
'Light Detection Enabled': ((_g = this.details.light_detection_switch) !== null && _g !== void 0 ? _g : false).toString(),
|
|
188
|
+
'Environment Light State': ((_h = this.details.environment_light_state) !== null && _h !== void 0 ? _h : false).toString()
|
|
189
|
+
};
|
|
190
|
+
if (this.hasFeature('air_quality')) {
|
|
191
|
+
details['Air Quality Level'] = ((_j = this.details.air_quality) !== null && _j !== void 0 ? _j : '').toString();
|
|
192
|
+
details['Air Quality Value'] = ((_k = this.details.air_quality_value) !== null && _k !== void 0 ? _k : '').toString();
|
|
193
|
+
}
|
|
194
|
+
const everestKeys = {
|
|
195
|
+
'pm1': 'PM1',
|
|
196
|
+
'pm10': 'PM10',
|
|
197
|
+
'fan_rotate_angle': 'Fan Rotate Angle',
|
|
198
|
+
'filter_open_state': 'Filter Open State'
|
|
199
|
+
};
|
|
200
|
+
for (const [key, value] of Object.entries(everestKeys)) {
|
|
201
|
+
if (key in this.details) {
|
|
202
|
+
details[value] = (_m = (_l = this.details[key]) === null || _l === void 0 ? void 0 : _l.toString()) !== null && _m !== void 0 ? _m : '';
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
return JSON.stringify(details, null, 4);
|
|
206
|
+
}
|
|
207
|
+
/**
|
|
208
|
+
* Set oscillation state
|
|
209
|
+
*/
|
|
210
|
+
async setOscillation(toggle) {
|
|
211
|
+
logger_1.logger.debug(`Setting oscillation to ${toggle ? 'on' : 'off'} for device: ${this.deviceName}`);
|
|
212
|
+
const [head, body] = this.buildApiDict('setSwitch');
|
|
213
|
+
body.payload.data = {
|
|
214
|
+
oscillationSwitch: toggle ? 1 : 0,
|
|
215
|
+
switchIdx: 0
|
|
216
|
+
};
|
|
217
|
+
const [response, status] = await this.callApi('/cloud/v2/deviceManaged/bypassV2', 'post', body, head);
|
|
218
|
+
const success = this.checkResponse([response, status], 'setOscillation');
|
|
219
|
+
if (success) {
|
|
220
|
+
this.details.oscillationState = toggle;
|
|
221
|
+
this.details.oscillationSwitch = toggle ? 1 : 0;
|
|
222
|
+
}
|
|
223
|
+
return success;
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
exports.VeSyncAirBaseV2 = VeSyncAirBaseV2;
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { VeSyncFan } from '../vesyncFan';
|
|
2
|
+
import { VeSync } from '../vesync';
|
|
3
|
+
/**
|
|
4
|
+
* VeSync Air Purifier with Bypass
|
|
5
|
+
*/
|
|
6
|
+
export declare class VeSyncAirBypass extends VeSyncFan {
|
|
7
|
+
protected readonly modes: readonly ["auto", "manual", "sleep"];
|
|
8
|
+
protected readonly displayModes: readonly ["on", "off"];
|
|
9
|
+
protected readonly childLockModes: readonly ["on", "off"];
|
|
10
|
+
constructor(details: Record<string, any>, manager: VeSync);
|
|
11
|
+
/**
|
|
12
|
+
* Build API dictionary
|
|
13
|
+
*/
|
|
14
|
+
protected buildApiDict(method: string): [Record<string, any>, Record<string, any>];
|
|
15
|
+
/**
|
|
16
|
+
* Get device details
|
|
17
|
+
*/
|
|
18
|
+
getDetails(): Promise<Boolean>;
|
|
19
|
+
/**
|
|
20
|
+
* Turn device on
|
|
21
|
+
*/
|
|
22
|
+
turnOn(): Promise<boolean>;
|
|
23
|
+
/**
|
|
24
|
+
* Turn device off
|
|
25
|
+
*/
|
|
26
|
+
turnOff(): Promise<boolean>;
|
|
27
|
+
/**
|
|
28
|
+
* Change fan speed
|
|
29
|
+
*/
|
|
30
|
+
changeFanSpeed(speed: number): Promise<boolean>;
|
|
31
|
+
/**
|
|
32
|
+
* Set device mode
|
|
33
|
+
*/
|
|
34
|
+
setMode(mode: string): Promise<boolean>;
|
|
35
|
+
/**
|
|
36
|
+
* Set display status
|
|
37
|
+
*/
|
|
38
|
+
setDisplay(enabled: boolean): Promise<boolean>;
|
|
39
|
+
/**
|
|
40
|
+
* Set child lock
|
|
41
|
+
*/
|
|
42
|
+
setChildLock(enabled: boolean): Promise<boolean>;
|
|
43
|
+
/**
|
|
44
|
+
* Set timer
|
|
45
|
+
*/
|
|
46
|
+
setTimer(hours: number): Promise<boolean>;
|
|
47
|
+
/**
|
|
48
|
+
* Clear timer
|
|
49
|
+
*/
|
|
50
|
+
clearTimer(): Promise<boolean>;
|
|
51
|
+
/**
|
|
52
|
+
* Turn automatic stop on
|
|
53
|
+
*/
|
|
54
|
+
automaticStopOn(): Promise<boolean>;
|
|
55
|
+
/**
|
|
56
|
+
* Turn automatic stop off
|
|
57
|
+
*/
|
|
58
|
+
automaticStopOff(): Promise<boolean>;
|
|
59
|
+
/**
|
|
60
|
+
* Set auto mode
|
|
61
|
+
*/
|
|
62
|
+
autoMode(): Promise<boolean>;
|
|
63
|
+
/**
|
|
64
|
+
* Set manual mode
|
|
65
|
+
*/
|
|
66
|
+
manualMode(): Promise<boolean>;
|
|
67
|
+
/**
|
|
68
|
+
* Set sleep mode
|
|
69
|
+
*/
|
|
70
|
+
sleepMode(): Promise<boolean>;
|
|
71
|
+
/**
|
|
72
|
+
* Turn off display
|
|
73
|
+
*/
|
|
74
|
+
turnOffDisplay(): Promise<boolean>;
|
|
75
|
+
/**
|
|
76
|
+
* Turn on display
|
|
77
|
+
*/
|
|
78
|
+
turnOnDisplay(): Promise<boolean>;
|
|
79
|
+
}
|