diff --git a/homeassistant/__init__.py b/homeassistant/__init__.py index 9894626d920..304d7060418 100644 --- a/homeassistant/__init__.py +++ b/homeassistant/__init__.py @@ -19,7 +19,7 @@ from homeassistant.const import ( EVENT_HOMEASSISTANT_START, EVENT_HOMEASSISTANT_STOP, SERVICE_HOMEASSISTANT_STOP, EVENT_TIME_CHANGED, EVENT_STATE_CHANGED, EVENT_CALL_SERVICE, ATTR_NOW, ATTR_DOMAIN, ATTR_SERVICE, MATCH_ALL, - EVENT_SERVICE_EXECUTED, ATTR_SERVICE_CALL_ID) + EVENT_SERVICE_EXECUTED, ATTR_SERVICE_CALL_ID, EVENT_SERVICE_REGISTERED) import homeassistant.util as util DOMAIN = "homeassistant" @@ -683,6 +683,10 @@ class ServiceRegistry(object): else: self._services[domain] = {service: service_func} + self._bus.fire( + EVENT_SERVICE_REGISTERED, + {ATTR_DOMAIN: domain, ATTR_SERVICE: service}) + def call(self, domain, service, service_data=None, blocking=False): """ Calls specified service. diff --git a/homeassistant/bootstrap.py b/homeassistant/bootstrap.py index 6b35c268652..99278a6a426 100644 --- a/homeassistant/bootstrap.py +++ b/homeassistant/bootstrap.py @@ -18,9 +18,12 @@ import homeassistant import homeassistant.loader as loader import homeassistant.components as core_components import homeassistant.components.group as group +from homeassistant.const import EVENT_COMPONENT_LOADED _LOGGER = logging.getLogger(__name__) +ATTR_COMPONENT = "component" + def setup_component(hass, domain, config=None): """ Setup a component for Home Assistant. """ @@ -39,13 +42,14 @@ def setup_component(hass, domain, config=None): if component.setup(hass, config): hass.components.append(component.DOMAIN) - _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() + hass.bus.fire( + EVENT_COMPONENT_LOADED, {ATTR_COMPONENT: component.DOMAIN}) + return True else: diff --git a/homeassistant/const.py b/homeassistant/const.py index 616baa5c42a..d64033f4ba3 100644 --- a/homeassistant/const.py +++ b/homeassistant/const.py @@ -28,6 +28,8 @@ EVENT_TIME_CHANGED = "time_changed" EVENT_CALL_SERVICE = "call_service" EVENT_SERVICE_EXECUTED = "service_executed" EVENT_PLATFORM_DISCOVERED = "platform_discovered" +EVENT_COMPONENT_LOADED = "component_loaded" +EVENT_SERVICE_REGISTERED = "service_registered" # #### STATES #### STATE_ON = 'on'