homebridge-melcloud-control 4.3.16-beta.7 → 4.3.16-beta.9

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/deviceata.js +106 -36
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.16-beta.7",
4
+ "version": "4.3.16-beta.9",
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/deviceata.js CHANGED
@@ -697,7 +697,7 @@ class DeviceAta extends EventEmitter {
697
697
  }
698
698
 
699
699
  //frost protection
700
- if (this.frostProtectionSupport && this.accessory.frostProtectionEnabled !== null) {
700
+ if (this.frostProtectionSupport && this.accessory.frostProtection.Enabled !== null) {
701
701
  //control
702
702
  if (this.logDebug) this.emit('debug', `Prepare frost protection control service`);
703
703
  const frostProtectionControlService = new Service.HeaterCooler(`${serviceName} Frost Protection`, `frostProtectionControlService${deviceId}`);
@@ -710,7 +710,7 @@ class DeviceAta extends EventEmitter {
710
710
  })
711
711
  .onSet(async (state) => {
712
712
  try {
713
- deviceData.FrostProtection.Enabled = state;
713
+ deviceData.FrostProtection.Enabled = state ? true : false;
714
714
  if (this.logInfo) this.emit('info', `Frost protection: ${state ? 'Enabled' : 'Disabled'}`);
715
715
  await this.melCloudAta.send(this.accountType, this.displayType, deviceData, 'frostprotection');
716
716
  } catch (error) {
@@ -734,11 +734,11 @@ class DeviceAta extends EventEmitter {
734
734
  })
735
735
  .onSet(async (value) => {
736
736
  try {
737
- deviceData.Device.FrostProtection.Enabled = true;
737
+ deviceData.FrostProtection.Enabled = true;
738
738
  if (this.logInfo) this.emit('info', `Frost protection: Enabled`);
739
739
  await this.melCloudAta.send(this.accountType, this.displayType, deviceData, 'frostprotection');
740
740
  } catch (error) {
741
- if (this.logWarn) this.emit('warn', `Set operation mode error: ${error}`);
741
+ if (this.logWarn) this.emit('warn', `Set frost protection error: ${error}`);
742
742
  };
743
743
  });
744
744
  frostProtectionControlService.getCharacteristic(Characteristic.CurrentTemperature)
@@ -746,7 +746,7 @@ class DeviceAta extends EventEmitter {
746
746
  const value = this.accessory.roomTemperature;
747
747
  return value;
748
748
  });
749
- frostProtectionControlService.getCharacteristic(Characteristic.CoolingThresholdTemperature) //frost max
749
+ frostProtectionControlService.getCharacteristic(Characteristic.CoolingThresholdTemperature) //max
750
750
  .setProps({
751
751
  minValue: 6,
752
752
  maxValue: 16,
@@ -765,7 +765,7 @@ class DeviceAta extends EventEmitter {
765
765
  if (this.logWarn) this.emit('warn', `Set frost protection max. temperature error: ${error}`);
766
766
  };
767
767
  });
768
- frostProtectionControlService.getCharacteristic(Characteristic.HeatingThresholdTemperature) //frost min
768
+ frostProtectionControlService.getCharacteristic(Characteristic.HeatingThresholdTemperature) //min
769
769
  .setProps({
770
770
  minValue: 4,
771
771
  maxValue: 14,
@@ -793,7 +793,7 @@ class DeviceAta extends EventEmitter {
793
793
  this.frostProtectionControlSensorService.setCharacteristic(Characteristic.ConfiguredName, `${accessoryName} Frost Protection Control`);
794
794
  this.frostProtectionControlSensorService.getCharacteristic(Characteristic.ContactSensorState)
795
795
  .onGet(async () => {
796
- const state = this.accessory.frostProtectionEnabled;
796
+ const state = this.accessory.frostProtection.Enabled;
797
797
  return state;
798
798
  })
799
799
  accessory.addService(this.frostProtectionControlSensorService);
@@ -805,34 +805,102 @@ class DeviceAta extends EventEmitter {
805
805
  this.frostProtectionSensorService.setCharacteristic(Characteristic.ConfiguredName, `${accessoryName} Frost Protection`);
806
806
  this.frostProtectionSensorService.getCharacteristic(Characteristic.ContactSensorState)
807
807
  .onGet(async () => {
808
- const state = this.accessory.frostProtectionActive;
808
+ const state = this.accessory.frostProtection.Active;
809
809
  return state;
810
810
  })
811
811
  accessory.addService(this.frostProtectionSensorService);
812
812
  }
813
813
 
814
814
  //overheat protection
815
- if (this.overheatProtectionSupport && this.accessory.overheatProtectionEnabled !== null) {
815
+ if (this.overheatProtectionSupport && this.accessory.overheatProtection.Enabled !== null) {
816
816
  //control
817
817
  if (this.logDebug) this.emit('debug', `Prepare overheat protection control service`);
818
- this.overheatProtectionControlService = new Service.Switch(`${serviceName} Overheat Protection`, `overheatProtectionControlService${deviceId}`);
819
- this.overheatProtectionControlService.addOptionalCharacteristic(Characteristic.ConfiguredName);
820
- this.overheatProtectionControlService.setCharacteristic(Characteristic.ConfiguredName, `${accessoryName} Overheat Protection`);
821
- this.overheatProtectionControlService.getCharacteristic(Characteristic.On)
818
+ const overheatProtectionControlService = new Service.HeaterCooler(`${serviceName} Overheat Protection`, `overheatProtectionControlService${deviceId}`);
819
+ overheatProtectionControlService.addOptionalCharacteristic(Characteristic.ConfiguredName);
820
+ overheatProtectionControlService.setCharacteristic(Characteristic.ConfiguredName, `${accessoryName} Overheat Protection`);
821
+ overheatProtectionControlService.getCharacteristic(Characteristic.Active)
822
822
  .onGet(async () => {
823
- const state = this.accessory.overheatProtectionEnabled;
823
+ const state = this.accessory.overheatProtection.Enabled;
824
824
  return state;
825
825
  })
826
826
  .onSet(async (state) => {
827
827
  try {
828
- deviceData.OverheatProtection.Enabled = state;
828
+ deviceData.OverheatProtection.Enabled = state ? true : false;
829
829
  if (this.logInfo) this.emit('info', `Overheat protection: ${state ? 'Enabled' : 'Disabled'}`);
830
830
  await this.melCloudAta.send(this.accountType, this.displayType, deviceData, 'overheatprotection');
831
831
  } catch (error) {
832
832
  if (this.logWarn) this.emit('warn', `Set overheat protection error: ${error}`);
833
833
  };
834
834
  });
835
- accessory.addService(this.overheatProtectionControlService);
835
+ overheatProtectionControlService.getCharacteristic(Characteristic.CurrentHeaterCoolerState)
836
+ .onGet(async () => {
837
+ const value = this.accessory.overheatProtection.Active ? 2 : 1;
838
+ return value;
839
+ })
840
+ overheatProtectionControlService.getCharacteristic(Characteristic.TargetHeaterCoolerState)
841
+ .setProps({
842
+ minValue: 0,
843
+ maxValue: 0,
844
+ validValues: [0]
845
+ })
846
+ .onGet(async () => {
847
+ const value = 0
848
+ return value;
849
+ })
850
+ .onSet(async (value) => {
851
+ try {
852
+ deviceData.OverheatProtection.Enabled = true;
853
+ if (this.logInfo) this.emit('info', `Set overheat protection: Enabled`);
854
+ await this.melCloudAta.send(this.accountType, this.displayType, deviceData, 'overheatprotection');
855
+ } catch (error) {
856
+ if (this.logWarn) this.emit('warn', `Set overheat protection error: ${error}`);
857
+ };
858
+ });
859
+ overheatProtectionControlService.getCharacteristic(Characteristic.CurrentTemperature)
860
+ .onGet(async () => {
861
+ const value = this.accessory.roomTemperature;
862
+ return value;
863
+ });
864
+ overheatProtectionControlService.getCharacteristic(Characteristic.CoolingThresholdTemperature) //max
865
+ .setProps({
866
+ minValue: 33,
867
+ maxValue: 40,
868
+ minStep: 1
869
+ })
870
+ .onGet(async () => {
871
+ const value = this.accessory.overheatProtection.Max;
872
+ return value;
873
+ })
874
+ .onSet(async (value) => {
875
+ try {
876
+ deviceData.OverheatProtection.Max = value;
877
+ if (this.logInfo) this.emit('info', `Set overheat protection max. temperature: ${value}${this.accessory.temperatureUnit}`);
878
+ await this.melCloudAta.send(this.accountType, this.displayType, deviceData, 'overheatprotection');
879
+ } catch (error) {
880
+ if (this.logWarn) this.emit('warn', `Set overheat protection max. temperature error: ${error}`);
881
+ };
882
+ });
883
+ overheatProtectionControlService.getCharacteristic(Characteristic.HeatingThresholdTemperature) //min
884
+ .setProps({
885
+ minValue: 31,
886
+ maxValue: 38,
887
+ minStep: 1
888
+ })
889
+ .onGet(async () => {
890
+ const value = this.accessory.overheatProtection.Min;
891
+ return value;
892
+ })
893
+ .onSet(async (value) => {
894
+ try {
895
+ deviceData.OverheatProtection.Min = value;
896
+ if (this.logInfo) this.emit('info', `Set overheat protection min. temperature: ${value}${this.accessory.temperatureUnit}`);
897
+ await this.melCloudAta.send(this.accountType, this.displayType, deviceData, 'overheatprotection');
898
+ } catch (error) {
899
+ if (this.logWarn) this.emit('warn', `Set overheat protection min. temperature error: ${error}`);
900
+ };
901
+ });
902
+ this.overheatProtectionControlService = overheatProtectionControlService;
903
+ accessory.addService(overheatProtectionControlService);
836
904
 
837
905
  if (this.logDebug) this.emit('debug', `Prepare overheat protection control sensor service`);
838
906
  this.overheatProtectionControlSensorService = new Service.ContactSensor(`${serviceName} Overheat Protection Control`, `overheatProtectionControlSensorService${deviceId}`);
@@ -840,7 +908,7 @@ class DeviceAta extends EventEmitter {
840
908
  this.overheatProtectionControlSensorService.setCharacteristic(Characteristic.ConfiguredName, `${accessoryName} Overheat Protection Control`);
841
909
  this.overheatProtectionControlSensorService.getCharacteristic(Characteristic.ContactSensorState)
842
910
  .onGet(async () => {
843
- const state = this.accessory.overheatProtectionEnabled;
911
+ const state = this.accessory.overheatProtection.Enabled;
844
912
  return state;
845
913
  })
846
914
  accessory.addService(this.overheatProtectionControlSensorService);
@@ -851,7 +919,7 @@ class DeviceAta extends EventEmitter {
851
919
  this.overheatProtectionSensorService.setCharacteristic(Characteristic.ConfiguredName, `${accessoryName} Overheat Protection`);
852
920
  this.overheatProtectionSensorService.getCharacteristic(Characteristic.ContactSensorState)
853
921
  .onGet(async () => {
854
- const state = this.accessory.overheatProtectionActive;
922
+ const state = this.accessory.overheatProtection.Active;
855
923
  return state;
856
924
  })
857
925
  accessory.addService(this.overheatProtectionSensorService);
@@ -1437,12 +1505,8 @@ class DeviceAta extends EventEmitter {
1437
1505
  const holidayModeActive = deviceData.HolidayMode?.Active ?? false;
1438
1506
 
1439
1507
  //protection
1440
- const frostProtection = deviceData.FrostProtection;
1441
- const frostProtectionEnabled = frostProtection?.Enabled;
1442
- const frostProtectionActive = frostProtection?.Active ?? false;
1443
- const overheatProtection = deviceData.OverheatProtection;
1444
- const overheatProtectionEnabled = overheatProtection?.Enabled;
1445
- const overheatProtectionActive = overheatProtection?.Active ?? false;
1508
+ const frostProtection = deviceData.FrostProtection ?? {};
1509
+ const overheatProtection = deviceData.OverheatProtection ?? {};
1446
1510
 
1447
1511
  //device control
1448
1512
  const hideVaneControls = deviceData.HideVaneControls ?? false;
@@ -1536,11 +1600,7 @@ class DeviceAta extends EventEmitter {
1536
1600
  isConnected: isConnected,
1537
1601
  isInError: isInError,
1538
1602
  frostProtection: frostProtection,
1539
- frostProtectionEnabled: frostProtectionEnabled,
1540
- frostProtectionActive: frostProtectionActive,
1541
1603
  overheatProtection: overheatProtection,
1542
- overheatProtectionEnabled: overheatProtectionEnabled,
1543
- overheatProtectionActive: overheatProtectionActive,
1544
1604
  holidayModeEnabled: holidayModeEnabled,
1545
1605
  holidayModeActive: holidayModeActive,
1546
1606
  scheduleEnabled: scheduleEnabled
@@ -1704,17 +1764,27 @@ class DeviceAta extends EventEmitter {
1704
1764
  this.errorService?.updateCharacteristic(Characteristic.ContactSensorState, isInError);
1705
1765
 
1706
1766
  //frost protection
1707
- if (this.frostProtectionSupport && frostProtectionEnabled !== null) {
1708
- this.frostProtectionControlService?.updateCharacteristic(Characteristic.On, frostProtectionEnabled);
1709
- this.frostProtectionControlSensorService?.updateCharacteristic(Characteristic.ContactSensorState, frostProtectionEnabled);
1710
- this.frostProtectionSensorService?.updateCharacteristic(Characteristic.ContactSensorState, frostProtectionActive);
1767
+ if (this.frostProtectionSupport && frostProtection.Enabled !== null) {
1768
+ this.frostProtectionControlService?.updateCharacteristic(Characteristic.Active, frostProtection.Enabled);
1769
+ this.frostProtectionControlService?.updateCharacteristic(Characteristic.CurrentHeaterCoolerState, frostProtection.Active ? 2 : 1);
1770
+ this.frostProtectionControlService?.updateCharacteristic(Characteristic.TargetHeaterCoolerState, frostProtection.Active ? 2 : 1);
1771
+ this.frostProtectionControlService?.updateCharacteristic(Characteristic.CurrentTemperature, roomTemperature);
1772
+ this.frostProtectionControlService?.updateCharacteristic(Characteristic.CoolingThresholdTemperature, frostProtection.Max);
1773
+ this.frostProtectionControlService?.updateCharacteristic(Characteristic.HeatingThresholdTemperature, frostProtection.Min);
1774
+ this.frostProtectionControlSensorService?.updateCharacteristic(Characteristic.ContactSensorState, frostProtection.Enabled);
1775
+ this.frostProtectionSensorService?.updateCharacteristic(Characteristic.ContactSensorState, frostProtection.Active);
1711
1776
  }
1712
1777
 
1713
1778
  //overheat protection
1714
- if (this.overheatProtectionSupport && overheatProtectionEnabled !== null) {
1715
- this.overheatProtectionControlService?.updateCharacteristic(Characteristic.On, overheatProtectionEnabled);
1716
- this.overheatProtectionControlSensorService?.updateCharacteristic(Characteristic.ContactSensorState, overheatProtectionEnabled);
1717
- this.overheatProtectionSensorService?.updateCharacteristic(Characteristic.ContactSensorState, overheatProtectionActive);
1779
+ if (this.overheatProtectionSupport && overheatProtection.Enabled !== null) {
1780
+ this.overheatProtectionControlService?.updateCharacteristic(Characteristic.Active, overheatProtection.Enabled);
1781
+ this.overheatProtectionControlService?.updateCharacteristic(Characteristic.CurrentHeaterCoolerState, overheatProtection.Active ? 2 : 1);
1782
+ this.overheatProtectionControlService?.updateCharacteristic(Characteristic.TargetHeaterCoolerState, overheatProtection.Active ? 2 : 1);
1783
+ this.overheatProtectionControlService?.updateCharacteristic(Characteristic.CurrentTemperature, roomTemperature);
1784
+ this.overheatProtectionControlService?.updateCharacteristic(Characteristic.CoolingThresholdTemperature, overheatProtection.Max);
1785
+ this.overheatProtectionControlService?.updateCharacteristic(Characteristic.HeatingThresholdTemperature, overheatProtection.Min);
1786
+ this.overheatProtectionControlSensorService?.updateCharacteristic(Characteristic.ContactSensorState, overheatProtection.Enabled);
1787
+ this.overheatProtectionSensorService?.updateCharacteristic(Characteristic.ContactSensorState, overheatProtection.Active);
1718
1788
  }
1719
1789
 
1720
1790
  //holiday mode