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

@@ -128,14 +128,14 @@ async def async_setup_platform(hass, config, async_add_entities,
slot = service.data.get(CONF_SLOT, entity.slot)
await hass.async_add_job(device.learn, slot)
await hass.async_add_executor_job(device.learn, slot)
timeout = service.data.get(CONF_TIMEOUT, entity.timeout)
_LOGGER.info("Press the key you want Home Assistant to learn")
start_time = utcnow()
while (utcnow() - start_time) < timedelta(seconds=timeout):
message = await hass.async_add_job(
message = await hass.async_add_executor_job(
device.read, slot)
_LOGGER.debug("Message received from device: '%s'", message)
@@ -148,7 +148,7 @@ async def async_setup_platform(hass, config, async_add_entities,
if ('error' in message and
message['error']['message'] == "learn timeout"):
await hass.async_add_job(device.learn, slot)
await hass.async_add_executor_job(device.learn, slot)
await asyncio.sleep(1, loop=hass.loop)