homebridge-melcloud-control 4.0.0-beta.267 → 4.0.0-beta.269
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 +14 -9
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.269",
|
|
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
|
@@ -283,14 +283,15 @@ class MelCloud extends EventEmitter {
|
|
|
283
283
|
async connectToMelCloudHome() {
|
|
284
284
|
let browser;
|
|
285
285
|
try {
|
|
286
|
-
browser = await puppeteer.launch({
|
|
287
|
-
|
|
286
|
+
browser = await puppeteer.launch({
|
|
287
|
+
headless: true,
|
|
288
|
+
args: ['--no-sandbox', '--disable-setuid-sandbox']
|
|
289
|
+
});
|
|
288
290
|
|
|
289
|
-
|
|
290
|
-
await page.goto(
|
|
291
|
+
const page = await browser.newPage();
|
|
292
|
+
await page.goto(ApiUrlsHome.BaseURL, { waitUntil: 'networkidle2' });
|
|
291
293
|
|
|
292
294
|
// 2. Kliknij login (jeżeli strona główna ma przycisk)
|
|
293
|
-
// Zastąp fragment z page.$x
|
|
294
295
|
const buttons = await page.$$('button.btn--blue');
|
|
295
296
|
let loginBtn = null;
|
|
296
297
|
|
|
@@ -302,10 +303,11 @@ class MelCloud extends EventEmitter {
|
|
|
302
303
|
}
|
|
303
304
|
}
|
|
304
305
|
|
|
305
|
-
if (!loginBtn
|
|
306
|
+
if (!loginBtn && this.logWarn) this.emit('warn', `Login button not found`);
|
|
307
|
+
|
|
306
308
|
await Promise.all([
|
|
307
309
|
loginBtn.click(),
|
|
308
|
-
page.waitForNavigation({ waitUntil: 'networkidle2' })
|
|
310
|
+
page.waitForNavigation({ waitUntil: 'networkidle2', timeout: 10000 })
|
|
309
311
|
]);
|
|
310
312
|
|
|
311
313
|
// 3. Wypełnij login i hasło
|
|
@@ -313,8 +315,11 @@ class MelCloud extends EventEmitter {
|
|
|
313
315
|
await page.type('input[name="username"]', this.user, { delay: 50 });
|
|
314
316
|
await page.type('input[name="password"]', this.passwd, { delay: 50 });
|
|
315
317
|
|
|
316
|
-
const
|
|
317
|
-
await
|
|
318
|
+
const button1 = await page.$('input[type="submit"]');
|
|
319
|
+
await Promise.all([
|
|
320
|
+
button1.click(),
|
|
321
|
+
page.waitForNavigation({ waitUntil: 'networkidle2', timeout: 10000 })
|
|
322
|
+
]);
|
|
318
323
|
|
|
319
324
|
// 4. Czekamy na przekierowanie z 'code' w URL
|
|
320
325
|
await page.waitForFunction(() => window.location.href.includes('code'), { timeout: 15000 });
|