homebridge-melcloud-control 4.0.0-beta.503 → 4.0.0-beta.505
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 +19 -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.505",
|
|
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
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import axios from 'axios';
|
|
2
|
+
import { exec } from 'child_process';
|
|
2
3
|
import EventEmitter from 'events';
|
|
3
4
|
import puppeteer from 'puppeteer-core';
|
|
4
5
|
import ImpulseGenerator from './impulsegenerator.js';
|
|
5
6
|
import Functions from './functions.js';
|
|
6
7
|
import { ApiUrls, ApiUrlsHome } from './constants.js';
|
|
8
|
+
const execPromise = promisify(exec);
|
|
7
9
|
|
|
8
10
|
class MelCloud extends EventEmitter {
|
|
9
11
|
constructor(account, accountFile, buildingsFile, devicesFile, pluginStart = false) {
|
|
@@ -311,6 +313,16 @@ class MelCloud extends EventEmitter {
|
|
|
311
313
|
return accountInfo;
|
|
312
314
|
}
|
|
313
315
|
|
|
316
|
+
try {
|
|
317
|
+
const { stdout } = await execPromise(`"${chromiumPath}" --version`);
|
|
318
|
+
this.emit('warn', `Test 0`);
|
|
319
|
+
if (this.logDebug) this.emit('debug', `Chromium detected: ${stdout.trim()}`);
|
|
320
|
+
} catch (error) {
|
|
321
|
+
accountInfo.State = false;
|
|
322
|
+
accountInfo.Info = `Chromium found at ${chromiumPath}, but cannot be executed: ${error.message}`;
|
|
323
|
+
return accountInfo;
|
|
324
|
+
}
|
|
325
|
+
|
|
314
326
|
this.emit('warn', `Test 1`);
|
|
315
327
|
browser = await puppeteer.launch({
|
|
316
328
|
headless: true,
|
|
@@ -344,12 +356,15 @@ class MelCloud extends EventEmitter {
|
|
|
344
356
|
page.on('close', () => { if (this.logDebug) this.emit('debug', 'Page was closed unexpectedly'); });
|
|
345
357
|
browser.on('disconnected', () => { if (this.logWarn) this.emit('debug', 'Browser disconnected unexpectedly'); });
|
|
346
358
|
|
|
347
|
-
page.setDefaultTimeout(45000);
|
|
348
|
-
page.setDefaultNavigationTimeout(45000);
|
|
349
|
-
|
|
350
359
|
// Now safe to navigate
|
|
351
360
|
this.emit('warn', `Test 4`);
|
|
352
|
-
|
|
361
|
+
try {
|
|
362
|
+
await page.goto(ApiUrlsHome.BaseURL, { waitUntil: ['domcontentloaded', 'networkidle2'], timeout: 45000 });
|
|
363
|
+
} catch (error) {
|
|
364
|
+
accountInfo.State = false;
|
|
365
|
+
accountInfo.Info = `Navigation to ${ApiUrlsHome.BaseURL} failed: ${error.message}`;
|
|
366
|
+
return accountInfo;
|
|
367
|
+
}
|
|
353
368
|
await new Promise(r => setTimeout(r, 4000));
|
|
354
369
|
|
|
355
370
|
let loginBtn;
|