Use async_add_executor_job at the xiaomi_miio platforms (#18294)

This commit is contained in:
Sebastian Muszynski authored and GitHub committed 2018-11-07 09:03:35 +01:00
1 parent 35ae85e14e
commit df3d82e0e3
7 files changed
+29 -24

No files matched your search

@@ -38,7 +38,8 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
'zimi.powerstrip.v2',
'chuangmi.plug.m1',
'chuangmi.plug.v2',
'chuangmi.plug.v3']),
'chuangmi.plug.v3',
]),
})
ATTR_POWER = 'power'
@@ -247,7 +248,7 @@ class XiaomiPlugGenericSwitch(SwitchDevice):
"""Call a plug command handling error messages."""
from miio import DeviceException
try:
result = await self.hass.async_add_job(
result = await self.hass.async_add_executor_job(
partial(func, *args, **kwargs))
_LOGGER.debug("Response received from plug: %s", result)
@@ -290,7 +291,7 @@ class XiaomiPlugGenericSwitch(SwitchDevice):
return
try:
state = await self.hass.async_add_job(self._plug.status)
state = await self.hass.async_add_executor_job(self._plug.status)
_LOGGER.debug("Got new state: %s", state)
self._available = True
@@ -366,7 +367,7 @@ class XiaomiPowerStripSwitch(XiaomiPlugGenericSwitch):
return
try:
state = await self.hass.async_add_job(self._plug.status)
state = await self.hass.async_add_executor_job(self._plug.status)
_LOGGER.debug("Got new state: %s", state)
self._available = True
@@ -463,7 +464,7 @@ class ChuangMiPlugSwitch(XiaomiPlugGenericSwitch):
return
try:
state = await self.hass.async_add_job(self._plug.status)
state = await self.hass.async_add_executor_job(self._plug.status)
_LOGGER.debug("Got new state: %s", state)
self._available = True