homebridge-melcloud-control 4.0.0-beta.446 → 4.0.0-beta.447
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 +11 -27
- package/src/melcloud.js +1 -2
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.447",
|
|
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
|
@@ -2,7 +2,6 @@ import fs from 'fs';
|
|
|
2
2
|
import util from 'util';
|
|
3
3
|
import { exec } from 'child_process';
|
|
4
4
|
import { promises as fsPromises } from 'fs';
|
|
5
|
-
import puppeteer from 'puppeteer';
|
|
6
5
|
import EventEmitter from 'events';
|
|
7
6
|
const access = util.promisify(fs.access);
|
|
8
7
|
const execPromise = util.promisify(exec);
|
|
@@ -59,31 +58,31 @@ class Functions extends EventEmitter {
|
|
|
59
58
|
let chromiumPath = '/usr/bin/chromium-browser';
|
|
60
59
|
|
|
61
60
|
try {
|
|
62
|
-
//
|
|
61
|
+
// Detect architecture
|
|
63
62
|
const { stdout: archOut } = await execPromise('uname -m');
|
|
64
63
|
const arch = archOut.trim();
|
|
65
64
|
if (this.logDebug) this.emit('debug', `Detected architecture: ${arch}`);
|
|
66
65
|
|
|
67
|
-
//
|
|
66
|
+
// Detect OS
|
|
68
67
|
const { stdout: osOut } = await execPromise('uname -s');
|
|
69
68
|
const osName = osOut.trim();
|
|
70
69
|
if (this.logDebug) this.emit('debug', `Detected OS: ${osName}`);
|
|
71
70
|
|
|
72
|
-
//
|
|
71
|
+
// macOS fallback
|
|
73
72
|
if (osName === 'Darwin') {
|
|
74
73
|
chromiumPath = '/Applications/Google Chrome.app/Contents/MacOS/Google Chrome';
|
|
75
74
|
|
|
76
75
|
try {
|
|
77
76
|
await access(chromiumPath, fs.constants.X_OK);
|
|
78
77
|
if (this.logDebug) this.emit('debug', `Using system Chrome at ${chromiumPath}`);
|
|
78
|
+
return chromiumPath;
|
|
79
79
|
} catch {
|
|
80
|
-
if (this.logError) this.emit('error', 'System Chrome not found
|
|
81
|
-
|
|
80
|
+
if (this.logError) this.emit('error', 'System Chrome not found, using builtin chrome.');
|
|
81
|
+
return null;
|
|
82
82
|
}
|
|
83
|
-
return chromiumPath;
|
|
84
83
|
}
|
|
85
84
|
|
|
86
|
-
//
|
|
85
|
+
// Linux distro detection
|
|
87
86
|
let linuxDistro = 'unknown';
|
|
88
87
|
try {
|
|
89
88
|
const { stdout: distroOut } = await execPromise('cat /etc/os-release');
|
|
@@ -93,7 +92,7 @@ class Functions extends EventEmitter {
|
|
|
93
92
|
}
|
|
94
93
|
if (this.logDebug) this.emit('debug', `Linux distro: ${linuxDistro}`);
|
|
95
94
|
|
|
96
|
-
//
|
|
95
|
+
// Check if Chromium exists
|
|
97
96
|
let chromiumCheck = '';
|
|
98
97
|
try {
|
|
99
98
|
const { stdout: checkOut } = await execPromise('which chromium || which chromium-browser || true');
|
|
@@ -107,7 +106,7 @@ class Functions extends EventEmitter {
|
|
|
107
106
|
|
|
108
107
|
if (this.logWarn) this.emit('warn', 'Chromium not found. Attempting installation...');
|
|
109
108
|
|
|
110
|
-
//
|
|
109
|
+
// apt-get
|
|
111
110
|
try {
|
|
112
111
|
await execPromise('sudo apt-get update -y && sudo apt-get install -y chromium-browser chromium-codecs-ffmpeg');
|
|
113
112
|
if (this.logDebug) this.emit('debug', 'Chromium installed successfully via apt-get.');
|
|
@@ -116,7 +115,7 @@ class Functions extends EventEmitter {
|
|
|
116
115
|
if (this.logError) this.emit('error', 'apt-get install failed. Trying apk or yum...');
|
|
117
116
|
}
|
|
118
117
|
|
|
119
|
-
//
|
|
118
|
+
// apk (Alpine)
|
|
120
119
|
try {
|
|
121
120
|
await execPromise('sudo apk add --no-cache chromium ffmpeg');
|
|
122
121
|
if (this.logDebug) this.emit('debug', 'Chromium installed successfully via apk.');
|
|
@@ -125,7 +124,7 @@ class Functions extends EventEmitter {
|
|
|
125
124
|
if (this.logError) this.emit('error', 'apk install failed. Trying yum...');
|
|
126
125
|
}
|
|
127
126
|
|
|
128
|
-
//
|
|
127
|
+
// yum (RHEL/CentOS)
|
|
129
128
|
try {
|
|
130
129
|
await execPromise('sudo yum install -y chromium chromium-codecs-ffmpeg');
|
|
131
130
|
if (this.logDebug) this.emit('debug', 'Chromium installed successfully via yum.');
|
|
@@ -134,25 +133,10 @@ class Functions extends EventEmitter {
|
|
|
134
133
|
if (this.logError) this.emit('error', 'yum install failed. Falling back to Puppeteer bundled Chromium.');
|
|
135
134
|
}
|
|
136
135
|
|
|
137
|
-
// --- Fallback Puppeteer ---
|
|
138
|
-
chromiumPath = puppeteer.executablePath();
|
|
139
|
-
if (this.logDebug) this.emit('debug', `Using bundled Puppeteer Chromium at ${chromiumPath || 'not found'}`);
|
|
140
136
|
return chromiumPath;
|
|
141
|
-
|
|
142
137
|
} catch (error) {
|
|
143
138
|
throw new Error(`Chromium detection/install error: ${error.message}`);
|
|
144
139
|
}
|
|
145
140
|
}
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
async isRunningInDocker() {
|
|
149
|
-
try {
|
|
150
|
-
if (fs.existsSync('/.dockerenv')) return true;
|
|
151
|
-
const cgroup = fs.readFileSync('/proc/1/cgroup', 'utf8');
|
|
152
|
-
return cgroup.includes('docker') || cgroup.includes('kubepods');
|
|
153
|
-
} catch {
|
|
154
|
-
return false;
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
141
|
}
|
|
158
142
|
export default Functions
|
package/src/melcloud.js
CHANGED
|
@@ -333,7 +333,7 @@ class MelCloud extends EventEmitter {
|
|
|
333
333
|
const chromiumPath = await this.functions.ensureChromiumInstalled();
|
|
334
334
|
browser = await puppeteer.launch({
|
|
335
335
|
headless: true,
|
|
336
|
-
executablePath: chromiumPath,
|
|
336
|
+
executablePath: chromiumPath || puppeteer.executablePath(),
|
|
337
337
|
args: [
|
|
338
338
|
'--no-sandbox',
|
|
339
339
|
'--disable-setuid-sandbox',
|
|
@@ -427,7 +427,6 @@ class MelCloud extends EventEmitter {
|
|
|
427
427
|
|
|
428
428
|
if (!refresh) this.emit('success', 'Connect to MELCloud Home Success');
|
|
429
429
|
return accountInfo;
|
|
430
|
-
|
|
431
430
|
} catch (error) {
|
|
432
431
|
throw new Error(`Connect error: ${error.message}`);
|
|
433
432
|
} finally {
|