homebridge-melcloud-control 3.3.28 → 3.3.29

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "displayName": "MELCloud Control",
3
3
  "name": "homebridge-melcloud-control",
4
- "version": "3.3.28",
4
+ "version": "3.3.29",
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
@@ -241,7 +241,7 @@ class DeviceAta extends EventEmitter {
241
241
  const defaultCoolingSetTemperature = deviceData.Device.DefaultCoolingSetTemperature ?? 23;
242
242
  const actualFanSpeed = deviceData.Device.ActualFanSpeed;
243
243
  const automaticFanSpeed = deviceData.Device.AutomaticFanSpeed;
244
- const fanSpeed = deviceData.Device.FanSpeed;
244
+ const fanSpeed = deviceData.Device.FanSpeed ?? 0;
245
245
  const operationMode = deviceData.Device.OperationMode;
246
246
  const vaneVerticalDirection = deviceData.Device.VaneVerticalDirection;
247
247
  const vaneVerticalSwing = deviceData.Device.VaneVerticalSwing;
@@ -828,8 +828,29 @@ class DeviceAta extends EventEmitter {
828
828
  })
829
829
  .onSet(async (value) => {
830
830
  try {
831
- const fanSpeedModeText = hasAutomaticFanSpeed ? [7, 1, 2, 3, 4, 5, 6, 0][value] : [7, 1, 2, 3, 4, 5, 6][value];
832
- deviceData.Device.FanSpeed = hasAutomaticFanSpeed ? [0, 1, 2, 3, 4, 5, 6, 0][value] : [1, 1, 2, 3, 4, 5, 6][value];
831
+ let fanSpeedModeText = '';
832
+ switch (numberOfFanSpeeds) {
833
+ case 2: //Fan speed mode 2
834
+ fanSpeedModeText = hasAutomaticFanSpeed ? [7, 1, 2, 0][value] : [7, 1, 2][value];
835
+ deviceData.Device.FanSpeed = hasAutomaticFanSpeed ? [0, 1, 2, 0][value] : [1, 1, 2][value];
836
+ break;
837
+ case 3: //Fan speed mode 3
838
+ fanSpeedModeText = hasAutomaticFanSpeed ? [7, 1, 2, 3, 0][value] : [7, 1, 2, 3][value];
839
+ deviceData.Device.FanSpeed = hasAutomaticFanSpeed ? [0, 1, 2, 3, 0][value] : [1, 1, 2, 3][value];
840
+ break;
841
+ case 4: //Fan speed mode 4
842
+ fanSpeedModeText = hasAutomaticFanSpeed ? [7, 1, 2, 3, 4, 0][value] : [7, 1, 2, 3, 4][value];
843
+ deviceData.Device.FanSpeed = hasAutomaticFanSpeed ? [0, 1, 2, 3, 4, 0][value] : [1, 1, 2, 3, 4][value];
844
+ break;
845
+ case 5: //Fan speed mode 5
846
+ 5; fanSpeedModeText = hasAutomaticFanSpeed ? [7, 1, 2, 3, 4, 5, 0][value] : [7, 1, 2, 3, 4, 5][value];
847
+ deviceData.Device.FanSpeed = hasAutomaticFanSpeed ? [0, 1, 2, 3, 4, 5, 0][value] : [1, 1, 2, 3, 4, 5][value];
848
+ break;
849
+ case 6: //Fan speed mode 6
850
+ fanSpeedModeText = hasAutomaticFanSpeed ? [7, 1, 2, 3, 4, 5, 6, 0][value] : [7, 1, 2, 3, 4, 5, 6][value];
851
+ deviceData.Device.FanSpeed = hasAutomaticFanSpeed ? [0, 1, 2, 3, 4, 5, 6, 0][value] : [1, 1, 2, 3, 4, 5, 6][value];
852
+ break;
853
+ };
833
854
  deviceData.Device.EffectiveFlags = CONSTANTS.AirConditioner.EffectiveFlags.SetFanSpeed;
834
855
  await this.melCloudAta.send(deviceData, this.displayMode);
835
856
  const info = this.disableLogInfo ? false : this.emit('message', `Set fan speed mode: ${CONSTANTS.AirConditioner.FanSpeed[fanSpeedModeText]}`);
package/src/deviceerv.js CHANGED
@@ -668,6 +668,7 @@ class DeviceErv extends EventEmitter {
668
668
  const hasAutomaticFanSpeed = this.accessory.hasAutomaticFanSpeed;
669
669
  const hasCO2Sensor = this.accessory.hasCO2Sensor;
670
670
  const hasPM25Sensor = this.accessory.hasPM25Sensor;
671
+ const numberOfFanSpeeds = this.accessory.numberOfFanSpeeds;
671
672
 
672
673
  //accessory
673
674
  const debug = this.enableDebugMode ? this.emit('debug', `Prepare accessory`) : false;
@@ -760,8 +761,25 @@ class DeviceErv extends EventEmitter {
760
761
  })
761
762
  .onSet(async (value) => {
762
763
  try {
763
- const fanSpeedModeText = hasAutomaticFanSpeed ? [5, 1, 2, 3, 4, 0][value] : [5, 1, 2, 3, 4][value];
764
- deviceData.Device.SetFanSpeed = hasAutomaticFanSpeed ? [0, 1, 2, 3, 4, 0][value] : [1, 1, 2, 3, 4][value];
764
+ let fanSpeedModeText = '';
765
+ switch (numberOfFanSpeeds) {
766
+ case 2: //Fan speed mode 2
767
+ fanSpeedModeText = hasAutomaticFanSpeed ? [5, 1, 2, 0][value] : [5, 1, 2][value];
768
+ deviceData.Device.SetFanSpeed = hasAutomaticFanSpeed ? [0, 1, 2, 0][value] : [1, 1, 2][value];
769
+ break;
770
+ case 3: //Fan speed mode 3
771
+ fanSpeedModeText = hasAutomaticFanSpeed ? [5, 1, 2, 3, 0][value] : [5, 1, 2, 3][value];
772
+ deviceData.Device.SetFanSpeed = hasAutomaticFanSpeed ? [0, 1, 2, 3, 0][value] : [1, 1, 2, 3][value];
773
+ break;
774
+ case 4: //Fan speed mode 4
775
+ fanSpeedModeText = hasAutomaticFanSpeed ? [5, 1, 2, 3, 4, 0][value] : [5, 1, 2, 3, 4][value];
776
+ deviceData.Device.SetFanSpeed = hasAutomaticFanSpeed ? [0, 1, 2, 3, 4, 0][value] : [1, 1, 2, 3, 4][value];
777
+ break;
778
+ case 5: //Fan speed mode 5
779
+ 5; fanSpeedModeText = hasAutomaticFanSpeed ? [5, 1, 2, 3, 4, 5, 0][value] : [5, 1, 2, 3, 4, 5][value];
780
+ deviceData.Device.SetFanSpeed = hasAutomaticFanSpeed ? [0, 1, 2, 3, 4, 5, 0][value] : [1, 1, 2, 3, 4, 5][value];
781
+ break;;
782
+ };
765
783
  deviceData.Device.EffectiveFlags = CONSTANTS.Ventilation.EffectiveFlags.SetFanSpeed;
766
784
  await this.melCloudErv.send(deviceData, this.displayMode);
767
785
  const info = this.disableLogInfo ? false : this.emit('message', `Set fan speed mode: ${CONSTANTS.Ventilation.FanSpeed[fanSpeedModeText]}`);