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
This commit is contained in:
J. Nick Koston
2020-10-13 15:45:00 -05:00
committed by GitHub
parent 5c540dcfcf
commit ff2872e376
5 changed files with 7 additions and 15 deletions

View File

@@ -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."""

View File

@@ -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."""

View File

@@ -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."""

View File

@@ -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."""

View File

@@ -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."""