homebridge-melcloud-control 4.0.0-beta.449 → 4.0.0-beta.451

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "displayName": "MELCloud Control",
3
3
  "name": "homebridge-melcloud-control",
4
- "version": "4.0.0-beta.449",
4
+ "version": "4.0.0-beta.451",
5
5
  "description": "Homebridge plugin to control Mitsubishi Air Conditioner, Heat Pump and Energy Recovery Ventilation.",
6
6
  "license": "MIT",
7
7
  "author": "grzegorz914",
@@ -39,10 +39,7 @@
39
39
  "async-mqtt": "^2.6.3",
40
40
  "axios": "^1.13.0",
41
41
  "express": "^5.1.0",
42
- "puppeteer": "^24.26.1",
43
- "axios-cookiejar-support": "^6.0.4",
44
- "tough-cookie": "^6.0.0",
45
- "jsdom": "^27.0.1"
42
+ "puppeteer": "^24.26.1"
46
43
  },
47
44
  "keywords": [
48
45
  "homebridge",
package/src/functions.js CHANGED
@@ -54,28 +54,55 @@ class Functions extends EventEmitter {
54
54
  }
55
55
  }
56
56
 
57
- async ensureChromiumInstalled() {
58
- let chromiumPath = '/usr/bin/chromium-browser';
57
+ async ensureChromiumInstalled() {
58
+ let chromiumPath = '/usr/bin/chromium-browser';
59
59
 
60
- try {
61
- // Detect OS
62
- const { stdout: osOut } = await execPromise('uname -s');
63
- const osName = osOut.trim();
64
- if (this.logDebug) this.emit('debug', `Detected OS: ${osName}`);
60
+ try {
61
+ // --- Detect OS ---
62
+ const { stdout: osOut } = await execPromise('uname -s');
63
+ const osName = osOut.trim();
64
+ if (this.logDebug) this.emit('debug', `Detected OS: ${osName}`);
65
+
66
+ // --- Detect Architecture ---
67
+ const { stdout: archOut } = await execPromise('uname -m');
68
+ const arch = archOut.trim();
69
+ if (this.logDebug) this.emit('debug', `Detected architecture: ${arch}`);
70
+
71
+ // === macOS ===
72
+ if (osName === 'Darwin') {
73
+ chromiumPath = '/Applications/Google Chrome.app/Contents/MacOS/Google Chrome';
74
+ try {
75
+ await access(chromiumPath, fs.constants.X_OK);
76
+ if (this.logDebug) this.emit('debug', `Using system Chrome at ${chromiumPath}`);
77
+ return chromiumPath;
78
+ } catch {
79
+ if (this.logDebug) this.emit('debug', 'System Chrome not found on macOS, will use Puppeteer bundled Chromium.');
80
+ return null;
81
+ }
82
+ }
65
83
 
66
- if (osName === 'Darwin') {
67
- chromiumPath = '/Applications/Google Chrome.app/Contents/MacOS/Google Chrome';
84
+ // === ARM (e.g. Raspberry Pi) ===
85
+ if (arch.startsWith('arm')) {
86
+ try {
87
+ await access('/usr/bin/chromium-browser', fs.constants.X_OK);
88
+ if (this.logDebug) this.emit('debug', 'Using system Chromium on ARM platform.');
89
+ return '/usr/bin/chromium-browser';
90
+ } catch {
91
+ if (this.logWarn) this.emit('warn', 'System Chromium not found on ARM. Attempting installation...');
68
92
  try {
69
- await access(chromiumPath, fs.constants.X_OK);
70
- if (this.logDebug) this.emit('debug', `Using system Chrome at ${chromiumPath}`);
71
- return chromiumPath;
93
+ await execPromise('sudo apt-get update -y && sudo apt-get install -y chromium-browser chromium-codecs-ffmpeg');
94
+ if (this.logDebug) this.emit('debug', 'Chromium installed successfully on ARM.');
95
+ return '/usr/bin/chromium-browser';
72
96
  } catch {
73
- if (this.logWarn) this.emit('warn', 'System Chrome not found on macOS.');
97
+ if (this.logError) this.emit('error', 'Failed to install Chromium on ARM. Bundled Chromium will likely not work.');
98
+ if (this.logDebug) this.emit('debug', 'Falling back to Puppeteer bundled Chromium.');
74
99
  return null;
75
100
  }
76
101
  }
102
+ }
77
103
 
78
- // Check if Chromium exists on Linux
104
+ // === Linux (x64 etc.) ===
105
+ if (osName === 'Linux') {
79
106
  try {
80
107
  const { stdout: checkOut } = await execPromise('which chromium || which chromium-browser || true');
81
108
  chromiumPath = checkOut.trim();
@@ -85,21 +112,42 @@ class Functions extends EventEmitter {
85
112
  }
86
113
  } catch { }
87
114
 
88
- // Optional: attempt installation (Linux)
89
115
  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 { }
93
116
 
94
- // If everything fails, return null
95
- if (this.logWarn) this.emit('warn', 'Chromium not found. Use Puppeteer bundled Chromium.');
96
- return null;
117
+ try {
118
+ await execPromise('sudo apt-get update -y && sudo apt-get install -y chromium-browser chromium-codecs-ffmpeg');
119
+ if (this.logDebug) this.emit('debug', 'Chromium installed successfully via apt-get.');
120
+ return '/usr/bin/chromium-browser';
121
+ } catch {
122
+ if (this.logError) this.emit('error', 'apt-get failed. Trying apk or yum...');
123
+ }
97
124
 
98
- } catch (error) {
99
- if (this.logError) this.emit('error', `Chromium detection/install error: ${error.message}`);
125
+ try {
126
+ await execPromise('sudo apk add --no-cache chromium ffmpeg');
127
+ if (this.logDebug) this.emit('debug', 'Chromium installed successfully via apk.');
128
+ return '/usr/bin/chromium-browser';
129
+ } catch { }
130
+
131
+ try {
132
+ await execPromise('sudo yum install -y chromium chromium-codecs-ffmpeg');
133
+ if (this.logDebug) this.emit('debug', 'Chromium installed successfully via yum.');
134
+ return '/usr/bin/chromium-browser';
135
+ } catch { }
136
+
137
+ if (this.logDebug) this.emit('debug', 'Chromium not found on Linux. Using Puppeteer bundled Chromium.');
100
138
  return null;
101
139
  }
140
+
141
+ // Unknown OS
142
+ if (this.logDebug) this.emit('debug', `Unsupported OS: ${osName}. Using Puppeteer bundled Chromium.`);
143
+ return null;
144
+
145
+ } catch (error) {
146
+ if (this.logError) this.emit('error', `Chromium detection/install error: ${error.message}`);
147
+ if (this.logDebug) this.emit('debug', 'Using Puppeteer bundled Chromium due to detection error.');
148
+ return null;
102
149
  }
150
+ }
103
151
 
104
152
  }
105
153
  export default Functions
package/src/melcloud.js CHANGED
@@ -344,8 +344,8 @@ class MelCloud extends EventEmitter {
344
344
  });
345
345
 
346
346
  const page = await browser.newPage();
347
- page.on('error', err => { if (this.logError) this.emit('error', `Page crashed: ${err.message}`); });
348
- page.on('pageerror', err => { if (this.logError) this.emit('error', `Browser error: ${err.message}`); });
347
+ page.on('error', error => { if (this.logError) this.emit('error', `Page crashed: ${error.message}`); });
348
+ page.on('pageerror', error => { if (this.logError) this.emit('error', `Browser error: ${error.message}`); });
349
349
  page.on('close', () => { if (this.logDebug) this.emit('debug', 'Page was closed unexpectedly'); });
350
350
  browser.on('disconnected', () => { if (this.logDebug) this.emit('debug', 'Browser disconnected unexpectedly'); });
351
351