Ensure we do not start discovered flows until after the started event has fired (#38047)

* Ensure we do not start discovered flows until after the start event has fired

This change makes zeroconf and ssdp match discovery behavior of not
creating config flows until the start event has been fired.  This
prevents config flow creation/dependency installs for discovered
config flows from competing for cpu time during startup.

* Start discovery/service browser/ssdp when EVENT_HOMEASSISTANT_STARTED is fired instead of EVENT_HOMEASSISTANT_START
This commit is contained in:
J. Nick Koston authored and GitHub committed 2020-07-21 14:18:43 -10:00
1 parent e766a119d2
commit 5cf7b1b1bc
5 files changed
+43 -10

No files matched your search

@@ -21,6 +21,7 @@ from homeassistant import util
from homeassistant.const import (
ATTR_NAME,
EVENT_HOMEASSISTANT_START,
EVENT_HOMEASSISTANT_STARTED,
EVENT_HOMEASSISTANT_STOP,
__version__,
)
@@ -247,7 +248,13 @@ def setup(hass, config):
if HOMEKIT_TYPE not in ZEROCONF:
types.append(HOMEKIT_TYPE)
HaServiceBrowser(zeroconf, types, handlers=[service_update])
def zeroconf_hass_started(_event):
"""Start the service browser."""
_LOGGER.debug("Starting Zeroconf browser")
HaServiceBrowser(zeroconf, types, handlers=[service_update])
hass.bus.listen_once(EVENT_HOMEASSISTANT_STARTED, zeroconf_hass_started)
return True