homebridge-melcloud-control 4.0.0-beta.26 → 4.0.0-beta.28
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 +21 -30
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.28",
|
|
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
|
@@ -267,45 +267,36 @@ class MelCloud extends EventEmitter {
|
|
|
267
267
|
}
|
|
268
268
|
}
|
|
269
269
|
|
|
270
|
-
if (!loginBtn)
|
|
271
|
-
await browser.close();
|
|
272
|
-
return;
|
|
273
|
-
}
|
|
270
|
+
if (!loginBtn) throw new Error('Login button not found on homepage');
|
|
274
271
|
|
|
275
|
-
|
|
276
|
-
const [resp] = await Promise.all([
|
|
277
|
-
page.waitForNavigation({ waitUntil: 'domcontentloaded', timeout: 20000 }),
|
|
272
|
+
await Promise.all([
|
|
278
273
|
loginBtn.click(),
|
|
274
|
+
page.waitForNavigation({ waitUntil: 'networkidle2', timeout: 20000 })
|
|
279
275
|
]);
|
|
280
276
|
|
|
281
|
-
//
|
|
282
|
-
|
|
283
|
-
// Zamknij przeglądarkę
|
|
284
|
-
await browser.close();
|
|
277
|
+
// Poczekaj, aż strona przekieruje do Cognito login
|
|
278
|
+
await page.waitForSelector('input[name="username"]', { timeout: 15000 });
|
|
285
279
|
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
form.append('input[password]', this.passwd);
|
|
280
|
+
this.emit('warn', 'Typing credentials...');
|
|
281
|
+
await page.type('input[name="username"]', this.user, { delay: 50 });
|
|
282
|
+
await page.type('input[name="password"]', this.passwd, { delay: 50 });
|
|
290
283
|
|
|
291
|
-
//
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
284
|
+
// Kliknij przycisk logowania
|
|
285
|
+
const button1 = await page.$('input[type="submit"]');
|
|
286
|
+
await Promise.all([
|
|
287
|
+
button1.click(),
|
|
288
|
+
page.waitForNavigation({ waitUntil: 'networkidle2', timeout: 20000 })
|
|
289
|
+
]);
|
|
295
290
|
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
return null;
|
|
300
|
-
}
|
|
291
|
+
// Pobierz treść strony po zalogowaniu
|
|
292
|
+
const responseHtml = await page.content(); // jeśli chcesz HTML
|
|
293
|
+
this.emit('warn', `Login failed: ${responseHtml}`);
|
|
301
294
|
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
}
|
|
295
|
+
//await this.functions.saveData(this.cookiesFile, data);
|
|
296
|
+
|
|
297
|
+
this.emit('warn', 'Login successful.');
|
|
298
|
+
return data;
|
|
307
299
|
|
|
308
|
-
return cookie;
|
|
309
300
|
} catch (err) {
|
|
310
301
|
this.emit('error', `Login failed: ${err.message}`);
|
|
311
302
|
return null;
|