diff --git a/homeassistant/bootstrap.py b/homeassistant/bootstrap.py index 07dc46692d1..aa95878c649 100644 --- a/homeassistant/bootstrap.py +++ b/homeassistant/bootstrap.py @@ -17,7 +17,7 @@ from collections import defaultdict import homeassistant import homeassistant.loader as loader import homeassistant.components as core_components - +import homeassistant.components.group as group _LOGGER = logging.getLogger(__name__) @@ -35,6 +35,11 @@ def setup_component(hass, domain, config=None): _LOGGER.info("component %s initialized", domain) + # Assumption: if a component does not depend on groups + # it communicates with devices + if group.DOMAIN not in component.DEPENDENCIES: + hass.pool.add_worker() + return True else: @@ -75,18 +80,8 @@ def from_config_dict(config, hass=None): _LOGGER.info("Home Assistant core initialized") # Setup the components - - # We assume that all components that load before the group component loads - # are components that poll devices. As their tasks are IO based, we will - # add an extra worker for each of them. - add_worker = True - for domain in loader.load_order_components(components): - if setup_component(hass, domain, config): - add_worker = add_worker and domain != "group" - - if add_worker: - hass.pool.add_worker() + setup_component(hass, domain, config) return hass diff --git a/homeassistant/components/discovery.py b/homeassistant/components/discovery.py index c9f770dc4ea..fde6061dfaa 100644 --- a/homeassistant/components/discovery.py +++ b/homeassistant/components/discovery.py @@ -68,8 +68,7 @@ def setup(hass, config): logger.info("Found new service: %s %s", service, info) if component and component not in hass.components: - if bootstrap.setup_component(hass, component, config): - hass.pool.add_worker() + bootstrap.setup_component(hass, component, config) hass.bus.fire(EVENT_PLATFORM_DISCOVERED, { ATTR_SERVICE: service, diff --git a/homeassistant/components/wink.py b/homeassistant/components/wink.py index ab660281e0e..0ccabd27f73 100644 --- a/homeassistant/components/wink.py +++ b/homeassistant/components/wink.py @@ -39,9 +39,7 @@ def setup(hass, config): # Ensure component is loaded if component.DOMAIN not in hass.components: - # Add a worker on succesfull setup - if bootstrap.setup_component(hass, component.DOMAIN, config): - hass.pool.add_worker() + bootstrap.setup_component(hass, component.DOMAIN, config) # Fire discovery event hass.bus.fire(EVENT_PLATFORM_DISCOVERED, {