def component_setup(): """Set up a component.""" if not core_components.setup(hass, config): _LOGGER.error("Home Assistant core failed to initialize. " "Further initialization aborted.") return hass persistent_notification.setup(hass, config) _LOGGER.info("Home Assistant core initialized") # Give event decorators access to HASS event_decorators.HASS = hass service.HASS = hass # Setup the components for domain in loader.load_order_components(components): _setup_component(hass, domain, config)
def component_setup(): """Set up a component.""" if not core_components.setup(hass, config): _LOGGER.error('Home Assistant core failed to initialize. ' 'Further initialization aborted.') return hass persistent_notification.setup(hass, config) _LOGGER.info('Home Assistant core initialized') # Give event decorators access to HASS event_decorators.HASS = hass service.HASS = hass # Setup the components for domain in loader.load_order_components(components): _setup_component(hass, domain, config)
def from_config_dict(config, hass=None, config_dir=None, enable_log=True, verbose=False, skip_pip=False, log_rotate_days=None): """Try to configure Home Assistant from a config dict. Dynamically loads required components and its dependencies. """ if hass is None: hass = core.HomeAssistant() if config_dir is not None: config_dir = os.path.abspath(config_dir) hass.config.config_dir = config_dir _mount_local_lib_path(config_dir) core_config = config.get(core.DOMAIN, {}) try: conf_util.process_ha_core_config(hass, core_config) except vol.Invalid as ex: cv.log_exception(_LOGGER, ex, 'homeassistant', core_config) return None conf_util.process_ha_config_upgrade(hass) if enable_log: enable_logging(hass, verbose, log_rotate_days) hass.config.skip_pip = skip_pip if skip_pip: _LOGGER.warning('Skipping pip installation of required modules. ' 'This may cause issues.') _ensure_loader_prepared(hass) # Make a copy because we are mutating it. # Convert it to defaultdict so components can always have config dict # Convert values to dictionaries if they are None config = defaultdict(dict, {key: value or {} for key, value in config.items()}) # Filter out the repeating and common config section [homeassistant] components = set( key.split(' ')[0] for key in config.keys() if key != core.DOMAIN) if not core_components.setup(hass, config): _LOGGER.error('Home Assistant core failed to initialize. ' 'Further initialization aborted.') return hass persistent_notification.setup(hass, config) _LOGGER.info('Home Assistant core initialized') # Give event decorators access to HASS event_decorators.HASS = hass service.HASS = hass # Setup the components for domain in loader.load_order_components(components): _setup_component(hass, domain, config) return hass
def from_config_dict(config: Dict[str, Any], hass: Optional[core.HomeAssistant]=None, config_dir: Optional[str]=None, enable_log: bool=True, verbose: bool=False, skip_pip: bool=False, log_rotate_days: Any=None) \ -> Optional[core.HomeAssistant]: """Try to configure Home Assistant from a config dict. Dynamically loads required components and its dependencies. """ if hass is None: hass = core.HomeAssistant() if config_dir is not None: config_dir = os.path.abspath(config_dir) hass.config.config_dir = config_dir mount_local_lib_path(config_dir) core_config = config.get(core.DOMAIN, {}) try: conf_util.process_ha_core_config(hass, core_config) except vol.Invalid as ex: _log_exception(ex, 'homeassistant', core_config) return None conf_util.process_ha_config_upgrade(hass) if enable_log: enable_logging(hass, verbose, log_rotate_days) hass.config.skip_pip = skip_pip if skip_pip: _LOGGER.warning('Skipping pip installation of required modules. ' 'This may cause issues.') _ensure_loader_prepared(hass) # Make a copy because we are mutating it. # Convert it to defaultdict so components can always have config dict # Convert values to dictionaries if they are None config = defaultdict( dict, {key: value or {} for key, value in config.items()}) # Filter out the repeating and common config section [homeassistant] components = set(key.split(' ')[0] for key in config.keys() if key != core.DOMAIN) if not core_components.setup(hass, config): _LOGGER.error('Home Assistant core failed to initialize. ' 'Further initialization aborted.') return hass persistent_notification.setup(hass, config) _LOGGER.info('Home Assistant core initialized') # Give event decorators access to HASS event_decorators.HASS = hass service.HASS = hass # Setup the components for domain in loader.load_order_components(components): _setup_component(hass, domain, config) return hass
def setup_method(self, method): """Setup things to be run when tests are started.""" self.hass = get_test_home_assistant() pn.setup(self.hass, {})