From 1bf6166817c7dcef7f7a030168c1e9967473239a Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Thu, 8 Oct 2020 02:21:29 -0500 Subject: [PATCH] Update fan to use async_add_executor_job (#41457) --- homeassistant/components/fan/__init__.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/homeassistant/components/fan/__init__.py b/homeassistant/components/fan/__init__.py index a4518b15f99..789299bd1ac 100644 --- a/homeassistant/components/fan/__init__.py +++ b/homeassistant/components/fan/__init__.py @@ -117,7 +117,7 @@ class FanEntity(ToggleEntity): if speed == SPEED_OFF: await self.async_turn_off() 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: """Set the direction of the fan.""" @@ -125,7 +125,7 @@ class FanEntity(ToggleEntity): async def async_set_direction(self, direction: str): """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 def turn_on(self, speed: Optional[str] = None, **kwargs) -> None: @@ -138,14 +138,16 @@ class FanEntity(ToggleEntity): if speed == SPEED_OFF: await self.async_turn_off() 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: """Oscillate the fan.""" async def async_oscillate(self, oscillating: bool): """Oscillate the fan.""" - await self.hass.async_add_job(self.oscillate, oscillating) + await self.hass.async_add_executor_job(self.oscillate, oscillating) @property def is_on(self):