homebridge-melcloud-control 4.0.0-beta.562 → 4.0.0-beta.564

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 +2 -2
  2. package/src/melcloud.js +8 -18
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.562",
4
+ "version": "4.0.0-beta.564",
5
5
  "description": "Homebridge plugin to control Mitsubishi Air Conditioner, Heat Pump and Energy Recovery Ventilation.",
6
6
  "license": "MIT",
7
7
  "author": "grzegorz914",
@@ -39,7 +39,7 @@
39
39
  "async-mqtt": "^2.6.3",
40
40
  "axios": "^1.13.1",
41
41
  "express": "^5.1.0",
42
- "puppeteer-core": "^24.27.0",
42
+ "puppeteer-core": "^24.28.0",
43
43
  "util": "^0.12.5"
44
44
  },
45
45
  "keywords": [
package/src/melcloud.js CHANGED
@@ -323,14 +323,14 @@ class MelCloud extends EventEmitter {
323
323
  // Verify executable works
324
324
  try {
325
325
  const { stdout } = await execPromise(`"${chromiumPath}" --version`);
326
- this.emit('warn', `Chromium detected: ${stdout.trim()}`);
326
+ if (this.logDebug) this.emit('debug', `Chromium detected: ${stdout.trim()}`);
327
327
  if (this.logDebug) this.emit('debug', `Chromium detected: ${stdout.trim()}`);
328
328
  } catch (error) {
329
329
  accountInfo.Info = `Chromium found at ${chromiumPath}, but cannot be executed: ${error.message}`;
330
330
  return accountInfo;
331
331
  }
332
332
 
333
- this.emit('warn', `Launching Chromium...`);
333
+ if (this.logDebug) this.emit('debug', `Launching Chromium...`);
334
334
  browser = await puppeteer.launch({
335
335
  headless: true,
336
336
  executablePath: chromiumPath,
@@ -354,14 +354,13 @@ class MelCloud extends EventEmitter {
354
354
  const client = await page.createCDPSession();
355
355
  await client.send('Network.clearBrowserCookies');
356
356
  } catch (error) {
357
- this.emit('warn', `Warning: could not clear cookies: ${error.message}`);
357
+ if (this.logError) this.emit('error', `Clear cookies error: ${error.message}`);
358
358
  }
359
359
 
360
360
  page.on('error', error => this.emit('error', `Page crashed: ${error.message}`));
361
361
  page.on('pageerror', error => this.emit('error', `Browser error: ${error.message}`));
362
362
  browser.on('disconnected', () => this.emit('debug', 'Browser disconnected'));
363
363
 
364
- this.emit('warn', `Navigating to MELCloud...`);
365
364
  try {
366
365
  await page.goto(ApiUrlsHome.BaseURL, { waitUntil: ['domcontentloaded', 'networkidle2'], timeout: GLOBAL_TIMEOUT });
367
366
  } catch (error) {
@@ -371,21 +370,17 @@ class MelCloud extends EventEmitter {
371
370
 
372
371
  // Wait extra to ensure UI is rendered
373
372
  await new Promise(r => setTimeout(r, 3000));
374
-
375
- this.emit('warn', `Looking for login button...`);
376
373
  const loginBtn = await page.waitForSelector('button.btn--blue', { timeout: GLOBAL_TIMEOUT / 4 });
377
374
  const loginText = await page.evaluate(el => el.textContent.trim(), loginBtn);
378
375
 
379
376
  if (!['Zaloguj', 'Sign In', 'Login'].includes(loginText)) {
380
- accountInfo.Info = `Login button ${loginText} not found in search array`;
377
+ accountInfo.Info = `Login button ${loginText} not found`;
381
378
  return accountInfo;
382
379
  }
383
-
384
- this.emit('warn', `Found login button ${loginText}`);
380
+ ;
385
381
  await loginBtn.click();
386
382
  await page.waitForNavigation({ waitUntil: 'networkidle2', timeout: GLOBAL_TIMEOUT / 3 });
387
383
 
388
- this.emit('warn', `Looking for credentials form...`);
389
384
  const usernameInput = await page.$('input[name="username"]');
390
385
  const passwordInput = await page.$('input[name="password"]');
391
386
  if (!usernameInput || !passwordInput) {
@@ -393,22 +388,16 @@ class MelCloud extends EventEmitter {
393
388
  return accountInfo;
394
389
  }
395
390
 
396
- this.emit('warn', `Type credentials data...`);
397
391
  await page.type('input[name="username"]', this.user, { delay: 50 });
398
392
  await page.type('input[name="password"]', this.passwd, { delay: 50 });
399
393
 
400
- this.emit('warn', `Looking for submit button...`);
401
394
  const submitButton = await page.$('input[type="submit"], button[type="submit"]');
402
395
  if (!submitButton) {
403
396
  accountInfo.Info = 'Submit button not found';
404
397
  return accountInfo;
405
398
  }
406
-
407
- this.emit('warn', `Found submit button ${submitButton}`);
408
399
  await Promise.race([Promise.all([submitButton.click(), page.waitForNavigation({ waitUntil: ['domcontentloaded', 'networkidle2'], timeout: GLOBAL_TIMEOUT / 4 })]), new Promise(r => setTimeout(r, GLOBAL_TIMEOUT / 3))]);
409
400
 
410
- this.emit('warn', `Looking for cookies...`);
411
-
412
401
  // Extract cookies
413
402
  let c1 = null, c2 = null;
414
403
  const start = Date.now();
@@ -424,7 +413,6 @@ class MelCloud extends EventEmitter {
424
413
  return accountInfo;
425
414
  }
426
415
 
427
- this.emit('warn', `Found cookies`);
428
416
  const contextKey = [
429
417
  '__Secure-monitorandcontrol=chunks-2',
430
418
  `__Secure-monitorandcontrolC1=${c1}`,
@@ -443,7 +431,9 @@ class MelCloud extends EventEmitter {
443
431
  } finally {
444
432
  if (browser) {
445
433
  try { await browser.close(); }
446
- catch (closeErr) { this.emit('error', `Failed to close Puppeteer: ${closeErr.message}`); }
434
+ catch (closeErr) {
435
+ if (this.logError) this.emit('error', `Failed to close Puppeteer: ${closeErr.message}`);
436
+ }
447
437
  }
448
438
  }
449
439
  }