Fjaraskupan stop on 0 percentage (#79367)

* Make sure fan turns off on 0 percentage

* Remember old percentage
This commit is contained in:
Joakim Plate 2022-09-30 18:41:38 +02:00 committed by GitHub
parent 6694d06b37
commit 5cdf4220ee
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -82,10 +82,17 @@ class Fan(CoordinatorEntity[Coordinator], FanEntity):
async def async_set_percentage(self, percentage: int) -> None: async def async_set_percentage(self, percentage: int) -> None:
"""Set speed.""" """Set speed."""
# Proactively update percentage to mange successive increases
self._percentage = percentage
async with self.coordinator.async_connect_and_update() as device:
if percentage == 0:
await device.send_command(COMMAND_STOP_FAN)
else:
new_speed = percentage_to_ordered_list_item( new_speed = percentage_to_ordered_list_item(
ORDERED_NAMED_FAN_SPEEDS, percentage ORDERED_NAMED_FAN_SPEEDS, percentage
) )
async with self.coordinator.async_connect_and_update() as device:
await device.send_fan_speed(int(new_speed)) await device.send_fan_speed(int(new_speed))
async def async_turn_on( async def async_turn_on(