homebridge-melcloud-control 4.3.0-beta.50 → 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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/melcloudata.js +4 -15
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.50",
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",
@@ -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.reconnect();
108
+ this.cleanupSocket();
120
109
  })
121
110
  .on('open', () => {
122
111
  this.socket = socket;
@@ -179,7 +168,7 @@ class MelCloudAta extends EventEmitter {
179
168
  });
180
169
  } catch (error) {
181
170
  if (this.logError) this.emit('error', `Socket connection failed: ${error}`);
182
- this.reconnect();
171
+ this.cleanupSocket();
183
172
  }
184
173
  }
185
174
  }