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

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.13",
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,29 +149,47 @@ 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
  }
160
+
161
+ // 4. Jeśli dalej brak → path = null
162
+ return result;
138
163
  }
139
164
 
165
+
140
166
  /* ===================== Linux x64 ===================== */
141
167
  if (isLinux) {
142
168
  const linuxCandidates = ['/usr/bin/chromium', '/usr/bin/chromium-browser', '/usr/bin/google-chrome', '/snap/bin/chromium', '/usr/local/bin/chromium'];
143
169
  try {
144
170
  const { stdout } = await execPromise('which chromium || which chromium-browser || which google-chrome || true');
145
- if (stdout.trim()) { result.path = stdout.trim(); return result; }
171
+ if (stdout.trim()) {
172
+ result.path = stdout.trim();
173
+ return result;
174
+ }
146
175
  } catch { }
147
176
 
148
177
  for (const path of linuxCandidates) {
149
- try { await access(path, fs.constants.X_OK); result.path = path; return result; } catch { }
178
+ try {
179
+ await access(path, fs.constants.X_OK);
180
+ result.path = path;
181
+ return result;
182
+ } catch { }
150
183
  }
151
184
 
152
185
  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 { }
186
+ try {
187
+ await execPromise('apt-get update -y && apt-get install -y chromium || true');
188
+ await access('/usr/bin/chromium', fs.constants.X_OK);
189
+ result.path = '/usr/bin/chromium';
190
+ return result;
191
+ } catch { }
154
192
  }
155
-
156
- // Fallback Puppeteer tylko jeśli nie ARM/QNAP
157
- try { result.path = puppeteer.executablePath(); return result; } catch { }
158
193
  }
159
194
 
160
195
  return result;
@@ -164,7 +199,6 @@ class Functions extends EventEmitter {
164
199
  }
165
200
  }
166
201
 
167
-
168
202
  isValidValue(v) {
169
203
  return v !== undefined && v !== null && !(typeof v === 'number' && Number.isNaN(v));
170
204
  }
@@ -230,7 +264,6 @@ class Functions extends EventEmitter {
230
264
 
231
265
  return { min, max };
232
266
  }
233
-
234
267
  }
235
268
 
236
269
  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
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
  }
@@ -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