homebridge-melcloud-control 4.0.0-beta.533 → 4.0.0-beta.535

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: 900000 }, { name: 'checkDevicesList', sampling: deviceRefreshInterval }] : [{ name: 'checkDevicesList', sampling: refreshInterval }];
202
+ const timmers = accountType === 'melcloudhome' ? [{ name: 'connect', sampling: 3300000 }, { 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.533",
4
+ "version": "4.0.0-beta.535",
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,8 @@ class MelCloud extends EventEmitter {
344
344
  ]
345
345
  });
346
346
 
347
- const [page] = await browser.pages();
347
+ const context = await browser.createIncognitoBrowserContext();
348
+ const page = await context.newPage();
348
349
  page.setDefaultTimeout(GLOBAL_TIMEOUT);
349
350
  page.setDefaultNavigationTimeout(GLOBAL_TIMEOUT);
350
351
 
@@ -365,20 +366,18 @@ class MelCloud extends EventEmitter {
365
366
  await new Promise(r => setTimeout(r, 3000));
366
367
 
367
368
  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 {
369
+ const loginBtn = await page.waitForSelector('button.btn--blue', { timeout: GLOBAL_TIMEOUT / 6 });
370
+ const loginText = await loginBtn.evaluate(el => el.textContent.trim());
371
+ if (!['Zaloguj', 'Sign In', 'Login'].includes(loginText)) {
375
372
  accountInfo.State = false;
376
- accountInfo.Info = 'Login button not found';
373
+ accountInfo.Info = 'Login button not found or has unexpected label';
377
374
  return accountInfo;
378
375
  }
379
376
 
380
377
  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))]);
378
+ await loginBtn.click();
379
+ await page.waitForNavigation({ waitUntil: ['domcontentloaded', 'networkidle2'], timeout: GLOBAL_TIMEOUT / 4 });
380
+
382
381
 
383
382
  this.emit('warn', `Looking for credentials form...`);
384
383
  const usernameInput = await page.$('input[name="username"]');
@@ -439,8 +438,15 @@ class MelCloud extends EventEmitter {
439
438
  throw new Error(`Connect error: ${error.message}`);
440
439
  } finally {
441
440
  if (browser) {
442
- try { await browser.close(); }
443
- catch (closeErr) { this.emit('error', `Failed to close Puppeteer: ${closeErr.message}`); }
441
+ try {
442
+ const contexts = browser.browserContexts();
443
+ for (const ctx of contexts) {
444
+ await ctx.close().catch(() => { });
445
+ }
446
+ await browser.close();
447
+ } catch (closeErr) {
448
+ this.emit('error', `Failed to close Puppeteer: ${closeErr.message}`);
449
+ }
444
450
  }
445
451
  }
446
452
  }