homebridge-melcloud-control 4.3.2-beta.20 → 4.3.2-beta.22

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 +9 -13
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.2-beta.20",
4
+ "version": "4.3.2-beta.22",
5
5
  "description": "Homebridge plugin to control Mitsubishi Air Conditioner, Heat Pump and Energy Recovery Ventilation.",
6
6
  "license": "MIT",
7
7
  "author": "grzegorz914",
@@ -126,6 +126,11 @@ class MelCloudAta extends EventEmitter {
126
126
  this.emit('mqtt', 'State', deviceData.Device);
127
127
  }
128
128
 
129
+ //check state changes
130
+ const deviceDataNotChanged = JSON.stringify(deviceData) === JSON.stringify(this.deviceData);
131
+ if (deviceDataNotChanged) return;
132
+ this.deviceData = deviceData;
133
+
129
134
  //emit info
130
135
  this.emit('deviceInfo', indoor.model, outdoor.model, serialNumber, firmwareAppVersion);
131
136
 
@@ -149,15 +154,6 @@ class MelCloudAta extends EventEmitter {
149
154
  const deviceData = devicesData.Devices.find(device => device.DeviceID === this.deviceId);
150
155
  deviceData.Scenes = devicesData.Scenes ?? [];
151
156
 
152
- //check state changes
153
- const deviceDataNotChanged = JSON.stringify(deviceData) === JSON.stringify(this.deviceData);
154
- if (!deviceDataNotChanged) {
155
- this.deviceData = deviceData;
156
-
157
- //update state
158
- await this.updateState(deviceData);
159
- }
160
-
161
157
  //web cocket connection
162
158
  if (this.accountType === 'melcloudhome' && !this.connecting && !this.socketConnected) {
163
159
  this.connecting = true;
@@ -230,10 +226,7 @@ class MelCloudAta extends EventEmitter {
230
226
  }
231
227
 
232
228
  //update state
233
- if (updateState) {
234
- this.deviceData = deviceData;
235
- await this.updateState(deviceData);
236
- }
229
+ if (updateState) await this.updateState(deviceData);
237
230
  });
238
231
  } catch (error) {
239
232
  if (this.logError) this.emit('error', `Socket connection failed: ${error}`);
@@ -241,6 +234,9 @@ class MelCloudAta extends EventEmitter {
241
234
  }
242
235
  }
243
236
 
237
+ //update state
238
+ await this.updateState(deviceData);
239
+
244
240
  return true;
245
241
  } catch (error) {
246
242
  throw new Error(`Check state error: ${error.message}`);