homebridge-melcloud-control 4.5.6-beta.0 → 4.5.6-beta.1
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 +1 -1
- package/src/functions.js +39 -62
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.
|
|
4
|
+
"version": "4.5.6-beta.1",
|
|
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
|
-
|
|
63
|
+
const rawArch = archOut.trim() || 'unknown';
|
|
64
64
|
|
|
65
|
-
|
|
66
|
-
if (
|
|
67
|
-
else if (
|
|
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
|
-
//
|
|
75
|
+
// Docker detection
|
|
76
76
|
let isDocker = false;
|
|
77
77
|
try {
|
|
78
78
|
await access('/.dockerenv');
|
|
@@ -81,23 +81,22 @@ class Functions extends EventEmitter {
|
|
|
81
81
|
|
|
82
82
|
try {
|
|
83
83
|
const { stdout } = await execPromise('cat /proc/1/cgroup');
|
|
84
|
-
if (stdout.includes('docker') || stdout.includes('containerd'))
|
|
84
|
+
if (stdout.includes('docker') || stdout.includes('containerd')) {
|
|
85
|
+
isDocker = true;
|
|
86
|
+
}
|
|
85
87
|
} catch { }
|
|
86
88
|
|
|
87
|
-
const result = { path: null, arch, system: 'unknown' };
|
|
88
|
-
|
|
89
89
|
/* ===================== macOS ===================== */
|
|
90
90
|
if (isMac) {
|
|
91
91
|
const macCandidates = ['/Applications/Google Chrome.app/Contents/MacOS/Google Chrome', '/Applications/Chromium.app/Contents/MacOS/Chromium'];
|
|
92
92
|
for (const path of macCandidates) {
|
|
93
93
|
try {
|
|
94
94
|
await access(path, fs.constants.X_OK);
|
|
95
|
-
|
|
96
|
-
result.system = 'macOS';
|
|
97
|
-
return result;
|
|
95
|
+
return { path, arch, system: 'macOS' };
|
|
98
96
|
} catch { }
|
|
99
97
|
}
|
|
100
|
-
|
|
98
|
+
|
|
99
|
+
return { path: null, arch, system: 'macOS' };
|
|
101
100
|
}
|
|
102
101
|
|
|
103
102
|
/* ===================== QNAP ===================== */
|
|
@@ -106,9 +105,7 @@ class Functions extends EventEmitter {
|
|
|
106
105
|
for (const path of qnapCandidates) {
|
|
107
106
|
try {
|
|
108
107
|
await access(path, fs.constants.X_OK);
|
|
109
|
-
|
|
110
|
-
result.system = 'Qnap';
|
|
111
|
-
return result;
|
|
108
|
+
return { path, arch, system: 'Qnap' };
|
|
112
109
|
} catch { }
|
|
113
110
|
}
|
|
114
111
|
|
|
@@ -124,92 +121,72 @@ class Functions extends EventEmitter {
|
|
|
124
121
|
for (const path of qnapCandidates) {
|
|
125
122
|
try {
|
|
126
123
|
await access(path, fs.constants.X_OK);
|
|
127
|
-
|
|
128
|
-
result.system = 'Qnap';
|
|
129
|
-
return result;
|
|
124
|
+
return { path, arch, system: 'Qnap' };
|
|
130
125
|
} catch { }
|
|
131
126
|
}
|
|
132
|
-
|
|
127
|
+
|
|
128
|
+
return { path: null, arch, system: 'Qnap' };
|
|
133
129
|
}
|
|
134
130
|
|
|
135
131
|
/* ===================== Linux ARM ===================== */
|
|
136
132
|
if (isLinux && isARM) {
|
|
137
|
-
const armCandidates = ['/usr/bin/chromium-browser', '/usr/bin/chromium'
|
|
133
|
+
const armCandidates = ['/usr/bin/chromium-browser', '/usr/bin/chromium'];
|
|
138
134
|
for (const path of armCandidates) {
|
|
139
135
|
try {
|
|
140
136
|
await access(path, fs.constants.X_OK);
|
|
141
|
-
|
|
142
|
-
result.system = 'Linux';
|
|
143
|
-
return result;
|
|
137
|
+
return { path, arch, system: 'Linux ARM' };
|
|
144
138
|
} catch { }
|
|
145
139
|
}
|
|
146
140
|
|
|
147
|
-
|
|
148
|
-
|
|
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;
|
|
141
|
+
// ARM: detect only, no runtime install
|
|
142
|
+
return { path: null, arch, system: 'Linux ARM' };
|
|
166
143
|
}
|
|
167
144
|
|
|
168
145
|
/* ===================== Linux x64 ===================== */
|
|
169
|
-
if (isLinux) {
|
|
170
|
-
const linuxCandidates = ['/usr/bin/
|
|
146
|
+
if (isLinux && !isARM) {
|
|
147
|
+
const linuxCandidates = ['/usr/bin/google-chrome', '/usr/bin/chromium-browser', '/usr/bin/chromium'];
|
|
148
|
+
|
|
171
149
|
try {
|
|
172
|
-
const { stdout } = await execPromise('
|
|
150
|
+
const { stdout } = await execPromise('command -v google-chrome || command -v chromium-browser || command -v chromium');
|
|
173
151
|
if (stdout.trim()) {
|
|
174
|
-
|
|
175
|
-
return result;
|
|
152
|
+
return { path: stdout.trim(), arch, system: isDocker ? 'Linux Docker' : 'Linux' };
|
|
176
153
|
}
|
|
177
154
|
} catch { }
|
|
178
155
|
|
|
179
|
-
for (const path of linuxCandidates) {
|
|
180
|
-
try {
|
|
181
|
-
await access(path, fs.constants.X_OK);
|
|
182
|
-
result.path = path;
|
|
183
|
-
result.system = 'Linux';
|
|
184
|
-
return result;
|
|
185
|
-
} catch { }
|
|
186
|
-
}
|
|
187
|
-
|
|
188
156
|
if (isDocker) {
|
|
189
157
|
try {
|
|
190
|
-
await execPromise(
|
|
158
|
+
await execPromise(`
|
|
159
|
+
apt update -y &&
|
|
160
|
+
apt install -y wget gnupg ca-certificates &&
|
|
161
|
+
mkdir -p /etc/apt/keyrings &&
|
|
162
|
+
wget -qO /etc/apt/keyrings/google.gpg https://dl.google.com/linux/linux_signing_key.pub &&
|
|
163
|
+
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' &&
|
|
164
|
+
apt update -y &&
|
|
165
|
+
apt install -y google-chrome-stable
|
|
166
|
+
`);
|
|
191
167
|
} catch (error) {
|
|
192
|
-
if (this.logError) this.emit('error', `
|
|
168
|
+
if (this.logError) this.emit('error', `Chrome install error: ${error}`);
|
|
193
169
|
}
|
|
194
170
|
|
|
195
171
|
for (const path of linuxCandidates) {
|
|
196
172
|
try {
|
|
197
173
|
await access(path, fs.constants.X_OK);
|
|
198
|
-
|
|
199
|
-
result.system = 'Linux Docker';
|
|
200
|
-
return result;
|
|
174
|
+
return { path, arch, system: 'Linux Docker' };
|
|
201
175
|
} catch { }
|
|
202
176
|
}
|
|
203
177
|
}
|
|
178
|
+
|
|
179
|
+
return { path: null, arch, system: 'Linux' };
|
|
204
180
|
}
|
|
205
181
|
|
|
206
|
-
return
|
|
182
|
+
return { path: null, arch, system: 'unknown' };
|
|
207
183
|
} catch (error) {
|
|
208
184
|
if (this.logError) this.emit('error', `Chromium detection error: ${error.message}`);
|
|
209
185
|
return { path: null, arch: 'unknown', system: 'unknown' };
|
|
210
186
|
}
|
|
211
187
|
}
|
|
212
188
|
|
|
189
|
+
|
|
213
190
|
isValidValue(v) {
|
|
214
191
|
return v !== undefined && v !== null && !(typeof v === 'number' && Number.isNaN(v));
|
|
215
192
|
}
|