mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 03:07:37 +00:00
Adjust set_percentage routine in fans (#73837)
This commit is contained in:
parent
86fde1a644
commit
837957d89e
@ -67,8 +67,11 @@ class EsphomeFan(EsphomeEntity[FanInfo, FanState], FanEntity):
|
||||
api_version = self._api_version
|
||||
return api_version.major == 1 and api_version.minor > 3
|
||||
|
||||
async def async_set_percentage(self, percentage: int | None) -> None:
|
||||
async def async_set_percentage(self, percentage: int) -> None:
|
||||
"""Set the speed percentage of the fan."""
|
||||
await self._async_set_percentage(percentage)
|
||||
|
||||
async def _async_set_percentage(self, percentage: int | None) -> None:
|
||||
if percentage == 0:
|
||||
await self.async_turn_off()
|
||||
return
|
||||
@ -95,7 +98,7 @@ class EsphomeFan(EsphomeEntity[FanInfo, FanState], FanEntity):
|
||||
**kwargs: Any,
|
||||
) -> None:
|
||||
"""Turn on the fan."""
|
||||
await self.async_set_percentage(percentage)
|
||||
await self._async_set_percentage(percentage)
|
||||
|
||||
async def async_turn_off(self, **kwargs: Any) -> None:
|
||||
"""Turn off the fan."""
|
||||
|
@ -52,8 +52,11 @@ class SmartThingsFan(SmartThingsEntity, FanEntity):
|
||||
|
||||
_attr_supported_features = FanEntityFeature.SET_SPEED
|
||||
|
||||
async def async_set_percentage(self, percentage: int | None) -> None:
|
||||
async def async_set_percentage(self, percentage: int) -> None:
|
||||
"""Set the speed percentage of the fan."""
|
||||
await self._async_set_percentage(percentage)
|
||||
|
||||
async def _async_set_percentage(self, percentage: int | None) -> None:
|
||||
if percentage is None:
|
||||
await self._device.switch_on(set_status=True)
|
||||
elif percentage == 0:
|
||||
@ -72,7 +75,7 @@ class SmartThingsFan(SmartThingsEntity, FanEntity):
|
||||
**kwargs,
|
||||
) -> None:
|
||||
"""Turn the fan on."""
|
||||
await self.async_set_percentage(percentage)
|
||||
await self._async_set_percentage(percentage)
|
||||
|
||||
async def async_turn_off(self, **kwargs) -> None:
|
||||
"""Turn the fan off."""
|
||||
|
@ -136,15 +136,18 @@ class WemoHumidifier(WemoBinaryStateEntity, FanEntity):
|
||||
**kwargs: Any,
|
||||
) -> None:
|
||||
"""Turn the fan on."""
|
||||
self.set_percentage(percentage)
|
||||
self._set_percentage(percentage)
|
||||
|
||||
def turn_off(self, **kwargs: Any) -> None:
|
||||
"""Turn the switch off."""
|
||||
with self._wemo_call_wrapper("turn off"):
|
||||
self.wemo.set_state(FanMode.Off)
|
||||
|
||||
def set_percentage(self, percentage: int | None) -> None:
|
||||
def set_percentage(self, percentage: int) -> None:
|
||||
"""Set the fan_mode of the Humidifier."""
|
||||
self._set_percentage(percentage)
|
||||
|
||||
def _set_percentage(self, percentage: int | None) -> None:
|
||||
if percentage is None:
|
||||
named_speed = self._last_fan_on_mode
|
||||
elif percentage == 0:
|
||||
|
Loading…
x
Reference in New Issue
Block a user