homebridge-melcloud-control 4.0.0-beta.40 → 4.0.0-beta.41
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/package.json +1 -1
- package/src/melcloud.js +11 -22
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"displayName": "MELCloud Control",
|
|
3
3
|
"name": "homebridge-melcloud-control",
|
|
4
|
-
"version": "4.0.0-beta.
|
|
4
|
+
"version": "4.0.0-beta.41",
|
|
5
5
|
"description": "Homebridge plugin to control Mitsubishi Air Conditioner, Heat Pump and Energy Recovery Ventilation.",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"author": "grzegorz914",
|
package/src/melcloud.js
CHANGED
|
@@ -162,28 +162,15 @@ class MelCloud extends EventEmitter {
|
|
|
162
162
|
}
|
|
163
163
|
}
|
|
164
164
|
|
|
165
|
-
async checkMelcloudHomeDevicesList(
|
|
165
|
+
async checkMelcloudHomeDevicesList(contextKey) {
|
|
166
166
|
try {
|
|
167
|
-
const c1 = cookies.c1.trim();
|
|
168
|
-
const c2 = cookies.c2.trim();
|
|
169
|
-
|
|
170
|
-
const cookie = [
|
|
171
|
-
'__Secure-monitorandcontrol=chunks-2',
|
|
172
|
-
`__Secure-monitorandcontrolC1=${c1}`,
|
|
173
|
-
`__Secure-monitorandcontrolC2=${c2}`,
|
|
174
|
-
].join('; ');
|
|
175
|
-
|
|
176
167
|
const axiosInstance = axios.create({
|
|
168
|
+
method: 'GET',
|
|
177
169
|
baseURL: ApiUrlsHome.BaseURL,
|
|
178
|
-
timeout: 20000,
|
|
179
|
-
httpsAgent: new Agent({
|
|
180
|
-
keepAlive: false,
|
|
181
|
-
rejectUnauthorized: false
|
|
182
|
-
}),
|
|
183
170
|
headers: {
|
|
184
171
|
'Accept': '*/*',
|
|
185
172
|
'Accept-Language': 'en-US,en;q=0.9',
|
|
186
|
-
'Cookie':
|
|
173
|
+
'Cookie': contextKey,
|
|
187
174
|
'User-Agent': 'homebridge-melcloud-control/4.0.0',
|
|
188
175
|
'DNT': '1',
|
|
189
176
|
'Origin': 'https://melcloudhome.com',
|
|
@@ -192,11 +179,12 @@ class MelCloud extends EventEmitter {
|
|
|
192
179
|
'Sec-Fetch-Mode': 'cors',
|
|
193
180
|
'Sec-Fetch-Site': 'same-origin',
|
|
194
181
|
'X-CSRF': '1'
|
|
195
|
-
}
|
|
182
|
+
},
|
|
183
|
+
...this.axiosDefaults
|
|
196
184
|
});
|
|
197
185
|
|
|
198
186
|
if (this.logDebug) this.emit('debug', `Scanning for devices`);
|
|
199
|
-
const listDevicesData = await axiosInstance
|
|
187
|
+
const listDevicesData = await axiosInstance(ApiUrlsHome.GetUserContext);
|
|
200
188
|
const buildingsList = listDevicesData.data.buildings;
|
|
201
189
|
if (this.logDebug) this.emit('debug', `Buildings: ${JSON.stringify(buildingsList, null, 2)}`);
|
|
202
190
|
|
|
@@ -276,10 +264,11 @@ class MelCloud extends EventEmitter {
|
|
|
276
264
|
}
|
|
277
265
|
|
|
278
266
|
const accountInfo = {};
|
|
279
|
-
const contextKey = {
|
|
267
|
+
const contextKey = ['__Secure-monitorandcontrol=chunks-2', `__Secure-monitorandcontrolC1=${c1}`, `__Secure-monitorandcontrolC2=${c2}`,].join('; ');
|
|
280
268
|
const useFahrenheit = false;
|
|
281
269
|
this.contextKey = contextKey;
|
|
282
270
|
|
|
271
|
+
|
|
283
272
|
this.emit('success', `Connect to MELCloud Home Success`);
|
|
284
273
|
|
|
285
274
|
return { accountInfo, contextKey, useFahrenheit };
|
|
@@ -304,14 +293,14 @@ class MelCloud extends EventEmitter {
|
|
|
304
293
|
}
|
|
305
294
|
}
|
|
306
295
|
|
|
307
|
-
async checkDevicesList(
|
|
296
|
+
async checkDevicesList(contextKey) {
|
|
308
297
|
let devices = null;
|
|
309
298
|
switch (this.displayType) {
|
|
310
299
|
case "1":
|
|
311
|
-
devices = await this.checkMelcloudDevicesList(
|
|
300
|
+
devices = await this.checkMelcloudDevicesList(contextKey);
|
|
312
301
|
return devices
|
|
313
302
|
case "2":
|
|
314
|
-
devices = await this.checkMelcloudHomeDevicesList(
|
|
303
|
+
devices = await this.checkMelcloudHomeDevicesList(contextKey);
|
|
315
304
|
return devices
|
|
316
305
|
default:
|
|
317
306
|
return null;
|