homebridge-melcloud-control 4.2.5-beta.16 → 4.2.5-beta.18
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/index.js +1 -1
- package/package.json +1 -1
- package/src/melcloudhome.js +19 -11
package/index.js
CHANGED
|
@@ -202,7 +202,7 @@ class MelCloudPlatform {
|
|
|
202
202
|
if (logLevel.success) log.success(`${accountName}, ${deviceTypeText}, ${deviceName}, Published as external accessory.`);
|
|
203
203
|
|
|
204
204
|
//start impulse generators\
|
|
205
|
-
const timmers = accountType === 'melcloudhome' ? [{ name: 'connect', sampling:
|
|
205
|
+
const timmers = accountType === 'melcloudhome' ? [{ name: 'connect', sampling: 3000000 }, { name: 'checkDevicesList', sampling: deviceRefreshInterval }] : [{ name: 'checkDevicesList', sampling: refreshInterval }];
|
|
206
206
|
await melCloud.impulseGenerator.state(true, timmers, false);
|
|
207
207
|
await configuredDevice.startStopImpulseGenerator(true, [{ name: 'checkState', sampling: deviceRefreshInterval }]);
|
|
208
208
|
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"displayName": "MELCloud Control",
|
|
3
3
|
"name": "homebridge-melcloud-control",
|
|
4
|
-
"version": "4.2.5-beta.
|
|
4
|
+
"version": "4.2.5-beta.18",
|
|
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/melcloudhome.js
CHANGED
|
@@ -276,14 +276,6 @@ class MelCloud extends EventEmitter {
|
|
|
276
276
|
page.setDefaultTimeout(GLOBAL_TIMEOUT);
|
|
277
277
|
page.setDefaultNavigationTimeout(GLOBAL_TIMEOUT);
|
|
278
278
|
|
|
279
|
-
// Clear cookies before navigation
|
|
280
|
-
try {
|
|
281
|
-
const client = await page.createCDPSession();
|
|
282
|
-
await client.send('Network.clearBrowserCookies');
|
|
283
|
-
} catch (error) {
|
|
284
|
-
if (this.logError) this.emit('error', `Clear cookies error: ${error.message}`);
|
|
285
|
-
}
|
|
286
|
-
|
|
287
279
|
try {
|
|
288
280
|
await page.goto(ApiUrlsHome.BaseURL, { waitUntil: ['domcontentloaded', 'networkidle2'], timeout: GLOBAL_TIMEOUT });
|
|
289
281
|
} catch (error) {
|
|
@@ -320,11 +312,27 @@ class MelCloud extends EventEmitter {
|
|
|
320
312
|
return accountInfo;
|
|
321
313
|
}
|
|
322
314
|
await Promise.race([Promise.all([submitButton.click(), page.waitForNavigation({ waitUntil: ['domcontentloaded', 'networkidle2'], timeout: GLOBAL_TIMEOUT / 4 })]), new Promise(r => setTimeout(r, GLOBAL_TIMEOUT / 3))]);
|
|
323
|
-
await page.goto(ApiUrlsHome.GetConfiguration, { waitUntil: ['domcontentloaded', 'networkidle2'], timeout: GLOBAL_TIMEOUT / 3 });
|
|
324
|
-
const cookies = await page.browserContext().cookies();
|
|
325
|
-
this.emit('warn', `Cookies: ${JSON.stringify(cookies)}`);
|
|
326
315
|
|
|
316
|
+
// Extract cookies
|
|
317
|
+
let c1 = null, c2 = null;
|
|
318
|
+
const start = Date.now();
|
|
319
|
+
while ((!c1 || !c2) && Date.now() - start < GLOBAL_TIMEOUT / 2) {
|
|
320
|
+
const cookies = await browser.cookies();
|
|
321
|
+
c1 = cookies.find(c => c.name === '__Secure-monitorandcontrolC1')?.value || c1;
|
|
322
|
+
c2 = cookies.find(c => c.name === '__Secure-monitorandcontrolC2')?.value || c2;
|
|
323
|
+
if (!c1 || !c2) await new Promise(r => setTimeout(r, 500));
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
if (!c1 || !c2) {
|
|
327
|
+
accountInfo.Info = 'Cookies C1/C2 missing';
|
|
328
|
+
return accountInfo;
|
|
329
|
+
}
|
|
327
330
|
|
|
331
|
+
const cookies = [
|
|
332
|
+
'__Secure-monitorandcontrol=chunks-2',
|
|
333
|
+
`__Secure-monitorandcontrolC1=${c1}`,
|
|
334
|
+
`__Secure-monitorandcontrolC2=${c2}`
|
|
335
|
+
].join('; ');
|
|
328
336
|
|
|
329
337
|
|
|
330
338
|
const userAgent = await page.evaluate(() => navigator.userAgent);
|