homebridge-melcloud-control 4.0.0-beta.272 → 4.0.0-beta.274
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 +8 -26
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.274",
|
|
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,38 +296,20 @@ 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="
|
|
322
|
-
await Promise.all([
|
|
323
|
-
button1.click(),
|
|
324
|
-
page.waitForNavigation({ waitUntil: 'networkidle2', timeout: 10000 })
|
|
325
|
-
]);
|
|
303
|
+
const button1 = await page.$('input[type="Submit"]');
|
|
304
|
+
await Promise.all([button1.click(), page.waitForNavigation({ waitUntil: 'networkidle2', timeout: 10000 })]);
|
|
326
305
|
|
|
327
306
|
// 4. Czekamy na przekierowanie z 'code' w URL
|
|
328
|
-
await page.
|
|
307
|
+
await page.waitForNavigation({ waitUntil: 'networkidle2', timeout: 20000 });
|
|
329
308
|
const currentUrl = page.url();
|
|
330
|
-
|
|
309
|
+
if (currentUrl.includes('code=')) {
|
|
310
|
+
const code = new URL(currentUrl).searchParams.get('code');
|
|
311
|
+
console.log('Authorization code:', code);
|
|
312
|
+
}
|
|
331
313
|
|
|
332
314
|
if (!authCode) throw new Error('Authorization code not found in URL');
|
|
333
315
|
|
|
@@ -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
|
}
|