Implement percentage step sizes for fans (#46512)

Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io>
This commit is contained in:
J. Nick Koston 2021-02-18 21:05:09 -10:00 committed by GitHub
parent 5df46b60e8
commit f2b303d509
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
24 changed files with 447 additions and 3 deletions

View file

@ -13,6 +13,7 @@ import voluptuous as vol
from homeassistant.components.fan import SUPPORT_OSCILLATE, SUPPORT_SET_SPEED, FanEntity
from homeassistant.helpers import config_validation as cv, entity_platform
from homeassistant.util.percentage import (
int_states_in_range,
percentage_to_ranged_value,
ranged_value_to_percentage,
)
@ -154,6 +155,11 @@ class DysonFanEntity(DysonEntity, FanEntity):
return None
return ranged_value_to_percentage(SPEED_RANGE, int(self._device.state.speed))
@property
def speed_count(self) -> Optional[int]:
"""Return the number of speeds the fan supports."""
return int_states_in_range(SPEED_RANGE)
@property
def preset_modes(self):
"""Return the available preset modes."""