Skip to content

Commit

Permalink
use async_add_executor_job for creating the device instance
Browse files Browse the repository at this point in the history
  • Loading branch information
rytilahti committed Dec 6, 2022
1 parent 1c1854d commit 2498abe
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion homeassistant/components/xiaomi_miio/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 2498abe

Please sign in to comment.