homebridge-melcloud-control 4.0.0-beta.447 → 4.0.0-beta.449
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 +17 -54
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.
|
|
4
|
+
"version": "4.0.0-beta.449",
|
|
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
|
@@ -58,85 +58,48 @@ class Functions extends EventEmitter {
|
|
|
58
58
|
let chromiumPath = '/usr/bin/chromium-browser';
|
|
59
59
|
|
|
60
60
|
try {
|
|
61
|
-
// Detect architecture
|
|
62
|
-
const { stdout: archOut } = await execPromise('uname -m');
|
|
63
|
-
const arch = archOut.trim();
|
|
64
|
-
if (this.logDebug) this.emit('debug', `Detected architecture: ${arch}`);
|
|
65
|
-
|
|
66
61
|
// Detect OS
|
|
67
62
|
const { stdout: osOut } = await execPromise('uname -s');
|
|
68
63
|
const osName = osOut.trim();
|
|
69
64
|
if (this.logDebug) this.emit('debug', `Detected OS: ${osName}`);
|
|
70
65
|
|
|
71
|
-
// macOS fallback
|
|
72
66
|
if (osName === 'Darwin') {
|
|
73
67
|
chromiumPath = '/Applications/Google Chrome.app/Contents/MacOS/Google Chrome';
|
|
74
|
-
|
|
75
68
|
try {
|
|
76
69
|
await access(chromiumPath, fs.constants.X_OK);
|
|
77
70
|
if (this.logDebug) this.emit('debug', `Using system Chrome at ${chromiumPath}`);
|
|
78
71
|
return chromiumPath;
|
|
79
72
|
} catch {
|
|
80
|
-
if (this.
|
|
73
|
+
if (this.logWarn) this.emit('warn', 'System Chrome not found on macOS.');
|
|
81
74
|
return null;
|
|
82
75
|
}
|
|
83
76
|
}
|
|
84
77
|
|
|
85
|
-
//
|
|
86
|
-
let linuxDistro = 'unknown';
|
|
87
|
-
try {
|
|
88
|
-
const { stdout: distroOut } = await execPromise('cat /etc/os-release');
|
|
89
|
-
linuxDistro = distroOut.split('\n')[0] || 'unknown';
|
|
90
|
-
} catch {
|
|
91
|
-
if (this.logError) this.emit('error', '/etc/os-release not found, skipping OS detection.');
|
|
92
|
-
}
|
|
93
|
-
if (this.logDebug) this.emit('debug', `Linux distro: ${linuxDistro}`);
|
|
94
|
-
|
|
95
|
-
// Check if Chromium exists
|
|
96
|
-
let chromiumCheck = '';
|
|
78
|
+
// Check if Chromium exists on Linux
|
|
97
79
|
try {
|
|
98
80
|
const { stdout: checkOut } = await execPromise('which chromium || which chromium-browser || true');
|
|
99
|
-
|
|
81
|
+
chromiumPath = checkOut.trim();
|
|
82
|
+
if (chromiumPath) {
|
|
83
|
+
if (this.logDebug) this.emit('debug', `Found system Chromium: ${chromiumPath}`);
|
|
84
|
+
return chromiumPath;
|
|
85
|
+
}
|
|
100
86
|
} catch { }
|
|
101
|
-
if (chromiumCheck) {
|
|
102
|
-
chromiumPath = chromiumCheck;
|
|
103
|
-
if (this.logDebug) this.emit('debug', `Found system Chromium: ${chromiumPath}`);
|
|
104
|
-
return chromiumPath;
|
|
105
|
-
}
|
|
106
87
|
|
|
88
|
+
// Optional: attempt installation (Linux)
|
|
107
89
|
if (this.logWarn) this.emit('warn', 'Chromium not found. Attempting installation...');
|
|
90
|
+
try { await execPromise('sudo apt-get update -y && sudo apt-get install -y chromium-browser chromium-codecs-ffmpeg'); return chromiumPath; } catch { }
|
|
91
|
+
try { await execPromise('sudo apk add --no-cache chromium ffmpeg'); return chromiumPath; } catch { }
|
|
92
|
+
try { await execPromise('sudo yum install -y chromium chromium-codecs-ffmpeg'); return chromiumPath; } catch { }
|
|
108
93
|
|
|
109
|
-
//
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
if (this.logDebug) this.emit('debug', 'Chromium installed successfully via apt-get.');
|
|
113
|
-
return chromiumPath;
|
|
114
|
-
} catch {
|
|
115
|
-
if (this.logError) this.emit('error', 'apt-get install failed. Trying apk or yum...');
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
// apk (Alpine)
|
|
119
|
-
try {
|
|
120
|
-
await execPromise('sudo apk add --no-cache chromium ffmpeg');
|
|
121
|
-
if (this.logDebug) this.emit('debug', 'Chromium installed successfully via apk.');
|
|
122
|
-
return chromiumPath;
|
|
123
|
-
} catch {
|
|
124
|
-
if (this.logError) this.emit('error', 'apk install failed. Trying yum...');
|
|
125
|
-
}
|
|
94
|
+
// If everything fails, return null
|
|
95
|
+
if (this.logWarn) this.emit('warn', 'Chromium not found. Use Puppeteer bundled Chromium.');
|
|
96
|
+
return null;
|
|
126
97
|
|
|
127
|
-
// yum (RHEL/CentOS)
|
|
128
|
-
try {
|
|
129
|
-
await execPromise('sudo yum install -y chromium chromium-codecs-ffmpeg');
|
|
130
|
-
if (this.logDebug) this.emit('debug', 'Chromium installed successfully via yum.');
|
|
131
|
-
return chromiumPath;
|
|
132
|
-
} catch {
|
|
133
|
-
if (this.logError) this.emit('error', 'yum install failed. Falling back to Puppeteer bundled Chromium.');
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
return chromiumPath;
|
|
137
98
|
} catch (error) {
|
|
138
|
-
|
|
99
|
+
if (this.logError) this.emit('error', `Chromium detection/install error: ${error.message}`);
|
|
100
|
+
return null;
|
|
139
101
|
}
|
|
140
102
|
}
|
|
103
|
+
|
|
141
104
|
}
|
|
142
105
|
export default Functions
|