Make discovery not block start (#6991)

* Make discovery not block start

* Fix tests
This commit is contained in:
Paulus Schoutsen authored and GitHub committed 2017-04-09 01:05:34 -07:00
1 parent eb0a9869d8
commit ba8488d8f1
2 files changed
+35 -54

No files matched your search

+8 -2
View File
@@ -13,6 +13,7 @@ import logging
import voluptuous as vol
from homeassistant.core import callback
from homeassistant.const import EVENT_HOMEASSISTANT_START
import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.event import async_track_point_in_utc_time
@@ -105,7 +106,7 @@ def async_setup(hass, config):
hass, component, platform, info, config)
@asyncio.coroutine
def scan_devices(_):
def scan_devices(now):
"""Scan for devices."""
results = yield from hass.loop.run_in_executor(
None, _discover, netdisco)
@@ -116,7 +117,12 @@ def async_setup(hass, config):
async_track_point_in_utc_time(hass, scan_devices,
dt_util.utcnow() + SCAN_INTERVAL)
hass.bus.async_listen_once(EVENT_HOMEASSISTANT_START, scan_devices)
@callback
def schedule_first(event):
"""Schedule the first discovery when Home Assistant starts up."""
async_track_point_in_utc_time(hass, scan_devices, dt_util.utcnow())
hass.bus.async_listen_once(EVENT_HOMEASSISTANT_START, schedule_first)
return True