Skip to content

Commit

Permalink
Always wait for the start event to run startup tasks (hacs#1407)
Browse files Browse the repository at this point in the history
* Always wait for the start event to run startup tasks

* remove ()

* Looks like it never worked

* s/EVENT_HOMEASSISTANT_START/EVENT_HOMEASSISTANT_STARTED/g

Co-authored-by: Joakim Sørensen <[email protected]>
  • Loading branch information
bdraco and ludeeus authored Jul 28, 2020
1 parent e844f24 commit 0ee039d
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions custom_components/hacs/operational/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from aiogithubapi import AIOGitHubAPIException, GitHub
from homeassistant import config_entries
from homeassistant.components.lovelace import system_health_info
from homeassistant.const import EVENT_HOMEASSISTANT_START
from homeassistant.const import EVENT_HOMEASSISTANT_STARTED
from homeassistant.const import __version__ as HAVERSION
from homeassistant.exceptions import ConfigEntryNotReady, ServiceNotFound
from homeassistant.helpers.aiohttp_client import async_create_clientsession
Expand Down Expand Up @@ -113,6 +113,11 @@ async def async_startup_wrapper_for_yaml():
hacs.system.disabled = False


async def _wait_for_startup(event):
"""Startup after the start event."""
await get_hacs().startup_tasks()


async def async_hacs_startup():
"""HACS startup tasks."""
hacs = get_hacs()
Expand Down Expand Up @@ -183,10 +188,7 @@ async def async_hacs_startup():
await async_setup_frontend()

# Setup startup tasks
if hacs.configuration.config_type == "yaml":
hacs.hass.bus.async_listen_once(EVENT_HOMEASSISTANT_START, hacs.startup_tasks())
else:
async_call_later(hacs.hass, 5, hacs.startup_tasks())
hacs.hass.bus.async_listen_once(EVENT_HOMEASSISTANT_STARTED, _wait_for_startup)

# Set up sensor
await async_add_sensor()
Expand Down

0 comments on commit 0ee039d

Please sign in to comment.