Fix smartthings doing blocking I/O in the event loop to import platforms (#113382)

pull/113401/head
J. Nick Koston 2024-03-13 23:47:18 -10:00 committed by GitHub
parent 972efada75
commit 6832611550
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 7 additions and 0 deletions

View File

@ -27,6 +27,7 @@ from homeassistant.helpers.dispatcher import (
from homeassistant.helpers.entity import Entity
from homeassistant.helpers.event import async_track_time_interval
from homeassistant.helpers.typing import ConfigType
from homeassistant.loader import async_get_loaded_integration
from .config_flow import SmartThingsFlowHandler # noqa: F401
from .const import (
@ -104,6 +105,12 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
api = SmartThings(async_get_clientsession(hass), entry.data[CONF_ACCESS_TOKEN])
# Ensure platform modules are loaded since the DeviceBroker will
# import them below and we want them to be cached ahead of time
# so the integration does not do blocking I/O in the event loop
# to import the modules.
await async_get_loaded_integration(hass, DOMAIN).async_get_platforms(PLATFORMS)
remove_entry = False
try:
# See if the app is already setup. This occurs when there are