homebridge-melcloud-control 4.0.0-beta.509 → 4.0.0-beta.510
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 +13 -17
- package/src/melcloudata.js +1 -1
- package/src/melcloudatw.js +1 -1
- package/src/melclouderv.js +1 -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.510",
|
|
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
|
@@ -42,7 +42,7 @@ class MelCloud extends EventEmitter {
|
|
|
42
42
|
await this.checkDevicesList();
|
|
43
43
|
}))
|
|
44
44
|
.on('state', (state) => {
|
|
45
|
-
this.emit('success', `Impulse generator ${state ? 'started' : 'stopped'}
|
|
45
|
+
this.emit(state ? 'success' : 'warn', `Impulse generator ${state ? 'started' : 'stopped'}`);
|
|
46
46
|
});
|
|
47
47
|
}
|
|
48
48
|
}
|
|
@@ -347,7 +347,7 @@ class MelCloud extends EventEmitter {
|
|
|
347
347
|
|
|
348
348
|
page.on('error', err => this.emit('error', `Page crashed: ${err.message}`));
|
|
349
349
|
page.on('pageerror', err => this.emit('error', `Browser error: ${err.message}`));
|
|
350
|
-
browser.on('disconnected', () => this.emit('
|
|
350
|
+
browser.on('disconnected', () => this.emit('debug', 'Browser disconnected'));
|
|
351
351
|
|
|
352
352
|
this.emit('warn', `Navigating to MELCloud...`);
|
|
353
353
|
try {
|
|
@@ -366,7 +366,8 @@ class MelCloud extends EventEmitter {
|
|
|
366
366
|
try {
|
|
367
367
|
loginBtn = await page.waitForFunction(() => {
|
|
368
368
|
const btns = Array.from(document.querySelectorAll('button.btn--blue'));
|
|
369
|
-
|
|
369
|
+
btns.find(b => ['Zaloguj', 'Sign In', 'Login'].includes(b.textContent.trim()));
|
|
370
|
+
return btns;
|
|
370
371
|
}, { timeout: GLOBAL_TIMEOUT / 6 });
|
|
371
372
|
} catch {
|
|
372
373
|
accountInfo.State = false;
|
|
@@ -374,14 +375,10 @@ class MelCloud extends EventEmitter {
|
|
|
374
375
|
return accountInfo;
|
|
375
376
|
}
|
|
376
377
|
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
loginBtn.click(),
|
|
380
|
-
page.waitForNavigation({ waitUntil: ['domcontentloaded', 'networkidle2'], timeout: GLOBAL_TIMEOUT / 4 })
|
|
381
|
-
]),
|
|
382
|
-
new Promise(r => setTimeout(r, GLOBAL_TIMEOUT / 3))
|
|
383
|
-
]);
|
|
378
|
+
this.emit('warn', `Found login button ${loginBtn}`);
|
|
379
|
+
await Promise.race([Promise.all([loginBtn.click(), page.waitForNavigation({ waitUntil: ['domcontentloaded', 'networkidle2'], timeout: GLOBAL_TIMEOUT / 4 })]), new Promise(r => setTimeout(r, GLOBAL_TIMEOUT / 3))]);
|
|
384
380
|
|
|
381
|
+
this.emit('warn', `Looking for credentials form...`);
|
|
385
382
|
const usernameInput = await page.$('input[name="username"]');
|
|
386
383
|
const passwordInput = await page.$('input[name="password"]');
|
|
387
384
|
if (!usernameInput || !passwordInput) {
|
|
@@ -390,9 +387,11 @@ class MelCloud extends EventEmitter {
|
|
|
390
387
|
return accountInfo;
|
|
391
388
|
}
|
|
392
389
|
|
|
390
|
+
this.emit('warn', `Type credentials data..`);
|
|
393
391
|
await page.type('input[name="username"]', this.user, { delay: 50 });
|
|
394
392
|
await page.type('input[name="password"]', this.passwd, { delay: 50 });
|
|
395
393
|
|
|
394
|
+
this.emit('warn', `Looking for submit button...`);
|
|
396
395
|
const submitButton = await page.$('input[type="submit"], button[type="submit"]');
|
|
397
396
|
if (!submitButton) {
|
|
398
397
|
accountInfo.State = false;
|
|
@@ -400,14 +399,10 @@ class MelCloud extends EventEmitter {
|
|
|
400
399
|
return accountInfo;
|
|
401
400
|
}
|
|
402
401
|
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
submitButton.click(),
|
|
406
|
-
page.waitForNavigation({ waitUntil: ['domcontentloaded', 'networkidle2'], timeout: GLOBAL_TIMEOUT / 4 })
|
|
407
|
-
]),
|
|
408
|
-
new Promise(r => setTimeout(r, GLOBAL_TIMEOUT / 3))
|
|
409
|
-
]);
|
|
402
|
+
this.emit('warn', `Found submit button ${submitButton}`);
|
|
403
|
+
await Promise.race([Promise.all([submitButton.click(), page.waitForNavigation({ waitUntil: ['domcontentloaded', 'networkidle2'], timeout: GLOBAL_TIMEOUT / 4 })]), new Promise(r => setTimeout(r, GLOBAL_TIMEOUT / 3))]);
|
|
410
404
|
|
|
405
|
+
this.emit('warn', `Looking for cookies...`);
|
|
411
406
|
// Extract cookies
|
|
412
407
|
let c1 = null, c2 = null;
|
|
413
408
|
const start = Date.now();
|
|
@@ -424,6 +419,7 @@ class MelCloud extends EventEmitter {
|
|
|
424
419
|
return accountInfo;
|
|
425
420
|
}
|
|
426
421
|
|
|
422
|
+
this.emit('warn', `Found cookies`);
|
|
427
423
|
const contextKey = [
|
|
428
424
|
'__Secure-monitorandcontrol=chunks-2',
|
|
429
425
|
`__Secure-monitorandcontrolC1=${c1}`,
|
package/src/melcloudata.js
CHANGED
|
@@ -31,7 +31,7 @@ class MelCloudAta extends EventEmitter {
|
|
|
31
31
|
await this.checkState();
|
|
32
32
|
}))
|
|
33
33
|
.on('state', (state) => {
|
|
34
|
-
this.emit('success', `Impulse generator ${state ? 'started' : 'stopped'}
|
|
34
|
+
this.emit(state ? 'success' : 'warn', `Impulse generator ${state ? 'started' : 'stopped'}`);
|
|
35
35
|
});
|
|
36
36
|
}
|
|
37
37
|
|
package/src/melcloudatw.js
CHANGED
|
@@ -31,7 +31,7 @@ class MelCloudAtw extends EventEmitter {
|
|
|
31
31
|
await this.checkState();
|
|
32
32
|
}))
|
|
33
33
|
.on('state', (state) => {
|
|
34
|
-
this.emit('success', `Impulse generator ${state ? 'started' : 'stopped'}
|
|
34
|
+
this.emit(state ? 'success' : 'warn', `Impulse generator ${state ? 'started' : 'stopped'}`);
|
|
35
35
|
});
|
|
36
36
|
}
|
|
37
37
|
|
package/src/melclouderv.js
CHANGED
|
@@ -31,7 +31,7 @@ class MelCloudErv extends EventEmitter {
|
|
|
31
31
|
await this.checkState();
|
|
32
32
|
}))
|
|
33
33
|
.on('state', (state) => {
|
|
34
|
-
this.emit('success', `Impulse generator ${state ? 'started' : 'stopped'}
|
|
34
|
+
this.emit(state ? 'success' : 'warn', `Impulse generator ${state ? 'started' : 'stopped'}`);
|
|
35
35
|
});
|
|
36
36
|
}
|
|
37
37
|
|