homebridge-melcloud-control 4.0.0-beta.497 → 4.0.0-beta.499
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 +10 -13
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.499",
|
|
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();
|
|
@@ -314,7 +313,7 @@ class MelCloud extends EventEmitter {
|
|
|
314
313
|
|
|
315
314
|
this.emit('warn', `Test 1`);
|
|
316
315
|
browser = await puppeteer.launch({
|
|
317
|
-
headless:
|
|
316
|
+
headless: true,
|
|
318
317
|
executablePath: chromiumPath,
|
|
319
318
|
timeout: 30000,
|
|
320
319
|
args: [
|
|
@@ -359,7 +358,7 @@ class MelCloud extends EventEmitter {
|
|
|
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
|
|