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

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/deviceata.js CHANGED
@@ -279,14 +279,14 @@ class DeviceAta extends EventEmitter {
279
279
  const coolDryFanMode = [this.accessory.operationMode, 3, modelSupportsDry ? 2 : 3, 7][this.coolDryFanMode]; //NONE, COOL - 3, DRY - 2, FAN - 7
280
280
 
281
281
  //accessory
282
- const debug = this.enableDebugMode ? this.emit('debug', `Prepare accessory`) : false;
282
+ if (this.enableDebugMode) this.emit('debug', `Prepare accessory`);
283
283
  const accessoryName = deviceName;
284
284
  const accessoryUUID = AccessoryUUID.generate(accountName + deviceId.toString());
285
285
  const accessoryCategory = [Categories.OTHER, Categories.AIR_HEATER, Categories.THERMOSTAT][this.displayType];
286
286
  const accessory = new Accessory(accessoryName, accessoryUUID, accessoryCategory);
287
287
 
288
288
  //information service
289
- const debug1 = this.enableDebugMode ? this.emit('debug', `Prepare information service`) : false;
289
+ if (this.enableDebugMode) this.emit('debug', `Prepare information service`);
290
290
  accessory.getService(Service.AccessoryInformation)
291
291
  .setCharacteristic(Characteristic.Manufacturer, this.manufacturer)
292
292
  .setCharacteristic(Characteristic.Model, this.model)
@@ -298,7 +298,7 @@ class DeviceAta extends EventEmitter {
298
298
  const serviceName = `${deviceTypeText} ${accessoryName}`;
299
299
  switch (this.displayMode) {
300
300
  case 1: //Heater Cooler
301
- const debug = this.enableDebugMode ? this.emit('debug', `Prepare heater/cooler service`) : false;
301
+ if (this.enableDebugMode) this.emit('debug', `Prepare heater/cooler service`);
302
302
  this.melCloudService = new Service.HeaterCooler(serviceName, `HeaterCooler ${deviceId}`);
303
303
  this.melCloudService.setPrimaryService(true);
304
304
  this.melCloudService.getCharacteristic(Characteristic.Active)
@@ -311,7 +311,7 @@ class DeviceAta extends EventEmitter {
311
311
  deviceData.Device.Power = [false, true][state];
312
312
  deviceData.Device.EffectiveFlags = AirConditioner.EffectiveFlags.Power;
313
313
  await this.melCloudAta.send(deviceData, this.displayMode);
314
- const info = this.disableLogInfo ? false : this.emit('info', `Set power: ${state ? 'ON' : 'OFF'}`);
314
+ if (!this.disableLogInfo) this.emit('info', `Set power: ${state ? 'ON' : 'OFF'}`);
315
315
  } catch (error) {
316
316
  this.emit('warn', `Set power error: ${error}`);
317
317
  };
@@ -348,7 +348,7 @@ class DeviceAta extends EventEmitter {
348
348
  deviceData.Device.EffectiveFlags = AirConditioner.EffectiveFlags.OperationModeSetTemperature;
349
349
  await this.melCloudAta.send(deviceData, this.displayMode);
350
350
  const operationModeText = AirConditioner.DriveMode[deviceData.Device.OperationMode];
351
- const info = this.disableLogInfo ? false : this.emit('info', `Set operation mode: ${operationModeText}`);
351
+ if (!this.disableLogInfo) this.emit('info', `Set operation mode: ${operationModeText}`);
352
352
  } catch (error) {
353
353
  this.emit('warn', `Set operation mode error: ${error}`);
354
354
  };
@@ -396,7 +396,7 @@ class DeviceAta extends EventEmitter {
396
396
  };
397
397
  deviceData.Device.EffectiveFlags = AirConditioner.EffectiveFlags.SetFanSpeed;
398
398
  await this.melCloudAta.send(deviceData, this.displayMode);
399
- const info = this.disableLogInfo ? false : this.emit('info', `Set fan speed mode: ${AirConditioner.FanSpeed[fanSpeedModeText]}`);
399
+ if (!this.disableLogInfo) this.emit('info', `Set fan speed mode: ${AirConditioner.FanSpeed[fanSpeedModeText]}`);
400
400
  } catch (error) {
401
401
  this.emit('warn', `Set fan speed mode error: ${error}`);
402
402
  };
@@ -415,7 +415,7 @@ class DeviceAta extends EventEmitter {
415
415
  deviceData.Device.VaneVertical = value ? 7 : 0;
416
416
  deviceData.Device.EffectiveFlags = AirConditioner.EffectiveFlags.VaneVerticalVaneHorizontal;
417
417
  await this.melCloudAta.send(deviceData, this.displayMode);
418
- const info = this.disableLogInfo ? false : this.emit('info', `Set air direction mode: ${AirConditioner.AirDirection[value]}`);
418
+ if (!this.disableLogInfo) this.emit('info', `Set air direction mode: ${AirConditioner.AirDirection[value]}`);
419
419
  } catch (error) {
420
420
  this.emit('warn', `Set vane swing mode error: ${error}`);
421
421
  };
@@ -436,7 +436,7 @@ class DeviceAta extends EventEmitter {
436
436
  deviceData.Device.DefaultCoolingSetTemperature = value;
437
437
  deviceData.Device.EffectiveFlags = AirConditioner.EffectiveFlags.SetTemperature;
438
438
  await this.melCloudAta.send(deviceData, this.displayMode);
439
- const info = this.disableLogInfo ? false : this.emit('info', `Set cooling threshold temperature: ${value}${this.accessory.temperatureUnit}`);
439
+ if (!this.disableLogInfo) this.emit('info', `Set cooling threshold temperature: ${value}${this.accessory.temperatureUnit}`);
440
440
  } catch (error) {
441
441
  this.emit('warn', `Set cooling threshold temperature error: ${error}`);
442
442
  };
@@ -457,7 +457,7 @@ class DeviceAta extends EventEmitter {
457
457
  deviceData.Device.DefaultHeatingSetTemperature = value;
458
458
  deviceData.Device.EffectiveFlags = AirConditioner.EffectiveFlags.SetTemperature;
459
459
  await this.melCloudAta.send(deviceData, this.displayMode);
460
- const info = this.disableLogInfo ? false : this.emit('info', `Set heating threshold temperature: ${value}${this.accessory.temperatureUnit}`);
460
+ if (!this.disableLogInfo) this.emit('info', `Set heating threshold temperature: ${value}${this.accessory.temperatureUnit}`);
461
461
  } catch (error) {
462
462
  this.emit('warn', `Set heating threshold temperature error: ${error}`);
463
463
  };
@@ -476,7 +476,7 @@ class DeviceAta extends EventEmitter {
476
476
  deviceData.Device.ProhibitPower = value;
477
477
  deviceData.Device.EffectiveFlags = AirConditioner.EffectiveFlags.Prohibit;
478
478
  await this.melCloudAta.send(deviceData, this.displayMode);
479
- const info = this.disableLogInfo ? false : this.emit('info', `Set local physical controls: ${value ? 'LOCK' : 'UNLOCK'}`);
479
+ if (!this.disableLogInfo) this.emit('info', `Set local physical controls: ${value ? 'LOCK' : 'UNLOCK'}`);
480
480
  } catch (error) {
481
481
  this.emit('warn', `Set lock physical controls error: ${error}`);
482
482
  };
@@ -491,7 +491,7 @@ class DeviceAta extends EventEmitter {
491
491
  value = [false, true][value];
492
492
  this.accessory.useFahrenheit = value;
493
493
  this.emit('melCloud', 'UseFahrenheit', value);
494
- const info = this.disableLogInfo ? false : this.emit('info', `Set temperature display unit: ${TemperatureDisplayUnits[value]}`);
494
+ if (!this.disableLogInfo) this.emit('info', `Set temperature display unit: ${TemperatureDisplayUnits[value]}`);
495
495
  } catch (error) {
496
496
  this.emit('warn', `Set temperature display unit error: ${error}`);
497
497
  };
@@ -499,7 +499,7 @@ class DeviceAta extends EventEmitter {
499
499
  accessory.addService(this.melCloudService);
500
500
  break;
501
501
  case 2: //Thermostat
502
- const debug1 = this.enableDebugMode ? this.emit('debug', `Prepare thermostat service`) : false;
502
+ if (this.enableDebugMode) this.emit('debug', `Prepare thermostat service`);
503
503
  this.melCloudService = new Service.Thermostat(serviceName, `Thermostat ${deviceId}`);
504
504
  this.melCloudService.setPrimaryService(true);
505
505
  this.melCloudService.getCharacteristic(Characteristic.CurrentHeatingCoolingState)
@@ -543,7 +543,7 @@ class DeviceAta extends EventEmitter {
543
543
 
544
544
  await this.melCloudAta.send(deviceData, this.displayMode);
545
545
  const operationModeText = AirConditioner.DriveMode[deviceData.Device.OperationMode];
546
- const info = this.disableLogInfo ? false : this.emit('info', `Set operation mode: ${operationModeText}`);
546
+ if (!this.disableLogInfo) this.emit('info', `Set operation mode: ${operationModeText}`);
547
547
  } catch (error) {
548
548
  this.emit('warn', `Set operation mode error: ${error}`);
549
549
  };
@@ -568,7 +568,7 @@ class DeviceAta extends EventEmitter {
568
568
  deviceData.Device.SetTemperature = value;
569
569
  deviceData.Device.EffectiveFlags = AirConditioner.EffectiveFlags.SetTemperature;
570
570
  await this.melCloudAta.send(deviceData, this.displayMode);
571
- const info = this.disableLogInfo ? false : this.emit('info', `Set temperature: ${value}${this.accessory.temperatureUnit}`);
571
+ if (!this.disableLogInfo) this.emit('info', `Set temperature: ${value}${this.accessory.temperatureUnit}`);
572
572
  } catch (error) {
573
573
  this.emit('warn', `Set temperature error: ${error}`);
574
574
  };
@@ -583,7 +583,7 @@ class DeviceAta extends EventEmitter {
583
583
  value = [false, true][value];
584
584
  this.accessory.useFahrenheit = value;
585
585
  this.emit('melCloud', 'UseFahrenheit', value);
586
- const info = this.disableLogInfo ? false : this.emit('info', `Set temperature display unit: ${TemperatureDisplayUnits[value]}`);
586
+ if (!this.disableLogInfo) this.emit('info', `Set temperature display unit: ${TemperatureDisplayUnits[value]}`);
587
587
  } catch (error) {
588
588
  this.emit('warn', `Set temperature display unit error: ${error}`);
589
589
  };
@@ -594,7 +594,7 @@ class DeviceAta extends EventEmitter {
594
594
 
595
595
  //temperature sensor services
596
596
  if (this.temperatureSensor && this.accessory.roomTemperature !== null) {
597
- const debug = this.enableDebugMode ? this.emit('debug', `Prepare room temperature sensor service`) : false;
597
+ if (this.enableDebugMode) this.emit('debug', `Prepare room temperature sensor service`);
598
598
  this.roomTemperatureSensorService = new Service.TemperatureSensor(`${serviceName} Room`, `Room Temperature Sensor ${deviceId}`);
599
599
  this.roomTemperatureSensorService.addOptionalCharacteristic(Characteristic.ConfiguredName);
600
600
  this.roomTemperatureSensorService.setCharacteristic(Characteristic.ConfiguredName, `${accessoryName} Room`);
@@ -612,7 +612,7 @@ class DeviceAta extends EventEmitter {
612
612
  };
613
613
 
614
614
  if (this.temperatureSensorOutdoor && hasOutdoorTemperature && this.accessory.outdoorTemperature !== null) {
615
- const debug = this.enableDebugMode ? this.emit('debug', `Prepare outdoor temperature sensor service`) : false;
615
+ if (this.enableDebugMode) this.emit('debug', `Prepare outdoor temperature sensor service`);
616
616
  this.outdoorTemperatureSensorService = new Service.TemperatureSensor(`${serviceName} Outdoor`, `Outdoor Temperature Sensor ${deviceId}`);
617
617
  this.outdoorTemperatureSensorService.addOptionalCharacteristic(Characteristic.ConfiguredName);
618
618
  this.outdoorTemperatureSensorService.setCharacteristic(Characteristic.ConfiguredName, `${accessoryName} Outdoor`);
@@ -631,7 +631,7 @@ class DeviceAta extends EventEmitter {
631
631
 
632
632
  //presets services
633
633
  if (this.presetsConfiguredCount > 0) {
634
- const debug = this.enableDebugMode ? this.emit('debug', `Prepare presets services`) : false;
634
+ if (this.enableDebugMode) this.emit('debug', `Prepare presets services`);
635
635
  this.presetsServices = [];
636
636
  this.presetsConfigured.forEach((preset, i) => {
637
637
  const presetData = presetsOnServer.find(p => p.ID === preset.Id);
@@ -678,7 +678,7 @@ class DeviceAta extends EventEmitter {
678
678
  };
679
679
 
680
680
  await this.melCloudAta.send(deviceData, this.displayMode);
681
- const info = this.disableLogInfo ? false : this.emit('info', `${state ? 'Set:' : 'Unset:'} ${name}`);
681
+ if (!this.disableLogInfo) this.emit('info', `${state ? 'Set:' : 'Unset:'} ${name}`);
682
682
  } catch (error) {
683
683
  this.emit('warn', `Set preset error: ${error}`);
684
684
  };
@@ -690,7 +690,7 @@ class DeviceAta extends EventEmitter {
690
690
 
691
691
  //buttons services
692
692
  if (this.buttonsConfiguredCount > 0) {
693
- const debug = this.enableDebugMode ? this.emit('debug', `Prepare buttons/sensors services`) : false;
693
+ if (this.enableDebugMode) this.emit('debug', `Prepare buttons/sensors services`);
694
694
  this.buttonsServices = [];
695
695
  this.buttonsConfigured.forEach((button, i) => {
696
696
  //get button mode
@@ -918,7 +918,7 @@ class DeviceAta extends EventEmitter {
918
918
  };
919
919
 
920
920
  await this.melCloudAta.send(deviceData, this.displayMode);
921
- const info = this.disableLogInfo ? false : this.emit('info', `${state ? `Set: ${name}` : `Unset: ${name}, Set: ${button.previousValue}`}`);
921
+ if (!this.disableLogInfo) this.emit('info', `${state ? `Set: ${name}` : `Unset: ${name}, Set: ${button.previousValue}`}`);
922
922
  } catch (error) {
923
923
  this.emit('warn', `Set button error: ${error}`);
924
924
  };
package/src/deviceatw.js CHANGED
@@ -305,14 +305,14 @@ class DeviceAtw extends EventEmitter {
305
305
  const caseZone2Sensor = this.accessory.caseZone2Sensor;
306
306
 
307
307
  //accessory
308
- const debug = this.enableDebugMode ? this.emit('debug', `Prepare accessory`) : false;
308
+ if (this.enableDebugMode) this.emit('debug', `Prepare accessory`);
309
309
  const accessoryName = deviceName;
310
310
  const accessoryUUID = AccessoryUUID.generate(accountName + deviceId.toString());
311
311
  const accessoryCategory = [Categories.OTHER, Categories.AIR_HEATER, Categories.THERMOSTAT][this.displayType];
312
312
  const accessory = new Accessory(accessoryName, accessoryUUID, accessoryCategory);
313
313
 
314
314
  //information service
315
- const debug1 = this.enableDebugMode ? this.emit('debug', `Prepare information service`) : false;
315
+ if (this.enableDebugMode) this.emit('debug', `Prepare information service`);
316
316
  accessory.getService(Service.AccessoryInformation)
317
317
  .setCharacteristic(Characteristic.Manufacturer, this.manufacturer)
318
318
  .setCharacteristic(Characteristic.Model, this.model)
@@ -328,7 +328,7 @@ class DeviceAtw extends EventEmitter {
328
328
  const serviceName = `${deviceTypeText} ${accessoryName}: ${zoneName}`;
329
329
  switch (this.displayMode) {
330
330
  case 1: //Heater Cooler
331
- const debug = this.enableDebugMode ? this.emit('debug', `Prepare heather/cooler ${zoneName} service`) : false;
331
+ if (this.enableDebugMode) this.emit('debug', `Prepare heather/cooler ${zoneName} service`);
332
332
  const melCloudService = new Service.HeaterCooler(serviceName, `HeaterCooler ${deviceId} ${i}`);
333
333
  melCloudService.setPrimaryService(true);
334
334
  melCloudService.getCharacteristic(Characteristic.Active)
@@ -343,7 +343,7 @@ class DeviceAtw extends EventEmitter {
343
343
  deviceData.Device.Power = [false, true][state];
344
344
  deviceData.Device.EffectiveFlags = HeatPump.EffectiveFlags.Power;
345
345
  await this.melCloudAtw.send(deviceData);
346
- const info = this.disableLogInfo ? false : this.emit('info', `${zoneName}, Set power: ${state ? 'ON' : 'OFF'}`);
346
+ if (!this.disableLogInfo) this.emit('info', `${zoneName}, Set power: ${state ? 'ON' : 'OFF'}`);
347
347
  break;
348
348
  };
349
349
  } catch (error) {
@@ -442,7 +442,7 @@ class DeviceAtw extends EventEmitter {
442
442
  };
443
443
 
444
444
  await this.melCloudAtw.send(deviceData);
445
- const info = this.disableLogInfo ? false : this.emit('info', `${zoneName}, Set operation mode: ${operationModeText}`);
445
+ if (!this.disableLogInfo) this.emit('info', `${zoneName}, Set operation mode: ${operationModeText}`);
446
446
  } catch (error) {
447
447
  this.emit('warn', `${zoneName}, Set operation mode error: ${error}`);
448
448
  };
@@ -615,7 +615,7 @@ class DeviceAtw extends EventEmitter {
615
615
  };
616
616
 
617
617
  await this.melCloudAtw.send(deviceData);
618
- const info = this.disableLogInfo ? false : this.emit('info', `${zoneName}, Set lock physical controls: ${value ? 'LOCK' : 'UNLOCK'}`);
618
+ if (!this.disableLogInfo) this.emit('info', `${zoneName}, Set lock physical controls: ${value ? 'LOCK' : 'UNLOCK'}`);
619
619
  } catch (error) {
620
620
  this.emit('warn', `${zoneName}, Set lock physical controls error: ${error}`);
621
621
  };
@@ -630,7 +630,7 @@ class DeviceAtw extends EventEmitter {
630
630
  value = [false, true][value];
631
631
  this.accessory.useFahrenheit = value;
632
632
  this.emit('melCloud', 'UseFahrenheit', value);
633
- const info = this.disableLogInfo ? false : this.emit('info', `Set temperature display unit: ${TemperatureDisplayUnits[value]}`);
633
+ if (!this.disableLogInfo) this.emit('info', `Set temperature display unit: ${TemperatureDisplayUnits[value]}`);
634
634
  } catch (error) {
635
635
  this.emit('warn', `Set temperature display unit error: ${error}`);
636
636
  };
@@ -639,7 +639,7 @@ class DeviceAtw extends EventEmitter {
639
639
  accessory.addService(melCloudService);
640
640
  break;
641
641
  case 2: //Thermostat
642
- const debug3 = this.enableDebugMode ? this.emit('debug', `Prepare thermostat ${zoneName} service`) : false;
642
+ if (this.enableDebugMode) this.emit('debug', `Prepare thermostat ${zoneName} service`);
643
643
  const melCloudServiceT = new Service.Thermostat(serviceName, `Thermostat ${deviceId} ${i}`);
644
644
  melCloudServiceT.setPrimaryService(true);
645
645
  melCloudServiceT.getCharacteristic(Characteristic.CurrentHeatingCoolingState)
@@ -750,7 +750,7 @@ class DeviceAtw extends EventEmitter {
750
750
  };
751
751
 
752
752
  await this.melCloudAtw.send(deviceData);
753
- const info = this.disableLogInfo ? false : this.emit('info', `${zoneName}, Set operation mode: ${operationModeText}`);
753
+ if (!this.disableLogInfo) this.emit('info', `${zoneName}, Set operation mode: ${operationModeText}`);
754
754
  } catch (error) {
755
755
  this.emit('warn', `${zoneName}, Set operation mode error: ${error}`);
756
756
  };
@@ -812,7 +812,7 @@ class DeviceAtw extends EventEmitter {
812
812
  value = [false, true][value];
813
813
  this.accessory.useFahrenheit = value;
814
814
  this.emit('melCloud', 'UseFahrenheit', value);
815
- const info = this.disableLogInfo ? false : this.emit('info', `Set temperature display unit: ${TemperatureDisplayUnits[value]}`);
815
+ if (!this.disableLogInfo) this.emit('info', `Set temperature display unit: ${TemperatureDisplayUnits[value]}`);
816
816
  } catch (error) {
817
817
  this.emit('warn', `Set temperature display unit error: ${error}`);
818
818
  };
@@ -832,7 +832,7 @@ class DeviceAtw extends EventEmitter {
832
832
  switch (i) {
833
833
  case caseHeatPumpSensor: //Heat Pump
834
834
  if (zone.roomTemperature !== null) {
835
- const debug = this.enableDebugMode ? this.emit('debug', `${zoneName}, Prepare temperature sensor service`) : false;
835
+ if (this.enableDebugMode) this.emit('debug', `${zoneName}, Prepare temperature sensor service`);
836
836
  this.roomTemperatureSensorService = new Service.TemperatureSensor(`${serviceName}`, `${zoneName} Temperature Sensor ${deviceId} ${i}`);
837
837
  this.roomTemperatureSensorService.addOptionalCharacteristic(Characteristic.ConfiguredName);
838
838
  this.roomTemperatureSensorService.setCharacteristic(Characteristic.ConfiguredName, `${accessoryName} ${zoneName}`);
@@ -850,7 +850,7 @@ class DeviceAtw extends EventEmitter {
850
850
  };
851
851
 
852
852
  if (zone.flowTemperature !== null) {
853
- const debug = this.enableDebugMode ? this.emit('debug', `Prepare flow temperature sensor service`) : false;
853
+ if (this.enableDebugMode) this.emit('debug', `Prepare flow temperature sensor service`);
854
854
  this.flowTemperatureSensorService = new Service.TemperatureSensor(`${serviceName} Flow`, `${zoneName} Temperature Sensor Flow ${deviceId} ${i}`);
855
855
  this.flowTemperatureSensorService.addOptionalCharacteristic(Characteristic.ConfiguredName);
856
856
  this.flowTemperatureSensorService.setCharacteristic(Characteristic.ConfiguredName, `${accessoryName} ${zoneName} Flow`);
@@ -869,7 +869,7 @@ class DeviceAtw extends EventEmitter {
869
869
  };
870
870
 
871
871
  if (zone.returnTemperature !== null) {
872
- const debug1 = this.enableDebugMode ? this.emit('debug', `Prepare return temperature sensor service`) : false;
872
+ if (this.enableDebugMode) this.emit('debug', `Prepare return temperature sensor service`);
873
873
  this.returnTemperatureSensorService = new Service.TemperatureSensor(`${serviceName} Return`, `${zoneName} Temperature Sensor Return ${deviceId} ${i}`);
874
874
  this.returnTemperatureSensorService.addOptionalCharacteristic(Characteristic.ConfiguredName);
875
875
  this.returnTemperatureSensorService.setCharacteristic(Characteristic.ConfiguredName, `${accessoryName} ${zoneName} Return`);
@@ -888,7 +888,7 @@ class DeviceAtw extends EventEmitter {
888
888
  break;
889
889
  case caseZone1Sensor: //Zone 1
890
890
  if (zone.roomTemperature !== null) {
891
- const debug = this.enableDebugMode ? this.emit('debug', `${zoneName}, Prepare temperature sensor service`) : false;
891
+ if (this.enableDebugMode) this.emit('debug', `${zoneName}, Prepare temperature sensor service`);
892
892
  this.roomTemperatureZone1SensorService = new Service.TemperatureSensor(`${serviceName}`, `${zoneName} Temperature Sensor ${deviceId} ${i}`);
893
893
  this.roomTemperatureZone1SensorService.addOptionalCharacteristic(Characteristic.ConfiguredName);
894
894
  this.roomTemperatureZone1SensorService.setCharacteristic(Characteristic.ConfiguredName, `${accessoryName} ${zoneName}`);
@@ -906,7 +906,7 @@ class DeviceAtw extends EventEmitter {
906
906
  };
907
907
 
908
908
  if (zone.flowTemperature !== null) {
909
- const debug2 = this.enableDebugMode ? this.emit('debug', `Prepare flow temperature zone 1 sensor service`) : false;
909
+ if (this.enableDebugMode) this.emit('debug', `Prepare flow temperature zone 1 sensor service`);
910
910
  this.flowTemperatureZone1SensorService = new Service.TemperatureSensor(`${serviceName} Flow`, `${zoneName} Temperature Sensor Flow ${deviceId} ${i}`);
911
911
  this.flowTemperatureZone1SensorService.addOptionalCharacteristic(Characteristic.ConfiguredName);
912
912
  this.flowTemperatureZone1SensorService.setCharacteristic(Characteristic.ConfiguredName, `${accessoryName} ${zoneName} Flow`);
@@ -924,7 +924,7 @@ class DeviceAtw extends EventEmitter {
924
924
  };
925
925
 
926
926
  if (zone.returnTemperature !== null) {
927
- const debug3 = this.enableDebugMode ? this.emit('debug', `Prepare return temperature zone 1 sensor service`) : false;
927
+ if (this.enableDebugMode) this.emit('debug', `Prepare return temperature zone 1 sensor service`);
928
928
  this.returnTemperatureZone1SensorService = new Service.TemperatureSensor(`${serviceName} Return`, `${zoneName} Temperature Sensor Return ${deviceId} ${i}`);
929
929
  this.returnTemperatureZone1SensorService.addOptionalCharacteristic(Characteristic.ConfiguredName);
930
930
  this.returnTemperatureZone1SensorService.setCharacteristic(Characteristic.ConfiguredName, `${accessoryName} ${zoneName} Return`);
@@ -943,7 +943,7 @@ class DeviceAtw extends EventEmitter {
943
943
  break;
944
944
  case caseHotWaterSensor: //Hot Water
945
945
  if (zone.roomTemperature !== null) {
946
- const debug = this.enableDebugMode ? this.emit('debug', `${zoneName}, Prepare temperature sensor service`) : false;
946
+ if (this.enableDebugMode) this.emit('debug', `${zoneName}, Prepare temperature sensor service`);
947
947
  this.roomTemperatureWaterTankSensorService = new Service.TemperatureSensor(`${serviceName}`, `${zoneName} Temperature Sensor ${deviceId} ${i}`);
948
948
  this.roomTemperatureWaterTankSensorService.addOptionalCharacteristic(Characteristic.ConfiguredName);
949
949
  this.roomTemperatureWaterTankSensorService.setCharacteristic(Characteristic.ConfiguredName, `${accessoryName} ${zoneName}`);
@@ -961,7 +961,7 @@ class DeviceAtw extends EventEmitter {
961
961
  };
962
962
 
963
963
  if (zone.flowTemperature !== null) {
964
- const debug = this.enableDebugMode ? this.emit('debug', `Prepare flow temperature water tank sensor service`) : false;
964
+ if (this.enableDebugMode) this.emit('debug', `Prepare flow temperature water tank sensor service`);
965
965
  this.flowTemperatureWaterTankSensorService = new Service.TemperatureSensor(`${serviceName} Flow`, `${zoneName} Temperature Sensor Flow ${deviceId} ${i}`);
966
966
  this.flowTemperatureWaterTankSensorService.addOptionalCharacteristic(Characteristic.ConfiguredName);
967
967
  this.flowTemperatureWaterTankSensorService.setCharacteristic(Characteristic.ConfiguredName, `${accessoryName} ${zoneName} Flow`);
@@ -979,7 +979,7 @@ class DeviceAtw extends EventEmitter {
979
979
  };
980
980
 
981
981
  if (zone.returnTemperature !== null) {
982
- const debug1 = this.enableDebugMode ? this.emit('debug', `Prepare return temperature water tank sensor service`) : false;
982
+ if (this.enableDebugMode) this.emit('debug', `Prepare return temperature water tank sensor service`);
983
983
  this.returnTemperatureWaterTankSensorService = new Service.TemperatureSensor(`${serviceName} Return`, `${zoneName} Temperature Sensor Return ${deviceId} ${i}`);
984
984
  this.returnTemperatureWaterTankSensorService.addOptionalCharacteristic(Characteristic.ConfiguredName);
985
985
  this.returnTemperatureWaterTankSensorService.setCharacteristic(Characteristic.ConfiguredName, `${accessoryName} ${zoneName} Return`);
@@ -998,7 +998,7 @@ class DeviceAtw extends EventEmitter {
998
998
  break;
999
999
  case caseZone2Sensor: //Zone 2
1000
1000
  if (zone.roomTemperature !== null) {
1001
- const debug = this.enableDebugMode ? this.emit('debug', `${zoneName}, Prepare temperature sensor service`) : false;
1001
+ if (this.enableDebugMode) this.emit('debug', `${zoneName}, Prepare temperature sensor service`);
1002
1002
  this.roomTemperatureZone2SensorService = new Service.TemperatureSensor(`${serviceName}`, `${zoneName} Temperature Sensor ${deviceId} ${i}`);
1003
1003
  this.roomTemperatureZone2SensorService.addOptionalCharacteristic(Characteristic.ConfiguredName);
1004
1004
  this.roomTemperatureZone2SensorService.setCharacteristic(Characteristic.ConfiguredName, `${accessoryName} ${zoneName}`);
@@ -1016,7 +1016,7 @@ class DeviceAtw extends EventEmitter {
1016
1016
  };
1017
1017
 
1018
1018
  if (zone.flowTemperature !== null) {
1019
- const debug = this.enableDebugMode ? this.emit('debug', `Prepare flow temperature zone 2 sensor service`) : false;
1019
+ if (this.enableDebugMode) this.emit('debug', `Prepare flow temperature zone 2 sensor service`);
1020
1020
  this.flowTemperatureZone2SensorService = new Service.TemperatureSensor(`${serviceName} Flow`, `${zoneName} Temperature Sensor Flow${deviceId} ${i}`);
1021
1021
  this.flowTemperatureZone2SensorService.addOptionalCharacteristic(Characteristic.ConfiguredName);
1022
1022
  this.flowTemperatureZone2SensorService.setCharacteristic(Characteristic.ConfiguredName, `${accessoryName} ${zoneName} Flow`);
@@ -1034,7 +1034,7 @@ class DeviceAtw extends EventEmitter {
1034
1034
  };
1035
1035
 
1036
1036
  if (zone.returnTemperature !== null) {
1037
- const debug1 = this.enableDebugMode ? this.emit('debug', `Prepare return temperature zone 2 sensor service`) : false;
1037
+ if (this.enableDebugMode) this.emit('debug', `Prepare return temperature zone 2 sensor service`);
1038
1038
  this.returnTemperatureZone2SensorService = new Service.TemperatureSensor(`${serviceName} Return`, `${zoneName} Temperature Sensor Return${deviceId} ${i}`);
1039
1039
  this.returnTemperatureZone2SensorService.addOptionalCharacteristic(Characteristic.ConfiguredName);
1040
1040
  this.returnTemperatureZone2SensorService.setCharacteristic(Characteristic.ConfiguredName, `${accessoryName} ${zoneName} Return`);
@@ -1057,7 +1057,7 @@ class DeviceAtw extends EventEmitter {
1057
1057
 
1058
1058
  //presets services
1059
1059
  if (this.presetsConfiguredCount > 0) {
1060
- const debug = this.enableDebugMode ? this.emit('debug', `Prepare presets services`) : false;
1060
+ if (this.enableDebugMode) this.emit('debug', `Prepare presets services`);
1061
1061
  this.presetsServices = [];
1062
1062
  this.presetsConfigured.forEach((preset, i) => {
1063
1063
  const presetData = presetsOnServer.find(p => p.ID === preset.Id);
@@ -1116,7 +1116,7 @@ class DeviceAtw extends EventEmitter {
1116
1116
  };
1117
1117
 
1118
1118
  await this.melCloudAtw.send(deviceData);
1119
- const info = this.disableLogInfo ? false : this.emit('info', `${state ? 'Set:' : 'Unset:'} ${name}`);
1119
+ if (!this.disableLogInfo) this.emit('info', `${state ? 'Set:' : 'Unset:'} ${name}`);
1120
1120
  } catch (error) {
1121
1121
  this.emit('warn', `Set preset error: ${error}`);
1122
1122
  };
@@ -1128,7 +1128,7 @@ class DeviceAtw extends EventEmitter {
1128
1128
 
1129
1129
  //buttons services
1130
1130
  if (this.buttonsConfiguredCount > 0) {
1131
- const debug = this.enableDebugMode ? this.emit('debug', `Prepare buttons services`) : false;
1131
+ if (this.enableDebugMode) this.emit('debug', `Prepare buttons services`);
1132
1132
  this.buttonsServices = [];
1133
1133
  this.buttonsConfigured.forEach((button, i) => {
1134
1134
  //get button mode
@@ -1284,7 +1284,7 @@ class DeviceAtw extends EventEmitter {
1284
1284
  };
1285
1285
 
1286
1286
  await this.melCloudAtw.send(deviceData);
1287
- const info = this.disableLogInfo ? false : this.emit('info', `${state ? `Set: ${name}` : `Unset: ${name}, Set: ${button.previousValue}`}`);
1287
+ if (!this.disableLogInfo) this.emit('info', `${state ? `Set: ${name}` : `Unset: ${name}, Set: ${button.previousValue}`}`);
1288
1288
  } catch (error) {
1289
1289
  this.emit('warn', `Set button error: ${error}`);
1290
1290
  };
package/src/deviceerv.js CHANGED
@@ -266,14 +266,14 @@ class DeviceErv extends EventEmitter {
266
266
  const numberOfFanSpeeds = this.accessory.numberOfFanSpeeds;
267
267
 
268
268
  //accessory
269
- const debug = this.enableDebugMode ? this.emit('debug', `Prepare accessory`) : false;
269
+ if (this.enableDebugMode) this.emit('debug', `Prepare accessory`);
270
270
  const accessoryName = deviceName;
271
271
  const accessoryUUID = AccessoryUUID.generate(accountName + deviceId.toString());
272
272
  const accessoryCategory = [Categories.OTHER, Categories.AIR_PURIFIER, Categories.THERMOSTAT][this.displayType];
273
273
  const accessory = new Accessory(accessoryName, accessoryUUID, accessoryCategory);
274
274
 
275
275
  //information service
276
- const debug1 = this.enableDebugMode ? this.emit('debug', `Prepare information service`) : false;
276
+ if (this.enableDebugMode) this.emit('debug', `Prepare information service`);
277
277
  accessory.getService(Service.AccessoryInformation)
278
278
  .setCharacteristic(Characteristic.Manufacturer, this.manufacturer)
279
279
  .setCharacteristic(Characteristic.Model, this.model)
@@ -285,7 +285,7 @@ class DeviceErv extends EventEmitter {
285
285
  const serviceName = `${deviceTypeText} ${accessoryName}`;
286
286
  switch (this.displayMode) {
287
287
  case 1: //Heater Cooler
288
- const debug = this.enableDebugMode ? this.emit('debug', `Prepare heather/cooler service`) : false;
288
+ if (this.enableDebugMode) this.emit('debug', `Prepare heather/cooler service`);
289
289
  this.melCloudService = new Service.HeaterCooler(serviceName, `HeaterCooler ${deviceId}`);
290
290
  this.melCloudService.setPrimaryService(true);
291
291
  this.melCloudService.getCharacteristic(Characteristic.Active)
@@ -298,7 +298,7 @@ class DeviceErv extends EventEmitter {
298
298
  deviceData.Device.Power = [false, true][state];
299
299
  deviceData.Device.EffectiveFlags = Ventilation.EffectiveFlags.Power;
300
300
  await this.melCloudErv.send(deviceData, this.displayMode);
301
- const info = this.disableLogInfo ? false : this.emit('info', `Set power: ${state ? 'ON' : 'OFF'}`);
301
+ if (!this.disableLogInfo) this.emit('info', `Set power: ${state ? 'ON' : 'OFF'}`);
302
302
  } catch (error) {
303
303
  this.emit('warn', `Set power error: ${error}`);
304
304
  };
@@ -335,7 +335,7 @@ class DeviceErv extends EventEmitter {
335
335
  deviceData.Device.EffectiveFlags = Ventilation.EffectiveFlags.VentilationMode;
336
336
  await this.melCloudErv.send(deviceData, this.displayMode);
337
337
  const operationModeText = Ventilation.VentilationMode[deviceData.Device.VentilationMode];
338
- const info = this.disableLogInfo ? false : this.emit('info', `Set operation mode: ${operationModeText}`);
338
+ if (!this.disableLogInfo) this.emit('info', `Set operation mode: ${operationModeText}`);
339
339
  } catch (error) {
340
340
  this.emit('warn', `Set operation mode error: ${error}`);
341
341
  };
@@ -378,7 +378,7 @@ class DeviceErv extends EventEmitter {
378
378
  };
379
379
  deviceData.Device.EffectiveFlags = Ventilation.EffectiveFlags.SetFanSpeed;
380
380
  await this.melCloudErv.send(deviceData, this.displayMode);
381
- const info = this.disableLogInfo ? false : this.emit('info', `Set fan speed mode: ${Ventilation.FanSpeed[fanSpeedModeText]}`);
381
+ if (!this.disableLogInfo) this.emit('info', `Set fan speed mode: ${Ventilation.FanSpeed[fanSpeedModeText]}`);
382
382
  } catch (error) {
383
383
  this.emit('warn', `Set fan speed mode error: ${error}`);
384
384
  };
@@ -400,7 +400,7 @@ class DeviceErv extends EventEmitter {
400
400
  deviceData.Device.DefaultCoolingSetTemperature = value;
401
401
  deviceData.Device.EffectiveFlags = Ventilation.EffectiveFlags.SetTemperature;
402
402
  await this.melCloudErv.send(deviceData, this.displayMode);
403
- const info = this.disableLogInfo ? false : this.emit('info', `Set cooling threshold temperature: ${value}${this.accessory.temperatureUnit}`);
403
+ if (!this.disableLogInfo) this.emit('info', `Set cooling threshold temperature: ${value}${this.accessory.temperatureUnit}`);
404
404
  } catch (error) {
405
405
  this.emit('warn', `Set cooling threshold temperature error: ${error}`);
406
406
  };
@@ -423,7 +423,7 @@ class DeviceErv extends EventEmitter {
423
423
  deviceData.Device.DefaultHeatingSetTemperature = value;
424
424
  deviceData.Device.EffectiveFlags = Ventilation.EffectiveFlags.SetTemperature;
425
425
  await this.melCloudErv.send(deviceData, this.displayMode);
426
- const info = this.disableLogInfo ? false : this.emit('info', `Set heating threshold temperature: ${value}${this.accessory.temperatureUnit}`);
426
+ if (!this.disableLogInfo) this.emit('info', `Set heating threshold temperature: ${value}${this.accessory.temperatureUnit}`);
427
427
  } catch (error) {
428
428
  this.emit('warn', `Set heating threshold temperature error: ${error}`);
429
429
  };
@@ -432,7 +432,7 @@ class DeviceErv extends EventEmitter {
432
432
  //this.melCloudService.getCharacteristic(Characteristic.LockPhysicalControls)
433
433
  // .onGet(async () => {
434
434
  // const value = this.accessory.lockPhysicalControl;
435
- // const info = this.disableLogInfo ? false : this.emit('info', `Lock physical controls: ${value ? 'LOCKED' : 'UNLOCKED'}`);
435
+ // if (!this.disableLogInfo) this.emit('info', `Lock physical controls: ${value ? 'LOCKED' : 'UNLOCKED'}`);
436
436
  // return value;
437
437
  // })
438
438
  // .onSet(async (value) => {
@@ -441,7 +441,7 @@ class DeviceErv extends EventEmitter {
441
441
  // deviceData.Device = deviceData.Device;
442
442
  // deviceData.Device.EffectiveFlags = CONSTANTS.Ventilation.EffectiveFlags.Prohibit;
443
443
  // await this.melCloudErv.send(deviceData, this.displayMode);
444
- // const info = this.disableLogInfo ? false : this.emit('info', `Set local physical controls: ${value ? 'LOCK' : 'UNLOCK'}`);
444
+ // if (!this.disableLogInfo) this.emit('info', `Set local physical controls: ${value ? 'LOCK' : 'UNLOCK'}`);
445
445
  // } catch (error) {
446
446
  // this.emit('warn', `Set lock physical controls error: ${error}`);
447
447
  // };
@@ -456,7 +456,7 @@ class DeviceErv extends EventEmitter {
456
456
  value = [false, true][value];
457
457
  this.accessory.useFahrenheit = value;
458
458
  this.emit('melCloud', 'UseFahrenheit', value);
459
- const info = this.disableLogInfo ? false : this.emit('info', `Set temperature display unit: ${TemperatureDisplayUnits[value]}`);
459
+ if (!this.disableLogInfo) this.emit('info', `Set temperature display unit: ${TemperatureDisplayUnits[value]}`);
460
460
  } catch (error) {
461
461
  this.emit('warn', `Set temperature display unit error: ${error}`);
462
462
  };
@@ -464,7 +464,7 @@ class DeviceErv extends EventEmitter {
464
464
  accessory.addService(this.melCloudService);
465
465
  break;
466
466
  case 2: //Thermostat
467
- const debug1 = this.enableDebugMode ? this.emit('debug', `Prepare thermostat service`) : false;
467
+ if (this.enableDebugMode) this.emit('debug', `Prepare thermostat service`);
468
468
  this.melCloudService = new Service.Thermostat(serviceName, `Thermostat ${deviceId}`);
469
469
  this.melCloudService.setPrimaryService(true);
470
470
  this.melCloudService.getCharacteristic(Characteristic.CurrentHeatingCoolingState)
@@ -508,7 +508,7 @@ class DeviceErv extends EventEmitter {
508
508
 
509
509
  await this.melCloudErv.send(deviceData, this.displayMode);
510
510
  const operationModeText = Ventilation.VentilationMode[deviceData.Device.VentilationMode];
511
- const info = this.disableLogInfo ? false : this.emit('info', `Set operation mode: ${operationModeText}`);
511
+ if (!this.disableLogInfo) this.emit('info', `Set operation mode: ${operationModeText}`);
512
512
  } catch (error) {
513
513
  this.emit('warn', `Set operation mode error: ${error}`);
514
514
  };
@@ -533,7 +533,7 @@ class DeviceErv extends EventEmitter {
533
533
  deviceData.Device.SetTemperature = value;
534
534
  deviceData.Device.EffectiveFlags = Ventilation.EffectiveFlags.SetTemperature;
535
535
  await this.melCloudErv.send(deviceData, this.displayMode);
536
- const info = this.disableLogInfo ? false : this.emit('info', `Set temperature: ${value}${this.accessory.temperatureUnit}`);
536
+ if (!this.disableLogInfo) this.emit('info', `Set temperature: ${value}${this.accessory.temperatureUnit}`);
537
537
  } catch (error) {
538
538
  this.emit('warn', `Set temperature error: ${error}`);
539
539
  };
@@ -548,7 +548,7 @@ class DeviceErv extends EventEmitter {
548
548
  value = [false, true][value];
549
549
  this.accessory.useFahrenheit = value;
550
550
  this.emit('melCloud', 'UseFahrenheit', value);
551
- const info = this.disableLogInfo ? false : this.emit('info', `Set temperature display unit: ${TemperatureDisplayUnits[value]}`);
551
+ if (!this.disableLogInfo) this.emit('info', `Set temperature display unit: ${TemperatureDisplayUnits[value]}`);
552
552
  } catch (error) {
553
553
  this.emit('warn', `Set temperature display unit error: ${error}`);
554
554
  };
@@ -559,7 +559,7 @@ class DeviceErv extends EventEmitter {
559
559
 
560
560
  //temperature sensor service room
561
561
  if (this.temperatureSensor && hasRoomTemperature && this.accessory.roomTemperature !== null) {
562
- const debug = this.enableDebugMode ? this.emit('debug', `Prepare room temperature sensor service`) : false;
562
+ if (this.enableDebugMode) this.emit('debug', `Prepare room temperature sensor service`);
563
563
  this.roomTemperatureSensorService = new Service.TemperatureSensor(`${serviceName} Room`, `Room Temperature Sensor ${deviceId}`);
564
564
  this.roomTemperatureSensorService.addOptionalCharacteristic(Characteristic.ConfiguredName);
565
565
  this.roomTemperatureSensorService.setCharacteristic(Characteristic.ConfiguredName, `${serviceName} Room`);
@@ -578,7 +578,7 @@ class DeviceErv extends EventEmitter {
578
578
 
579
579
  //temperature sensor service supply
580
580
  if (this.temperatureSensorSupply && hasSupplyTemperature && this.accessory.supplyTemperature !== null) {
581
- const debug = this.enableDebugMode ? this.emit('debug', `Prepare supply temperature sensor service`) : false;
581
+ if (this.enableDebugMode) this.emit('debug', `Prepare supply temperature sensor service`);
582
582
  this.supplyTemperatureSensorService = new Service.TemperatureSensor(`${serviceName} Supply`, `Supply Temperature Sensor ${deviceId}`);
583
583
  this.supplyTemperatureSensorService.addOptionalCharacteristic(Characteristic.ConfiguredName);
584
584
  this.supplyTemperatureSensorService.setCharacteristic(Characteristic.ConfiguredName, `${serviceName} Supply`);
@@ -597,7 +597,7 @@ class DeviceErv extends EventEmitter {
597
597
 
598
598
  //temperature sensor service outdoor
599
599
  if (this.temperatureSensorOutdoor && hasOutdoorTemperature && this.accessory.outdoorTemperature !== null) {
600
- const debug = this.enableDebugMode ? this.emit('debug', `Prepare outdoor temperature sensor service`) : false;
600
+ if (this.enableDebugMode) this.emit('debug', `Prepare outdoor temperature sensor service`);
601
601
  this.outdoorTemperatureSensorService = new Service.TemperatureSensor(`${serviceName} Outdoor`, `Outdoor Temperature Sensor ${deviceId}`);
602
602
  this.outdoorTemperatureSensorService.addOptionalCharacteristic(Characteristic.ConfiguredName);
603
603
  this.outdoorTemperatureSensorService.setCharacteristic(Characteristic.ConfiguredName, `${serviceName} Outdoor`);
@@ -680,7 +680,7 @@ class DeviceErv extends EventEmitter {
680
680
 
681
681
  //presets services
682
682
  if (this.presetsConfiguredCount > 0) {
683
- const debug = this.enableDebugMode ? this.emit('debug', `Prepare presets services`) : false;
683
+ if (this.enableDebugMode) this.emit('debug', `Prepare presets services`);
684
684
  this.presetsServices = [];
685
685
  this.presetsConfigured.forEach((preset, i) => {
686
686
  const presetData = presetsOnServer.find(p => p.ID === preset.Id);
@@ -725,7 +725,7 @@ class DeviceErv extends EventEmitter {
725
725
  };
726
726
 
727
727
  await this.melCloudErv.send(deviceData, this.displayMode);
728
- const info = this.disableLogInfo ? false : this.emit('info', `${state ? 'Set:' : 'Unset:'} ${name}`);
728
+ if (!this.disableLogInfo) this.emit('info', `${state ? 'Set:' : 'Unset:'} ${name}`);
729
729
  } catch (error) {
730
730
  this.emit('warn', `Set preset error: ${error}`);
731
731
  };
@@ -737,7 +737,7 @@ class DeviceErv extends EventEmitter {
737
737
 
738
738
  //buttons services
739
739
  if (this.buttonsConfiguredCount > 0) {
740
- const debug = this.enableDebugMode ? this.emit('debug', `Prepare buttons services`) : false;
740
+ if (this.enableDebugMode) this.emit('debug', `Prepare buttons services`);
741
741
  this.buttonsServices = [];
742
742
  this.buttonsConfigured.forEach((button, i) => {
743
743
  //get button mode
@@ -839,7 +839,7 @@ class DeviceErv extends EventEmitter {
839
839
  };
840
840
 
841
841
  await this.melCloudErv.send(deviceData, this.displayMode);
842
- const info = this.disableLogInfo ? false : this.emit('info', `${state ? `Set: ${buttonName}` : `Unset: ${buttonName}, Set: ${button.previousValue}`}`);
842
+ if (!this.disableLogInfo) this.emit('info', `${state ? `Set: ${buttonName}` : `Unset: ${buttonName}, Set: ${button.previousValue}`}`);
843
843
  } catch (error) {
844
844
  this.emit('warn', `Set button error: ${error}`);
845
845
  };