homebridge-melcloud-control 3.8.0 → 3.8.2-beta.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/deviceata.js CHANGED
@@ -44,6 +44,10 @@ class DeviceAta extends EventEmitter {
44
44
  this.mqtt = mqtt;
45
45
  this.mqttConnected = false;
46
46
 
47
+ //variables
48
+ this.useFahrenheit = useFahrenheit ? 1 : 0;
49
+ this.temperatureUnit = TemperatureDisplayUnits[this.useFahrenheit];
50
+
47
51
  //function
48
52
  this.melCloud = melCloud; //function
49
53
 
@@ -57,9 +61,9 @@ class DeviceAta extends EventEmitter {
57
61
 
58
62
  const presetyServiceType = ['', Service.Outlet, Service.Switch, Service.MotionSensor, Service.OccupancySensor, Service.ContactSensor][displayType];
59
63
  const presetCharacteristicType = ['', Characteristic.On, Characteristic.On, Characteristic.MotionDetected, Characteristic.OccupancyDetected, Characteristic.ContactSensorState][displayType];
60
- preset.name = preset.name || 'Preset'
61
64
  preset.serviceType = presetyServiceType;
62
65
  preset.characteristicType = presetCharacteristicType;
66
+ preset.name = preset.name || 'Preset'
63
67
  preset.state = false;
64
68
  preset.previousSettings = {};
65
69
  this.presetsConfigured.push(preset);
@@ -76,9 +80,9 @@ class DeviceAta extends EventEmitter {
76
80
 
77
81
  const buttonServiceType = ['', Service.Outlet, Service.Switch, Service.MotionSensor, Service.OccupancySensor, Service.ContactSensor][displayType];
78
82
  const buttonCharacteristicType = ['', Characteristic.On, Characteristic.On, Characteristic.MotionDetected, Characteristic.OccupancyDetected, Characteristic.ContactSensorState][displayType];
79
- button.name = button.name || 'Button'
80
83
  button.serviceType = buttonServiceType;
81
84
  button.characteristicType = buttonCharacteristicType;
85
+ button.name = button.name || 'Button'
82
86
  button.state = false;
83
87
  button.previousValue = null;
84
88
  this.buttonsConfigured.push(button);;
@@ -89,9 +93,7 @@ class DeviceAta extends EventEmitter {
89
93
  this.deviceData = {};
90
94
 
91
95
  //accessory
92
- this.accessory = {};
93
- this.accessory.useFahrenheit = useFahrenheit ? 1 : 0;
94
- this.accessory.temperatureUnit = TemperatureDisplayUnits[this.accessory.useFahrenheit];
96
+ this.mielHvac = {};
95
97
  };
96
98
 
97
99
  async externalIntegrations() {
@@ -259,19 +261,19 @@ class DeviceAta extends EventEmitter {
259
261
  //prepare accessory
260
262
  async prepareAccessory(accountInfo, deviceData, deviceId, deviceTypeText, deviceName, accountName) {
261
263
  try {
262
- const presetsOnServer = this.accessory.presets;
263
- const modelSupportsHeat = this.accessory.modelSupportsHeat;
264
- const modelSupportsDry = this.accessory.modelSupportsDry;
265
- const modelSupportsCool = this.accessory.modelSupportsCool;
266
- const modelSupportsAuto = this.accessory.modelSupportsAuto;
267
- const modelSupportsFanSpeed = this.accessory.modelSupportsFanSpeed;
268
- const hasAutomaticFanSpeed = this.accessory.hasAutomaticFanSpeed;
269
- const hasOutdoorTemperature = this.accessory.hasOutdoorTemperature;
270
- const numberOfFanSpeeds = this.accessory.numberOfFanSpeeds;
271
- const swingFunction = this.accessory.swingFunction;
272
- const autoDryFanMode = [this.accessory.operationMode, 8, modelSupportsDry ? 2 : 8, 7][this.autoDryFanMode]; //NONE, AUTO - 8, DRY - 2, FAN - 7
273
- const heatDryFanMode = [this.accessory.operationMode, 1, modelSupportsDry ? 2 : 1, 7][this.heatDryFanMode]; //NONE, HEAT - 1, DRY - 2, FAN - 7
274
- const coolDryFanMode = [this.accessory.operationMode, 3, modelSupportsDry ? 2 : 3, 7][this.coolDryFanMode]; //NONE, COOL - 3, DRY - 2, FAN - 7
264
+ const presetsOnServer = this.mielHvac.presets;
265
+ const modelSupportsHeat = this.mielHvac.modelSupportsHeat;
266
+ const modelSupportsDry = this.mielHvac.modelSupportsDry;
267
+ const modelSupportsCool = this.mielHvac.modelSupportsCool;
268
+ const modelSupportsAuto = this.mielHvac.modelSupportsAuto;
269
+ const modelSupportsFanSpeed = this.mielHvac.modelSupportsFanSpeed;
270
+ const hasAutomaticFanSpeed = this.mielHvac.hasAutomaticFanSpeed;
271
+ const hasOutdoorTemperature = this.mielHvac.hasOutdoorTemperature;
272
+ const numberOfFanSpeeds = this.mielHvac.numberOfFanSpeeds;
273
+ const swingFunction = this.mielHvac.swingFunction;
274
+ const autoDryFanMode = [this.mielHvac.operationMode, 8, modelSupportsDry ? 2 : 8, 7][this.autoDryFanMode]; //NONE, AUTO - 8, DRY - 2, FAN - 7
275
+ const heatDryFanMode = [this.mielHvac.operationMode, 1, modelSupportsDry ? 2 : 1, 7][this.heatDryFanMode]; //NONE, HEAT - 1, DRY - 2, FAN - 7
276
+ const coolDryFanMode = [this.mielHvac.operationMode, 3, modelSupportsDry ? 2 : 3, 7][this.coolDryFanMode]; //NONE, COOL - 3, DRY - 2, FAN - 7
275
277
 
276
278
  //accessory
277
279
  const debug = this.enableDebugMode ? this.emit('debug', `Prepare accessory`) : false;
@@ -298,7 +300,7 @@ class DeviceAta extends EventEmitter {
298
300
  this.melCloudService.setPrimaryService(true);
299
301
  this.melCloudService.getCharacteristic(Characteristic.Active)
300
302
  .onGet(async () => {
301
- const state = this.accessory.power;
303
+ const state = this.mielHvac.power;
302
304
  return state;
303
305
  })
304
306
  .onSet(async (state) => {
@@ -313,17 +315,17 @@ class DeviceAta extends EventEmitter {
313
315
  });
314
316
  this.melCloudService.getCharacteristic(Characteristic.CurrentHeaterCoolerState)
315
317
  .onGet(async () => {
316
- const value = this.accessory.currentOperationMode;
318
+ const value = this.mielHvac.currentOperationMode;
317
319
  return value;
318
320
  });
319
321
  this.melCloudService.getCharacteristic(Characteristic.TargetHeaterCoolerState)
320
322
  .setProps({
321
- minValue: this.accessory.operationModeSetPropsMinValue,
322
- maxValue: this.accessory.operationModeSetPropsMaxValue,
323
- validValues: this.accessory.operationModeSetPropsValidValues
323
+ minValue: this.mielHvac.operationModeSetPropsMinValue,
324
+ maxValue: this.mielHvac.operationModeSetPropsMaxValue,
325
+ validValues: this.mielHvac.operationModeSetPropsValidValues
324
326
  })
325
327
  .onGet(async () => {
326
- const value = this.accessory.targetOperationMode; //1 = HEAT, 2 = DRY 3 = COOL, 7 = FAN, 8 = AUTO
328
+ const value = this.mielHvac.targetOperationMode; //1 = HEAT, 2 = DRY 3 = COOL, 7 = FAN, 8 = AUTO
327
329
  return value;
328
330
  })
329
331
  .onSet(async (value) => {
@@ -350,18 +352,18 @@ class DeviceAta extends EventEmitter {
350
352
  });
351
353
  this.melCloudService.getCharacteristic(Characteristic.CurrentTemperature)
352
354
  .onGet(async () => {
353
- const value = this.accessory.roomTemperature;
355
+ const value = this.mielHvac.roomTemperature;
354
356
  return value;
355
357
  });
356
358
  if (modelSupportsFanSpeed) {
357
359
  this.melCloudService.getCharacteristic(Characteristic.RotationSpeed)
358
360
  .setProps({
359
361
  minValue: 0,
360
- maxValue: this.accessory.fanSpeedSetPropsMaxValue,
362
+ maxValue: this.mielHvac.fanSpeedSetPropsMaxValue,
361
363
  minStep: 1
362
364
  })
363
365
  .onGet(async () => {
364
- const value = this.accessory.fanSpeed; //AUTO, 1, 2, 3, 4, 5, 6, OFF
366
+ const value = this.mielHvac.fanSpeed; //AUTO, 1, 2, 3, 4, 5, 6, OFF
365
367
  return value;
366
368
  })
367
369
  .onSet(async (value) => {
@@ -401,7 +403,7 @@ class DeviceAta extends EventEmitter {
401
403
  this.melCloudService.getCharacteristic(Characteristic.SwingMode)
402
404
  .onGet(async () => {
403
405
  //Vane Horizontal: Auto, 1, 2, 3, 4, 5, 6, 12 = Swing //Vertical: Auto, 1, 2, 3, 4, 5, 7 = Swing
404
- const value = this.accessory.swingMode;
406
+ const value = this.mielHvac.swingMode;
405
407
  return value;
406
408
  })
407
409
  .onSet(async (value) => {
@@ -418,12 +420,12 @@ class DeviceAta extends EventEmitter {
418
420
  };
419
421
  this.melCloudService.getCharacteristic(Characteristic.CoolingThresholdTemperature)
420
422
  .setProps({
421
- minValue: this.accessory.minTempCoolDry,
422
- maxValue: this.accessory.maxTempCoolDry,
423
- minStep: this.accessory.temperatureIncrement
423
+ minValue: this.mielHvac.minTempCoolDry,
424
+ maxValue: this.mielHvac.maxTempCoolDry,
425
+ minStep: this.mielHvac.temperatureIncrement
424
426
  })
425
427
  .onGet(async () => {
426
- const value = this.accessory.operationMode === 8 ? this.accessory.defaultCoolingSetTemperature : this.accessory.setTemperature;
428
+ const value = this.mielHvac.operationMode === 8 ? this.mielHvac.defaultCoolingSetTemperature : this.mielHvac.setTemperature;
427
429
  return value;
428
430
  })
429
431
  .onSet(async (value) => {
@@ -431,7 +433,7 @@ class DeviceAta extends EventEmitter {
431
433
  deviceData.Device.DefaultCoolingSetTemperature = value;
432
434
  deviceData.Device.EffectiveFlags = AirConditioner.EffectiveFlags.SetTemperature;
433
435
  await this.melCloudAta.send(deviceData, this.displayMode);
434
- const info = this.disableLogInfo ? false : this.emit('message', `Set cooling threshold temperature: ${value}${this.accessory.temperatureUnit}`);
436
+ const info = this.disableLogInfo ? false : this.emit('message', `Set cooling threshold temperature: ${value}${this.mielHvac.temperatureUnit}`);
435
437
  } catch (error) {
436
438
  this.emit('warn', `Set cooling threshold temperature error: ${error}`);
437
439
  };
@@ -439,12 +441,12 @@ class DeviceAta extends EventEmitter {
439
441
  if (modelSupportsHeat) {
440
442
  this.melCloudService.getCharacteristic(Characteristic.HeatingThresholdTemperature)
441
443
  .setProps({
442
- minValue: this.accessory.minTempHeat,
443
- maxValue: this.accessory.maxTempHeat,
444
- minStep: this.accessory.temperatureIncrement
444
+ minValue: this.mielHvac.minTempHeat,
445
+ maxValue: this.mielHvac.maxTempHeat,
446
+ minStep: this.mielHvac.temperatureIncrement
445
447
  })
446
448
  .onGet(async () => {
447
- const value = this.accessory.operationMode === 8 ? this.accessory.defaultHeatingSetTemperature : this.accessory.setTemperature;
449
+ const value = this.mielHvac.operationMode === 8 ? this.mielHvac.defaultHeatingSetTemperature : this.mielHvac.setTemperature;
448
450
  return value;
449
451
  })
450
452
  .onSet(async (value) => {
@@ -452,7 +454,7 @@ class DeviceAta extends EventEmitter {
452
454
  deviceData.Device.DefaultHeatingSetTemperature = value;
453
455
  deviceData.Device.EffectiveFlags = AirConditioner.EffectiveFlags.SetTemperature;
454
456
  await this.melCloudAta.send(deviceData, this.displayMode);
455
- const info = this.disableLogInfo ? false : this.emit('message', `Set heating threshold temperature: ${value}${this.accessory.temperatureUnit}`);
457
+ const info = this.disableLogInfo ? false : this.emit('message', `Set heating threshold temperature: ${value}${this.mielHvac.temperatureUnit}`);
456
458
  } catch (error) {
457
459
  this.emit('warn', `Set heating threshold temperature error: ${error}`);
458
460
  };
@@ -460,7 +462,7 @@ class DeviceAta extends EventEmitter {
460
462
  };
461
463
  this.melCloudService.getCharacteristic(Characteristic.LockPhysicalControls)
462
464
  .onGet(async () => {
463
- const value = this.accessory.lockPhysicalControl;
465
+ const value = this.mielHvac.lockPhysicalControl;
464
466
  return value;
465
467
  })
466
468
  .onSet(async (value) => {
@@ -478,14 +480,14 @@ class DeviceAta extends EventEmitter {
478
480
  });
479
481
  this.melCloudService.getCharacteristic(Characteristic.TemperatureDisplayUnits)
480
482
  .onGet(async () => {
481
- const value = this.accessory.useFahrenheit;
483
+ const value = this.mielHvac.useFahrenheit;
482
484
  return value;
483
485
  })
484
486
  .onSet(async (value) => {
485
487
  try {
486
488
  accountInfo.UseFahrenheit = [false, true][value];
487
489
  await this.melCloud.send(accountInfo);
488
- this.accessory.useFahrenheit = value;
490
+ this.mielHvac.useFahrenheit = value;
489
491
  const info = this.disableLogInfo ? false : this.emit('message', `Set temperature display unit: ${TemperatureDisplayUnits[value]}`);
490
492
  } catch (error) {
491
493
  this.emit('warn', `Set temperature display unit error: ${error}`);
@@ -499,17 +501,17 @@ class DeviceAta extends EventEmitter {
499
501
  this.melCloudService.setPrimaryService(true);
500
502
  this.melCloudService.getCharacteristic(Characteristic.CurrentHeatingCoolingState)
501
503
  .onGet(async () => {
502
- const value = this.accessory.currentOperationMode;
504
+ const value = this.mielHvac.currentOperationMode;
503
505
  return value;
504
506
  });
505
507
  this.melCloudService.getCharacteristic(Characteristic.TargetHeatingCoolingState)
506
508
  .setProps({
507
- minValue: this.accessory.operationModeSetPropsMinValue,
508
- maxValue: this.accessory.operationModeSetPropsMaxValue,
509
- validValues: this.accessory.operationModeSetPropsValidValues
509
+ minValue: this.mielHvac.operationModeSetPropsMinValue,
510
+ maxValue: this.mielHvac.operationModeSetPropsMaxValue,
511
+ validValues: this.mielHvac.operationModeSetPropsValidValues
510
512
  })
511
513
  .onGet(async () => {
512
- const value = this.accessory.targetOperationMode; //1 = HEAT, 2 = DRY 3 = COOL, 7 = FAN, 8 = AUTO
514
+ const value = this.mielHvac.targetOperationMode; //1 = HEAT, 2 = DRY 3 = COOL, 7 = FAN, 8 = AUTO
513
515
  return value;
514
516
  })
515
517
  .onSet(async (value) => {
@@ -545,17 +547,17 @@ class DeviceAta extends EventEmitter {
545
547
  });
546
548
  this.melCloudService.getCharacteristic(Characteristic.CurrentTemperature)
547
549
  .onGet(async () => {
548
- const value = this.accessory.roomTemperature;
550
+ const value = this.mielHvac.roomTemperature;
549
551
  return value;
550
552
  });
551
553
  this.melCloudService.getCharacteristic(Characteristic.TargetTemperature)
552
554
  .setProps({
553
- minValue: this.accessory.minTempHeat,
554
- maxValue: this.accessory.maxTempHeat,
555
- minStep: this.accessory.temperatureIncrement
555
+ minValue: this.mielHvac.minTempHeat,
556
+ maxValue: this.mielHvac.maxTempHeat,
557
+ minStep: this.mielHvac.temperatureIncrement
556
558
  })
557
559
  .onGet(async () => {
558
- const value = this.accessory.setTemperature;
560
+ const value = this.mielHvac.setTemperature;
559
561
  return value;
560
562
  })
561
563
  .onSet(async (value) => {
@@ -563,21 +565,21 @@ class DeviceAta extends EventEmitter {
563
565
  deviceData.Device.SetTemperature = value;
564
566
  deviceData.Device.EffectiveFlags = AirConditioner.EffectiveFlags.SetTemperature;
565
567
  await this.melCloudAta.send(deviceData, this.displayMode);
566
- const info = this.disableLogInfo ? false : this.emit('message', `Set temperature: ${value}${this.accessory.temperatureUnit}`);
568
+ const info = this.disableLogInfo ? false : this.emit('message', `Set temperature: ${value}${this.mielHvac.temperatureUnit}`);
567
569
  } catch (error) {
568
570
  this.emit('warn', `Set temperature error: ${error}`);
569
571
  };
570
572
  });
571
573
  this.melCloudService.getCharacteristic(Characteristic.TemperatureDisplayUnits)
572
574
  .onGet(async () => {
573
- const value = this.accessory.useFahrenheit;
575
+ const value = this.mielHvac.useFahrenheit;
574
576
  return value;
575
577
  })
576
578
  .onSet(async (value) => {
577
579
  try {
578
580
  accountInfo.UseFahrenheit = [false, true][value];
579
581
  await this.melCloud.send(accountInfo);
580
- this.accessory.useFahrenheit = value;
582
+ this.mielHvac.useFahrenheit = value;
581
583
  const info = this.disableLogInfo ? false : this.emit('message', `Set temperature display unit: ${TemperatureDisplayUnits[value]}`);
582
584
  } catch (error) {
583
585
  this.emit('warn', `Set temperature display unit error: ${error}`);
@@ -588,7 +590,7 @@ class DeviceAta extends EventEmitter {
588
590
  };
589
591
 
590
592
  //temperature sensor services
591
- if (this.temperatureSensor && this.accessory.roomTemperature !== null) {
593
+ if (this.temperatureSensor && this.mielHvac.roomTemperature !== null) {
592
594
  const debug = this.enableDebugMode ? this.emit('debug', `Prepare room temperature sensor service`) : false;
593
595
  this.roomTemperatureSensorService = new Service.TemperatureSensor(`${serviceName} Room`, `Room Temperature Sensor ${deviceId}`);
594
596
  this.roomTemperatureSensorService.addOptionalCharacteristic(Characteristic.ConfiguredName);
@@ -600,13 +602,13 @@ class DeviceAta extends EventEmitter {
600
602
  minStep: 0.5
601
603
  })
602
604
  .onGet(async () => {
603
- const state = this.accessory.roomTemperature;
605
+ const state = this.mielHvac.roomTemperature;
604
606
  return state;
605
607
  })
606
608
  accessory.addService(this.roomTemperatureSensorService);
607
609
  };
608
610
 
609
- if (this.temperatureSensorOutdoor && hasOutdoorTemperature && this.accessory.outdoorTemperature !== null) {
611
+ if (this.temperatureSensorOutdoor && hasOutdoorTemperature && this.mielHvac.outdoorTemperature !== null) {
610
612
  const debug = this.enableDebugMode ? this.emit('debug', `Prepare outdoor temperature sensor service`) : false;
611
613
  this.outdoorTemperatureSensorService = new Service.TemperatureSensor(`${serviceName} Outdoor`, `Outdoor Temperature Sensor ${deviceId}`);
612
614
  this.outdoorTemperatureSensorService.addOptionalCharacteristic(Characteristic.ConfiguredName);
@@ -618,7 +620,7 @@ class DeviceAta extends EventEmitter {
618
620
  minStep: 0.5
619
621
  })
620
622
  .onGet(async () => {
621
- const state = this.accessory.outdoorTemperature;
623
+ const state = this.mielHvac.outdoorTemperature;
622
624
  return state;
623
625
  })
624
626
  accessory.addService(this.outdoorTemperatureSensorService);
@@ -1016,106 +1018,111 @@ class DeviceAta extends EventEmitter {
1016
1018
  const outdoorTemperature = deviceData.Device.OutdoorTemperature;
1017
1019
 
1018
1020
  //accessory
1019
- this.accessory.presets = presetsOnServer;
1020
- this.accessory.hasAutomaticFanSpeed = hasAutomaticFanSpeed;
1021
- this.accessory.airDirectionFunction = airDirectionFunction;
1022
- this.accessory.swingFunction = swingFunction;
1023
- this.accessory.hasOutdoorTemperature = hasOutdoorTemperature;
1024
- this.accessory.numberOfFanSpeeds = numberOfFanSpeeds;
1025
- this.accessory.modelSupportsFanSpeed = modelSupportsFanSpeed;
1026
- this.accessory.modelSupportsAuto = modelSupportsAuto;
1027
- this.accessory.modelSupportsHeat = modelSupportsHeat;
1028
- this.accessory.modelSupportsDry = modelSupportsDry;
1029
- this.accessory.modelSupportsCool = modelSupportsCool;
1030
- this.accessory.minTempHeat = minTempHeat;
1031
- this.accessory.maxTempHeat = maxTempHeat;
1032
- this.accessory.minTempCoolDry = minTempCoolDry;
1033
- this.accessory.maxTempCoolDry = maxTempCoolDry;
1034
-
1035
- this.accessory.power = power ? 1 : 0;
1036
- this.accessory.inStandbyMode = inStandbyMode;
1037
- this.accessory.operationMode = operationMode;
1038
- this.accessory.roomTemperature = roomTemperature;
1039
- this.accessory.outdoorTemperature = outdoorTemperature;
1040
- this.accessory.setTemperature = setTemperature;
1041
- this.accessory.defaultHeatingSetTemperature = defaultHeatingSetTemperature;
1042
- this.accessory.defaultCoolingSetTemperature = defaultCoolingSetTemperature;
1043
- this.accessory.actualFanSpeed = actualFanSpeed;
1044
- this.accessory.automaticFanSpeed = automaticFanSpeed;
1045
- this.accessory.vaneVerticalSwing = vaneVerticalSwing;
1046
- this.accessory.vaneHorizontalSwing = vaneHorizontalSwing;
1047
- this.accessory.swingMode = swingFunction && vaneHorizontalDirection === 12 && vaneVerticalDirection === 7 ? 1 : 0;
1048
- this.accessory.lockPhysicalControl = prohibitSetTemperature && prohibitOperationMode && prohibitPower ? 1 : 0;
1049
- this.accessory.temperatureIncrement = temperatureIncrement;
1021
+ const obj = {
1022
+ presets: presetsOnServer,
1023
+ hasAutomaticFanSpeed: hasAutomaticFanSpeed,
1024
+ airDirectionFunction: airDirectionFunction,
1025
+ swingFunction: swingFunction,
1026
+ hasOutdoorTemperature: hasOutdoorTemperature,
1027
+ numberOfFanSpeeds: numberOfFanSpeeds,
1028
+ modelSupportsFanSpeed: modelSupportsFanSpeed,
1029
+ modelSupportsAuto: modelSupportsAuto,
1030
+ modelSupportsHeat: modelSupportsHeat,
1031
+ modelSupportsDry: modelSupportsDry,
1032
+ modelSupportsCool: modelSupportsCool,
1033
+ minTempHeat: minTempHeat,
1034
+ maxTempHeat: maxTempHeat,
1035
+ minTempCoolDry: minTempCoolDry,
1036
+ maxTempCoolDry: maxTempCoolDry,
1037
+ power: power ? 1 : 0,
1038
+ inStandbyMode: inStandbyMode,
1039
+ operationMode: operationMode,
1040
+ currentOperationMode: 0,
1041
+ targetOperationMode: 0,
1042
+ roomTemperature: roomTemperature,
1043
+ outdoorTemperature: outdoorTemperature,
1044
+ setTemperature: setTemperature,
1045
+ defaultHeatingSetTemperature: defaultHeatingSetTemperature,
1046
+ defaultCoolingSetTemperature: defaultCoolingSetTemperature,
1047
+ actualFanSpeed: actualFanSpeed,
1048
+ automaticFanSpeed: automaticFanSpeed,
1049
+ vaneVerticalSwing: vaneVerticalSwing,
1050
+ vaneHorizontalSwing: vaneHorizontalSwing,
1051
+ swingMode: swingFunction && vaneHorizontalDirection === 12 && vaneVerticalDirection === 7 ? 1 : 0,
1052
+ lockPhysicalControl: prohibitSetTemperature && prohibitOperationMode && prohibitPower ? 1 : 0,
1053
+ useFahrenheit: this.useFahrenheit,
1054
+ temperatureUnit: this.useFahrenheit,
1055
+ temperatureIncrement: temperatureIncrement
1056
+ };
1050
1057
 
1051
1058
  //operating mode 0, HEAT, DRY, COOL, 4, 5, 6, FAN, AUTO, ISEE HEAT, ISEE DRY, ISEE COOL
1052
1059
  switch (this.displayMode) {
1053
1060
  case 1: //Heater Cooler
1054
1061
  switch (operationMode) {
1055
1062
  case 1: //HEAT
1056
- this.accessory.currentOperationMode = roomTemperature > setTemperature ? 1 : 2; //INACTIVE, IDLE, HEATING, COOLING
1057
- this.accessory.targetOperationMode = 1; //AUTO, HEAT, COOL
1063
+ obj.currentOperationMode = roomTemperature > setTemperature ? 1 : 2; //INACTIVE, IDLE, HEATING, COOLING
1064
+ obj.targetOperationMode = 1; //AUTO, HEAT, COOL
1058
1065
  break;
1059
1066
  case 2: //DRY
1060
- this.accessory.currentOperationMode = 1;
1061
- this.accessory.targetOperationMode = this.autoDryFanMode === 2 ? 0 : this.heatDryFanMode === 2 ? 1 : this.coolDryFanMode === 2 ? 2 : this.accessory.targetOperationMode ?? 0;
1067
+ obj.currentOperationMode = 1;
1068
+ obj.targetOperationMode = this.autoDryFanMode === 2 ? 0 : this.heatDryFanMode === 2 ? 1 : this.coolDryFanMode === 2 ? 2 : obj.targetOperationMode ?? 0;
1062
1069
  break;
1063
1070
  case 3: //COOL
1064
- this.accessory.currentOperationMode = roomTemperature < setTemperature ? 1 : 3;
1065
- this.accessory.targetOperationMode = 2;
1071
+ obj.currentOperationMode = roomTemperature < setTemperature ? 1 : 3;
1072
+ obj.targetOperationMode = 2;
1066
1073
  break;
1067
1074
  case 7: //FAN
1068
- this.accessory.currentOperationMode = 1;
1069
- this.accessory.targetOperationMode = this.autoDryFanMode === 3 ? 0 : this.heatDryFanMode === 3 ? 1 : this.coolDryFanMode === 3 ? 2 : this.accessory.targetOperationMode ?? 0;
1075
+ obj.currentOperationMode = 1;
1076
+ obj.targetOperationMode = this.autoDryFanMode === 3 ? 0 : this.heatDryFanMode === 3 ? 1 : this.coolDryFanMode === 3 ? 2 : obj.targetOperationMode ?? 0;
1070
1077
  break;
1071
1078
  case 8: //AUTO
1072
- this.accessory.currentOperationMode = roomTemperature > setTemperature ? 3 : roomTemperature < setTemperature ? 2 : 1;
1073
- this.accessory.targetOperationMode = 0;
1079
+ obj.currentOperationMode = roomTemperature > setTemperature ? 3 : roomTemperature < setTemperature ? 2 : 1;
1080
+ obj.targetOperationMode = 0;
1074
1081
  break;
1075
1082
  case 9: //ISEE HEAT
1076
- this.accessory.currentOperationMode = roomTemperature > setTemperature ? 1 : 2
1077
- this.accessory.targetOperationMode = 1;
1083
+ obj.currentOperationMode = roomTemperature > setTemperature ? 1 : 2
1084
+ obj.targetOperationMode = 1;
1078
1085
  break;
1079
1086
  case 10: //ISEE DRY
1080
- this.accessory.currentOperationMode = 1;
1081
- this.accessory.targetOperationMode = this.autoDryFanMode === 2 ? 0 : this.heatDryFanMode === 2 ? 1 : this.coolDryFanMode === 2 ? 2 : this.accessory.targetOperationMode ?? 0;
1087
+ obj.currentOperationMode = 1;
1088
+ obj.targetOperationMode = this.autoDryFanMode === 2 ? 0 : this.heatDryFanMode === 2 ? 1 : this.coolDryFanMode === 2 ? 2 : obj.targetOperationMode ?? 0;
1082
1089
  break;
1083
1090
  case 11: //ISEE COOL;
1084
- this.accessory.currentOperationMode = roomTemperature < setTemperature ? 1 : 3;
1085
- this.accessory.targetOperationMode = 2;
1091
+ obj.currentOperationMode = roomTemperature < setTemperature ? 1 : 3;
1092
+ obj.targetOperationMode = 2;
1086
1093
  break;
1087
1094
  default:
1088
1095
  this.emit('warn', `Unknown operating mode: ${operationMode}`);
1089
1096
  return
1090
1097
  };
1091
1098
 
1092
- this.accessory.currentOperationMode = !power ? 0 : inStandbyMode ? 1 : this.accessory.currentOperationMode;
1093
- this.accessory.operationModeSetPropsMinValue = modelSupportsAuto && modelSupportsHeat ? 0 : !modelSupportsAuto && modelSupportsHeat ? 1 : modelSupportsAuto && !modelSupportsHeat ? 0 : 2;
1094
- this.accessory.operationModeSetPropsMaxValue = 2
1095
- this.accessory.operationModeSetPropsValidValues = modelSupportsAuto && modelSupportsHeat ? [0, 1, 2] : !modelSupportsAuto && modelSupportsHeat ? [1, 2] : modelSupportsAuto && !modelSupportsHeat ? [0, 2] : [2];
1099
+ obj.currentOperationMode = !power ? 0 : inStandbyMode ? 1 : obj.currentOperationMode;
1100
+ obj.operationModeSetPropsMinValue = modelSupportsAuto && modelSupportsHeat ? 0 : !modelSupportsAuto && modelSupportsHeat ? 1 : modelSupportsAuto && !modelSupportsHeat ? 0 : 2;
1101
+ obj.operationModeSetPropsMaxValue = 2
1102
+ obj.operationModeSetPropsValidValues = modelSupportsAuto && modelSupportsHeat ? [0, 1, 2] : !modelSupportsAuto && modelSupportsHeat ? [1, 2] : modelSupportsAuto && !modelSupportsHeat ? [0, 2] : [2];
1096
1103
 
1097
1104
  //fan speed mode
1098
1105
  if (modelSupportsFanSpeed) {
1099
1106
  switch (numberOfFanSpeeds) {
1100
1107
  case 2: //Fan speed mode 2
1101
- this.accessory.fanSpeed = hasAutomaticFanSpeed ? [3, 1, 2][fanSpeed] : [0, 1, 2][fanSpeed];
1102
- this.accessory.fanSpeedSetPropsMaxValue = hasAutomaticFanSpeed ? 3 : 2;
1108
+ obj.fanSpeed = hasAutomaticFanSpeed ? [3, 1, 2][fanSpeed] : [0, 1, 2][fanSpeed];
1109
+ obj.fanSpeedSetPropsMaxValue = hasAutomaticFanSpeed ? 3 : 2;
1103
1110
  break;
1104
1111
  case 3: //Fan speed mode 3
1105
- this.accessory.fanSpeed = hasAutomaticFanSpeed ? [4, 1, 2, 3][fanSpeed] : [0, 1, 2, 3][fanSpeed];
1106
- this.accessory.fanSpeedSetPropsMaxValue = hasAutomaticFanSpeed ? 4 : 3;
1112
+ obj.fanSpeed = hasAutomaticFanSpeed ? [4, 1, 2, 3][fanSpeed] : [0, 1, 2, 3][fanSpeed];
1113
+ obj.fanSpeedSetPropsMaxValue = hasAutomaticFanSpeed ? 4 : 3;
1107
1114
  break;
1108
1115
  case 4: //Fan speed mode 4
1109
- this.accessory.fanSpeed = hasAutomaticFanSpeed ? [5, 1, 2, 3, 4][fanSpeed] : [0, 1, 2, 3, 4][fanSpeed];
1110
- this.accessory.fanSpeedSetPropsMaxValue = hasAutomaticFanSpeed ? 5 : 4;
1116
+ obj.fanSpeed = hasAutomaticFanSpeed ? [5, 1, 2, 3, 4][fanSpeed] : [0, 1, 2, 3, 4][fanSpeed];
1117
+ obj.fanSpeedSetPropsMaxValue = hasAutomaticFanSpeed ? 5 : 4;
1111
1118
  break;
1112
1119
  case 5: //Fan speed mode 5
1113
- this.accessory.fanSpeed = hasAutomaticFanSpeed ? [6, 1, 2, 3, 4, 5][fanSpeed] : [0, 1, 2, 3, 4, 5][fanSpeed];
1114
- this.accessory.fanSpeedSetPropsMaxValue = hasAutomaticFanSpeed ? 6 : 5;
1120
+ obj.fanSpeed = hasAutomaticFanSpeed ? [6, 1, 2, 3, 4, 5][fanSpeed] : [0, 1, 2, 3, 4, 5][fanSpeed];
1121
+ obj.fanSpeedSetPropsMaxValue = hasAutomaticFanSpeed ? 6 : 5;
1115
1122
  break;
1116
1123
  case 6: //Fan speed mode 6
1117
- this.accessory.fanSpeed = hasAutomaticFanSpeed ? [7, 1, 2, 3, 4, 5, 6][fanSpeed] : [0, 1, 2, 3, 4, 5, 6][fanSpeed];
1118
- this.accessory.fanSpeedSetPropsMaxValue = hasAutomaticFanSpeed ? 7 : 6;
1124
+ obj.fanSpeed = hasAutomaticFanSpeed ? [7, 1, 2, 3, 4, 5, 6][fanSpeed] : [0, 1, 2, 3, 4, 5, 6][fanSpeed];
1125
+ obj.fanSpeedSetPropsMaxValue = hasAutomaticFanSpeed ? 7 : 6;
1119
1126
  break;
1120
1127
  };
1121
1128
  };
@@ -1124,73 +1131,74 @@ class DeviceAta extends EventEmitter {
1124
1131
  if (this.melCloudService) {
1125
1132
  this.melCloudService
1126
1133
  .updateCharacteristic(Characteristic.Active, power ? 1 : 0)
1127
- .updateCharacteristic(Characteristic.CurrentHeaterCoolerState, this.accessory.currentOperationMode)
1128
- .updateCharacteristic(Characteristic.TargetHeaterCoolerState, this.accessory.targetOperationMode)
1134
+ .updateCharacteristic(Characteristic.CurrentHeaterCoolerState, obj.currentOperationMode)
1135
+ .updateCharacteristic(Characteristic.TargetHeaterCoolerState, obj.targetOperationMode)
1129
1136
  .updateCharacteristic(Characteristic.CurrentTemperature, roomTemperature)
1130
- .updateCharacteristic(Characteristic.LockPhysicalControls, this.accessory.lockPhysicalControl)
1131
- .updateCharacteristic(Characteristic.TemperatureDisplayUnits, this.accessory.useFahrenheit)
1137
+ .updateCharacteristic(Characteristic.LockPhysicalControls, obj.lockPhysicalControl)
1138
+ .updateCharacteristic(Characteristic.TemperatureDisplayUnits, obj.useFahrenheit)
1132
1139
  .updateCharacteristic(Characteristic.CoolingThresholdTemperature, defaultCoolingSetTemperature);
1133
1140
  const updateDefHeat = modelSupportsHeat ? this.melCloudService.updateCharacteristic(Characteristic.HeatingThresholdTemperature, defaultHeatingSetTemperature) : false;
1134
- const updateRS = modelSupportsFanSpeed ? this.melCloudService.updateCharacteristic(Characteristic.RotationSpeed, this.accessory.fanSpeed) : false;
1135
- const updateSM = swingFunction ? this.melCloudService.updateCharacteristic(Characteristic.SwingMode, this.accessory.swingMode) : false;
1141
+ const updateRS = modelSupportsFanSpeed ? this.melCloudService.updateCharacteristic(Characteristic.RotationSpeed, obj.fanSpeed) : false;
1142
+ const updateSM = swingFunction ? this.melCloudService.updateCharacteristic(Characteristic.SwingMode, obj.swingMode) : false;
1136
1143
  };
1137
1144
  break;
1138
1145
  case 2: //Thermostat
1139
1146
  switch (operationMode) {
1140
1147
  case 1: //HEAT
1141
- this.accessory.currentOperationMode = roomTemperature > setTemperature ? 0 : 1; //OFF, HEATING, COOLING
1142
- this.accessory.targetOperationMode = 1; //OFF, HEAT, COOL, AUTO
1148
+ obj.currentOperationMode = roomTemperature > setTemperature ? 0 : 1; //OFF, HEATING, COOLING
1149
+ obj.targetOperationMode = 1; //OFF, HEAT, COOL, AUTO
1143
1150
  break;
1144
1151
  case 2: //DRY
1145
- this.accessory.currentOperationMode = 0;
1146
- this.accessory.targetOperationMode = this.autoDryFanMode === 2 ? 3 : this.heatDryFanMode === 2 ? 1 : this.coolDryFanMode === 2 ? 2 : this.accessory.targetOperationMode ?? 0;
1152
+ obj.currentOperationMode = 0;
1153
+ obj.targetOperationMode = this.autoDryFanMode === 2 ? 3 : this.heatDryFanMode === 2 ? 1 : this.coolDryFanMode === 2 ? 2 : obj.targetOperationMode ?? 0;
1147
1154
  break;
1148
1155
  case 3: //COOL
1149
- this.accessory.currentOperationMode = roomTemperature < setTemperature ? 0 : 2;
1150
- this.accessory.targetOperationMode = 2;
1156
+ obj.currentOperationMode = roomTemperature < setTemperature ? 0 : 2;
1157
+ obj.targetOperationMode = 2;
1151
1158
  break;
1152
1159
  case 7: //FAN
1153
- this.accessory.currentOperationMode = 0;
1154
- this.accessory.targetOperationMode = this.autoDryFanMode === 3 ? 3 : this.heatDryFanMode === 3 ? 1 : this.coolDryFanMode === 3 ? 2 : this.accessory.targetOperationMode ?? 0;
1160
+ obj.currentOperationMode = 0;
1161
+ obj.targetOperationMode = this.autoDryFanMode === 3 ? 3 : this.heatDryFanMode === 3 ? 1 : this.coolDryFanMode === 3 ? 2 : obj.targetOperationMode ?? 0;
1155
1162
  break;
1156
1163
  case 8: //AUTO
1157
- this.accessory.currentOperationMode = roomTemperature < setTemperature ? 1 : roomTemperature > setTemperature ? 2 : 0;
1158
- this.accessory.targetOperationMode = 3;
1164
+ obj.currentOperationMode = roomTemperature < setTemperature ? 1 : roomTemperature > setTemperature ? 2 : 0;
1165
+ obj.targetOperationMode = 3;
1159
1166
  break;
1160
1167
  case 9: //ISEE HEAT
1161
- this.accessory.currentOperationMode = roomTemperature > setTemperature ? 0 : 1;
1162
- this.accessory.targetOperationMode = 1;
1168
+ obj.currentOperationMode = roomTemperature > setTemperature ? 0 : 1;
1169
+ obj.targetOperationMode = 1;
1163
1170
  break;
1164
1171
  case 10: //ISEE DRY
1165
- this.accessory.currentOperationMode = 0;
1166
- this.accessory.targetOperationMode = this.autoDryFanMode === 2 ? 3 : this.heatDryFanMode === 2 ? 1 : this.coolDryFanMode === 2 ? 2 : this.accessory.targetOperationMode ?? 0;
1172
+ obj.currentOperationMode = 0;
1173
+ obj.targetOperationMode = this.autoDryFanMode === 2 ? 3 : this.heatDryFanMode === 2 ? 1 : this.coolDryFanMode === 2 ? 2 : obj.targetOperationMode ?? 0;
1167
1174
  break;
1168
1175
  case 11: //ISEE COOL;
1169
- this.accessory.currentOperationMode = roomTemperature < setTemperature ? 0 : 2;
1170
- this.accessory.targetOperationMode = 2;
1176
+ obj.currentOperationMode = roomTemperature < setTemperature ? 0 : 2;
1177
+ obj.targetOperationMode = 2;
1171
1178
  break;
1172
1179
  default:
1173
1180
  this.emit('warn', `Unknown operating mode: ${operationMode}`);
1174
1181
  break;
1175
1182
  };
1176
1183
 
1177
- this.accessory.currentOperationMode = !power ? 0 : this.accessory.currentOperationMode;
1178
- this.accessory.targetOperationMode = !power ? 0 : this.accessory.targetOperationMode;
1179
- this.accessory.operationModeSetPropsMinValue = 0
1180
- this.accessory.operationModeSetPropsMaxValue = modelSupportsAuto && modelSupportsHeat ? 3 : !modelSupportsAuto && modelSupportsHeat ? 2 : modelSupportsAuto && !modelSupportsHeat ? 3 : 2;
1181
- this.accessory.operationModeSetPropsValidValues = modelSupportsAuto && modelSupportsHeat ? [0, 1, 2, 3] : !modelSupportsAuto && modelSupportsHeat ? [0, 1, 2] : modelSupportsAuto && !modelSupportsHeat ? [0, 2, 3] : [0, 2];
1184
+ obj.currentOperationMode = !power ? 0 : obj.currentOperationMode;
1185
+ obj.targetOperationMode = !power ? 0 : obj.targetOperationMode;
1186
+ obj.operationModeSetPropsMinValue = 0
1187
+ obj.operationModeSetPropsMaxValue = modelSupportsAuto && modelSupportsHeat ? 3 : !modelSupportsAuto && modelSupportsHeat ? 2 : modelSupportsAuto && !modelSupportsHeat ? 3 : 2;
1188
+ obj.operationModeSetPropsValidValues = modelSupportsAuto && modelSupportsHeat ? [0, 1, 2, 3] : !modelSupportsAuto && modelSupportsHeat ? [0, 1, 2] : modelSupportsAuto && !modelSupportsHeat ? [0, 2, 3] : [0, 2];
1182
1189
 
1183
1190
  //update characteristics
1184
1191
  if (this.melCloudService) {
1185
1192
  this.melCloudService
1186
- .updateCharacteristic(Characteristic.CurrentHeatingCoolingState, this.accessory.currentOperationMode)
1187
- .updateCharacteristic(Characteristic.TargetHeatingCoolingState, this.accessory.targetOperationMode)
1193
+ .updateCharacteristic(Characteristic.CurrentHeatingCoolingState, obj.currentOperationMode)
1194
+ .updateCharacteristic(Characteristic.TargetHeatingCoolingState, obj.targetOperationMode)
1188
1195
  .updateCharacteristic(Characteristic.CurrentTemperature, roomTemperature)
1189
1196
  .updateCharacteristic(Characteristic.TargetTemperature, setTemperature)
1190
- .updateCharacteristic(Characteristic.TemperatureDisplayUnits, this.accessory.useFahrenheit);
1197
+ .updateCharacteristic(Characteristic.TemperatureDisplayUnits, obj.useFahrenheit);
1191
1198
  };
1192
1199
  break;
1193
1200
  };
1201
+ this.mielHvac = obj;
1194
1202
 
1195
1203
  if (this.roomTemperatureSensorService) {
1196
1204
  this.roomTemperatureSensorService
@@ -1321,7 +1329,7 @@ class DeviceAta extends EventEmitter {
1321
1329
  button.state = power ? (fanSpeed === 6) : false;
1322
1330
  break;
1323
1331
  case 37: //PHYSICAL LOCK CONTROLS ALL
1324
- button.state = (this.accessory.lockPhysicalControl === 1);
1332
+ button.state = (obj.lockPhysicalControl === 1);
1325
1333
  break;
1326
1334
  case 38: //PHYSICAL LOCK CONTROLS POWER
1327
1335
  button.state = (prohibitPower === true);
@@ -1350,17 +1358,17 @@ class DeviceAta extends EventEmitter {
1350
1358
  if (!this.disableLogInfo) {
1351
1359
  this.emit('message', `Power: ${power ? 'ON' : 'OFF'}`);
1352
1360
  this.emit('message', `Target operation mode: ${AirConditioner.DriveMode[operationMode]}`);
1353
- this.emit('message', `Current operation mode: ${this.displayMode === 1 ? AirConditioner.CurrentOperationModeHeatherCooler[this.accessory.currentOperationMode] : AirConditioner.CurrentOperationModeThermostat[this.accessory.currentOperationMode]}`);
1354
- this.emit('message', `Target temperature: ${setTemperature}${this.accessory.temperatureUnit}`);
1355
- this.emit('message', `Current temperature: ${roomTemperature}${this.accessory.temperatureUnit}`);
1356
- const info = hasOutdoorTemperature && outdoorTemperature !== null ? this.emit('message', `Outdoor temperature: ${outdoorTemperature}${this.accessory.temperatureUnit}`) : false;
1361
+ this.emit('message', `Current operation mode: ${this.displayMode === 1 ? AirConditioner.CurrentOperationModeHeatherCooler[obj.currentOperationMode] : AirConditioner.CurrentOperationModeThermostat[obj.currentOperationMode]}`);
1362
+ this.emit('message', `Target temperature: ${setTemperature}${obj.temperatureUnit}`);
1363
+ this.emit('message', `Current temperature: ${roomTemperature}${obj.temperatureUnit}`);
1364
+ const info = hasOutdoorTemperature && outdoorTemperature !== null ? this.emit('message', `Outdoor temperature: ${outdoorTemperature}${obj.temperatureUnit}`) : false;
1357
1365
  const info3 = modelSupportsFanSpeed ? this.emit('message', `Target fan speed: ${AirConditioner.FanSpeed[fanSpeed]}`) : false;
1358
1366
  const info4 = modelSupportsFanSpeed ? this.emit('message', `Current fan speed: ${AirConditioner.FanSpeed[actualFanSpeed]}`) : false;
1359
1367
  const info5 = vaneHorizontalDirection !== null ? this.emit('message', `Vane horizontal: ${AirConditioner.HorizontalVane[vaneHorizontalDirection] ?? vaneHorizontalDirection}`) : false;
1360
1368
  const info6 = vaneVerticalDirection !== null ? this.emit('message', `Vane vertical: ${AirConditioner.VerticalVane[vaneVerticalDirection] ?? vaneVerticalDirection}`) : false;
1361
- const info7 = swingFunction ? this.emit('message', `Air direction: ${AirConditioner.AirDirection[this.accessory.swingMode]}`) : false;
1362
- this.emit('message', `Temperature display unit: ${this.accessory.temperatureUnit}`);
1363
- this.emit('message', `Lock physical controls: ${this.accessory.lockPhysicalControl ? 'LOCKED' : 'UNLOCKED'}`);
1369
+ const info7 = swingFunction ? this.emit('message', `Air direction: ${AirConditioner.AirDirection[obj.swingMode]}`) : false;
1370
+ this.emit('message', `Temperature display unit: ${obj.temperatureUnit}`);
1371
+ this.emit('message', `Lock physical controls: ${obj.lockPhysicalControl ? 'LOCKED' : 'UNLOCKED'}`);
1364
1372
  };
1365
1373
 
1366
1374
  //prepare accessory