homebridge-melcloud-control 4.3.2-beta.17 → 4.3.2-beta.19

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 +12 -11
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.17",
4
+ "version": "4.3.2-beta.19",
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,11 +126,6 @@ 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
-
134
129
  //emit info
135
130
  this.emit('deviceInfo', indoor.model, outdoor.model, serialNumber, firmwareAppVersion);
136
131
 
@@ -154,6 +149,15 @@ class MelCloudAta extends EventEmitter {
154
149
  const deviceData = devicesData.Devices.find(device => device.DeviceID === this.deviceId);
155
150
  deviceData.Scenes = devicesData.Scenes ?? [];
156
151
 
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
+
157
161
  //web cocket connection
158
162
  if (this.accountType === 'melcloudhome' && !this.connecting && !this.socketConnected) {
159
163
  this.connecting = true;
@@ -234,9 +238,6 @@ class MelCloudAta extends EventEmitter {
234
238
  }
235
239
  }
236
240
 
237
- //update state
238
- await this.updateState(deviceData);
239
-
240
241
  return true;
241
242
  } catch (error) {
242
243
  throw new Error(`Check state error: ${error.message}`);
@@ -384,7 +385,7 @@ class MelCloudAta extends EventEmitter {
384
385
  data: payload
385
386
  });
386
387
 
387
- await this.updateData(deviceData, updateState);
388
+ this.updateData(deviceData, updateState);
388
389
  return true;
389
390
  default:
390
391
  return;
@@ -395,9 +396,9 @@ class MelCloudAta extends EventEmitter {
395
396
  }
396
397
  }
397
398
 
398
- async updateData(deviceData, updateState = true) {
399
+ updateData(deviceData, updateState = true) {
399
400
  this.locks = true;
400
- if (updateState) await this.updateState(deviceData);
401
+ if (updateState) this.emit('deviceState', deviceData);
401
402
 
402
403
  setTimeout(() => {
403
404
  this.locks = false