mirror of
https://github.com/home-assistant/core.git
synced 2025-07-15 01:07:10 +00:00
Fix typing of fan speed count and steps (#46790)
This commit is contained in:
parent
0e9148e239
commit
3e334a4950
@ -87,7 +87,7 @@ class BondFan(BondEntity, FanEntity):
|
|||||||
return ranged_value_to_percentage(self._speed_range, self._speed)
|
return ranged_value_to_percentage(self._speed_range, self._speed)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def speed_count(self) -> Optional[int]:
|
def speed_count(self) -> int:
|
||||||
"""Return the number of speeds the fan supports."""
|
"""Return the number of speeds the fan supports."""
|
||||||
return int_states_in_range(self._speed_range)
|
return int_states_in_range(self._speed_range)
|
||||||
|
|
||||||
|
@ -216,7 +216,7 @@ class DemoPercentageFan(BaseDemoFan, FanEntity):
|
|||||||
return self._percentage
|
return self._percentage
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def speed_count(self) -> Optional[float]:
|
def speed_count(self) -> int:
|
||||||
"""Return the number of speeds the fan supports."""
|
"""Return the number of speeds the fan supports."""
|
||||||
return 3
|
return 3
|
||||||
|
|
||||||
@ -276,7 +276,7 @@ class AsyncDemoPercentageFan(BaseDemoFan, FanEntity):
|
|||||||
return self._percentage
|
return self._percentage
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def speed_count(self) -> Optional[float]:
|
def speed_count(self) -> int:
|
||||||
"""Return the number of speeds the fan supports."""
|
"""Return the number of speeds the fan supports."""
|
||||||
return 3
|
return 3
|
||||||
|
|
||||||
|
@ -156,7 +156,7 @@ class DysonFanEntity(DysonEntity, FanEntity):
|
|||||||
return ranged_value_to_percentage(SPEED_RANGE, int(self._device.state.speed))
|
return ranged_value_to_percentage(SPEED_RANGE, int(self._device.state.speed))
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def speed_count(self) -> Optional[int]:
|
def speed_count(self) -> int:
|
||||||
"""Return the number of speeds the fan supports."""
|
"""Return the number of speeds the fan supports."""
|
||||||
return int_states_in_range(SPEED_RANGE)
|
return int_states_in_range(SPEED_RANGE)
|
||||||
|
|
||||||
|
@ -120,7 +120,7 @@ class EsphomeFan(EsphomeEntity, FanEntity):
|
|||||||
)
|
)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def speed_count(self) -> Optional[int]:
|
def speed_count(self) -> int:
|
||||||
"""Return the number of speeds the fan supports."""
|
"""Return the number of speeds the fan supports."""
|
||||||
return len(ORDERED_NAMED_FAN_SPEEDS)
|
return len(ORDERED_NAMED_FAN_SPEEDS)
|
||||||
|
|
||||||
|
@ -272,15 +272,17 @@ class FanEntity(ToggleEntity):
|
|||||||
else:
|
else:
|
||||||
await self.async_set_speed(self.percentage_to_speed(percentage))
|
await self.async_set_speed(self.percentage_to_speed(percentage))
|
||||||
|
|
||||||
async def async_increase_speed(self, percentage_step=None) -> None:
|
async def async_increase_speed(self, percentage_step: Optional[int] = None) -> None:
|
||||||
"""Increase the speed of the fan."""
|
"""Increase the speed of the fan."""
|
||||||
await self._async_adjust_speed(1, percentage_step)
|
await self._async_adjust_speed(1, percentage_step)
|
||||||
|
|
||||||
async def async_decrease_speed(self, percentage_step=None) -> None:
|
async def async_decrease_speed(self, percentage_step: Optional[int] = None) -> None:
|
||||||
"""Decrease the speed of the fan."""
|
"""Decrease the speed of the fan."""
|
||||||
await self._async_adjust_speed(-1, percentage_step)
|
await self._async_adjust_speed(-1, percentage_step)
|
||||||
|
|
||||||
async def _async_adjust_speed(self, modifier, percentage_step) -> None:
|
async def _async_adjust_speed(
|
||||||
|
self, modifier: int, percentage_step: Optional[int]
|
||||||
|
) -> None:
|
||||||
"""Increase or decrease the speed of the fan."""
|
"""Increase or decrease the speed of the fan."""
|
||||||
current_percentage = self.percentage or 0
|
current_percentage = self.percentage or 0
|
||||||
|
|
||||||
@ -462,7 +464,7 @@ class FanEntity(ToggleEntity):
|
|||||||
return 0
|
return 0
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def speed_count(self) -> Optional[int]:
|
def speed_count(self) -> int:
|
||||||
"""Return the number of speeds the fan supports."""
|
"""Return the number of speeds the fan supports."""
|
||||||
speed_list = speed_list_without_preset_modes(self.speed_list)
|
speed_list = speed_list_without_preset_modes(self.speed_list)
|
||||||
if speed_list:
|
if speed_list:
|
||||||
@ -470,7 +472,7 @@ class FanEntity(ToggleEntity):
|
|||||||
return 100
|
return 100
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def percentage_step(self) -> Optional[float]:
|
def percentage_step(self) -> float:
|
||||||
"""Return the step size for percentage."""
|
"""Return the step size for percentage."""
|
||||||
return 100 / self.speed_count
|
return 100 / self.speed_count
|
||||||
|
|
||||||
|
@ -70,7 +70,7 @@ class KNXFan(KnxEntity, FanEntity):
|
|||||||
return self._device.current_speed
|
return self._device.current_speed
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def speed_count(self) -> Optional[int]:
|
def speed_count(self) -> int:
|
||||||
"""Return the number of speeds the fan supports."""
|
"""Return the number of speeds the fan supports."""
|
||||||
if self._step_range is None:
|
if self._step_range is None:
|
||||||
return super().speed_count
|
return super().speed_count
|
||||||
|
@ -81,7 +81,7 @@ class SmartThingsFan(SmartThingsEntity, FanEntity):
|
|||||||
return ranged_value_to_percentage(SPEED_RANGE, self._device.status.fan_speed)
|
return ranged_value_to_percentage(SPEED_RANGE, self._device.status.fan_speed)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def speed_count(self) -> Optional[int]:
|
def speed_count(self) -> int:
|
||||||
"""Return the number of speeds the fan supports."""
|
"""Return the number of speeds the fan supports."""
|
||||||
return int_states_in_range(SPEED_RANGE)
|
return int_states_in_range(SPEED_RANGE)
|
||||||
|
|
||||||
|
@ -103,7 +103,7 @@ class TuyaFanDevice(TuyaDevice, FanEntity):
|
|||||||
self._tuya.oscillate(oscillating)
|
self._tuya.oscillate(oscillating)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def speed_count(self) -> Optional[int]:
|
def speed_count(self) -> int:
|
||||||
"""Return the number of speeds the fan supports."""
|
"""Return the number of speeds the fan supports."""
|
||||||
if self.speeds is None:
|
if self.speeds is None:
|
||||||
return super().speed_count
|
return super().speed_count
|
||||||
|
@ -98,7 +98,7 @@ class ZwaveFan(ZWaveBaseEntity, FanEntity):
|
|||||||
return ranged_value_to_percentage(SPEED_RANGE, self.info.primary_value.value)
|
return ranged_value_to_percentage(SPEED_RANGE, self.info.primary_value.value)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def speed_count(self) -> Optional[int]:
|
def speed_count(self) -> int:
|
||||||
"""Return the number of speeds the fan supports."""
|
"""Return the number of speeds the fan supports."""
|
||||||
return int_states_in_range(SPEED_RANGE)
|
return int_states_in_range(SPEED_RANGE)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user