homebridge-melcloud-control 4.1.2-beta.58 → 4.1.2-beta.59

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 +17 -24
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "displayName": "MELCloud Control",
3
3
  "name": "homebridge-melcloud-control",
4
- "version": "4.1.2-beta.58",
4
+ "version": "4.1.2-beta.59",
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
@@ -68,14 +68,13 @@ class Functions extends EventEmitter {
68
68
  const arch = archOut.trim();
69
69
  if (this.logDebug) this.emit('debug', `Detected architecture: ${arch}`);
70
70
 
71
- // --- Detect Docker environment ---
71
+ // --- Detect Docker ---
72
72
  let isDocker = false;
73
73
  try { await access('/.dockerenv', fs.constants.F_OK); isDocker = true; } catch { }
74
74
  try {
75
75
  const { stdout } = await execPromise('cat /proc/1/cgroup || true');
76
76
  if (stdout.includes('docker') || stdout.includes('containerd')) isDocker = true;
77
77
  } catch { }
78
-
79
78
  if (isDocker && this.logDebug) this.emit('debug', 'Running inside Docker container.');
80
79
 
81
80
  // === macOS ===
@@ -86,8 +85,10 @@ class Functions extends EventEmitter {
86
85
 
87
86
  // === ARM ===
88
87
  if (arch.startsWith('arm')) {
89
- try { await access('/usr/bin/chromium-browser', fs.constants.X_OK); return '/usr/bin/chromium-browser'; } catch {
90
- try { await execPromise('sudo apt-get update -y && sudo apt-get install -y chromium-browser chromium-codecs-ffmpeg'); return '/usr/bin/chromium-browser'; } catch { return null; }
88
+ try { await access('/usr/bin/chromium-browser', fs.constants.X_OK); return '/usr/bin/chromium-browser'; }
89
+ catch {
90
+ try { await execPromise('sudo apt-get update -y && sudo apt-get install -y chromium-browser chromium-codecs-ffmpeg'); return '/usr/bin/chromium-browser'; }
91
+ catch { return null; }
91
92
  }
92
93
  }
93
94
 
@@ -107,35 +108,27 @@ class Functions extends EventEmitter {
107
108
 
108
109
  if (entwareExists) {
109
110
  try {
110
- if (this.logDebug) this.emit('debug', 'Detected Entware. Installing Chromium via opkg...');
111
+ if (this.logDebug) this.emit('debug', 'Detected Entware. Installing Chromium and libraries via opkg...');
111
112
  await execPromise('/opt/bin/opkg update');
112
113
  await execPromise('/opt/bin/opkg install chromium');
114
+
115
+ // Install all essential dependencies
113
116
  await execPromise('/opt/bin/opkg install nspr nss libx11 libxcomposite libxdamage libxrandr libatk libatk-bridge libcups libdrm libgbm libasound');
117
+
118
+ // Add Entware lib path to LD_LIBRARY_PATH
114
119
  process.env.LD_LIBRARY_PATH = '/opt/lib:' + (process.env.LD_LIBRARY_PATH || '');
120
+ if (this.logDebug) this.emit('debug', 'LD_LIBRARY_PATH set for Chromium');
121
+
122
+ // Verify binary exists
115
123
  const { stdout: checkOut } = await execPromise('which chromium || which chromium-browser || true');
116
124
  chromiumPath = checkOut.trim() || '/opt/bin/chromium';
117
- return chromiumPath;
125
+ if (chromiumPath) return chromiumPath;
118
126
  } catch (error) {
119
- if (this.logDebug) this.emit('debug', `Entware installation failed: ${error.message}`);
127
+ if (this.logError) this.emit('error', `Entware Chromium/libs installation failed: ${error.message}`);
120
128
  }
121
129
  }
122
130
 
123
- // --- Fallback Puppeteer Chromium ---
124
- try {
125
- const puppeteerPath = puppeteer.executablePath();
126
- if (puppeteerPath && fs.existsSync(puppeteerPath)) {
127
- chromiumPath = puppeteerPath;
128
- if (this.logDebug) this.emit('debug', `Using Puppeteer bundled Chromium at ${chromiumPath}`);
129
- // Try auto-set LD_LIBRARY_PATH for QNAP
130
- if (fs.existsSync('/opt/lib')) {
131
- process.env.LD_LIBRARY_PATH = '/opt/lib:' + (process.env.LD_LIBRARY_PATH || '');
132
- if (this.logDebug) this.emit('debug', 'LD_LIBRARY_PATH set for Chromium');
133
- }
134
- return chromiumPath;
135
- }
136
- } catch { }
137
-
138
- // --- Generic Linux installs ---
131
+ // --- Generic Linux install ---
139
132
  const installCommands = [
140
133
  'apt-get update -y && apt-get install -y chromium chromium-browser chromium-codecs-ffmpeg',
141
134
  'apk add --no-cache chromium ffmpeg',
@@ -155,11 +148,11 @@ class Functions extends EventEmitter {
155
148
 
156
149
  if (this.logDebug) this.emit('debug', `Unsupported OS: ${osName}.`);
157
150
  return null;
158
-
159
151
  } catch (error) {
160
152
  if (this.logError) this.emit('error', `Chromium detection/install error: ${error.message}`);
161
153
  return null;
162
154
  }
163
155
  }
156
+
164
157
  }
165
158
  export default Functions