homebridge-melcloud-control 4.0.0-beta.503 → 4.0.0-beta.504
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 -1
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.504",
|
|
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 (err) {
|
|
321
|
+
accountInfo.State = false;
|
|
322
|
+
accountInfo.Info = `Chromium found at ${chromiumPath}, but cannot be executed: ${err.message}`;
|
|
323
|
+
return accountInfo;
|
|
324
|
+
}
|
|
325
|
+
|
|
314
326
|
this.emit('warn', `Test 1`);
|
|
315
327
|
browser = await puppeteer.launch({
|
|
316
328
|
headless: true,
|
|
@@ -349,7 +361,13 @@ class MelCloud extends EventEmitter {
|
|
|
349
361
|
|
|
350
362
|
// Now safe to navigate
|
|
351
363
|
this.emit('warn', `Test 4`);
|
|
352
|
-
|
|
364
|
+
try {
|
|
365
|
+
await page.goto(ApiUrlsHome.BaseURL, { waitUntil: ['domcontentloaded', 'networkidle2'], timeout: 45000 });
|
|
366
|
+
} catch (err) {
|
|
367
|
+
accountInfo.State = false;
|
|
368
|
+
accountInfo.Info = `Navigation to ${ApiUrlsHome.BaseURL} failed: ${err.message}`;
|
|
369
|
+
return accountInfo;
|
|
370
|
+
}
|
|
353
371
|
await new Promise(r => setTimeout(r, 4000));
|
|
354
372
|
|
|
355
373
|
let loginBtn;
|