homebridge-melcloud-control 4.0.0-beta.271 → 4.0.0-beta.273
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 +2 -20
- package/src/melcloudhometoken.js +2 -6
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.273",
|
|
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
|
@@ -296,29 +296,11 @@ class MelCloud extends EventEmitter {
|
|
|
296
296
|
const page = await browser.newPage();
|
|
297
297
|
await page.goto(url, { waitUntil: 'networkidle2' });
|
|
298
298
|
|
|
299
|
-
const buttons = await page.$$('button.btn--blue');
|
|
300
|
-
let loginBtn = null;
|
|
301
|
-
|
|
302
|
-
for (const btn of buttons) {
|
|
303
|
-
const text = await page.evaluate(el => el.textContent, btn);
|
|
304
|
-
if (text.trim() === 'Zaloguj' || text.trim() === 'Log In') {
|
|
305
|
-
loginBtn = btn;
|
|
306
|
-
break;
|
|
307
|
-
}
|
|
308
|
-
}
|
|
309
|
-
|
|
310
|
-
if (!loginBtn && this.logWarn) this.emit('warn', `Login button not found`);
|
|
311
|
-
|
|
312
|
-
await Promise.all([
|
|
313
|
-
loginBtn.click(),
|
|
314
|
-
page.waitForNavigation({ waitUntil: 'networkidle2', timeout: 10000 })
|
|
315
|
-
]);
|
|
316
|
-
|
|
317
299
|
await page.waitForSelector('input[name="username"]', { timeout: 5000 });
|
|
318
300
|
await page.type('input[name="username"]', this.user, { delay: 50 });
|
|
319
301
|
await page.type('input[name="password"]', this.passwd, { delay: 50 });
|
|
320
302
|
|
|
321
|
-
const button1 = await page.$('input[type="
|
|
303
|
+
const button1 = await page.$('input[type="Submit"]');
|
|
322
304
|
await Promise.all([
|
|
323
305
|
button1.click(),
|
|
324
306
|
page.waitForNavigation({ waitUntil: 'networkidle2', timeout: 10000 })
|
|
@@ -374,7 +356,7 @@ class MelCloud extends EventEmitter {
|
|
|
374
356
|
|
|
375
357
|
for (const btn of buttons) {
|
|
376
358
|
const text = await page.evaluate(el => el.textContent, btn);
|
|
377
|
-
if (text.trim() === 'Zaloguj' || text.trim() === '
|
|
359
|
+
if (text.trim() === 'Zaloguj' || text.trim() === 'Sign In') {
|
|
378
360
|
loginBtn = btn;
|
|
379
361
|
break;
|
|
380
362
|
}
|
package/src/melcloudhometoken.js
CHANGED
|
@@ -32,11 +32,7 @@ class MelCloudHomeToken {
|
|
|
32
32
|
async getLoginPage(authUrl) {
|
|
33
33
|
console.log('Getting login page...');
|
|
34
34
|
const res = await this.client.get(authUrl, { maxRedirects: 10 });
|
|
35
|
-
|
|
36
|
-
const csrf = $('input[name="_csrf"]').attr('value');
|
|
37
|
-
if (!csrf) throw new Error('Could not extract CSRF token from login page');
|
|
38
|
-
console.log('CSRF token found:', csrf);
|
|
39
|
-
return { csrf, url: res.request.res.responseUrl };
|
|
35
|
+
return { url: res.request.res.responseUrl };
|
|
40
36
|
}
|
|
41
37
|
|
|
42
38
|
async getUrl() {
|
|
@@ -56,7 +52,7 @@ class MelCloudHomeToken {
|
|
|
56
52
|
|
|
57
53
|
const loginPage = await this.getLoginPage(authUrl.toString());
|
|
58
54
|
|
|
59
|
-
return loginPage;
|
|
55
|
+
return loginPage.url;
|
|
60
56
|
} catch (error) {
|
|
61
57
|
console.error('Failed to obtain OAuth tokens:', error);
|
|
62
58
|
throw error;
|