Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions homeassistant/components/comfoconnect/fan.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
CMD_FAN_MODE_HIGH,
CMD_FAN_MODE_LOW,
CMD_FAN_MODE_MEDIUM,
CMD_MODE_AUTO,
CMD_MODE_MANUAL,
SENSOR_FAN_SPEED_MODE,
)

Expand All @@ -29,6 +31,7 @@
1: CMD_FAN_MODE_LOW,
2: CMD_FAN_MODE_MEDIUM,
3: CMD_FAN_MODE_HIGH,
4: CMD_MODE_AUTO,
}

SPEED_RANGE = (1, 3) # away is not included in speeds and instead mapped to off
Expand Down Expand Up @@ -122,15 +125,18 @@ def turn_off(self, **kwargs) -> None:
def set_percentage(self, percentage: int):
"""Set fan speed percentage."""
_LOGGER.debug("Changing fan speed percentage to %s", percentage)

manual_cmd = None
if percentage is None:
cmd = CMD_FAN_MODE_LOW
cmd = CMD_MODE_AUTO
elif percentage == 0:
cmd = CMD_FAN_MODE_AWAY
manual_cmd = CMD_MODE_MANUAL
else:
manual_cmd = CMD_MODE_MANUAL
speed = math.ceil(percentage_to_ranged_value(SPEED_RANGE, percentage))
cmd = CMD_MAPPING[speed]

if manual_cmd is not None:
self._ccb.comfoconnect.cmd_rmi_request(manual_cmd)
self._ccb.comfoconnect.cmd_rmi_request(cmd)

# Update current mode
Expand Down