homebridge-melcloud-control 4.0.0-beta.543 → 4.0.0-beta.545
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 +11 -14
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.545",
|
|
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
|
@@ -350,12 +350,12 @@ class MelCloud extends EventEmitter {
|
|
|
350
350
|
try {
|
|
351
351
|
const client = await page.createCDPSession();
|
|
352
352
|
await client.send('Network.clearBrowserCookies');
|
|
353
|
-
} catch (
|
|
354
|
-
this.emit('warn', `Warning: could not clear cookies: ${
|
|
353
|
+
} catch (error) {
|
|
354
|
+
this.emit('warn', `Warning: could not clear cookies: ${error.message}`);
|
|
355
355
|
}
|
|
356
356
|
|
|
357
|
-
page.on('error',
|
|
358
|
-
page.on('pageerror',
|
|
357
|
+
page.on('error', error => this.emit('error', `Page crashed: ${error.message}`));
|
|
358
|
+
page.on('pageerror', error => this.emit('error', `Browser error: ${error.message}`));
|
|
359
359
|
browser.on('disconnected', () => this.emit('debug', 'Browser disconnected'));
|
|
360
360
|
|
|
361
361
|
this.emit('warn', `Navigating to MELCloud...`);
|
|
@@ -370,19 +370,16 @@ class MelCloud extends EventEmitter {
|
|
|
370
370
|
await new Promise(r => setTimeout(r, 3000));
|
|
371
371
|
|
|
372
372
|
this.emit('warn', `Looking for login button...`);
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
}, { timeout: GLOBAL_TIMEOUT / 6 });
|
|
379
|
-
} catch {
|
|
380
|
-
accountInfo.Info = 'Login button not found';
|
|
373
|
+
const loginBtn = await page.waitForSelector('button.btn--blue', { timeout: GLOBAL_TIMEOUT / 6 });
|
|
374
|
+
const loginText = await page.evaluate(el => el.textContent.trim(), loginBtn);
|
|
375
|
+
|
|
376
|
+
if (!['Zaloguj', 'Sign In', 'Login'].includes(loginText)) {
|
|
377
|
+
accountInfo.Info = 'Login button not found or has unexpected label';
|
|
381
378
|
return accountInfo;
|
|
382
379
|
}
|
|
383
380
|
|
|
384
|
-
|
|
385
|
-
await
|
|
381
|
+
await loginBtn.click();
|
|
382
|
+
await page.waitForNavigation({ waitUntil: 'networkidle2', timeout: GLOBAL_TIMEOUT / 3 });
|
|
386
383
|
|
|
387
384
|
this.emit('warn', `Looking for credentials form...`);
|
|
388
385
|
const usernameInput = await page.$('input[name="username"]');
|