tsvesync 1.0.11
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/LICENSE +21 -0
- package/README.md +227 -0
- package/api/vesync/VeSync.yaml +33 -0
- package/api/vesyncbulb/ESL100.yaml +74 -0
- package/api/vesyncbulb/ESL100CW.yaml +123 -0
- package/api/vesyncbulb/ESL100MC.yaml +169 -0
- package/api/vesyncbulb/XYD0001.yaml +193 -0
- package/api/vesyncfan/Classic200S.yaml +280 -0
- package/api/vesyncfan/Classic300S.yaml +278 -0
- package/api/vesyncfan/Core200S.yaml +256 -0
- package/api/vesyncfan/Core300S.yaml +281 -0
- package/api/vesyncfan/Core400S.yaml +281 -0
- package/api/vesyncfan/Core600S.yaml +281 -0
- package/api/vesyncfan/Dual200S.yaml +278 -0
- package/api/vesyncfan/LAP-C201S-AUSR.yaml +256 -0
- package/api/vesyncfan/LAP-C202S-WUSR.yaml +256 -0
- package/api/vesyncfan/LAP-C301S-WAAA.yaml +281 -0
- package/api/vesyncfan/LAP-C301S-WJP.yaml +281 -0
- package/api/vesyncfan/LAP-C302S-WUSB.yaml +281 -0
- package/api/vesyncfan/LAP-C401S-WAAA.yaml +281 -0
- package/api/vesyncfan/LAP-C401S-WJP.yaml +281 -0
- package/api/vesyncfan/LAP-C401S-WUSR.yaml +281 -0
- package/api/vesyncfan/LAP-C601S-WEU.yaml +281 -0
- package/api/vesyncfan/LAP-C601S-WUS.yaml +281 -0
- package/api/vesyncfan/LAP-C601S-WUSR.yaml +281 -0
- package/api/vesyncfan/LAP-EL551S-AEUR.yaml +167 -0
- package/api/vesyncfan/LAP-EL551S-AUS.yaml +167 -0
- package/api/vesyncfan/LAP-EL551S-WEU.yaml +167 -0
- package/api/vesyncfan/LAP-EL551S-WUS.yaml +167 -0
- package/api/vesyncfan/LAP-V102S-AASR.yaml +167 -0
- package/api/vesyncfan/LAP-V102S-AUSR.yaml +167 -0
- package/api/vesyncfan/LAP-V102S-WEU.yaml +167 -0
- package/api/vesyncfan/LAP-V102S-WJP.yaml +167 -0
- package/api/vesyncfan/LAP-V102S-WUS.yaml +167 -0
- package/api/vesyncfan/LAP-V201-AUSR.yaml +167 -0
- package/api/vesyncfan/LAP-V201S-AASR.yaml +167 -0
- package/api/vesyncfan/LAP-V201S-AEUR.yaml +167 -0
- package/api/vesyncfan/LAP-V201S-AUSR.yaml +167 -0
- package/api/vesyncfan/LAP-V201S-WEU.yaml +167 -0
- package/api/vesyncfan/LAP-V201S-WJP.yaml +167 -0
- package/api/vesyncfan/LAP-V201S-WUS.yaml +167 -0
- package/api/vesyncfan/LEH-S601S-WUS.yaml +303 -0
- package/api/vesyncfan/LEH-S601S-WUSR.yaml +82 -0
- package/api/vesyncfan/LTF-F422S-KEU.yaml +165 -0
- package/api/vesyncfan/LTF-F422S-WUS.yaml +165 -0
- package/api/vesyncfan/LTF-F422S-WUSR.yaml +167 -0
- package/api/vesyncfan/LTF-F422_WJP.yaml +165 -0
- package/api/vesyncfan/LUH-A601S-AUSW.yaml +82 -0
- package/api/vesyncfan/LUH-A601S-WUSB.yaml +305 -0
- package/api/vesyncfan/LUH-A602S-WEU.yaml +305 -0
- package/api/vesyncfan/LUH-A602S-WEUR.yaml +305 -0
- package/api/vesyncfan/LUH-A602S-WJP.yaml +305 -0
- package/api/vesyncfan/LUH-A602S-WUS.yaml +305 -0
- package/api/vesyncfan/LUH-A602S-WUSC.yaml +305 -0
- package/api/vesyncfan/LUH-A602S-WUSR.yaml +305 -0
- package/api/vesyncfan/LUH-D301S-WEU.yaml +305 -0
- package/api/vesyncfan/LUH-D301S-WJP.yaml +305 -0
- package/api/vesyncfan/LUH-D301S-WUSR.yaml +305 -0
- package/api/vesyncfan/LUH-M101S-WUS.yaml +278 -0
- package/api/vesyncfan/LUH-O451S-WEU.yaml +278 -0
- package/api/vesyncfan/LUH-O451S-WUS.yaml +278 -0
- package/api/vesyncfan/LUH-O451S-WUSR.yaml +305 -0
- package/api/vesyncfan/LUH-O601S-KUS.yaml +305 -0
- package/api/vesyncfan/LUH-O601S-WUS.yaml +305 -0
- package/api/vesyncfan/LV-PUR131S.yaml +108 -0
- package/api/vesyncfan/LV-RH131S.yaml +108 -0
- package/api/vesyncoutlet/ESO15-TB.yaml +124 -0
- package/api/vesyncoutlet/ESW01-EU.yaml +122 -0
- package/api/vesyncoutlet/ESW03-USA.yaml +122 -0
- package/api/vesyncoutlet/ESW15-USA.yaml +156 -0
- package/api/vesyncoutlet/wifi-switch-1.3.yaml +60 -0
- package/api/vesyncswitch/ESWD16.yaml +128 -0
- package/api/vesyncswitch/ESWL01.yaml +56 -0
- package/api/vesyncswitch/ESWL03.yaml +56 -0
- package/dist/lib/helpers.d.ts +87 -0
- package/dist/lib/helpers.js +222 -0
- package/dist/lib/helpers.js.map +1 -0
- package/dist/lib/vesync.d.ts +47 -0
- package/dist/lib/vesync.js +309 -0
- package/dist/lib/vesync.js.map +1 -0
- package/dist/lib/vesyncBaseDevice.d.ts +68 -0
- package/dist/lib/vesyncBaseDevice.js +116 -0
- package/dist/lib/vesyncBaseDevice.js.map +1 -0
- package/dist/lib/vesyncBulb.d.ts +0 -0
- package/dist/lib/vesyncBulb.js +2 -0
- package/dist/lib/vesyncBulb.js.map +1 -0
- package/dist/lib/vesyncFan.d.ts +92 -0
- package/dist/lib/vesyncFan.js +265 -0
- package/dist/lib/vesyncFan.js.map +1 -0
- package/dist/lib/vesyncKitchen.d.ts +0 -0
- package/dist/lib/vesyncKitchen.js +2 -0
- package/dist/lib/vesyncKitchen.js.map +1 -0
- package/dist/lib/vesyncOutlet.d.ts +0 -0
- package/dist/lib/vesyncOutlet.js +2 -0
- package/dist/lib/vesyncOutlet.js.map +1 -0
- package/dist/lib/vesyncSwitch.d.ts +0 -0
- package/dist/lib/vesyncSwitch.js +2 -0
- package/dist/lib/vesyncSwitch.js.map +1 -0
- package/dist/src/lib/helpers.d.ts +88 -0
- package/dist/src/lib/helpers.js +244 -0
- package/dist/src/lib/vesync.d.ts +89 -0
- package/dist/src/lib/vesync.js +430 -0
- package/dist/src/lib/vesyncBaseDevice.d.ts +43 -0
- package/dist/src/lib/vesyncBaseDevice.js +87 -0
- package/dist/src/lib/vesyncBulb.d.ts +79 -0
- package/dist/src/lib/vesyncBulb.js +198 -0
- package/dist/src/lib/vesyncBulbImpl.d.ts +38 -0
- package/dist/src/lib/vesyncBulbImpl.js +161 -0
- package/dist/src/lib/vesyncFan.d.ts +80 -0
- package/dist/src/lib/vesyncFan.js +406 -0
- package/dist/src/lib/vesyncFanImpl.d.ts +137 -0
- package/dist/src/lib/vesyncFanImpl.js +643 -0
- package/dist/src/lib/vesyncOutlet.d.ts +53 -0
- package/dist/src/lib/vesyncOutlet.js +98 -0
- package/dist/src/lib/vesyncOutletImpl.d.ts +70 -0
- package/dist/src/lib/vesyncOutletImpl.js +206 -0
- package/dist/src/lib/vesyncSwitch.d.ts +169 -0
- package/dist/src/lib/vesyncSwitch.js +414 -0
- package/dist/src/lib/vesyncSwitchImpl.d.ts +82 -0
- package/dist/src/lib/vesyncSwitchImpl.js +290 -0
- package/dist/test/testFeatures.d.ts +4 -0
- package/dist/test/testFeatures.js +394 -0
- package/dist/test/testService.d.ts +62 -0
- package/dist/test/testService.js +540 -0
- package/dist/test/testSpecial.d.ts +5 -0
- package/dist/test/testSpecial.js +227 -0
- package/package.json +53 -0
- package/src/lib/helpers.ts +290 -0
- package/src/lib/vesync.ts +530 -0
- package/src/lib/vesyncBaseDevice.ts +114 -0
- package/src/lib/vesyncBulb.ts +252 -0
- package/src/lib/vesyncBulbImpl.ts +215 -0
- package/src/lib/vesyncFan.ts +447 -0
- package/src/lib/vesyncFanImpl.ts +848 -0
- package/src/lib/vesyncOutlet.ts +148 -0
- package/src/lib/vesyncOutletImpl.ts +284 -0
- package/src/lib/vesyncSwitch.ts +546 -0
- package/src/lib/vesyncSwitchImpl.ts +408 -0
|
@@ -0,0 +1,265 @@
|
|
|
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
|
+
/**
|
|
7
|
+
* VeSync API for controlling fans and purifiers
|
|
8
|
+
*/
|
|
9
|
+
const vesyncBaseDevice_1 = require("./vesyncBaseDevice");
|
|
10
|
+
const helpers_1 = require("./helpers");
|
|
11
|
+
exports.humidFeatures = {
|
|
12
|
+
'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)
|
|
18
|
+
},
|
|
19
|
+
'Classic200S': {
|
|
20
|
+
module: 'VeSyncHumid200S',
|
|
21
|
+
models: ['Classic200S'],
|
|
22
|
+
features: [],
|
|
23
|
+
mist_modes: ['auto', 'manual'],
|
|
24
|
+
mist_levels: Array.from({ length: 9 }, (_, i) => i + 1)
|
|
25
|
+
},
|
|
26
|
+
'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]
|
|
56
|
+
},
|
|
57
|
+
'Core300S': {
|
|
58
|
+
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]
|
|
63
|
+
},
|
|
64
|
+
'Core400S': {
|
|
65
|
+
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]
|
|
75
|
+
}
|
|
76
|
+
};
|
|
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 {
|
|
100
|
+
constructor(details, manager) {
|
|
101
|
+
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;
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Get configuration and details for air purifier
|
|
120
|
+
*/
|
|
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
|
+
}
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* Build bypass body for air purifier
|
|
149
|
+
*/
|
|
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;
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* Turn air purifier on/off
|
|
158
|
+
*/
|
|
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;
|
|
169
|
+
}
|
|
170
|
+
async turnOff() {
|
|
171
|
+
return this.turnOn(false);
|
|
172
|
+
}
|
|
173
|
+
/**
|
|
174
|
+
* Set mode for air purifier
|
|
175
|
+
*/
|
|
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;
|
|
190
|
+
}
|
|
191
|
+
/**
|
|
192
|
+
* Set fan speed for air purifier
|
|
193
|
+
*/
|
|
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;
|
|
208
|
+
}
|
|
209
|
+
/**
|
|
210
|
+
* Set child lock for air purifier
|
|
211
|
+
*/
|
|
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;
|
|
222
|
+
}
|
|
223
|
+
/**
|
|
224
|
+
* Set display for air purifier
|
|
225
|
+
*/
|
|
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;
|
|
236
|
+
}
|
|
237
|
+
/**
|
|
238
|
+
* Update air purifier details
|
|
239
|
+
*/
|
|
240
|
+
async update() {
|
|
241
|
+
await this.getConfig();
|
|
242
|
+
}
|
|
243
|
+
/**
|
|
244
|
+
* Display air purifier details
|
|
245
|
+
*/
|
|
246
|
+
display() {
|
|
247
|
+
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]
|
|
255
|
+
];
|
|
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']);
|
|
258
|
+
}
|
|
259
|
+
for (const line of disp) {
|
|
260
|
+
console.log(`${line[0].padEnd(30, '.')} ${line[1]}`);
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
exports.VeSyncAir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AAO,CAAC,OAAO,CAAC,QAAQ,EAAE,CAAC;YAC7C,CAAC,aAAa,EAAE,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,QAAQ,EAAE,CAAC;YACnD,CAAC,cAAc,EAAE,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC;SAC7C,CAAC;QAEF,IAAI,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,aAAa,CAAC,EAAE,CAAC;YACzC,IAAI,CAAC,IAAI,CACL,CAAC,cAAc,EAAE,IAAI,CAAC,OAAO,CAAC,WAAW,EAAE,QAAQ,EAAE,IAAI,KAAK,CAAC,EAC/D,CAAC,QAAQ,EAAE,IAAI,CAAC,OAAO,CAAC,iBAAiB,EAAE,QAAQ,EAAE,IAAI,KAAK,CAAC,CAClE,CAAC;QACN,CAAC;QAED,KAAK,MAAM,IAAI,IAAI,IAAI,EAAE,CAAC;YACtB,OAAO,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,EAAE,EAAE,GAAG,CAAC,IAAI,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;QACzD,CAAC;IACL,CAAC;CACJ;AApPD,0CAoPC"}
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vesyncKitchen.js","sourceRoot":"","sources":["../../src/lib/vesyncKitchen.ts"],"names":[],"mappings":""}
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vesyncOutlet.js","sourceRoot":"","sources":["../../src/lib/vesyncOutlet.ts"],"names":[],"mappings":""}
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vesyncSwitch.js","sourceRoot":"","sources":["../../src/lib/vesyncSwitch.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Helper functions for VeSync API
|
|
3
|
+
*/
|
|
4
|
+
import { VeSync } from './vesync';
|
|
5
|
+
export declare function getApiBaseUrl(): string;
|
|
6
|
+
export declare function setApiBaseUrl(url: string): void;
|
|
7
|
+
export declare const API_RATE_LIMIT = 30;
|
|
8
|
+
export declare const API_TIMEOUT = 5000;
|
|
9
|
+
export declare const APP_VERSION = "2.8.6";
|
|
10
|
+
export declare const PHONE_BRAND = "SM N9005";
|
|
11
|
+
export declare const PHONE_OS = "Android";
|
|
12
|
+
export declare const USER_TYPE = "1";
|
|
13
|
+
export declare const DEFAULT_TZ = "America/New_York";
|
|
14
|
+
export declare const DEFAULT_REGION = "US";
|
|
15
|
+
export declare const MOBILE_ID = "1234567890123456";
|
|
16
|
+
export declare const BYPASS_HEADER_UA = "okhttp/3.12.1";
|
|
17
|
+
export interface RequestBody {
|
|
18
|
+
acceptLanguage?: string;
|
|
19
|
+
accountID?: string;
|
|
20
|
+
appVersion?: string;
|
|
21
|
+
cid?: string;
|
|
22
|
+
configModule?: string;
|
|
23
|
+
debugMode?: boolean;
|
|
24
|
+
deviceRegion?: string;
|
|
25
|
+
email?: string;
|
|
26
|
+
method?: string;
|
|
27
|
+
password?: string;
|
|
28
|
+
phoneBrand?: string;
|
|
29
|
+
phoneOS?: string;
|
|
30
|
+
timeZone?: string;
|
|
31
|
+
token?: string;
|
|
32
|
+
traceId?: string;
|
|
33
|
+
userType?: string;
|
|
34
|
+
uuid?: string;
|
|
35
|
+
status?: string;
|
|
36
|
+
[key: string]: any;
|
|
37
|
+
}
|
|
38
|
+
export declare class Helpers {
|
|
39
|
+
static shouldRedact: boolean;
|
|
40
|
+
/**
|
|
41
|
+
* Calculate MD5 hash
|
|
42
|
+
*/
|
|
43
|
+
static md5(text: string): string;
|
|
44
|
+
/**
|
|
45
|
+
* Build header for legacy api GET requests
|
|
46
|
+
*/
|
|
47
|
+
static reqHeaders(manager: VeSync): Record<string, string>;
|
|
48
|
+
/**
|
|
49
|
+
* Build header for api requests on 'bypass' endpoint
|
|
50
|
+
*/
|
|
51
|
+
static reqHeaderBypass(): Record<string, string>;
|
|
52
|
+
/**
|
|
53
|
+
* Return universal keys for body of api requests
|
|
54
|
+
*/
|
|
55
|
+
static reqBodyBase(manager: VeSync): Record<string, string>;
|
|
56
|
+
/**
|
|
57
|
+
* Keys for authenticating api requests
|
|
58
|
+
*/
|
|
59
|
+
static reqBodyAuth(manager: VeSync): Record<string, any>;
|
|
60
|
+
/**
|
|
61
|
+
* Detail keys for api requests
|
|
62
|
+
*/
|
|
63
|
+
static reqBodyDetails(): Record<string, string>;
|
|
64
|
+
/**
|
|
65
|
+
* Builder for body of api requests
|
|
66
|
+
*/
|
|
67
|
+
static reqBody(manager: VeSync, type: string): Record<string, any>;
|
|
68
|
+
/**
|
|
69
|
+
* Call VeSync API
|
|
70
|
+
*/
|
|
71
|
+
static callApi(endpoint: string, method: string, data?: any, headers?: Record<string, string>): Promise<[any, number]>;
|
|
72
|
+
/**
|
|
73
|
+
* Calculate hex value from energy response
|
|
74
|
+
*/
|
|
75
|
+
static calculateHex(hexStr: string): string;
|
|
76
|
+
/**
|
|
77
|
+
* Build energy dictionary from API response
|
|
78
|
+
*/
|
|
79
|
+
static buildEnergyDict(result: any): Record<string, any>;
|
|
80
|
+
/**
|
|
81
|
+
* Build configuration dictionary from API response
|
|
82
|
+
*/
|
|
83
|
+
static buildConfigDict(result: any): Record<string, any>;
|
|
84
|
+
/**
|
|
85
|
+
* Calculate MD5 hash
|
|
86
|
+
*/
|
|
87
|
+
static hashPassword(text: string): string;
|
|
88
|
+
}
|
|
@@ -0,0 +1,244 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Helper functions for VeSync API
|
|
4
|
+
*/
|
|
5
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
6
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
7
|
+
};
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.Helpers = exports.BYPASS_HEADER_UA = exports.MOBILE_ID = exports.DEFAULT_REGION = exports.DEFAULT_TZ = exports.USER_TYPE = exports.PHONE_OS = exports.PHONE_BRAND = exports.APP_VERSION = exports.API_TIMEOUT = exports.API_RATE_LIMIT = void 0;
|
|
10
|
+
exports.getApiBaseUrl = getApiBaseUrl;
|
|
11
|
+
exports.setApiBaseUrl = setApiBaseUrl;
|
|
12
|
+
const axios_1 = __importDefault(require("axios"));
|
|
13
|
+
const crypto_1 = __importDefault(require("crypto"));
|
|
14
|
+
// API configuration
|
|
15
|
+
let _apiBaseUrl = 'https://smartapi.vesync.com';
|
|
16
|
+
function getApiBaseUrl() {
|
|
17
|
+
return _apiBaseUrl;
|
|
18
|
+
}
|
|
19
|
+
function setApiBaseUrl(url) {
|
|
20
|
+
_apiBaseUrl = url;
|
|
21
|
+
}
|
|
22
|
+
exports.API_RATE_LIMIT = 30;
|
|
23
|
+
exports.API_TIMEOUT = 5000;
|
|
24
|
+
exports.APP_VERSION = '2.8.6';
|
|
25
|
+
exports.PHONE_BRAND = 'SM N9005';
|
|
26
|
+
exports.PHONE_OS = 'Android';
|
|
27
|
+
exports.USER_TYPE = '1';
|
|
28
|
+
exports.DEFAULT_TZ = 'America/New_York';
|
|
29
|
+
exports.DEFAULT_REGION = 'US';
|
|
30
|
+
exports.MOBILE_ID = '1234567890123456';
|
|
31
|
+
exports.BYPASS_HEADER_UA = 'okhttp/3.12.1';
|
|
32
|
+
class Helpers {
|
|
33
|
+
/**
|
|
34
|
+
* Calculate MD5 hash
|
|
35
|
+
*/
|
|
36
|
+
static md5(text) {
|
|
37
|
+
return crypto_1.default.createHash('md5').update(text).digest('hex');
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Build header for legacy api GET requests
|
|
41
|
+
*/
|
|
42
|
+
static reqHeaders(manager) {
|
|
43
|
+
if (!manager.accountId || !manager.token) {
|
|
44
|
+
throw new Error('Manager accountId and token must be set');
|
|
45
|
+
}
|
|
46
|
+
return {
|
|
47
|
+
'accept-language': 'en',
|
|
48
|
+
'accountId': manager.accountId,
|
|
49
|
+
'appVersion': exports.APP_VERSION,
|
|
50
|
+
'content-type': 'application/json',
|
|
51
|
+
'tk': manager.token,
|
|
52
|
+
'tz': manager.timeZone
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Build header for api requests on 'bypass' endpoint
|
|
57
|
+
*/
|
|
58
|
+
static reqHeaderBypass() {
|
|
59
|
+
return {
|
|
60
|
+
'Content-Type': 'application/json; charset=UTF-8',
|
|
61
|
+
'User-Agent': exports.BYPASS_HEADER_UA
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Return universal keys for body of api requests
|
|
66
|
+
*/
|
|
67
|
+
static reqBodyBase(manager) {
|
|
68
|
+
return {
|
|
69
|
+
'timeZone': manager.timeZone,
|
|
70
|
+
'acceptLanguage': 'en'
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Keys for authenticating api requests
|
|
75
|
+
*/
|
|
76
|
+
static reqBodyAuth(manager) {
|
|
77
|
+
if (!manager.accountId || !manager.token) {
|
|
78
|
+
throw new Error('Manager accountId and token must be set');
|
|
79
|
+
}
|
|
80
|
+
return {
|
|
81
|
+
'accountID': manager.accountId,
|
|
82
|
+
'token': manager.token
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Detail keys for api requests
|
|
87
|
+
*/
|
|
88
|
+
static reqBodyDetails() {
|
|
89
|
+
return {
|
|
90
|
+
'appVersion': exports.APP_VERSION,
|
|
91
|
+
'phoneBrand': exports.PHONE_BRAND,
|
|
92
|
+
'phoneOS': exports.PHONE_OS,
|
|
93
|
+
'traceId': Date.now().toString()
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Builder for body of api requests
|
|
98
|
+
*/
|
|
99
|
+
static reqBody(manager, type) {
|
|
100
|
+
const body = {
|
|
101
|
+
...this.reqBodyBase(manager)
|
|
102
|
+
};
|
|
103
|
+
if (type === 'login') {
|
|
104
|
+
return {
|
|
105
|
+
...body,
|
|
106
|
+
...this.reqBodyDetails(),
|
|
107
|
+
email: manager.username,
|
|
108
|
+
password: this.hashPassword(manager.password),
|
|
109
|
+
devToken: '',
|
|
110
|
+
userType: exports.USER_TYPE,
|
|
111
|
+
method: 'login'
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
const authBody = {
|
|
115
|
+
...body,
|
|
116
|
+
...this.reqBodyAuth(manager)
|
|
117
|
+
};
|
|
118
|
+
if (type === 'devicestatus') {
|
|
119
|
+
return authBody;
|
|
120
|
+
}
|
|
121
|
+
const fullBody = {
|
|
122
|
+
...authBody,
|
|
123
|
+
...this.reqBodyDetails()
|
|
124
|
+
};
|
|
125
|
+
switch (type) {
|
|
126
|
+
case 'devicelist':
|
|
127
|
+
return {
|
|
128
|
+
...fullBody,
|
|
129
|
+
method: 'devices',
|
|
130
|
+
pageNo: '1',
|
|
131
|
+
pageSize: '100'
|
|
132
|
+
};
|
|
133
|
+
case 'devicedetail':
|
|
134
|
+
return {
|
|
135
|
+
...fullBody,
|
|
136
|
+
method: 'devicedetail',
|
|
137
|
+
mobileId: exports.MOBILE_ID
|
|
138
|
+
};
|
|
139
|
+
case 'bypass':
|
|
140
|
+
return {
|
|
141
|
+
...fullBody,
|
|
142
|
+
method: 'bypass'
|
|
143
|
+
};
|
|
144
|
+
case 'bypassV2':
|
|
145
|
+
return {
|
|
146
|
+
...fullBody,
|
|
147
|
+
deviceRegion: exports.DEFAULT_REGION,
|
|
148
|
+
method: 'bypassV2'
|
|
149
|
+
};
|
|
150
|
+
case 'bypass_config':
|
|
151
|
+
return {
|
|
152
|
+
...fullBody,
|
|
153
|
+
method: 'firmwareUpdateInfo'
|
|
154
|
+
};
|
|
155
|
+
default:
|
|
156
|
+
return fullBody;
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
/**
|
|
160
|
+
* Call VeSync API
|
|
161
|
+
*/
|
|
162
|
+
static async callApi(endpoint, method, data = null, headers = {}) {
|
|
163
|
+
try {
|
|
164
|
+
const url = _apiBaseUrl + endpoint;
|
|
165
|
+
const response = await (0, axios_1.default)({
|
|
166
|
+
method,
|
|
167
|
+
url,
|
|
168
|
+
data,
|
|
169
|
+
headers,
|
|
170
|
+
timeout: exports.API_TIMEOUT
|
|
171
|
+
});
|
|
172
|
+
return [response.data, response.status];
|
|
173
|
+
}
|
|
174
|
+
catch (error) {
|
|
175
|
+
if (error.response) {
|
|
176
|
+
return [error.response.data, error.response.status];
|
|
177
|
+
}
|
|
178
|
+
console.error('API call failed:', error.message);
|
|
179
|
+
return [null, 0];
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
/**
|
|
183
|
+
* Calculate hex value from energy response
|
|
184
|
+
*/
|
|
185
|
+
static calculateHex(hexStr) {
|
|
186
|
+
if (!hexStr || !hexStr.includes(':')) {
|
|
187
|
+
return '0';
|
|
188
|
+
}
|
|
189
|
+
const [prefix, value] = hexStr.split(':');
|
|
190
|
+
if (!prefix || !value) {
|
|
191
|
+
return '0';
|
|
192
|
+
}
|
|
193
|
+
try {
|
|
194
|
+
const decoded = Buffer.from(value, 'hex');
|
|
195
|
+
return decoded.readFloatBE(0).toString();
|
|
196
|
+
}
|
|
197
|
+
catch (error) {
|
|
198
|
+
console.debug('Error decoding hex value:', error);
|
|
199
|
+
return '0';
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
/**
|
|
203
|
+
* Build energy dictionary from API response
|
|
204
|
+
*/
|
|
205
|
+
static buildEnergyDict(result) {
|
|
206
|
+
if (!result) {
|
|
207
|
+
return {};
|
|
208
|
+
}
|
|
209
|
+
return {
|
|
210
|
+
energy_consumption_of_today: result.energyConsumptionOfToday || 0,
|
|
211
|
+
cost_per_kwh: result.costPerKWH || 0,
|
|
212
|
+
max_energy: result.maxEnergy || 0,
|
|
213
|
+
total_energy: result.totalEnergy || 0,
|
|
214
|
+
data: result.data || [],
|
|
215
|
+
energy_consumption: result.energy || 0,
|
|
216
|
+
start_time: result.startTime || '',
|
|
217
|
+
end_time: result.endTime || ''
|
|
218
|
+
};
|
|
219
|
+
}
|
|
220
|
+
/**
|
|
221
|
+
* Build configuration dictionary from API response
|
|
222
|
+
*/
|
|
223
|
+
static buildConfigDict(result) {
|
|
224
|
+
if (!result) {
|
|
225
|
+
return {};
|
|
226
|
+
}
|
|
227
|
+
return {
|
|
228
|
+
configModule: result.configModule || '',
|
|
229
|
+
firmwareVersion: result.currentFirmVersion || '',
|
|
230
|
+
deviceRegion: result.deviceRegion || '',
|
|
231
|
+
debugMode: result.debugMode || false,
|
|
232
|
+
deviceTimezone: result.deviceTimezone || exports.DEFAULT_TZ,
|
|
233
|
+
...result
|
|
234
|
+
};
|
|
235
|
+
}
|
|
236
|
+
/**
|
|
237
|
+
* Calculate MD5 hash
|
|
238
|
+
*/
|
|
239
|
+
static hashPassword(text) {
|
|
240
|
+
return crypto_1.default.createHash('md5').update(text).digest('hex');
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
exports.Helpers = Helpers;
|
|
244
|
+
Helpers.shouldRedact = true;
|