homebridge-melcloud-control 3.9.0-beta.9 → 3.9.0

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/src/melcloud.js CHANGED
@@ -43,7 +43,7 @@ class MelCloud extends EventEmitter {
43
43
  };
44
44
 
45
45
  async connect() {
46
- const debug = this.enableDebugMode ? this.emit('debug', `Connecting to MELCloud`) : false;
46
+ if (this.enableDebugMode) this.emit('debug', `Connecting to MELCloud`);
47
47
 
48
48
  try {
49
49
  const axiosInstanceLogin = axios.create({
@@ -75,7 +75,7 @@ class MelCloud extends EventEmitter {
75
75
  MapLongitude: 'removed',
76
76
  MapLatitude: 'removed'
77
77
  };
78
- const debug1 = this.enableDebugMode ? this.emit('debug', `MELCloud Info: ${JSON.stringify(debugData, null, 2)}`) : false;
78
+ if (this.enableDebugMode) this.emit('debug', `MELCloud Info: ${JSON.stringify(debugData, null, 2)}`);
79
79
 
80
80
  if (contextKey === undefined || contextKey === null) {
81
81
  this.emit('warn', `Context key: ${contextKey}, missing`)
@@ -137,10 +137,10 @@ class MelCloud extends EventEmitter {
137
137
  })
138
138
  });
139
139
 
140
- const debug = this.enableDebugMode ? this.emit('debug', `Scanning for devices`) : false;
140
+ if (this.enableDebugMode) this.emit('debug', `Scanning for devices`);
141
141
  const listDevicesData = await axiosInstanceGet(ApiUrls.ListDevices);
142
142
  const buildingsList = listDevicesData.data;
143
- const debug1 = this.enableDebugMode ? this.emit('debug', `Buildings: ${JSON.stringify(buildingsList, null, 2)}`) : false;
143
+ if (this.enableDebugMode) this.emit('debug', `Buildings: ${JSON.stringify(buildingsList, null, 2)}`);
144
144
 
145
145
  if (!buildingsList) {
146
146
  this.emit('warn', `No building found`);
@@ -149,7 +149,7 @@ class MelCloud extends EventEmitter {
149
149
 
150
150
  //save buildings to the file
151
151
  await this.saveData(this.buildingsFile, buildingsList);
152
- const debug2 = this.enableDebugMode ? this.emit('debug', `Buildings list saved`) : false;
152
+ if (this.enableDebugMode) this.emit('debug', `Buildings list saved`);
153
153
 
154
154
  //read buildings structure and get the devices
155
155
  const devices = [];
@@ -175,7 +175,7 @@ class MelCloud extends EventEmitter {
175
175
 
176
176
  //save buildings to the file
177
177
  await this.saveData(this.devicesFile, devices);
178
- const debug3 = this.enableDebugMode ? this.emit('debug', `${devicesCount} devices saved`) : false;
178
+ if (this.enableDebugMode) this.emit('debug', `${devicesCount} devices saved`);
179
179
 
180
180
  return devices;
181
181
  } catch (error) {
@@ -186,7 +186,7 @@ class MelCloud extends EventEmitter {
186
186
  async saveData(path, data) {
187
187
  try {
188
188
  await fsPromises.writeFile(path, JSON.stringify(data, null, 2));
189
- const debug3 = this.enableDebugMode ? this.emit('debug', `Data saved to: ${path}`) : false;
189
+ if (this.enableDebugMode) this.emit('debug', `Data saved to: ${path}`);
190
190
  return true;
191
191
  } catch (error) {
192
192
  throw new Error(`Save data error: ${error}`);
@@ -52,7 +52,7 @@ class MelCloudAta extends EventEmitter {
52
52
  return null;
53
53
  }
54
54
  const deviceData = devicesData.find(device => device.DeviceID === this.deviceId);
55
- const debug = this.enableDebugMode ? this.emit('debug', `Device Data: ${JSON.stringify(deviceData, null, 2)}`) : false;
55
+ if (this.enableDebugMode) this.emit('debug', `Device Data: ${JSON.stringify(deviceData, null, 2)}`);
56
56
 
57
57
  //device info
58
58
  const deviceId = deviceData.DeviceID;
@@ -344,7 +344,7 @@ class MelCloudAta extends EventEmitter {
344
344
  //check state changes
345
345
  const deviceDataHasNotChanged = JSON.stringify(deviceState) === JSON.stringify(this.deviceState);
346
346
  if (deviceDataHasNotChanged) {
347
- const debug = this.enableDebugMode ? this.emit('debug', `Device state not changed`) : false;
347
+ if (this.enableDebugMode) this.emit('debug', `Device state not changed`);
348
348
  return;
349
349
  }
350
350
  this.deviceState = deviceState;
@@ -52,7 +52,7 @@ class MelCloudAtw extends EventEmitter {
52
52
  return null;
53
53
  }
54
54
  const deviceData = devicesData.find(device => device.DeviceID === this.deviceId);
55
- const debug = this.enableDebugMode ? this.emit('debug', `Device Data: ${JSON.stringify(deviceData, null, 2)}`) : false;
55
+ if (this.enableDebugMode) this.emit('debug', `Device Data: ${JSON.stringify(deviceData, null, 2)}`);
56
56
 
57
57
  //device info
58
58
  const deviceId = deviceData.DeviceID;
@@ -408,7 +408,7 @@ class MelCloudAtw extends EventEmitter {
408
408
  //check state changes
409
409
  const deviceDataHasNotChanged = JSON.stringify(deviceState) === JSON.stringify(this.deviceState);
410
410
  if (deviceDataHasNotChanged) {
411
- const debug = this.enableDebugMode ? this.emit('debug', `Device state not changed`) : false;
411
+ if (this.enableDebugMode) this.emit('debug', `Device state not changed`);
412
412
  return;
413
413
  }
414
414
  this.deviceState = deviceState;
@@ -52,7 +52,7 @@ class MelCloudErv extends EventEmitter {
52
52
  return null;
53
53
  }
54
54
  const deviceData = devicesData.find(device => device.DeviceID === this.deviceId);
55
- const debug = this.enableDebugMode ? this.emit('debug', `Device Data: ${JSON.stringify(deviceData, null, 2)}`) : false;
55
+ if (this.enableDebugMode) this.emit('debug', `Device Data: ${JSON.stringify(deviceData, null, 2)}`);
56
56
 
57
57
  //deviceData
58
58
  const deviceId = deviceData.DeviceID;
@@ -332,7 +332,7 @@ class MelCloudErv extends EventEmitter {
332
332
  //check state changes
333
333
  const deviceDataHasNotChanged = JSON.stringify(deviceState) === JSON.stringify(this.deviceState);
334
334
  if (deviceDataHasNotChanged) {
335
- const debug = this.enableDebugMode ? this.emit('debug', `Device state not changed`) : false;
335
+ if (this.enableDebugMode) this.emit('debug', `Device state not changed`);
336
336
  return;
337
337
  }
338
338
  this.deviceState = deviceState;