homebridge-melcloud-control 4.0.0-beta.6 → 4.0.0-beta.8
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/melcloud.js +16 -7
package/index.js
CHANGED
|
@@ -95,7 +95,7 @@ class MelCloudPlatform {
|
|
|
95
95
|
.on('warn', (msg) => logLevel.warn && log.warn(`${accountName}, ${msg}`))
|
|
96
96
|
.on('error', (msg) => logLevel.error && log.error(`${accountName}, ${msg}`));
|
|
97
97
|
|
|
98
|
-
await melCloud.
|
|
98
|
+
await melCloud.connectHomeCookies()
|
|
99
99
|
return;
|
|
100
100
|
|
|
101
101
|
|
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.8",
|
|
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
|
@@ -262,20 +262,29 @@ class MelCloud extends EventEmitter {
|
|
|
262
262
|
throw new Error('❌ Could not find login button on the page.');
|
|
263
263
|
}
|
|
264
264
|
|
|
265
|
-
// ✅
|
|
266
|
-
this.emit('warn', 'Waiting for MELCloud Home
|
|
267
|
-
|
|
265
|
+
// ✅ Czekanie aż cookies C1 i C2 będą ustawione (max 15s)
|
|
266
|
+
this.emit('warn', 'Waiting for MELCloud Home cookies (C1 & C2)...');
|
|
267
|
+
let c1 = null, c2 = null;
|
|
268
|
+
const start = Date.now();
|
|
269
|
+
while ((!c1 || !c2) && Date.now() - start < 15000) {
|
|
270
|
+
const cookies = await page.cookies();
|
|
271
|
+
c1 = cookies.find(c => c.name === '__Secure-monitorandcontrolC1')?.value || null;
|
|
272
|
+
c2 = cookies.find(c => c.name === '__Secure-monitorandcontrolC2')?.value || null;
|
|
273
|
+
if (!c1 || !c2) {
|
|
274
|
+
await new Promise(resolve => setTimeout(resolve, 500)); // retry co 0.5s
|
|
275
|
+
}
|
|
276
|
+
}
|
|
268
277
|
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
const c2 = cookies.find(c => c.name === '__Secure-monitorandcontrolC2')?.value || null;
|
|
278
|
+
if (!c1 || !c2) {
|
|
279
|
+
throw new Error('❌ Cookies C1/C2 not found after login');
|
|
280
|
+
}
|
|
273
281
|
|
|
274
282
|
const data = { C1: c1, C2: c2, date: new Date().toISOString() };
|
|
275
283
|
await this.functions.saveData(this.cookiesFile, data);
|
|
276
284
|
|
|
277
285
|
this.emit('warn', 'Login successful.');
|
|
278
286
|
return data;
|
|
287
|
+
|
|
279
288
|
} catch (err) {
|
|
280
289
|
this.emit('error', `Login failed: ${err.message}`);
|
|
281
290
|
return null;
|