homebridge-melcloud-control 4.0.0-beta.429 → 4.0.0-beta.430

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 +25 -10
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.429",
4
+ "version": "4.0.0-beta.430",
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
@@ -49,23 +49,38 @@ class Functions {
49
49
  }
50
50
  }
51
51
 
52
+
52
53
  async ensureChromiumInstalled(logInfo, logWarn, logError) {
53
- let chromiumPath = '/usr/bin/chromium-browser';
54
+ let chromiumPath = '/usr/bin/chromium-browser'; // default fallback Linux
54
55
 
55
56
  try {
56
- // --- Detect architecture ---
57
- const { stdout: arch } = await execAsync('uname -m');
58
- logInfo(`Detected architecture: ${arch.trim()}`);
57
+ // --- Detect platform ---
58
+ const { stdout: archStdout } = await execAsync('uname -m');
59
+ const arch = archStdout.trim();
60
+ logInfo(`Detected architecture: ${arch}`);
61
+
62
+ const { stdout: osNameStdout } = await execAsync('uname -s');
63
+ const osName = osNameStdout.trim();
64
+ logInfo(`Detected OS: ${osName}`);
65
+
66
+ // --- macOS handling ---
67
+ if (osName === 'Darwin') {
68
+ logInfo('Running on macOS — using Puppeteer bundled Chromium');
69
+ chromiumPath = puppeteer.executablePath();
70
+ logInfo(`Chromium path: ${chromiumPath}`);
71
+ return chromiumPath;
72
+ }
59
73
 
60
- // --- Detect OS safely ---
61
- let osName = 'unknown';
74
+ // --- Linux handling ---
75
+ // Detect OS release if available
76
+ let linuxDistro = 'unknown';
62
77
  try {
63
78
  const { stdout: osRelease } = await execAsync('cat /etc/os-release');
64
- osName = osRelease.split('\n')[0] || 'unknown';
79
+ linuxDistro = osRelease.split('\n')[0] || 'unknown';
65
80
  } catch {
66
81
  logWarn('/etc/os-release not found, skipping OS detection.');
67
82
  }
68
- logInfo(`Detected OS: ${osName}`);
83
+ logInfo(`Linux distro: ${linuxDistro}`);
69
84
 
70
85
  // --- Check existing Chromium ---
71
86
  const { stdout: chromiumCheck } = await execAsync('which chromium || which chromium-browser || true');
@@ -90,7 +105,7 @@ class Functions {
90
105
  // --- Try Alpine APK ---
91
106
  try {
92
107
  await execAsync('sudo apk add --no-cache chromium ffmpeg');
93
- chromiumPath = '/usr/bin/chromium-browser'; // standardowa ścieżka w Alpine
108
+ chromiumPath = '/usr/bin/chromium-browser';
94
109
  logInfo('Chromium installed successfully via apk.');
95
110
  return chromiumPath;
96
111
  } catch (apkErr) {
@@ -110,8 +125,8 @@ class Functions {
110
125
  // --- Fallback: Puppeteer Chromium ---
111
126
  chromiumPath = puppeteer.executablePath();
112
127
  logWarn(`Using bundled Puppeteer Chromium at ${chromiumPath}`);
113
-
114
128
  return chromiumPath;
129
+
115
130
  } catch (err) {
116
131
  logError(`Chromium detection/install error: ${err.message}`);
117
132
  throw err;