Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for HomeKit fan modes (issue #563) #704

Merged
9 changes: 6 additions & 3 deletions custom_components/smartthinq_sensors/wideq/devices/ac.py
Original file line number Diff line number Diff line change
Expand Up @@ -544,8 +544,8 @@ def op_modes(self):

@cached_property
def fan_speeds(self):
"""Return a list of available fan speeds."""
return self._get_property_values(SUPPORT_WIND_STRENGTH, ACFanSpeed)
"""Return a list of available fan speeds, converted to lowercase for HomeKit compatibility."""
return list(map(str.lower, self._get_property_values(SUPPORT_WIND_STRENGTH, ACFanSpeed)))

@cached_property
def horizontal_step_modes(self):
Expand Down Expand Up @@ -690,6 +690,8 @@ async def set_fan_speed(self, speed):
"""Set the fan speed to a value from the `ACFanSpeed` enum."""
if speed not in self.fan_speeds:
diegocjorge marked this conversation as resolved.
Show resolved Hide resolved
raise ValueError(f"Invalid fan speed: {speed}")
# Necessary for HomeKit compatibility
speed = speed.upper()
keys = self._get_cmd_keys(CMD_STATE_WIND_STRENGTH)
speed_value = self.model_info.enum_value(keys[2], ACFanSpeed[speed].value)
diegocjorge marked this conversation as resolved.
Show resolved Hide resolved
await self.set(keys[0], keys[1], key=keys[2], value=speed_value)
Expand Down Expand Up @@ -1070,7 +1072,8 @@ def fan_speed(self):
if (value := self.lookup_enum(key, True)) is None:
return None
try:
return ACFanSpeed(value).name
# Lowercase necessary for HomeKit compatibility
return ACFanSpeed(value).name.lower()
except ValueError:
return None

Expand Down
Loading