homebridge-melcloud-control 4.0.0-beta.563 → 4.0.0-beta.565

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "displayName": "MELCloud Control",
3
3
  "name": "homebridge-melcloud-control",
4
- "version": "4.0.0-beta.563",
4
+ "version": "4.0.0-beta.565",
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/deviceata.js CHANGED
@@ -949,7 +949,7 @@ class DeviceAta extends EventEmitter {
949
949
  this.serialNumber = serialNumber.toString();
950
950
  this.firmwareRevision = firmwareAppVersion.toString();
951
951
 
952
- this.informationService?.setCharacteristic(Characteristic.FirmwareRevision, this.firmwareAppVersion);
952
+ this.informationService?.setCharacteristic(Characteristic.FirmwareRevision, this.firmwareRevision);
953
953
  })
954
954
  .on('deviceState', async (deviceData) => {
955
955
  this.deviceData = deviceData;
package/src/deviceatw.js CHANGED
@@ -1324,7 +1324,7 @@ class DeviceAtw extends EventEmitter {
1324
1324
  this.serialNumber = serialNumber.toString();
1325
1325
  this.firmwareRevision = firmwareAppVersion.toString();
1326
1326
 
1327
- this.informationService?.setCharacteristic(Characteristic.FirmwareRevision, this.firmwareAppVersion);
1327
+ this.informationService?.setCharacteristic(Characteristic.FirmwareRevision, this.firmwareRevision);
1328
1328
  })
1329
1329
  .on('deviceState', async (deviceData) => {
1330
1330
  this.deviceData = deviceData;
package/src/deviceerv.js CHANGED
@@ -869,7 +869,7 @@ class DeviceErv extends EventEmitter {
869
869
  this.serialNumber = serialNumber.toString();
870
870
  this.firmwareRevision = firmwareAppVersion.toString();
871
871
 
872
- this.informationService?.setCharacteristic(Characteristic.FirmwareRevision, this.firmwareAppVersion);
872
+ this.informationService?.setCharacteristic(Characteristic.FirmwareRevision, this.firmwareRevision);
873
873
  })
874
874
  .on('deviceState', async (deviceData) => {
875
875
  this.deviceData = deviceData;
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
  }
@@ -252,7 +252,7 @@ class MelCloudAta extends EventEmitter {
252
252
  VaneVerticalDirection: AirConditioner.VaneVerticalDirectionMapEnumToString[deviceData.Device.VaneVerticalDirection]
253
253
  }
254
254
  };
255
- if (!this.logDebug) this.emit('warn', `Send Data: ${JSON.stringify(settings.data, null, 2)}`);
255
+ if (this.logDebug) this.emit('debug', `Send Data: ${JSON.stringify(settings.data, null, 2)}`);
256
256
 
257
257
  const path = ApiUrlsHome.SetAta.replace('deviceid', deviceData.DeviceID);
258
258
  await axiosInstancePut(path, settings);