homebridge-melcloud-control 4.3.2-beta.11 → 4.3.2-beta.12

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.2-beta.11",
4
+ "version": "4.3.2-beta.12",
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/functions.js CHANGED
@@ -160,13 +160,12 @@ class Functions extends EventEmitter {
160
160
  return v !== undefined && v !== null && !(typeof v === 'number' && Number.isNaN(v));
161
161
  }
162
162
 
163
- convertValue(value) {
164
- let parsedValue = value;
165
- if (value === "True") parsedValue = true;
166
- else if (value === "False") parsedValue = false;
167
- else if (!isNaN(value) && value !== "") parsedValue = Number(value);
163
+ convertValue(v) {
164
+ let parsedValue = v;
165
+ if (v === "True") parsedValue = true;
166
+ else if (v === "False") parsedValue = false;
167
+ else if (!isNaN(v) && v !== "") parsedValue = Number(v);
168
168
  return parsedValue;
169
169
  }
170
-
171
170
  }
172
171
  export default Functions
@@ -149,6 +149,15 @@ class MelCloudAta extends EventEmitter {
149
149
  const deviceData = devicesData.Devices.find(device => device.DeviceID === this.deviceId);
150
150
  deviceData.Scenes = devicesData.Scenes ?? [];
151
151
 
152
+ //check state changes
153
+ const deviceDataChanged = JSON.stringify(deviceData) !== JSON.stringify(this.deviceData);
154
+ if (deviceDataChanged) {
155
+ this.deviceData = deviceData;
156
+
157
+ //update state
158
+ await this.updateState(deviceData);
159
+ }
160
+
152
161
  //web cocket connection
153
162
  if (this.accountType === 'melcloudhome' && !this.connecting && !this.socketConnected) {
154
163
  this.connecting = true;
@@ -229,14 +238,6 @@ class MelCloudAta extends EventEmitter {
229
238
  }
230
239
  }
231
240
 
232
- //check state changes
233
- const deviceDataHasNotChanged = JSON.stringify(deviceData) === JSON.stringify(this.deviceData);
234
- if (deviceDataHasNotChanged) return;
235
- this.deviceData = deviceData;
236
-
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}`);