Fix hassio discovery (#17275)

* Update discovery.py

* Update test_discovery.py

* Update test_discovery.py

* Update test_discovery.py

* Update test_discovery.py

* Update test_discovery.py

* Update test_discovery.py

* Fix tests

* fix lint
This commit is contained in:
Pascal Vizeli 2018-10-10 13:50:11 +02:00 committed by Paulus Schoutsen
parent a1dac28e4b
commit 83dd961fde
3 changed files with 61 additions and 3 deletions

View file

@ -5,7 +5,7 @@ import logging
from aiohttp import web
from aiohttp.web_exceptions import HTTPServiceUnavailable
from homeassistant.core import callback
from homeassistant.core import callback, CoreState
from homeassistant.const import EVENT_HOMEASSISTANT_START
from homeassistant.components.http import HomeAssistantView
@ -40,8 +40,11 @@ def async_setup_discovery(hass, hassio, config):
if jobs:
await asyncio.wait(jobs)
hass.bus.async_listen_once(
EVENT_HOMEASSISTANT_START, async_discovery_start_handler)
if hass.state == CoreState.running:
hass.async_create_task(async_discovery_start_handler(None))
else:
hass.bus.async_listen_once(
EVENT_HOMEASSISTANT_START, async_discovery_start_handler)
hass.http.register_view(hassio_discovery)