homebridge-melcloud-control 4.3.13 → 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 +9 -14
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,13 +233,8 @@ 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
|
-
accountInfo.Info = `Puppeteer returned path, but file does not exist: ${puppeteerPath}`;
|
|
241
|
-
return accountInfo;
|
|
242
|
-
}
|
|
236
|
+
chromiumPath = puppeteerPath;
|
|
237
|
+
if (this.logDebug) this.emit('debug', `Using Puppeteer bundled Chromium at ${chromiumPath}`);
|
|
243
238
|
} else {
|
|
244
239
|
accountInfo.Info = `Puppeteer returned empty Chromium path`;
|
|
245
240
|
return accountInfo;
|
|
@@ -290,7 +285,7 @@ class MelCloudHome extends EventEmitter {
|
|
|
290
285
|
if (url.startsWith(`${ApiUrlsHome.WebSocketURL}`)) {
|
|
291
286
|
const params = new URL(url).searchParams;
|
|
292
287
|
const hash = params.get('hash');
|
|
293
|
-
if (this.logDebug) this.emit('debug', `
|
|
288
|
+
if (this.logDebug) this.emit('debug', `Web socket hash detected: ${hash}`);
|
|
294
289
|
|
|
295
290
|
//web socket connection
|
|
296
291
|
if (!this.connecting && !this.socketConnected) {
|
|
@@ -304,24 +299,24 @@ class MelCloudHome extends EventEmitter {
|
|
|
304
299
|
};
|
|
305
300
|
const webSocket = new WebSocket(`${ApiUrlsHome.WebSocketURL}${hash}`, { headers: headers })
|
|
306
301
|
.on('error', (error) => {
|
|
307
|
-
if (this.logError) this.emit('error', `
|
|
302
|
+
if (this.logError) this.emit('error', `Web socket error: ${error}`);
|
|
308
303
|
try {
|
|
309
304
|
webSocket.close();
|
|
310
305
|
} catch { }
|
|
311
306
|
})
|
|
312
307
|
.on('close', () => {
|
|
313
|
-
if (this.logDebug) this.emit('debug', `
|
|
308
|
+
if (this.logDebug) this.emit('debug', `Web socket closed`);
|
|
314
309
|
this.cleanupSocket();
|
|
315
310
|
})
|
|
316
311
|
.on('open', () => {
|
|
317
312
|
this.socketConnected = true;
|
|
318
313
|
this.connecting = false;
|
|
319
|
-
if (this.logSuccess) this.emit('success', `Socket Connect Success`);
|
|
314
|
+
if (this.logSuccess) this.emit('success', `Web Socket Connect Success`);
|
|
320
315
|
|
|
321
316
|
// heartbeat
|
|
322
317
|
this.heartbeat = setInterval(() => {
|
|
323
318
|
if (webSocket.readyState === webSocket.OPEN) {
|
|
324
|
-
if (this.logDebug) this.emit('debug', `
|
|
319
|
+
if (this.logDebug) this.emit('debug', `Web socket send heartbeat`);
|
|
325
320
|
webSocket.ping();
|
|
326
321
|
}
|
|
327
322
|
}, 30000);
|
|
@@ -337,13 +332,13 @@ class MelCloudHome extends EventEmitter {
|
|
|
337
332
|
this.emit('webSocket', parsedMessage);
|
|
338
333
|
});
|
|
339
334
|
} catch (error) {
|
|
340
|
-
if (this.logError) this.emit('error', `
|
|
335
|
+
if (this.logError) this.emit('error', `Web socket connection failed: ${error}`);
|
|
341
336
|
this.cleanupSocket();
|
|
342
337
|
}
|
|
343
338
|
}
|
|
344
339
|
}
|
|
345
340
|
} catch (error) {
|
|
346
|
-
if (this.logError) this.emit('error', `CDP
|
|
341
|
+
if (this.logError) this.emit('error', `CDP web socket created handler error: ${error.message}`);
|
|
347
342
|
}
|
|
348
343
|
});
|
|
349
344
|
|