homebridge-melcloud-control 4.0.0-beta.394 → 4.0.0-beta.396
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/melcloudhometoken.js +15 -7
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.396",
|
|
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/melcloudhometoken.js
CHANGED
|
@@ -65,19 +65,26 @@ class MelCloudHomeToken extends EventEmitter {
|
|
|
65
65
|
// Kliknij przycisk login
|
|
66
66
|
await Promise.all([
|
|
67
67
|
page.click('input[type="submit"]'),
|
|
68
|
-
page.waitForNavigation({ waitUntil: 'networkidle0' })
|
|
68
|
+
page.waitForNavigation({ waitUntil: 'networkidle0' }).catch(() => { }) // czasami redirect jest JS, więc catch
|
|
69
69
|
]);
|
|
70
70
|
|
|
71
|
-
|
|
71
|
+
// Spróbuj pobrać kod z formularza form_post
|
|
72
|
+
const code = await page.evaluate(() => {
|
|
73
|
+
const form = document.querySelector('form[action^="melcloudhome://"]');
|
|
74
|
+
if (form) {
|
|
75
|
+
const input = form.querySelector('input[name="code"]');
|
|
76
|
+
return input ? input.value : null;
|
|
77
|
+
}
|
|
78
|
+
return null;
|
|
79
|
+
});
|
|
80
|
+
|
|
72
81
|
await browser.close();
|
|
73
82
|
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
const code = match[1];
|
|
77
|
-
this.emit('warn', `Authorization code obtained: ${code}`);
|
|
83
|
+
if (code) {
|
|
84
|
+
this.emit('warn', `Authorization code obtained from form_post: ${code}`);
|
|
78
85
|
return code;
|
|
79
86
|
} else {
|
|
80
|
-
this.emit('warn', `Authorization code not found in Puppeteer
|
|
87
|
+
this.emit('warn', `Authorization code not found in Puppeteer`);
|
|
81
88
|
return null;
|
|
82
89
|
}
|
|
83
90
|
|
|
@@ -87,6 +94,7 @@ class MelCloudHomeToken extends EventEmitter {
|
|
|
87
94
|
}
|
|
88
95
|
}
|
|
89
96
|
|
|
97
|
+
|
|
90
98
|
async getTokens(code, codeVerifier) {
|
|
91
99
|
const tokenData = new URLSearchParams({
|
|
92
100
|
grant_type: 'authorization_code',
|