homebridge-melcloud-control 4.0.0-beta.534 → 4.0.0-beta.536

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/index.js CHANGED
@@ -199,7 +199,7 @@ class MelCloudPlatform {
199
199
  if (logLevel.success) log.success(`${accountName}, ${deviceTypeText}, ${deviceName}, Published as external accessory.`);
200
200
 
201
201
  //start impulse generators\
202
- const timmers = accountType === 'melcloudhome' ? [{ name: 'connect', sampling: 3300000 }, { name: 'checkDevicesList', sampling: deviceRefreshInterval }] : [{ name: 'checkDevicesList', sampling: refreshInterval }];
202
+ const timmers = accountType === 'melcloudhome' ? [{ name: 'connect', sampling: 3000000 }, { name: 'checkDevicesList', sampling: deviceRefreshInterval }] : [{ name: 'checkDevicesList', sampling: refreshInterval }];
203
203
  await melCloud.impulseGenerator.state(true, timmers, false);
204
204
  await configuredDevice.startStopImpulseGenerator(true, [{ name: 'checkState', sampling: deviceRefreshInterval }]);
205
205
 
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.534",
4
+ "version": "4.0.0-beta.536",
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
@@ -344,7 +344,10 @@ class MelCloud extends EventEmitter {
344
344
  ]
345
345
  });
346
346
 
347
- const [page] = await browser.pages();
347
+ const context = await browser.newContext();
348
+ const page = await context.newPage();
349
+ await page.goto('about:blank');
350
+ await context.clearCookies();
348
351
  page.setDefaultTimeout(GLOBAL_TIMEOUT);
349
352
  page.setDefaultNavigationTimeout(GLOBAL_TIMEOUT);
350
353
 
@@ -365,20 +368,18 @@ class MelCloud extends EventEmitter {
365
368
  await new Promise(r => setTimeout(r, 3000));
366
369
 
367
370
  this.emit('warn', `Looking for login button...`);
368
- let loginBtn;
369
- try {
370
- loginBtn = await page.waitForFunction(() => {
371
- const btns = Array.from(document.querySelectorAll('button.btn--blue'));
372
- return btns.find(b => ['Zaloguj', 'Sign In', 'Login'].includes(b.textContent.trim()));
373
- }, { timeout: GLOBAL_TIMEOUT / 6 });
374
- } catch {
371
+ const loginBtn = await page.waitForSelector('button.btn--blue', { timeout: GLOBAL_TIMEOUT / 6 });
372
+ const loginText = await loginBtn.evaluate(el => el.textContent.trim());
373
+ if (!['Zaloguj', 'Sign In', 'Login'].includes(loginText)) {
375
374
  accountInfo.State = false;
376
- accountInfo.Info = 'Login button not found';
375
+ accountInfo.Info = 'Login button not found or has unexpected label';
377
376
  return accountInfo;
378
377
  }
379
378
 
380
379
  this.emit('warn', `Found login button ${loginBtn}`);
381
- await Promise.race([Promise.all([loginBtn.click(), page.waitForNavigation({ waitUntil: ['domcontentloaded', 'networkidle2'], timeout: GLOBAL_TIMEOUT / 4 })]), new Promise(r => setTimeout(r, GLOBAL_TIMEOUT / 3))]);
380
+ await loginBtn.click();
381
+ await page.waitForNavigation({ waitUntil: ['domcontentloaded', 'networkidle2'], timeout: GLOBAL_TIMEOUT / 4 });
382
+
382
383
 
383
384
  this.emit('warn', `Looking for credentials form...`);
384
385
  const usernameInput = await page.$('input[name="username"]');
@@ -403,6 +404,7 @@ class MelCloud extends EventEmitter {
403
404
 
404
405
  this.emit('warn', `Found submit button ${submitButton}`);
405
406
  await Promise.race([Promise.all([submitButton.click(), page.waitForNavigation({ waitUntil: ['domcontentloaded', 'networkidle2'], timeout: GLOBAL_TIMEOUT / 4 })]), new Promise(r => setTimeout(r, GLOBAL_TIMEOUT / 3))]);
407
+ await new Promise(r => setTimeout(r, 2000));
406
408
 
407
409
  this.emit('warn', `Looking for cookies...`);
408
410
  // Extract cookies