homebridge-melcloud-control 4.3.11-beta.29 → 4.3.11-beta.30
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/melcloudhome.js +5 -10
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.11-beta.
|
|
4
|
+
"version": "4.3.11-beta.30",
|
|
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/melcloudhome.js
CHANGED
|
@@ -26,7 +26,6 @@ class MelCloudHome extends EventEmitter {
|
|
|
26
26
|
this.buildingsFile = buildingsFile;
|
|
27
27
|
|
|
28
28
|
this.client = null;
|
|
29
|
-
this.webSocket = null;
|
|
30
29
|
this.connecting = false;
|
|
31
30
|
this.socketConnected = false;
|
|
32
31
|
this.heartbeat = null;
|
|
@@ -74,11 +73,6 @@ class MelCloudHome extends EventEmitter {
|
|
|
74
73
|
this.heartbeat = null;
|
|
75
74
|
}
|
|
76
75
|
|
|
77
|
-
if (this.webSocket) {
|
|
78
|
-
try { this.webSocket.close(); } catch { }
|
|
79
|
-
this.webSocket = null;
|
|
80
|
-
}
|
|
81
|
-
|
|
82
76
|
this.socketConnected = false;
|
|
83
77
|
}
|
|
84
78
|
|
|
@@ -309,23 +303,24 @@ class MelCloudHome extends EventEmitter {
|
|
|
309
303
|
const webSocket = new WebSocket(`${ApiUrlsHome.WebSocketURL}${hash}`, { headers: headers })
|
|
310
304
|
.on('error', (error) => {
|
|
311
305
|
if (this.logError) this.emit('error', `Socket error: ${error}`);
|
|
312
|
-
|
|
306
|
+
try {
|
|
307
|
+
webSocket.close();
|
|
308
|
+
} catch { }
|
|
313
309
|
})
|
|
314
310
|
.on('close', () => {
|
|
315
311
|
if (this.logDebug) this.emit('debug', `Socket closed`);
|
|
316
312
|
this.cleanupSocket();
|
|
317
313
|
})
|
|
318
314
|
.on('open', () => {
|
|
319
|
-
this.webSocket = webSocket;
|
|
320
315
|
this.socketConnected = true;
|
|
321
316
|
this.connecting = false;
|
|
322
317
|
if (this.logSuccess) this.emit('success', `Socket Connect Success`);
|
|
323
318
|
|
|
324
319
|
// heartbeat
|
|
325
320
|
this.heartbeat = setInterval(() => {
|
|
326
|
-
if (
|
|
321
|
+
if (webSocket.readyState === webSocket.OPEN) {
|
|
327
322
|
if (this.logDebug) this.emit('debug', `Socket send heartbeat`);
|
|
328
|
-
|
|
323
|
+
webSocket.ping();
|
|
329
324
|
}
|
|
330
325
|
}, 30000);
|
|
331
326
|
})
|