mirror of
https://github.com/home-assistant/core.git
synced 2025-07-20 11:47:06 +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
|
api_version = self._api_version
|
||||||
return api_version.major == 1 and api_version.minor > 3
|
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."""
|
"""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:
|
if percentage == 0:
|
||||||
await self.async_turn_off()
|
await self.async_turn_off()
|
||||||
return
|
return
|
||||||
@ -95,7 +98,7 @@ class EsphomeFan(EsphomeEntity[FanInfo, FanState], FanEntity):
|
|||||||
**kwargs: Any,
|
**kwargs: Any,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Turn on the fan."""
|
"""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:
|
async def async_turn_off(self, **kwargs: Any) -> None:
|
||||||
"""Turn off the fan."""
|
"""Turn off the fan."""
|
||||||
|
@ -52,8 +52,11 @@ class SmartThingsFan(SmartThingsEntity, FanEntity):
|
|||||||
|
|
||||||
_attr_supported_features = FanEntityFeature.SET_SPEED
|
_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."""
|
"""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:
|
if percentage is None:
|
||||||
await self._device.switch_on(set_status=True)
|
await self._device.switch_on(set_status=True)
|
||||||
elif percentage == 0:
|
elif percentage == 0:
|
||||||
@ -72,7 +75,7 @@ class SmartThingsFan(SmartThingsEntity, FanEntity):
|
|||||||
**kwargs,
|
**kwargs,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Turn the fan on."""
|
"""Turn the fan on."""
|
||||||
await self.async_set_percentage(percentage)
|
await self._async_set_percentage(percentage)
|
||||||
|
|
||||||
async def async_turn_off(self, **kwargs) -> None:
|
async def async_turn_off(self, **kwargs) -> None:
|
||||||
"""Turn the fan off."""
|
"""Turn the fan off."""
|
||||||
|
@ -136,15 +136,18 @@ class WemoHumidifier(WemoBinaryStateEntity, FanEntity):
|
|||||||
**kwargs: Any,
|
**kwargs: Any,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Turn the fan on."""
|
"""Turn the fan on."""
|
||||||
self.set_percentage(percentage)
|
self._set_percentage(percentage)
|
||||||
|
|
||||||
def turn_off(self, **kwargs: Any) -> None:
|
def turn_off(self, **kwargs: Any) -> None:
|
||||||
"""Turn the switch off."""
|
"""Turn the switch off."""
|
||||||
with self._wemo_call_wrapper("turn off"):
|
with self._wemo_call_wrapper("turn off"):
|
||||||
self.wemo.set_state(FanMode.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."""
|
"""Set the fan_mode of the Humidifier."""
|
||||||
|
self._set_percentage(percentage)
|
||||||
|
|
||||||
|
def _set_percentage(self, percentage: int | None) -> None:
|
||||||
if percentage is None:
|
if percentage is None:
|
||||||
named_speed = self._last_fan_on_mode
|
named_speed = self._last_fan_on_mode
|
||||||
elif percentage == 0:
|
elif percentage == 0:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user