homebridge-melcloud-control 4.3.0-beta.51 → 4.3.0-beta.52
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/melcloudata.js +5 -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.3.0-beta.
|
|
4
|
+
"version": "4.3.0-beta.52",
|
|
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/melcloudata.js
CHANGED
|
@@ -29,6 +29,7 @@ class MelCloudAta extends EventEmitter {
|
|
|
29
29
|
this.socket = null;
|
|
30
30
|
this.connecting = false;
|
|
31
31
|
this.socketConnected = false;
|
|
32
|
+
this.heartbeat = null;
|
|
32
33
|
this.reconnectDelay = 1000;
|
|
33
34
|
|
|
34
35
|
//lock flag
|
|
@@ -69,19 +70,6 @@ class MelCloudAta extends EventEmitter {
|
|
|
69
70
|
this.socketConnected = false;
|
|
70
71
|
}
|
|
71
72
|
|
|
72
|
-
reconnect() {
|
|
73
|
-
this.cleanupSocket();
|
|
74
|
-
|
|
75
|
-
const delay = Math.min(this.reconnectDelay, 30000); // max 30s
|
|
76
|
-
if (this.logDebug) this.emit('debug', `Reconnect in ${delay}ms`);
|
|
77
|
-
|
|
78
|
-
setTimeout(() => {
|
|
79
|
-
this.reconnectDelay *= 2;
|
|
80
|
-
this.reconnectDelay = Math.max(1000, this.reconnectDelay);
|
|
81
|
-
this.connectSocket(deviceData);
|
|
82
|
-
}, delay);
|
|
83
|
-
};
|
|
84
|
-
|
|
85
73
|
async checkState() {
|
|
86
74
|
try {
|
|
87
75
|
|
|
@@ -113,10 +101,11 @@ class MelCloudAta extends EventEmitter {
|
|
|
113
101
|
const socket = new WebSocket(url, { headers: devicesData.WsHeaders.headers })
|
|
114
102
|
.on('error', (error) => {
|
|
115
103
|
if (this.logError) this.emit('error', `Socket error: ${error}`);
|
|
104
|
+
socket.close();
|
|
116
105
|
})
|
|
117
106
|
.on('close', () => {
|
|
118
107
|
if (this.logDebug) this.emit('debug', `Socket closed`);
|
|
119
|
-
this.
|
|
108
|
+
this.cleanupSocket();
|
|
120
109
|
})
|
|
121
110
|
.on('open', () => {
|
|
122
111
|
this.socket = socket;
|
|
@@ -175,14 +164,11 @@ class MelCloudAta extends EventEmitter {
|
|
|
175
164
|
return;
|
|
176
165
|
}
|
|
177
166
|
|
|
178
|
-
if (updateDeviceState)
|
|
179
|
-
this.deviceData = deviceData;
|
|
180
|
-
this.emit('deviceState', deviceData);
|
|
181
|
-
}
|
|
167
|
+
if (updateDeviceState) this.emit('deviceState', deviceData);
|
|
182
168
|
});
|
|
183
169
|
} catch (error) {
|
|
184
170
|
if (this.logError) this.emit('error', `Socket connection failed: ${error}`);
|
|
185
|
-
this.
|
|
171
|
+
this.cleanupSocket();
|
|
186
172
|
}
|
|
187
173
|
}
|
|
188
174
|
}
|