Skip to content

Commit 35f1912

Browse files
authored
Wait for platforms to load before connecting (#118)
A connection could potentially been made prior to the status sensor being set up, keeping it in an unknown state. Fixes #101
1 parent d6b8b62 commit 35f1912

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

custom_components/remote_homeassistant/__init__.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -252,10 +252,13 @@ async def setup_components_and_platforms():
252252
"""Set up platforms and initiate connection."""
253253
for domain in entry.options.get(CONF_LOAD_COMPONENTS, []):
254254
hass.async_create_task(async_setup_component(hass, domain, {}))
255-
for component in PLATFORMS:
256-
hass.async_create_task(
257-
hass.config_entries.async_forward_entry_setup(entry, component)
258-
)
255+
256+
await asyncio.gather(
257+
*[
258+
hass.config_entries.async_forward_entry_setup(entry, platform)
259+
for platform in PLATFORMS
260+
]
261+
)
259262
await remote.async_connect()
260263

261264
hass.async_create_task(setup_components_and_platforms())
@@ -268,8 +271,8 @@ async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry):
268271
unload_ok = all(
269272
await asyncio.gather(
270273
*[
271-
hass.config_entries.async_forward_entry_unload(entry, component)
272-
for component in PLATFORMS
274+
hass.config_entries.async_forward_entry_unload(entry, platform)
275+
for platform in PLATFORMS
273276
]
274277
)
275278
)

0 commit comments

Comments
 (0)