Skip to content

Commit 2498abe

Browse files
committed
use async_add_executor_job for creating the device instance
1 parent 1c1854d commit 2498abe

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

homeassistant/components/xiaomi_miio/__init__.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,9 +134,12 @@ async def async_create_miio_device_and_coordinator(
134134

135135
_LOGGER.debug("Initializing with host %s (token %s...)", host, token[:5])
136136

137+
def _create_dev_instance():
138+
return DeviceFactory.create(host, token, model=model, force_generic_miot=True)
139+
137140
# TODO: run in executor, this potentially performs I/O to find the model and initialize miot
138141
try:
139-
device = DeviceFactory.create(host, token, model=model, force_generic_miot=True)
142+
device = await hass.async_add_executor_job(_create_dev_instance)
140143
except DeviceException:
141144
_LOGGER.warning("Tried to initialize unsupported %s, skipping", model)
142145
raise

0 commit comments

Comments
 (0)