homebridge-melcloud-control 4.3.0-beta.27 → 4.3.0-beta.29

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "displayName": "MELCloud Control",
3
3
  "name": "homebridge-melcloud-control",
4
- "version": "4.3.0-beta.27",
4
+ "version": "4.3.0-beta.29",
5
5
  "description": "Homebridge plugin to control Mitsubishi Air Conditioner, Heat Pump and Energy Recovery Ventilation.",
6
6
  "license": "MIT",
7
7
  "author": "grzegorz914",
@@ -80,12 +80,13 @@ class MelCloudAta extends EventEmitter {
80
80
  }, delay);
81
81
  };
82
82
 
83
- async connectSocket(deviceData) {
83
+ async connectSocket(deviceData, wsHeaders) {
84
84
  if (this.connecting || this.socketConnected) return;
85
85
 
86
86
  this.connecting = true;
87
+ const url = `${ApiUrlsHome.WebSocketURL}${wsHeaders.hash}`;
87
88
  try {
88
- const socket = new WebSocket(`ApiUrlsHome.WebSocketURL${deviceData.WsHeaders.hash}`, { headers: deviceData.WsHeaders.headers })
89
+ const socket = new WebSocket(url, { headers: wsHeaders.headers })
89
90
  .on('error', (err) => {
90
91
  if (this.logDebug) this.emit('debug', `Socket error: ${err}`);
91
92
  })
@@ -131,9 +132,9 @@ class MelCloudAta extends EventEmitter {
131
132
  }
132
133
  });
133
134
 
134
- } catch (e) {
135
- this.emit('debug', `Socket connection failed: ${e}`);
136
- reconnect();
135
+ } catch (error) {
136
+ this.emit('debug', `Socket connection failed: ${error}`);
137
+ this.reconnect();
137
138
  }
138
139
  }
139
140
 
@@ -159,7 +160,7 @@ class MelCloudAta extends EventEmitter {
159
160
  deviceData.Device.DefaultHeatingSetTemperature = temps?.defaultHeatingSetTemperature ?? 20;
160
161
  deviceData.Device.DefaultCoolingSetTemperature = temps?.defaultCoolingSetTemperature ?? 24;
161
162
 
162
- await this.connectSocket(deviceData);
163
+ await this.connectSocket(deviceData, devicesData.WsHeaders);
163
164
  }
164
165
  if (this.logDebug) this.emit('debug', `Device Data: ${JSON.stringify(deviceData, null, 2)}`);
165
166