homebridge-melcloud-control 4.0.0-beta.496 → 4.0.0-beta.498
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 +12 -15
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.498",
|
|
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
|
@@ -302,7 +302,6 @@ class MelCloud extends EventEmitter {
|
|
|
302
302
|
if (this.logDebug) this.emit('debug', 'Connecting to MELCloud Home');
|
|
303
303
|
|
|
304
304
|
let browser;
|
|
305
|
-
|
|
306
305
|
try {
|
|
307
306
|
const accountInfo = { State: false, Info: '', ContextKey: null, UseFahrenheit: false }
|
|
308
307
|
const chromiumPath = await this.functions.ensureChromiumInstalled();
|
|
@@ -327,7 +326,7 @@ class MelCloud extends EventEmitter {
|
|
|
327
326
|
});
|
|
328
327
|
|
|
329
328
|
// Wait for Puppeteer target to be ready (browser internal page)
|
|
330
|
-
await new Promise(r => setTimeout(r,
|
|
329
|
+
await new Promise(r => setTimeout(r, 1000));
|
|
331
330
|
|
|
332
331
|
// Defensive check for main frame availability
|
|
333
332
|
this.emit('warn', `Test 2`);
|
|
@@ -336,7 +335,7 @@ class MelCloud extends EventEmitter {
|
|
|
336
335
|
if (!page) {
|
|
337
336
|
if (this.logWarn) this.emit('warn', 'No initial page found, creating a new one');
|
|
338
337
|
page = await browser.newPage();
|
|
339
|
-
await new Promise(r => setTimeout(r,
|
|
338
|
+
await new Promise(r => setTimeout(r, 1500));
|
|
340
339
|
}
|
|
341
340
|
|
|
342
341
|
this.emit('warn', `Test 3`);
|
|
@@ -351,15 +350,15 @@ class MelCloud extends EventEmitter {
|
|
|
351
350
|
// Now safe to navigate
|
|
352
351
|
this.emit('warn', `Test 4`);
|
|
353
352
|
await page.goto(ApiUrlsHome.BaseURL, { waitUntil: ['domcontentloaded', 'networkidle2'] });
|
|
354
|
-
|
|
355
353
|
await new Promise(r => setTimeout(r, 3500));
|
|
354
|
+
|
|
356
355
|
let loginBtn;
|
|
357
356
|
try {
|
|
358
357
|
this.emit('warn', `Test 5`);
|
|
359
358
|
loginBtn = await page.waitForFunction(() => {
|
|
360
359
|
const btns = Array.from(document.querySelectorAll('button.btn--blue'));
|
|
361
360
|
return btns.find(b => ['Zaloguj', 'Sign In', 'Login'].includes(b.textContent.trim()));
|
|
362
|
-
}, { timeout: 5000 });
|
|
361
|
+
}, { timeout: 5000 });
|
|
363
362
|
} catch {
|
|
364
363
|
accountInfo.State = false;
|
|
365
364
|
accountInfo.Info = 'Login button not found after 5s';
|
|
@@ -437,7 +436,7 @@ class MelCloud extends EventEmitter {
|
|
|
437
436
|
async checkDevicesList() {
|
|
438
437
|
const TIMEOUT_MS = 30000; // 30 seconds timeout
|
|
439
438
|
try {
|
|
440
|
-
const
|
|
439
|
+
const devicesList = await Promise.race([
|
|
441
440
|
(async () => {
|
|
442
441
|
switch (this.accountType) {
|
|
443
442
|
case "melcloud":
|
|
@@ -451,10 +450,9 @@ class MelCloud extends EventEmitter {
|
|
|
451
450
|
new Promise((_, reject) => setTimeout(() => reject(new Error('Device list timeout (30s)')), TIMEOUT_MS))
|
|
452
451
|
]);
|
|
453
452
|
|
|
454
|
-
return
|
|
455
|
-
} catch (
|
|
456
|
-
|
|
457
|
-
throw new Error(`Device list error: ${err.message}`);
|
|
453
|
+
return devicesList;
|
|
454
|
+
} catch (error) {
|
|
455
|
+
throw new Error(`Device list error: ${error.message}`);
|
|
458
456
|
}
|
|
459
457
|
}
|
|
460
458
|
|
|
@@ -462,7 +460,7 @@ class MelCloud extends EventEmitter {
|
|
|
462
460
|
const TIMEOUT_MS = 60000;
|
|
463
461
|
|
|
464
462
|
try {
|
|
465
|
-
const
|
|
463
|
+
const response = await Promise.race([
|
|
466
464
|
(async () => {
|
|
467
465
|
switch (this.accountType) {
|
|
468
466
|
case "melcloud":
|
|
@@ -476,10 +474,9 @@ class MelCloud extends EventEmitter {
|
|
|
476
474
|
new Promise((_, reject) => setTimeout(() => reject(new Error('Connection timeout (60s)')), TIMEOUT_MS))
|
|
477
475
|
]);
|
|
478
476
|
|
|
479
|
-
return
|
|
480
|
-
} catch (
|
|
481
|
-
|
|
482
|
-
throw new Error(`Connect error: ${err.message}`);
|
|
477
|
+
return response;
|
|
478
|
+
} catch (error) {
|
|
479
|
+
throw new Error(`Connect error: ${error.message}`);
|
|
483
480
|
}
|
|
484
481
|
}
|
|
485
482
|
|