homebridge-melcloud-control 4.4.1-beta.12 → 4.4.1-beta.14

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.4.1-beta.12",
4
+ "version": "4.4.1-beta.14",
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
@@ -70,13 +70,14 @@ class Functions extends EventEmitter {
70
70
  const isARM = arch === 'arm';
71
71
  const isMac = osName === 'Darwin';
72
72
  const isLinux = osName === 'Linux';
73
- const isQnap =
74
- fs.existsSync('/etc/config/uLinux.conf') ||
75
- fs.existsSync('/etc/config/qpkg.conf');
73
+ const isQnap = fs.existsSync('/etc/config/uLinux.conf') || fs.existsSync('/etc/config/qpkg.conf');
76
74
 
77
75
  // Detect Docker
78
76
  let isDocker = false;
79
- try { await access('/.dockerenv'); isDocker = true; } catch { }
77
+ try {
78
+ await access('/.dockerenv');
79
+ isDocker = true;
80
+ } catch { }
80
81
  try {
81
82
  const { stdout } = await execPromise('cat /proc/1/cgroup || true');
82
83
  if (stdout.includes('docker') || stdout.includes('containerd')) isDocker = true;
@@ -91,18 +92,23 @@ class Functions extends EventEmitter {
91
92
  '/Applications/Chromium.app/Contents/MacOS/Chromium'
92
93
  ];
93
94
  for (const path of macCandidates) {
94
- try { await access(path, fs.constants.X_OK); result.path = path; return result; } catch { }
95
+ try {
96
+ await access(path, fs.constants.X_OK);
97
+ result.path = path;
98
+ return result;
99
+ } catch { }
95
100
  }
96
-
97
- // Fallback do Puppeteer
98
- try { result.path = puppeteer.executablePath(); return result; } catch { }
99
101
  }
100
102
 
101
103
  /* ===================== QNAP ===================== */
102
104
  if (isQnap) {
103
105
  const qnapCandidates = ['/opt/bin/chromium', '/opt/bin/chromium-browser'];
104
106
  for (const path of qnapCandidates) {
105
- try { await access(path, fs.constants.X_OK); result.path = path; return result; } catch { }
107
+ try {
108
+ await access(path, fs.constants.X_OK);
109
+ result.path = path;
110
+ return result;
111
+ } catch { }
106
112
  }
107
113
 
108
114
  try {
@@ -113,17 +119,28 @@ class Functions extends EventEmitter {
113
119
  } catch { }
114
120
 
115
121
  for (const path of qnapCandidates) {
116
- try { await access(path, fs.constants.X_OK); result.path = path; return result; } catch { }
122
+ try {
123
+ await access(path, fs.constants.X_OK);
124
+ result.path = path;
125
+ return result;
126
+ } catch { }
117
127
  }
118
128
  }
119
129
 
120
130
  /* ===================== Linux ARM ===================== */
121
131
  if (isLinux && isARM) {
122
132
  const armCandidates = ['/usr/bin/chromium-browser', '/usr/bin/chromium', '/snap/bin/chromium'];
133
+
134
+ // 1. Sprawdź istniejące
123
135
  for (const path of armCandidates) {
124
- try { await access(path, fs.constants.X_OK); result.path = path; return result; } catch { }
136
+ try {
137
+ await access(path, fs.constants.X_OK);
138
+ result.path = path;
139
+ return result;
140
+ } catch { }
125
141
  }
126
142
 
143
+ // 2. Zainstaluj jeśli nie Docker
127
144
  if (!isDocker) {
128
145
  try {
129
146
  await execPromise('sudo apt-get update -y');
@@ -132,8 +149,13 @@ class Functions extends EventEmitter {
132
149
  } catch { }
133
150
  }
134
151
 
152
+ // 3. Retry po instalacji
135
153
  for (const path of armCandidates) {
136
- try { await access(path, fs.constants.X_OK); result.path = path; return result; } catch { }
154
+ try {
155
+ await access(path, fs.constants.X_OK);
156
+ result.path = path;
157
+ return result;
158
+ } catch { }
137
159
  }
138
160
  }
139
161
 
@@ -142,19 +164,28 @@ class Functions extends EventEmitter {
142
164
  const linuxCandidates = ['/usr/bin/chromium', '/usr/bin/chromium-browser', '/usr/bin/google-chrome', '/snap/bin/chromium', '/usr/local/bin/chromium'];
143
165
  try {
144
166
  const { stdout } = await execPromise('which chromium || which chromium-browser || which google-chrome || true');
145
- if (stdout.trim()) { result.path = stdout.trim(); return result; }
167
+ if (stdout.trim()) {
168
+ result.path = stdout.trim();
169
+ return result;
170
+ }
146
171
  } catch { }
147
172
 
148
173
  for (const path of linuxCandidates) {
149
- try { await access(path, fs.constants.X_OK); result.path = path; return result; } catch { }
174
+ try {
175
+ await access(path, fs.constants.X_OK);
176
+ result.path = path;
177
+ return result;
178
+ } catch { }
150
179
  }
151
180
 
152
181
  if (isDocker) {
153
- try { await execPromise('apt-get update -y && apt-get install -y chromium || true'); await access('/usr/bin/chromium', fs.constants.X_OK); result.path = '/usr/bin/chromium'; return result; } catch { }
182
+ try {
183
+ await execPromise('apt-get update -y && apt-get install -y chromium || true');
184
+ await access('/usr/bin/chromium', fs.constants.X_OK);
185
+ result.path = '/usr/bin/chromium';
186
+ return result;
187
+ } catch { }
154
188
  }
155
-
156
- // Fallback Puppeteer tylko jeśli nie ARM/QNAP
157
- try { result.path = puppeteer.executablePath(); return result; } catch { }
158
189
  }
159
190
 
160
191
  return result;
@@ -164,7 +195,6 @@ class Functions extends EventEmitter {
164
195
  }
165
196
  }
166
197
 
167
-
168
198
  isValidValue(v) {
169
199
  return v !== undefined && v !== null && !(typeof v === 'number' && Number.isNaN(v));
170
200
  }
@@ -230,7 +260,6 @@ class Functions extends EventEmitter {
230
260
 
231
261
  return { min, max };
232
262
  }
233
-
234
263
  }
235
264
 
236
265
  export default Functions
@@ -227,14 +227,13 @@ class MelCloudHome extends EventEmitter {
227
227
  const chromiumInfo = await this.functions.ensureChromiumInstalled();
228
228
  let chromiumPath = chromiumInfo.path;
229
229
 
230
- // zawsze próbuj Puppeteer jeśli brak binarki
230
+ // Try Puppeteer Chromium if path null
231
231
  if (!chromiumPath) {
232
232
  try {
233
233
  chromiumPath = puppeteer.executablePath();
234
- if (this.logDebug) this.emit('debug', `Using Puppeteer Chromium (${chromiumInfo.arch}) at ${chromiumPath}`);
234
+ if (!this.logDebug) this.emit('debug', `Using Puppeteer Chromium (${chromiumInfo.arch}) at ${chromiumPath}`);
235
235
  } catch (error) {
236
- accountInfo.Info =
237
- `No Chromium available for architecture ${chromiumInfo.arch}`;
236
+ accountInfo.Info = `No Chromium available for architecture ${chromiumInfo.arch}`;
238
237
  return accountInfo;
239
238
  }
240
239
  }
@@ -242,7 +241,7 @@ class MelCloudHome extends EventEmitter {
242
241
  // Verify Chromium executable
243
242
  try {
244
243
  const { stdout } = await execPromise(`"${chromiumPath}" --version`);
245
- if (this.logDebug) this.emit('debug', `Chromium detected: ${stdout.trim()}`);
244
+ if (!this.logDebug) this.emit('debug', `Chromium detected: ${stdout.trim()}`);
246
245
  } catch (error) {
247
246
  accountInfo.Info = `Chromium found at ${chromiumPath}, but cannot be executed: ${error.message}`;
248
247
  return accountInfo;
@@ -281,7 +280,7 @@ class MelCloudHome extends EventEmitter {
281
280
  const hash = params.get('hash');
282
281
  if (this.logDebug) this.emit('debug', `Web socket hash detected: ${hash}`);
283
282
 
284
- //web socket connection
283
+ // Web socket connection
285
284
  if (!this.connecting && !this.socketConnected) {
286
285
  this.connecting = true;
287
286