mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 03:07:37 +00:00
Update fan to use async_add_executor_job (#41457)
This commit is contained in:
parent
e10413fa4c
commit
1bf6166817
@ -117,7 +117,7 @@ class FanEntity(ToggleEntity):
|
|||||||
if speed == SPEED_OFF:
|
if speed == SPEED_OFF:
|
||||||
await self.async_turn_off()
|
await self.async_turn_off()
|
||||||
else:
|
else:
|
||||||
await self.hass.async_add_job(self.set_speed, speed)
|
await self.hass.async_add_executor_job(self.set_speed, speed)
|
||||||
|
|
||||||
def set_direction(self, direction: str) -> None:
|
def set_direction(self, direction: str) -> None:
|
||||||
"""Set the direction of the fan."""
|
"""Set the direction of the fan."""
|
||||||
@ -125,7 +125,7 @@ class FanEntity(ToggleEntity):
|
|||||||
|
|
||||||
async def async_set_direction(self, direction: str):
|
async def async_set_direction(self, direction: str):
|
||||||
"""Set the direction of the fan."""
|
"""Set the direction of the fan."""
|
||||||
await self.hass.async_add_job(self.set_direction, direction)
|
await self.hass.async_add_executor_job(self.set_direction, direction)
|
||||||
|
|
||||||
# pylint: disable=arguments-differ
|
# pylint: disable=arguments-differ
|
||||||
def turn_on(self, speed: Optional[str] = None, **kwargs) -> None:
|
def turn_on(self, speed: Optional[str] = None, **kwargs) -> None:
|
||||||
@ -138,14 +138,16 @@ class FanEntity(ToggleEntity):
|
|||||||
if speed == SPEED_OFF:
|
if speed == SPEED_OFF:
|
||||||
await self.async_turn_off()
|
await self.async_turn_off()
|
||||||
else:
|
else:
|
||||||
await self.hass.async_add_job(ft.partial(self.turn_on, speed, **kwargs))
|
await self.hass.async_add_executor_job(
|
||||||
|
ft.partial(self.turn_on, speed, **kwargs)
|
||||||
|
)
|
||||||
|
|
||||||
def oscillate(self, oscillating: bool) -> None:
|
def oscillate(self, oscillating: bool) -> None:
|
||||||
"""Oscillate the fan."""
|
"""Oscillate the fan."""
|
||||||
|
|
||||||
async def async_oscillate(self, oscillating: bool):
|
async def async_oscillate(self, oscillating: bool):
|
||||||
"""Oscillate the fan."""
|
"""Oscillate the fan."""
|
||||||
await self.hass.async_add_job(self.oscillate, oscillating)
|
await self.hass.async_add_executor_job(self.oscillate, oscillating)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def is_on(self):
|
def is_on(self):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user