homebridge-melcloud-control 4.0.0-beta.494 → 4.0.0-beta.496

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.
@@ -23,8 +23,8 @@ class PluginUiServer extends HomebridgePluginUiServer {
23
23
  const accountInfo = await melCloud.connect();
24
24
  if (!accountInfo.State) return accountInfo;
25
25
 
26
- const devices = await melCloud.checkDevicesList();
27
- return devices;
26
+ const devicesList = await melCloud.checkDevicesList();
27
+ return devicesList;
28
28
  } catch (error) {
29
29
  throw new Error(`MELCloud error: ${error.message ?? error}.`);
30
30
  };
package/index.js CHANGED
@@ -106,7 +106,7 @@ class MelCloudPlatform {
106
106
  }
107
107
 
108
108
  if (!accountInfo.State) {
109
- if (logLevel.warn) log.warn(`${accountName}, Connect not possible: ${accountInfo.Info}`);
109
+ if (logLevel.warn) log.warn(`${accountName}, ${accountInfo.Info}`);
110
110
  return;
111
111
  }
112
112
 
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.494",
4
+ "version": "4.0.0-beta.496",
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
@@ -175,7 +175,6 @@ class MelCloud extends EventEmitter {
175
175
  if (this.logDebug) this.emit('debug', `MELCloud Info: ${JSON.stringify(debugData, null, 2)}`);
176
176
 
177
177
  if (!contextKey) {
178
- if (this.logWarn) this.emit('warn', `Context key missing`);
179
178
  accountInfo.State = false;
180
179
  accountInfo.Info = 'Context key missing'
181
180
  return accountInfo;
@@ -308,7 +307,6 @@ class MelCloud extends EventEmitter {
308
307
  const accountInfo = { State: false, Info: '', ContextKey: null, UseFahrenheit: false }
309
308
  const chromiumPath = await this.functions.ensureChromiumInstalled();
310
309
  if (!chromiumPath) {
311
- if (this.logWarn) this.emit('warn', 'Chromium not found on Your device, please install it manually and try again');
312
310
  accountInfo.State = false;
313
311
  accountInfo.Info = 'Chromium not found on Your device, please install it manually and try again'
314
312
  return accountInfo;
@@ -363,7 +361,6 @@ class MelCloud extends EventEmitter {
363
361
  return btns.find(b => ['Zaloguj', 'Sign In', 'Login'].includes(b.textContent.trim()));
364
362
  }, { timeout: 5000 }); // max 5s czekania
365
363
  } catch {
366
- if (this.logWarn) this.emit('warn', 'Login button not found after 5s');
367
364
  accountInfo.State = false;
368
365
  accountInfo.Info = 'Login button not found after 5s';
369
366
  return accountInfo;
@@ -371,24 +368,22 @@ class MelCloud extends EventEmitter {
371
368
 
372
369
  await Promise.race([Promise.all([loginBtn.click(), page.waitForNavigation({ waitUntil: ['domcontentloaded', 'networkidle2'], timeout: 10000 })]), new Promise(r => setTimeout(r, 8000))]);
373
370
 
374
- this.emit('warn', `Test 7`);
371
+ this.emit('warn', `Test 6`);
375
372
  const usernameInput = await page.$('input[name="username"]');
376
373
  const passwordInput = await page.$('input[name="password"]');
377
374
  if (!usernameInput || !passwordInput) {
378
- if (this.logWarn) this.emit('warn', 'Username or password input not found');
379
375
  accountInfo.State = false;
380
376
  accountInfo.Info = 'Username or password input not found';
381
377
  return accountInfo;
382
378
  }
383
379
 
384
- this.emit('warn', `Test 8`);
380
+ this.emit('warn', `Test 7`);
385
381
  await page.type('input[name="username"]', this.user, { delay: 50 });
386
382
  await page.type('input[name="password"]', this.passwd, { delay: 50 });
387
383
 
388
- this.emit('warn', `Test 9`);
384
+ this.emit('warn', `Test 8`);
389
385
  const submitButton = await page.$('input[type="submit"], button[type="submit"]');
390
386
  if (!submitButton) {
391
- if (this.logWarn) this.emit('warn', 'Submit button not found on login form');
392
387
  accountInfo.State = false;
393
388
  accountInfo.Info = 'Submit button not found on login form';
394
389
  return accountInfo;
@@ -396,7 +391,7 @@ class MelCloud extends EventEmitter {
396
391
 
397
392
  await Promise.race([Promise.all([submitButton.click(), page.waitForNavigation({ waitUntil: ['domcontentloaded', 'networkidle2'], timeout: 10000 })]), new Promise(r => setTimeout(r, 8000))]);
398
393
 
399
- this.emit('warn', `Test 10`);
394
+ this.emit('warn', `Test 9`);
400
395
  let c1 = null, c2 = null;
401
396
  const start = Date.now();
402
397
  while ((!c1 || !c2) && Date.now() - start < 20000) {
@@ -406,9 +401,8 @@ class MelCloud extends EventEmitter {
406
401
  if (!c1 || !c2) await new Promise(r => setTimeout(r, 500));
407
402
  }
408
403
 
409
- this.emit('warn', `Test 11`);
404
+ this.emit('warn', `Test 10`);
410
405
  if (!c1 || !c2) {
411
- if (this.logWarn) this.emit('warn', 'Cookies C1/C2 missing after login');
412
406
  accountInfo.State = false;
413
407
  accountInfo.Info = 'Cookies C1/C2 missing';
414
408
  return accountInfo;
@@ -425,7 +419,7 @@ class MelCloud extends EventEmitter {
425
419
  accountInfo.Info = 'Connect success';
426
420
  accountInfo.ContextKey = contextKey;
427
421
 
428
- this.emit('warn', `Test 12`);
422
+ this.emit('warn', `Test 11`);
429
423
  await this.functions.saveData(this.accountFile, accountInfo);
430
424
 
431
425
  if (!refresh) this.emit('success', 'Connect to MELCloud Home Success');