From ff2872e3763fd676f42260abdac5d949847ae4da Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Tue, 13 Oct 2020 15:45:00 -0500 Subject: [PATCH] Remove unneeded context switch in dyson (#41793) dyson was running the add_message_listener code in the executor even though all it did was append to an array https://github.com/etheralm/libpurecool/blob/master/libpurecool/dyson_device.py#L213 --- homeassistant/components/dyson/air_quality.py | 4 +--- homeassistant/components/dyson/climate.py | 6 ++---- homeassistant/components/dyson/fan.py | 6 ++---- homeassistant/components/dyson/sensor.py | 4 +--- homeassistant/components/dyson/vacuum.py | 2 +- 5 files changed, 7 insertions(+), 15 deletions(-) diff --git a/homeassistant/components/dyson/air_quality.py b/homeassistant/components/dyson/air_quality.py index 84876f49127..4bc41e3b8fc 100644 --- a/homeassistant/components/dyson/air_quality.py +++ b/homeassistant/components/dyson/air_quality.py @@ -50,9 +50,7 @@ class DysonAirSensor(AirQualityEntity): async def async_added_to_hass(self): """Call when entity is added to hass.""" - self.hass.async_add_executor_job( - self._device.add_message_listener, self.on_message - ) + self._device.add_message_listener(self.on_message) def on_message(self, message): """Handle new messages which are received from the fan.""" diff --git a/homeassistant/components/dyson/climate.py b/homeassistant/components/dyson/climate.py index b17b510e93f..d2c23f46093 100644 --- a/homeassistant/components/dyson/climate.py +++ b/homeassistant/components/dyson/climate.py @@ -97,7 +97,7 @@ class DysonPureHotCoolLinkEntity(ClimateEntity): async def async_added_to_hass(self): """Call when entity is added to hass.""" - self.hass.async_add_job(self._device.add_message_listener, self.on_message) + self._device.add_message_listener(self.on_message) def on_message(self, message): """Call when new messages received from the climate.""" @@ -243,9 +243,7 @@ class DysonPureHotCoolEntity(ClimateEntity): async def async_added_to_hass(self): """Call when entity is added to hass.""" - self.hass.async_add_executor_job( - self._device.add_message_listener, self.on_message - ) + self._device.add_message_listener(self.on_message) def on_message(self, message): """Call when new messages received from the climate device.""" diff --git a/homeassistant/components/dyson/fan.py b/homeassistant/components/dyson/fan.py index 8613ab3e7af..4d9fe2eba2a 100644 --- a/homeassistant/components/dyson/fan.py +++ b/homeassistant/components/dyson/fan.py @@ -190,7 +190,7 @@ class DysonPureCoolLinkDevice(FanEntity): async def async_added_to_hass(self): """Call when entity is added to hass.""" - self.hass.async_add_job(self._device.add_message_listener, self.on_message) + self._device.add_message_listener(self.on_message) def on_message(self, message): """Call when new messages received from the fan.""" @@ -339,9 +339,7 @@ class DysonPureCoolDevice(FanEntity): async def async_added_to_hass(self): """Call when entity is added to hass.""" - self.hass.async_add_executor_job( - self._device.add_message_listener, self.on_message - ) + self._device.add_message_listener(self.on_message) def on_message(self, message): """Call when new messages received from the fan.""" diff --git a/homeassistant/components/dyson/sensor.py b/homeassistant/components/dyson/sensor.py index 98c69a7a7db..f26d83de45d 100644 --- a/homeassistant/components/dyson/sensor.py +++ b/homeassistant/components/dyson/sensor.py @@ -74,9 +74,7 @@ class DysonSensor(Entity): async def async_added_to_hass(self): """Call when entity is added to hass.""" - self.hass.async_add_executor_job( - self._device.add_message_listener, self.on_message - ) + self._device.add_message_listener(self.on_message) def on_message(self, message): """Handle new messages which are received from the fan.""" diff --git a/homeassistant/components/dyson/vacuum.py b/homeassistant/components/dyson/vacuum.py index 2306e07072d..a3db4f9c4d3 100644 --- a/homeassistant/components/dyson/vacuum.py +++ b/homeassistant/components/dyson/vacuum.py @@ -64,7 +64,7 @@ class Dyson360EyeDevice(VacuumEntity): async def async_added_to_hass(self): """Call when entity is added to hass.""" - self.hass.async_add_job(self._device.add_message_listener, self.on_message) + self._device.add_message_listener(self.on_message) def on_message(self, message): """Handle a new messages that was received from the vacuum."""