homebridge-melcloud-control 4.3.12 → 4.3.14
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 +30 -4
- package/src/melcloudhome.js +13 -20
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"displayName": "MELCloud Control",
|
|
3
3
|
"name": "homebridge-melcloud-control",
|
|
4
|
-
"version": "4.3.
|
|
4
|
+
"version": "4.3.14",
|
|
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
|
@@ -92,19 +92,45 @@ class Functions extends EventEmitter {
|
|
|
92
92
|
}
|
|
93
93
|
}
|
|
94
94
|
|
|
95
|
+
// ARM
|
|
95
96
|
// ARM
|
|
96
97
|
if (arch.startsWith('arm') || arch.startsWith('aarch')) {
|
|
98
|
+
|
|
99
|
+
const candidates = [
|
|
100
|
+
'/usr/bin/chromium-browser',
|
|
101
|
+
'/usr/bin/chromium'
|
|
102
|
+
];
|
|
103
|
+
|
|
104
|
+
// sprawdzam czy któryś istnieje
|
|
105
|
+
for (const path of candidates) {
|
|
106
|
+
try {
|
|
107
|
+
await access(path, fs.constants.X_OK);
|
|
108
|
+
chromiumPath = path;
|
|
109
|
+
return chromiumPath;
|
|
110
|
+
} catch { }
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
// instalacja Chromium
|
|
97
114
|
try {
|
|
98
|
-
await
|
|
99
|
-
return chromiumPath;
|
|
115
|
+
await execPromise('sudo apt-get update -y && sudo apt-get install -y chromium-browser chromium-codecs-ffmpeg');
|
|
100
116
|
} catch {
|
|
101
117
|
try {
|
|
102
|
-
await execPromise('sudo apt-get
|
|
103
|
-
return chromiumPath;
|
|
118
|
+
await execPromise('sudo apt-get install -y chromium');
|
|
104
119
|
} catch {
|
|
105
120
|
return null;
|
|
106
121
|
}
|
|
107
122
|
}
|
|
123
|
+
|
|
124
|
+
// po instalacji ponownie sprawdzam obie nazwy
|
|
125
|
+
for (const path of candidates) {
|
|
126
|
+
try {
|
|
127
|
+
await access(path, fs.constants.X_OK);
|
|
128
|
+
chromiumPath = path;
|
|
129
|
+
return chromiumPath;
|
|
130
|
+
} catch { }
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
return null;
|
|
108
134
|
}
|
|
109
135
|
|
|
110
136
|
// Linux x64
|
package/src/melcloudhome.js
CHANGED
|
@@ -233,25 +233,18 @@ class MelCloudHome extends EventEmitter {
|
|
|
233
233
|
try {
|
|
234
234
|
const puppeteerPath = puppeteer.executablePath();
|
|
235
235
|
if (puppeteerPath && puppeteerPath.length > 0) {
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
if (this.logDebug) this.emit('debug', `Using Puppeteer bundled Chromium at ${chromiumPath}`);
|
|
239
|
-
} else {
|
|
240
|
-
if (this.logDebug) this.emit('debug', `Puppeteer returned path, but file does not exist: ${puppeteerPath}`);
|
|
241
|
-
}
|
|
236
|
+
chromiumPath = puppeteerPath;
|
|
237
|
+
if (this.logDebug) this.emit('debug', `Using Puppeteer bundled Chromium at ${chromiumPath}`);
|
|
242
238
|
} else {
|
|
243
|
-
|
|
239
|
+
accountInfo.Info = `Puppeteer returned empty Chromium path`;
|
|
240
|
+
return accountInfo;
|
|
244
241
|
}
|
|
245
242
|
} catch (error) {
|
|
246
|
-
|
|
243
|
+
accountInfo.Info = `Failed to get Puppeteer Chromium path: ${error.message}`;
|
|
244
|
+
return accountInfo;
|
|
247
245
|
}
|
|
248
246
|
}
|
|
249
247
|
|
|
250
|
-
if (!chromiumPath) {
|
|
251
|
-
accountInfo.Info = 'Chromium not found on Your device, please install it manually and try again';
|
|
252
|
-
return accountInfo;
|
|
253
|
-
}
|
|
254
|
-
|
|
255
248
|
// Verify executable works
|
|
256
249
|
try {
|
|
257
250
|
const { stdout } = await execPromise(`"${chromiumPath}" --version`);
|
|
@@ -292,7 +285,7 @@ class MelCloudHome extends EventEmitter {
|
|
|
292
285
|
if (url.startsWith(`${ApiUrlsHome.WebSocketURL}`)) {
|
|
293
286
|
const params = new URL(url).searchParams;
|
|
294
287
|
const hash = params.get('hash');
|
|
295
|
-
if (this.logDebug) this.emit('debug', `
|
|
288
|
+
if (this.logDebug) this.emit('debug', `Web socket hash detected: ${hash}`);
|
|
296
289
|
|
|
297
290
|
//web socket connection
|
|
298
291
|
if (!this.connecting && !this.socketConnected) {
|
|
@@ -306,24 +299,24 @@ class MelCloudHome extends EventEmitter {
|
|
|
306
299
|
};
|
|
307
300
|
const webSocket = new WebSocket(`${ApiUrlsHome.WebSocketURL}${hash}`, { headers: headers })
|
|
308
301
|
.on('error', (error) => {
|
|
309
|
-
if (this.logError) this.emit('error', `
|
|
302
|
+
if (this.logError) this.emit('error', `Web socket error: ${error}`);
|
|
310
303
|
try {
|
|
311
304
|
webSocket.close();
|
|
312
305
|
} catch { }
|
|
313
306
|
})
|
|
314
307
|
.on('close', () => {
|
|
315
|
-
if (this.logDebug) this.emit('debug', `
|
|
308
|
+
if (this.logDebug) this.emit('debug', `Web socket closed`);
|
|
316
309
|
this.cleanupSocket();
|
|
317
310
|
})
|
|
318
311
|
.on('open', () => {
|
|
319
312
|
this.socketConnected = true;
|
|
320
313
|
this.connecting = false;
|
|
321
|
-
if (this.logSuccess) this.emit('success', `Socket Connect Success`);
|
|
314
|
+
if (this.logSuccess) this.emit('success', `Web Socket Connect Success`);
|
|
322
315
|
|
|
323
316
|
// heartbeat
|
|
324
317
|
this.heartbeat = setInterval(() => {
|
|
325
318
|
if (webSocket.readyState === webSocket.OPEN) {
|
|
326
|
-
if (this.logDebug) this.emit('debug', `
|
|
319
|
+
if (this.logDebug) this.emit('debug', `Web socket send heartbeat`);
|
|
327
320
|
webSocket.ping();
|
|
328
321
|
}
|
|
329
322
|
}, 30000);
|
|
@@ -339,13 +332,13 @@ class MelCloudHome extends EventEmitter {
|
|
|
339
332
|
this.emit('webSocket', parsedMessage);
|
|
340
333
|
});
|
|
341
334
|
} catch (error) {
|
|
342
|
-
if (this.logError) this.emit('error', `
|
|
335
|
+
if (this.logError) this.emit('error', `Web socket connection failed: ${error}`);
|
|
343
336
|
this.cleanupSocket();
|
|
344
337
|
}
|
|
345
338
|
}
|
|
346
339
|
}
|
|
347
340
|
} catch (error) {
|
|
348
|
-
if (this.logError) this.emit('error', `CDP
|
|
341
|
+
if (this.logError) this.emit('error', `CDP web socket created handler error: ${error.message}`);
|
|
349
342
|
}
|
|
350
343
|
});
|
|
351
344
|
|