mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 11:17:21 +00:00
Improve type hints in zha fan (#90042)
This commit is contained in:
parent
6f88fe93ef
commit
1303dd12e7
@ -278,10 +278,8 @@ class IkeaFan(BaseFan, ZhaEntity):
|
|||||||
"""Return the number of speeds the fan supports."""
|
"""Return the number of speeds the fan supports."""
|
||||||
return int_states_in_range(IKEA_SPEED_RANGE)
|
return int_states_in_range(IKEA_SPEED_RANGE)
|
||||||
|
|
||||||
async def async_set_percentage(self, percentage: int | None) -> None:
|
async def async_set_percentage(self, percentage: int) -> None:
|
||||||
"""Set the speed percenage of the fan."""
|
"""Set the speed percentage of the fan."""
|
||||||
if percentage is None:
|
|
||||||
percentage = 0
|
|
||||||
fan_mode = math.ceil(percentage_to_ranged_value(IKEA_SPEED_RANGE, percentage))
|
fan_mode = math.ceil(percentage_to_ranged_value(IKEA_SPEED_RANGE, percentage))
|
||||||
await self._async_set_fan_mode(fan_mode)
|
await self._async_set_fan_mode(fan_mode)
|
||||||
|
|
||||||
@ -311,12 +309,17 @@ class IkeaFan(BaseFan, ZhaEntity):
|
|||||||
"""Return the current preset mode."""
|
"""Return the current preset mode."""
|
||||||
return IKEA_PRESET_MODES_TO_NAME.get(self._fan_channel.fan_mode)
|
return IKEA_PRESET_MODES_TO_NAME.get(self._fan_channel.fan_mode)
|
||||||
|
|
||||||
async def async_turn_on(self, percentage=None, preset_mode=None, **kwargs) -> None:
|
async def async_turn_on(
|
||||||
|
self,
|
||||||
|
percentage: int | None = None,
|
||||||
|
preset_mode: str | None = None,
|
||||||
|
**kwargs: Any,
|
||||||
|
) -> None:
|
||||||
"""Turn the entity on."""
|
"""Turn the entity on."""
|
||||||
if percentage is None:
|
if percentage is None:
|
||||||
percentage = (100 / self.speed_count) * IKEA_NAME_TO_PRESET_MODE[
|
percentage = int(
|
||||||
PRESET_MODE_AUTO
|
(100 / self.speed_count) * IKEA_NAME_TO_PRESET_MODE[PRESET_MODE_AUTO]
|
||||||
]
|
)
|
||||||
await self.async_set_percentage(percentage)
|
await self.async_set_percentage(percentage)
|
||||||
|
|
||||||
async def async_turn_off(self, **kwargs: Any) -> None:
|
async def async_turn_off(self, **kwargs: Any) -> None:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user