homebridge-melcloud-control 4.5.6-beta.0 → 4.5.6-beta.2

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/functions.js +37 -68
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "displayName": "MELCloud Control",
3
3
  "name": "homebridge-melcloud-control",
4
- "version": "4.5.6-beta.0",
4
+ "version": "4.5.6-beta.2",
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
@@ -60,11 +60,11 @@ class Functions extends EventEmitter {
60
60
  const osName = osOut.trim();
61
61
 
62
62
  const { stdout: archOut } = await execPromise('uname -m');
63
- let arch = archOut.trim() || 'unknown';
63
+ const rawArch = archOut.trim() || 'unknown';
64
64
 
65
- // Normalizacja architektury
66
- if (arch.startsWith('arm') || arch.startsWith('aarch')) arch = 'arm';
67
- else if (arch.includes('64')) arch = 'x64';
65
+ let arch;
66
+ if (/^aarch64|^arm/.test(rawArch)) arch = 'arm';
67
+ else if (rawArch === 'x86_64' || rawArch === 'amd64') arch = 'x64';
68
68
  else arch = 'x86';
69
69
 
70
70
  const isARM = arch === 'arm';
@@ -72,7 +72,7 @@ class Functions extends EventEmitter {
72
72
  const isLinux = osName === 'Linux';
73
73
  const isQnap = fs.existsSync('/etc/config/uLinux.conf') || fs.existsSync('/etc/config/qpkg.conf');
74
74
 
75
- // Detect Docker
75
+ // Docker detection
76
76
  let isDocker = false;
77
77
  try {
78
78
  await access('/.dockerenv');
@@ -84,20 +84,17 @@ class Functions extends EventEmitter {
84
84
  if (stdout.includes('docker') || stdout.includes('containerd')) isDocker = true;
85
85
  } catch { }
86
86
 
87
- const result = { path: null, arch, system: 'unknown' };
88
-
89
87
  /* ===================== macOS ===================== */
90
88
  if (isMac) {
91
89
  const macCandidates = ['/Applications/Google Chrome.app/Contents/MacOS/Google Chrome', '/Applications/Chromium.app/Contents/MacOS/Chromium'];
92
90
  for (const path of macCandidates) {
93
91
  try {
94
92
  await access(path, fs.constants.X_OK);
95
- result.path = path;
96
- result.system = 'macOS';
97
- return result;
93
+ return { path, arch, system: 'macOS' };
98
94
  } catch { }
99
95
  }
100
- return result;
96
+
97
+ return { path: null, arch, system: 'macOS' };
101
98
  }
102
99
 
103
100
  /* ===================== QNAP ===================== */
@@ -106,9 +103,7 @@ class Functions extends EventEmitter {
106
103
  for (const path of qnapCandidates) {
107
104
  try {
108
105
  await access(path, fs.constants.X_OK);
109
- result.path = path;
110
- result.system = 'Qnap';
111
- return result;
106
+ return { path, arch, system: 'Qnap' };
112
107
  } catch { }
113
108
  }
114
109
 
@@ -124,92 +119,66 @@ class Functions extends EventEmitter {
124
119
  for (const path of qnapCandidates) {
125
120
  try {
126
121
  await access(path, fs.constants.X_OK);
127
- result.path = path;
128
- result.system = 'Qnap';
129
- return result;
130
- } catch { }
131
- }
132
- return result;
133
- }
134
-
135
- /* ===================== Linux ARM ===================== */
136
- if (isLinux && isARM) {
137
- const armCandidates = ['/usr/bin/chromium-browser', '/usr/bin/chromium', '/snap/bin/chromium'];
138
- for (const path of armCandidates) {
139
- try {
140
- await access(path, fs.constants.X_OK);
141
- result.path = path;
142
- result.system = 'Linux';
143
- return result;
122
+ return { path, arch, system: 'Qnap' };
144
123
  } catch { }
145
124
  }
146
125
 
147
- if (!isDocker) {
148
- try {
149
- await execPromise('sudo apt update -y');
150
- await execPromise('sudo apt install -y libnspr4 libnss3 libx11-6 libxcomposite1 libxdamage1 libxrandr2 libatk1.0-0 libcups2 libdrm2 libgbm1 libasound2');
151
- await execPromise('sudo apt install -y chromium chromium-browser chromium-codecs-ffmpeg');
152
- } catch (error) {
153
- if (this.logError) this.emit('error', `Install package for Linux ARM error: ${error}`);
154
- }
155
- }
156
-
157
- for (const path of armCandidates) {
158
- try {
159
- await access(path, fs.constants.X_OK);
160
- result.path = path;
161
- result.system = 'Linux';
162
- return result;
163
- } catch { }
164
- }
165
- return result;
126
+ return { path: null, arch, system: 'Qnap' };
166
127
  }
167
128
 
168
- /* ===================== Linux x64 ===================== */
129
+ /* ===================== Linux ===================== */
169
130
  if (isLinux) {
170
- const linuxCandidates = ['/usr/bin/chromium', '/usr/bin/chromium-browser', '/usr/bin/google-chrome', '/snap/bin/chromium', '/usr/local/bin/chromium'];
171
- try {
172
- const { stdout } = await execPromise('which chromium || which chromium-browser || which google-chrome');
173
- if (stdout.trim()) {
174
- result.path = stdout.trim();
175
- return result;
176
- }
177
- } catch { }
131
+ const linuxCandidates = ['/usr/bin/google-chrome', '/usr/bin/chromium-browser', '/usr/bin/chromium'];
178
132
 
133
+ // Detect existing browser (ARM + x64)
179
134
  for (const path of linuxCandidates) {
180
135
  try {
181
136
  await access(path, fs.constants.X_OK);
182
- result.path = path;
183
- result.system = 'Linux';
184
- return result;
137
+ return { path, arch, system: isDocker ? 'Linux Docker' : (isARM ? 'Linux ARM' : 'Linux') };
185
138
  } catch { }
186
139
  }
187
140
 
141
+ // ARM → detect only
142
+ if (isARM) {
143
+ return { path: null, arch, system: 'Linux ARM' };
144
+ }
145
+
146
+ /* ===================== Linux x64 ===================== */
188
147
  if (isDocker) {
189
148
  try {
190
- await execPromise('apt update -y && apt install -y chromium');
149
+ await execPromise(`
150
+ apt update -y &&
151
+ apt install -y wget gnupg ca-certificates &&
152
+ mkdir -p /etc/apt/keyrings &&
153
+ wget -qO /etc/apt/keyrings/google.gpg https://dl.google.com/linux/linux_signing_key.pub &&
154
+ sh -c 'echo "deb [arch=amd64 signed-by=/etc/apt/keyrings/google.gpg] http://dl.google.com/linux/chrome/deb/ stable main" > /etc/apt/sources.list.d/google-chrome.list' &&
155
+ apt update -y &&
156
+ apt install -y google-chrome-stable
157
+ `);
191
158
  } catch (error) {
192
- if (this.logError) this.emit('error', `Install package for Linux Docker error: ${error}`);
159
+ if (this.logError) this.emit('error', `Chrome install error: ${error}`);
160
+ return { path: null, arch, system: 'Linux Docker' };
193
161
  }
194
162
 
195
163
  for (const path of linuxCandidates) {
196
164
  try {
197
165
  await access(path, fs.constants.X_OK);
198
- result.path = path;
199
- result.system = 'Linux Docker';
200
- return result;
166
+ return { path, arch, system: 'Linux Docker' };
201
167
  } catch { }
202
168
  }
203
169
  }
170
+
171
+ return { path: null, arch, system: isDocker ? 'Linux Docker' : 'Linux' };
204
172
  }
205
173
 
206
- return result;
174
+ return { path: null, arch, system: 'unknown' };
207
175
  } catch (error) {
208
176
  if (this.logError) this.emit('error', `Chromium detection error: ${error.message}`);
209
177
  return { path: null, arch: 'unknown', system: 'unknown' };
210
178
  }
211
179
  }
212
180
 
181
+
213
182
  isValidValue(v) {
214
183
  return v !== undefined && v !== null && !(typeof v === 'number' && Number.isNaN(v));
215
184
  }