Skip to content

Commit

Permalink
Only display swing mode features if device supports a swing mode
Browse files Browse the repository at this point in the history
  • Loading branch information
mill1000 committed Oct 12, 2023
1 parent 3b5da28 commit a6a754f
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion custom_components/midea_ac/climate.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,11 @@ def __init__(self,
self._use_fan_only_workaround = options.get(
CONF_USE_FAN_ONLY_WORKAROUND, False)

# Setup default supported features
self._supported_features = (
SUPPORT_TARGET_TEMPERATURE | SUPPORT_FAN_MODE | SUPPORT_PRESET_MODE)

# Setup supported presets
if options.get(CONF_SHOW_ALL_PRESETS):
# Add all presets
self._preset_modes = [PRESET_NONE, PRESET_SLEEP, PRESET_AWAY,
Expand Down Expand Up @@ -128,6 +133,10 @@ def __init__(self,
supported_swing_modes = getattr(
self._device, "supported_swing_modes", AC.SwingMode.list())

# If device supports any swing mode, add it to supported features
if supported_swing_modes != [AC.SwingMode.OFF]:
self._supported_features |= SUPPORT_SWING_MODE

# Convert Midea swing modes to strings
self._swing_modes = [m.name.capitalize()
for m in supported_swing_modes]
Expand Down Expand Up @@ -189,7 +198,7 @@ def should_poll(self) -> bool:
@property
def supported_features(self) -> int:
"""Return the supported features."""
return SUPPORT_TARGET_TEMPERATURE | SUPPORT_FAN_MODE | SUPPORT_SWING_MODE | SUPPORT_PRESET_MODE
return self._supported_features

@property
def target_temperature_step(self) -> float | None:
Expand Down

0 comments on commit a6a754f

Please sign in to comment.