homebridge-melcloud-control 4.0.0-beta.287 → 4.0.0-beta.289
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 +5 -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.289",
|
|
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
|
@@ -312,12 +312,11 @@ class MelCloud extends EventEmitter {
|
|
|
312
312
|
|
|
313
313
|
// 2️⃣ Jeśli nie w URL, sprawdź body HTML (form_post)
|
|
314
314
|
const html = await page.content();
|
|
315
|
-
console.log(html);
|
|
316
315
|
|
|
317
316
|
// Check for form_post response (HTML with hidden form)
|
|
318
|
-
const formCodeMatch =
|
|
319
|
-
const formStateMatch =
|
|
320
|
-
const formActionMatch =
|
|
317
|
+
const formCodeMatch = html.match(/name="code"\s+value="([^"]+)"/);
|
|
318
|
+
const formStateMatch = html.match(/name="state"\s+value="([^"]+)"/);
|
|
319
|
+
const formActionMatch = html.match(/action="([^"]+)"/);
|
|
321
320
|
|
|
322
321
|
if (formCodeMatch && formStateMatch && formActionMatch) {
|
|
323
322
|
console.log('Found form_post response, submitting to callback endpoint...');
|
|
@@ -328,7 +327,7 @@ class MelCloud extends EventEmitter {
|
|
|
328
327
|
}
|
|
329
328
|
|
|
330
329
|
// Check for melcloudhome:// redirect in JS
|
|
331
|
-
const bodyCodeMatch =
|
|
330
|
+
const bodyCodeMatch = html.match(/melcloudhome:\/\/[^"'\s]*[?&]code=([^&"'\s]+)/);
|
|
332
331
|
if (bodyCodeMatch) {
|
|
333
332
|
console.log('Found authorization code in response body (JS)');
|
|
334
333
|
resolve(bodyCodeMatch[1]);
|
|
@@ -336,7 +335,7 @@ class MelCloud extends EventEmitter {
|
|
|
336
335
|
}
|
|
337
336
|
|
|
338
337
|
// 🆕 NEW: Check for data-url with code parameter (like in 500 error pages)
|
|
339
|
-
const dataUrlMatch =
|
|
338
|
+
const dataUrlMatch = html.match(/data-url="[^"]*code=([^&"']+)/);
|
|
340
339
|
if (dataUrlMatch) {
|
|
341
340
|
console.log('Found authorization code in data-url attribute');
|
|
342
341
|
resolve(dataUrlMatch[1]);
|