homebridge-melcloud-control 4.0.0-beta.436 → 4.0.0-beta.438

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 +18 -19
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.436",
4
+ "version": "4.0.0-beta.438",
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,9 +58,9 @@ class Functions {
58
58
  exec('uname -m', (e, out) => e ? rej(e) : res({ stdout: out }))
59
59
  );
60
60
  arch = stdout.trim();
61
- console.log('debug', `Detected architecture: ${arch}`);
61
+ console.log(`Detected architecture: ${arch}`);
62
62
  } catch (err) {
63
- if (this.logWarn) this.emit('warn', `Failed to detect architecture: ${err.message}`);
63
+ throw new Error(`Failed to detect architecture: ${err.message}`);
64
64
  }
65
65
 
66
66
  // --- Detect OS ---
@@ -70,16 +70,16 @@ class Functions {
70
70
  exec('uname -s', (e, out) => e ? rej(e) : res({ stdout: out }))
71
71
  );
72
72
  osName = stdout.trim();
73
- console.log('debug', `Detected OS: ${osName}`);
73
+ console.log(`Detected OS: ${osName}`);
74
74
  } catch (err) {
75
- if (this.logWarn) this.emit('warn', `Failed to detect OS: ${err.message}`);
75
+ throw new Error(`Failed to detect OS: ${err.message}`);
76
76
  }
77
77
 
78
78
  // --- macOS fallback ---
79
79
  if (osName === 'Darwin') {
80
- console.log('debug', 'Running on macOS — using Puppeteer bundled Chromium');
80
+ console.log('Running on macOS — using Puppeteer bundled Chromium');
81
81
  chromiumPath = puppeteer.executablePath();
82
- console.log('debug', `Chromium path: ${chromiumPath}`);
82
+ console.log(`Chromium path: ${chromiumPath}`);
83
83
  return chromiumPath;
84
84
  }
85
85
 
@@ -91,9 +91,9 @@ class Functions {
91
91
  );
92
92
  linuxDistro = stdout.split('\n')[0] || 'unknown';
93
93
  } catch {
94
- if (this.logWarn) this.emit('warn', '/etc/os-release not found, skipping OS detection.');
94
+ throw new Error('/etc/os-release not found, skipping OS detection.');
95
95
  }
96
- console.log('debug', `Linux distro: ${linuxDistro}`);
96
+ console.log(`Linux distro: ${linuxDistro}`);
97
97
 
98
98
  // --- Check if Chromium exists ---
99
99
  let chromiumCheck = '';
@@ -105,11 +105,11 @@ class Functions {
105
105
  } catch { }
106
106
  if (chromiumCheck) {
107
107
  chromiumPath = chromiumCheck;
108
- console.log('debug', `Found system Chromium: ${chromiumPath}`);
108
+ console.log(`Found system Chromium: ${chromiumPath}`);
109
109
  return chromiumPath;
110
110
  }
111
111
 
112
- if (this.logWarn) this.emit('warn', 'Chromium not found. Attempting installation...');
112
+ console.log('Chromium not found. Attempting installation...');
113
113
 
114
114
  // --- apt-get ---
115
115
  try {
@@ -117,10 +117,10 @@ class Functions {
117
117
  exec('sudo apt-get update -y && sudo apt-get install -y chromium-browser chromium-codecs-ffmpeg', e => e ? rej(e) : res())
118
118
  );
119
119
  chromiumPath = '/usr/bin/chromium-browser';
120
- console.log('debug', 'Chromium installed successfully via apt-get.');
120
+ console.log('Chromium installed successfully via apt-get.');
121
121
  return chromiumPath;
122
122
  } catch {
123
- if (this.logWarn) this.emit('warn', 'apt-get install failed. Trying apk or yum...');
123
+ console.log('apt-get install failed. Trying apk or yum...');
124
124
  }
125
125
 
126
126
  // --- apk (Alpine) ---
@@ -129,10 +129,10 @@ class Functions {
129
129
  exec('sudo apk add --no-cache chromium ffmpeg', e => e ? rej(e) : res())
130
130
  );
131
131
  chromiumPath = '/usr/bin/chromium-browser';
132
- console.log('debug', 'Chromium installed successfully via apk.');
132
+ console.log('Chromium installed successfully via apk.');
133
133
  return chromiumPath;
134
134
  } catch {
135
- if (this.logWarn) this.emit('warn', 'apk install failed. Trying yum...');
135
+ console.log('apk install failed. Trying yum...');
136
136
  }
137
137
 
138
138
  // --- yum (RHEL/CentOS) ---
@@ -141,20 +141,19 @@ class Functions {
141
141
  exec('sudo yum install -y chromium chromium-codecs-ffmpeg', e => e ? rej(e) : res())
142
142
  );
143
143
  chromiumPath = '/usr/bin/chromium-browser';
144
- console.log('debug', 'Chromium installed successfully via yum.');
144
+ console.log('Chromium installed successfully via yum.');
145
145
  return chromiumPath;
146
146
  } catch {
147
- if (this.logWarn) this.emit('warn', 'yum install failed. Falling back to Puppeteer bundled Chromium.');
147
+ console.log('yum install failed. Falling back to Puppeteer bundled Chromium.');
148
148
  }
149
149
 
150
150
  // --- Fallback Puppeteer Chromium ---
151
151
  chromiumPath = puppeteer.executablePath();
152
- if (this.logWarn) this.emit('warn', `Using bundled Puppeteer Chromium at ${chromiumPath}`);
152
+ console.log(`Using bundled Puppeteer Chromium at ${chromiumPath}`);
153
153
  return chromiumPath;
154
154
 
155
155
  } catch (err) {
156
- if (this.logError) this.emit('error', `Chromium detection/install error: ${err.message}`);
157
- throw err;
156
+ console.log(`Chromium detection/install error: ${err.message}`);
158
157
  }
159
158
  }
160
159