homebridge-melcloud-control 4.0.0-beta.28 → 4.0.0-beta.29
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 +18 -4
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.29",
|
|
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
|
@@ -288,11 +288,25 @@ class MelCloud extends EventEmitter {
|
|
|
288
288
|
page.waitForNavigation({ waitUntil: 'networkidle2', timeout: 20000 })
|
|
289
289
|
]);
|
|
290
290
|
|
|
291
|
-
|
|
292
|
-
const
|
|
293
|
-
|
|
291
|
+
let c1 = null, c2 = null;
|
|
292
|
+
const start = Date.now();
|
|
293
|
+
|
|
294
|
+
// Loop max 20s, czekamy aż pojawią się cookies
|
|
295
|
+
while ((!c1 || !c2) && Date.now() - start < 20000) {
|
|
296
|
+
const cookies = await page.cookies();
|
|
297
|
+
c1 = cookies.find(c => c.name === '__Secure-monitorandcontrolC1')?.value || c1;
|
|
298
|
+
c2 = cookies.find(c => c.name === '__Secure-monitorandcontrolC2')?.value || c2;
|
|
299
|
+
if (!c1 || !c2) await new Promise(r => setTimeout(r, 500));
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
if (!c1 || !c2) {
|
|
303
|
+
await browser.close();
|
|
304
|
+
throw new Error('❌ Cookies C1/C2 not found after login');
|
|
305
|
+
}
|
|
294
306
|
|
|
295
|
-
//
|
|
307
|
+
// Zapis do pliku
|
|
308
|
+
const data = { C1: c1, C2: c2, date: new Date().toISOString() };
|
|
309
|
+
await this.functions.saveData(this.cookiesFile, data);
|
|
296
310
|
|
|
297
311
|
this.emit('warn', 'Login successful.');
|
|
298
312
|
return data;
|