homebridge-melcloud-control 4.0.0-beta.16 → 4.0.0-beta.18

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/melcloud.js +8 -24
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.16",
4
+ "version": "4.0.0-beta.18",
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
@@ -214,23 +214,16 @@ class MelCloud extends EventEmitter {
214
214
  }
215
215
 
216
216
  async connectHomeCookies() {
217
- const loginUrl = new URL('https://live-melcloudhome.auth.eu-west-1.amazoncognito.com/login');
218
- loginUrl.searchParams.set('client_id', '3g4d5l5kivuqi7oia68gib7uso');
219
- loginUrl.searchParams.set('redirect_uri', 'https://auth.melcloudhome.com/signin-oidc-meu');
220
- loginUrl.searchParams.set('response_type', 'code');
221
- loginUrl.searchParams.set('scope', 'openid profile');
222
- loginUrl.searchParams.set('response_mode', 'form_post');
223
-
224
- const browser = await puppeteer.launch({
225
- headless: true,
226
- args: ['--no-sandbox', '--disable-setuid-sandbox']
227
- });
228
-
229
- const page = await browser.newPage();
230
-
231
217
  try {
218
+ const loginUrl = 'https://melcloudhome.com';
219
+ const browser = await puppeteer.launch({ headless: true, args: ['--no-sandbox', '--disable-setuid-sandbox'] });
220
+ const page = await browser.newPage();
221
+
232
222
  this.emit('warn', 'Opening login page...');
233
- await page.goto(loginUrl.toString(), { waitUntil: 'networkidle2' });
223
+ await page.goto(loginUrl, { waitUntil: 'networkidle2' });
224
+
225
+ // Poczekaj, aż strona przekieruje do Cognito login
226
+ await page.waitForSelector('input[name="username"]', { timeout: 15000 });
234
227
 
235
228
  this.emit('warn', 'Typing credentials...');
236
229
  await page.type('input[name="username"]', this.user, { delay: 50 });
@@ -243,15 +236,6 @@ class MelCloud extends EventEmitter {
243
236
  page.waitForNavigation({ waitUntil: 'networkidle2', timeout: 20000 })
244
237
  ]);
245
238
 
246
- // Obsługa ewentualnego "Stay signed in?"
247
- const staySignedInBtn = await page.$('input[type="submit"]');
248
- if (staySignedInBtn) {
249
- await Promise.all([
250
- staySignedInBtn.click(),
251
- page.waitForNavigation({ waitUntil: 'networkidle2', timeout: 20000 })
252
- ]);
253
- }
254
-
255
239
  let c1 = null, c2 = null;
256
240
  const start = Date.now();
257
241