From 2498abe75fe3785a89016f9ada2a48925d0a45f0 Mon Sep 17 00:00:00 2001 From: Teemu Rytilahti Date: Tue, 6 Dec 2022 23:11:37 +0100 Subject: [PATCH] use async_add_executor_job for creating the device instance --- homeassistant/components/xiaomi_miio/__init__.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/homeassistant/components/xiaomi_miio/__init__.py b/homeassistant/components/xiaomi_miio/__init__.py index 873e6d7bdaaf5c..04431e96c6b42c 100644 --- a/homeassistant/components/xiaomi_miio/__init__.py +++ b/homeassistant/components/xiaomi_miio/__init__.py @@ -134,9 +134,12 @@ async def async_create_miio_device_and_coordinator( _LOGGER.debug("Initializing with host %s (token %s...)", host, token[:5]) + def _create_dev_instance(): + return DeviceFactory.create(host, token, model=model, force_generic_miot=True) + # TODO: run in executor, this potentially performs I/O to find the model and initialize miot try: - device = DeviceFactory.create(host, token, model=model, force_generic_miot=True) + device = await hass.async_add_executor_job(_create_dev_instance) except DeviceException: _LOGGER.warning("Tried to initialize unsupported %s, skipping", model) raise