homebridge-melcloud-control 4.0.0-beta.206 → 4.0.0-beta.207

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.
@@ -793,7 +793,7 @@
793
793
  ]
794
794
  },
795
795
  "condition": {
796
- "functionBody": "const accounts = model.accounts[arrayIndices]?.ataDevices || []; return accounts.length > 0 && accounts.every(device => device.id != null);"
796
+ "functionBody": "return model.accounts[arrayIndices[0]].ataDevices.length > 0 && model.accounts[arrayIndices[0]].every(device => device.id != null);"
797
797
  }
798
798
  },
799
799
  "atwDevices": {
@@ -1983,7 +1983,7 @@
1983
1983
  },
1984
1984
  "accounts[].atwDevices[].displayType",
1985
1985
  {
1986
- "key": "accounts[].atwDevices",
1986
+ "key": "accounts[].atwDevices[]",
1987
1987
  "type": "section",
1988
1988
  "title": "Settings",
1989
1989
  "expandable": true,
@@ -1998,7 +1998,7 @@
1998
1998
  }
1999
1999
  },
2000
2000
  {
2001
- "key": "accounts[].atwDevices",
2001
+ "key": "accounts[].atwDevices[]",
2002
2002
  "title": "Temperature Sensors",
2003
2003
  "type": "section",
2004
2004
  "expandable": true,
@@ -2102,7 +2102,7 @@
2102
2102
  },
2103
2103
  "accounts[].ervDevices[].displayType",
2104
2104
  {
2105
- "key": "accounts[].ervDevices",
2105
+ "key": "accounts[].ervDevices[]",
2106
2106
  "title": "Settings",
2107
2107
  "type": "section",
2108
2108
  "expandable": true,
@@ -2116,7 +2116,7 @@
2116
2116
  }
2117
2117
  },
2118
2118
  {
2119
- "key": "accounts[].ervDevices",
2119
+ "key": "accounts[].ervDevices[]",
2120
2120
  "title": "Temperature Sensors",
2121
2121
  "type": "section",
2122
2122
  "expandable": true,
package/index.js CHANGED
@@ -145,15 +145,19 @@ class MelCloudPlatform {
145
145
 
146
146
  if (accountType === 'melcloudhome') {
147
147
  try {
148
- [defaultTempsFile].forEach(file => {
149
- const temps = JSON.stringify({
150
- defaultCoolingSetTemperature: 24,
151
- defaultHeatingSetTemperature: 20
152
- });
153
- if (!existsSync(file)) writeFileSync(file, temps);
154
- });
148
+ const temps = {
149
+ defaultCoolingSetTemperature: 24,
150
+ defaultHeatingSetTemperature: 20
151
+ };
152
+
153
+ if (!existsSync(defaultTempsFile)) {
154
+ writeFileSync(defaultTempsFile, JSON.stringify(temps, null, 2));
155
+ if (logLevel.debug) log.debug(`Default temperature file created: ${defaultTempsFile}`);
156
+ }
155
157
  } catch (error) {
156
- if (logLevel.error) log.error(`Device: ${host} ${deviceName}, File init error: ${error}`);
158
+ if (logLevel.error) {
159
+ log.error(`Device: ${host} ${deviceName}, File init error: ${error.message}`);
160
+ }
157
161
  continue;
158
162
  }
159
163
  }
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.206",
4
+ "version": "4.0.0-beta.207",
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/functions.js CHANGED
@@ -1,3 +1,4 @@
1
+ import fs from 'fs';
1
2
  import { promises as fsPromises } from 'fs';
2
3
 
3
4
  class Functions {
@@ -26,5 +27,15 @@ class Functions {
26
27
  throw new Error(`Read data error: ${error}`);
27
28
  }
28
29
  }
30
+
31
+ async isRunningInDocker() {
32
+ try {
33
+ if (fs.existsSync('/.dockerenv')) return true;
34
+ const cgroup = fs.readFileSync('/proc/1/cgroup', 'utf8');
35
+ return cgroup.includes('docker') || cgroup.includes('kubepods');
36
+ } catch {
37
+ return false;
38
+ }
39
+ }
29
40
  }
30
41
  export default Functions
package/src/melcloud.js CHANGED
@@ -1,4 +1,4 @@
1
- import fs from 'fs';
1
+
2
2
  import { execSync } from 'child_process';
3
3
  import puppeteer from 'puppeteer';
4
4
  import axios from 'axios';
@@ -56,6 +56,7 @@ class MelCloud extends EventEmitter {
56
56
  }
57
57
  }
58
58
 
59
+ // MELCloud
59
60
  async checkMelcloudDevicesList(contextKey) {
60
61
  try {
61
62
  const axiosInstanceGet = axios.create({
@@ -269,16 +270,7 @@ class MelCloud extends EventEmitter {
269
270
  }
270
271
  }
271
272
 
272
- async isRunningInDocker() {
273
- try {
274
- if (fs.existsSync('/.dockerenv')) return true;
275
- const cgroup = fs.readFileSync('/proc/1/cgroup', 'utf8');
276
- return cgroup.includes('docker') || cgroup.includes('kubepods');
277
- } catch {
278
- return false;
279
- }
280
- }
281
-
273
+ // MELCloud Home
282
274
  async connectToMelCloudHome(refresh = false) {
283
275
  if (this.logDebug) this.emit('debug', `Connecting to MELCloud Home`);
284
276
 
@@ -351,7 +343,7 @@ class MelCloud extends EventEmitter {
351
343
  return accountInfo;
352
344
  } catch (error) {
353
345
  if (error.message.includes('libnspr4.so') || error.message.includes('Failed to launch the browser process')) {
354
- const inDocker = await this.isRunningInDocker();
346
+ const inDocker = await this.functions.isRunningInDocker();
355
347
  if (this.logWarn) this.emit('warn', `Missing system libraries detected.`);
356
348
 
357
349
  if (inDocker) {
@@ -390,7 +382,6 @@ class MelCloud extends EventEmitter {
390
382
  }
391
383
  }
392
384
 
393
-
394
385
  async checkDevicesList(contextKey) {
395
386
  let devices = [];
396
387
  switch (this.accountType) {