Skip to content

Commit

Permalink
Fix blocking call to import_module inside the event loop
Browse files Browse the repository at this point in the history
  • Loading branch information
Necroneco committed May 7, 2024
1 parent 8ac1138 commit 741eafa
Showing 1 changed file with 16 additions and 13 deletions.
29 changes: 16 additions & 13 deletions custom_components/midea_ac_lan/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,19 +145,22 @@ async def async_setup_entry(hass: HomeAssistant, config_entry):
if protocol == 3 and (key is None or key is None):
_LOGGER.error("For V3 devices, the key and the token is required.")
return False
device = device_selector(
name=name,
device_id=device_id,
device_type=device_type,
ip_address=ip_address,
port=port,
token=token,
key=key,
protocol=protocol,
model=model,
subtype=subtype,
customize=customize,
)

def _device_selector():
return device_selector(
name=name,
device_id=device_id,
device_type=device_type,
ip_address=ip_address,
port=port,
token=token,
key=key,
protocol=protocol,
model=model,
subtype=subtype,
customize=customize,
)
device = await hass.async_add_import_executor_job(_device_selector)
if refresh_interval is not None:
device.set_refresh_interval(refresh_interval)
if device:
Expand Down

0 comments on commit 741eafa

Please sign in to comment.