async def async_from_config_dict( config: Dict[str, Any], hass: core.HomeAssistant, config_dir: Optional[str] = None, enable_log: bool = True, verbose: bool = False, skip_pip: bool = False, log_rotate_days: Any = None, log_file: Any = None, log_no_color: bool = False, ) -> Optional[core.HomeAssistant]: """Try to configure Home Assistant from a configuration dictionary. Dynamically loads required components and its dependencies. This method is a coroutine. """ start = time() if enable_log: async_enable_logging(hass, verbose, log_rotate_days, log_file, log_no_color) hass.config.skip_pip = skip_pip if skip_pip: _LOGGER.warning("Skipping pip installation of required modules. " "This may cause issues") core_config = config.get(core.DOMAIN, {}) api_password = config.get("http", {}).get("api_password") trusted_networks = config.get("http", {}).get("trusted_networks") try: await conf_util.async_process_ha_core_config(hass, core_config, api_password, trusted_networks) except vol.Invalid as config_err: conf_util.async_log_exception(config_err, "homeassistant", core_config, hass) return None except HomeAssistantError: _LOGGER.error("Home Assistant core failed to initialize. " "Further initialization aborted") return None # Make a copy because we are mutating it. config = OrderedDict(config) # Merge packages await conf_util.merge_packages_config( hass, config, core_config.get(conf_util.CONF_PACKAGES, {})) hass.config_entries = config_entries.ConfigEntries(hass, config) await hass.config_entries.async_initialize() await _async_set_up_integrations(hass, config) stop = time() _LOGGER.info("Home Assistant initialized in %.2fs", stop - start) return hass
async def async_from_config_dict( config: ConfigType, hass: core.HomeAssistant) -> Optional[core.HomeAssistant]: """Try to configure Home Assistant from a configuration dictionary. Dynamically loads required components and its dependencies. This method is a coroutine. """ start = monotonic() hass.config_entries = config_entries.ConfigEntries(hass, config) await hass.config_entries.async_initialize() # Set up core. _LOGGER.debug("Setting up %s", CORE_INTEGRATIONS) if not all(await asyncio.gather(*(async_setup_component(hass, domain, config) for domain in CORE_INTEGRATIONS))): _LOGGER.error("Home Assistant core failed to initialize. ") return None _LOGGER.debug("Home Assistant core initialized") core_config = config.get(core.DOMAIN, {}) try: await conf_util.async_process_ha_core_config(hass, core_config) except vol.Invalid as config_err: conf_util.async_log_exception(config_err, "homeassistant", core_config, hass) return None except HomeAssistantError: _LOGGER.error("Home Assistant core failed to initialize. " "Further initialization aborted") return None await _async_set_up_integrations(hass, config) stop = monotonic() _LOGGER.info("Home Assistant initialized in %.2fs", stop - start) if REQUIRED_NEXT_PYTHON_DATE and sys.version_info[: 3] < REQUIRED_NEXT_PYTHON_VER: msg = ( "Support for the running Python version " f"{'.'.join(str(x) for x in sys.version_info[:3])} is deprecated and will " f"be removed in the first release after {REQUIRED_NEXT_PYTHON_DATE}. " "Please upgrade Python to " f"{'.'.join(str(x) for x in REQUIRED_NEXT_PYTHON_VER)} or " "higher.") _LOGGER.warning(msg) hass.components.persistent_notification.async_create( msg, "Python version", "python_version") return hass
async def async_from_config_dict( config: ConfigType, hass: core.HomeAssistant) -> Optional[core.HomeAssistant]: """Try to configure Home Assistant from a configuration dictionary. Dynamically loads required components and its dependencies. This method is a coroutine. """ start = monotonic() hass.config_entries = config_entries.ConfigEntries(hass, config) await hass.config_entries.async_initialize() # Set up core. _LOGGER.debug("Setting up %s", CORE_INTEGRATIONS) if not all(await asyncio.gather(*(async_setup_component(hass, domain, config) for domain in CORE_INTEGRATIONS))): _LOGGER.error("Home Assistant core failed to initialize. ") return None _LOGGER.debug("Home Assistant core initialized") core_config = config.get(core.DOMAIN, {}) try: await conf_util.async_process_ha_core_config(hass, core_config) except vol.Invalid as config_err: conf_util.async_log_exception(config_err, "homeassistant", core_config, hass) return None except HomeAssistantError: _LOGGER.error("Home Assistant core failed to initialize. " "Further initialization aborted") return None await _async_set_up_integrations(hass, config) stop = monotonic() _LOGGER.info("Home Assistant initialized in %.2fs", stop - start) return hass
async def async_from_config_dict(config: Dict[str, Any], hass: core.HomeAssistant, config_dir: Optional[str] = None, enable_log: bool = True, verbose: bool = False, skip_pip: bool = False, log_rotate_days: Any = None, log_file: Any = None, log_no_color: bool = False) \ -> Optional[core.HomeAssistant]: """Try to configure Home Assistant from a configuration dictionary. Dynamically loads required components and its dependencies. This method is a coroutine. """ start = time() if enable_log: async_enable_logging(hass, verbose, log_rotate_days, log_file, log_no_color) core_config = config.get(core.DOMAIN, {}) has_api_password = bool((config.get('http') or {}).get('api_password')) has_trusted_networks = bool((config.get('http') or {}) .get('trusted_networks')) try: await conf_util.async_process_ha_core_config( hass, core_config, has_api_password, has_trusted_networks) except vol.Invalid as config_err: conf_util.async_log_exception( config_err, 'homeassistant', core_config, hass) return None except HomeAssistantError: _LOGGER.error("Home Assistant core failed to initialize. " "Further initialization aborted") return None await hass.async_add_executor_job( conf_util.process_ha_config_upgrade, hass) hass.config.skip_pip = skip_pip if skip_pip: _LOGGER.warning("Skipping pip installation of required modules. " "This may cause issues") # Make a copy because we are mutating it. config = OrderedDict(config) # Merge packages conf_util.merge_packages_config( hass, config, core_config.get(conf_util.CONF_PACKAGES, {})) hass.config_entries = config_entries.ConfigEntries(hass, config) await hass.config_entries.async_load() # Filter out the repeating and common config section [homeassistant] components = set(key.split(' ')[0] for key in config.keys() if key != core.DOMAIN) components.update(hass.config_entries.async_domains()) # Resolve all dependencies of all components. for component in list(components): try: components.update(loader.component_dependencies(hass, component)) except loader.LoaderError: # Ignore it, or we'll break startup # It will be properly handled during setup. pass # setup components res = await core_components.async_setup(hass, config) if not res: _LOGGER.error("Home Assistant core failed to initialize. " "Further initialization aborted") return hass await persistent_notification.async_setup(hass, config) _LOGGER.info("Home Assistant core initialized") # stage 1 for component in components: if component not in FIRST_INIT_COMPONENT: continue hass.async_create_task(async_setup_component(hass, component, config)) await hass.async_block_till_done() # stage 2 for component in components: if component in FIRST_INIT_COMPONENT: continue hass.async_create_task(async_setup_component(hass, component, config)) await hass.async_block_till_done() stop = time() _LOGGER.info("Home Assistant initialized in %.2fs", stop-start) # TEMP: warn users for invalid slugs # Remove after 0.94 or 1.0 if cv.INVALID_SLUGS_FOUND or cv.INVALID_ENTITY_IDS_FOUND: msg = [] if cv.INVALID_ENTITY_IDS_FOUND: msg.append( "Your configuration contains invalid entity ID references. " "Please find and update the following. " "This will become a breaking change." ) msg.append('\n'.join('- {} -> {}'.format(*item) for item in cv.INVALID_ENTITY_IDS_FOUND.items())) if cv.INVALID_SLUGS_FOUND: msg.append( "Your configuration contains invalid slugs. " "Please find and update the following. " "This will become a breaking change." ) msg.append('\n'.join('- {} -> {}'.format(*item) for item in cv.INVALID_SLUGS_FOUND.items())) hass.components.persistent_notification.async_create( '\n\n'.join(msg), "Config Warning", "config_warning" ) # TEMP: warn users of invalid extra keys # Remove after 0.92 if cv.INVALID_EXTRA_KEYS_FOUND: msg = [] msg.append( "Your configuration contains extra keys " "that the platform does not support (but were silently " "accepted before 0.88). Please find and remove the following." "This will become a breaking change." ) msg.append('\n'.join('- {}'.format(it) for it in cv.INVALID_EXTRA_KEYS_FOUND)) hass.components.persistent_notification.async_create( '\n\n'.join(msg), "Config Warning", "config_warning" ) return hass
def async_from_config_dict(config: Dict[str, Any], hass: core.HomeAssistant, config_dir: Optional[str] = None, enable_log: bool = True, verbose: bool = False, skip_pip: bool = False, log_rotate_days: Any = None, log_file: Any = None) \ -> Optional[core.HomeAssistant]: """Try to configure Home Assistant from a configuration dictionary. Dynamically loads required components and its dependencies. This method is a coroutine. """ start = time() if enable_log: async_enable_logging(hass, verbose, log_rotate_days, log_file) if sys.version_info[:2] < (3, 5): _LOGGER.warning( 'Python 3.4 support has been deprecated and will be removed in ' 'the beginning of 2018. Please upgrade Python or your operating ' 'system. More info: https://home-assistant.io/blog/2017/10/06/' 'deprecating-python-3.4-support/' ) core_config = config.get(core.DOMAIN, {}) try: yield from conf_util.async_process_ha_core_config(hass, core_config) except vol.Invalid as ex: conf_util.async_log_exception(ex, 'homeassistant', core_config, hass) return None yield from hass.async_add_job(conf_util.process_ha_config_upgrade, hass) hass.config.skip_pip = skip_pip if skip_pip: _LOGGER.warning("Skipping pip installation of required modules. " "This may cause issues") if not loader.PREPARED: yield from hass.async_add_job(loader.prepare, hass) # Make a copy because we are mutating it. config = OrderedDict(config) # Merge packages conf_util.merge_packages_config( config, core_config.get(conf_util.CONF_PACKAGES, {})) # Ensure we have no None values after merge for key, value in config.items(): if not value: config[key] = {} hass.config_entries = config_entries.ConfigEntries(hass, config) yield from hass.config_entries.async_load() # Filter out the repeating and common config section [homeassistant] components = set(key.split(' ')[0] for key in config.keys() if key != core.DOMAIN) components.update(hass.config_entries.async_domains()) # setup components # pylint: disable=not-an-iterable res = yield from core_components.async_setup(hass, config) if not res: _LOGGER.error("Home Assistant core failed to initialize. " "further initialization aborted") return hass yield from persistent_notification.async_setup(hass, config) _LOGGER.info("Home Assistant core initialized") # stage 1 for component in components: if component not in FIRST_INIT_COMPONENT: continue hass.async_add_job(async_setup_component(hass, component, config)) yield from hass.async_block_till_done() # stage 2 for component in components: if component in FIRST_INIT_COMPONENT: continue hass.async_add_job(async_setup_component(hass, component, config)) yield from hass.async_block_till_done() stop = time() _LOGGER.info("Home Assistant initialized in %.2fs", stop-start) async_register_signal_handling(hass) return hass
async def async_from_config_dict( config: Dict[str, Any], hass: core.HomeAssistant, config_dir: Optional[str] = None, enable_log: bool = True, verbose: bool = False, skip_pip: bool = False, log_rotate_days: Any = None, log_file: Any = None, log_no_color: bool = False, ) -> Optional[core.HomeAssistant]: """Try to configure Home Assistant from a configuration dictionary. Dynamically loads required components and its dependencies. This method is a coroutine. """ start = time() if enable_log: async_enable_logging(hass, verbose, log_rotate_days, log_file, log_no_color) hass.config.skip_pip = skip_pip if skip_pip: _LOGGER.warning( "Skipping pip installation of required modules. This may cause issues" ) core_config = config.get(core.DOMAIN, {}) try: await conf_util.async_process_ha_core_config(hass, core_config) except vol.Invalid as config_err: conf_util.async_log_exception(config_err, "homeassistant", core_config, hass) return None except HomeAssistantError: _LOGGER.error("Home Assistant core failed to initialize. " "Further initialization aborted") return None # Make a copy because we are mutating it. config = OrderedDict(config) # Merge packages await conf_util.merge_packages_config( hass, config, core_config.get(conf_util.CONF_PACKAGES, {})) hass.config_entries = config_entries.ConfigEntries(hass, config) await hass.config_entries.async_initialize() await _async_set_up_integrations(hass, config) stop = time() _LOGGER.info("Home Assistant initialized in %.2fs", stop - start) if REQUIRED_NEXT_PYTHON_DATE and sys.version_info[: 3] < REQUIRED_NEXT_PYTHON_VER: msg = ( "Support for the running Python version " f"{'.'.join(str(x) for x in sys.version_info[:3])} is deprecated and will " f"be removed in the first release after {REQUIRED_NEXT_PYTHON_DATE}. " "Please upgrade Python to " f"{'.'.join(str(x) for x in REQUIRED_NEXT_PYTHON_VER)} or " "higher.") _LOGGER.warning(msg) hass.components.persistent_notification.async_create( msg, "Python version", "python_version") return hass
def async_from_config_dict(config: Dict[str, Any], hass: core.HomeAssistant, config_dir: Optional[str] = None, enable_log: bool = True, verbose: bool = False, skip_pip: bool = False, log_rotate_days: Any = None, log_file: Any = None) \ -> Optional[core.HomeAssistant]: """Try to configure Home Assistant from a configuration dictionary. Dynamically loads required components and its dependencies. This method is a coroutine. """ start = time() if enable_log: async_enable_logging(hass, verbose, log_rotate_days, log_file) if sys.version_info[:2] < (3, 5): _LOGGER.warning( 'Python 3.4 support has been deprecated and will be removed in ' 'the beginning of 2018. Please upgrade Python or your operating ' 'system. More info: https://home-assistant.io/blog/2017/10/06/' 'deprecating-python-3.4-support/' ) core_config = config.get(core.DOMAIN, {}) try: yield from conf_util.async_process_ha_core_config(hass, core_config) except vol.Invalid as ex: conf_util.async_log_exception(ex, 'homeassistant', core_config, hass) return None yield from hass.async_add_job(conf_util.process_ha_config_upgrade, hass) hass.config.skip_pip = skip_pip if skip_pip: _LOGGER.warning("Skipping pip installation of required modules. " "This may cause issues") if not loader.PREPARED: yield from hass.async_add_job(loader.prepare, hass) # Make a copy because we are mutating it. new_config = OrderedDict() for key, value in config.items(): new_config[key] = value or {} config = new_config # Merge packages conf_util.merge_packages_config( config, core_config.get(conf_util.CONF_PACKAGES, {})) hass.config_entries = config_entries.ConfigEntries(hass, config) yield from hass.config_entries.async_load() # Filter out the repeating and common config section [homeassistant] components = set(key.split(' ')[0] for key in config.keys() if key != core.DOMAIN) components.update(hass.config_entries.async_domains()) # setup components # pylint: disable=not-an-iterable res = yield from core_components.async_setup(hass, config) if not res: _LOGGER.error("Home Assistant core failed to initialize. " "further initialization aborted") return hass yield from persistent_notification.async_setup(hass, config) _LOGGER.info("Home Assistant core initialized") # stage 1 for component in components: if component not in FIRST_INIT_COMPONENT: continue hass.async_add_job(async_setup_component(hass, component, config)) yield from hass.async_block_till_done() # stage 2 for component in components: if component in FIRST_INIT_COMPONENT: continue hass.async_add_job(async_setup_component(hass, component, config)) yield from hass.async_block_till_done() stop = time() _LOGGER.info("Home Assistant initialized in %.2fs", stop-start) async_register_signal_handling(hass) return hass
async def async_from_config_dict(config: Dict[str, Any], hass: core.HomeAssistant, config_dir: Optional[str] = None, enable_log: bool = True, verbose: bool = False, skip_pip: bool = False, log_rotate_days: Any = None, log_file: Any = None, log_no_color: bool = False) \ -> Optional[core.HomeAssistant]: """Try to configure Home Assistant from a configuration dictionary. Dynamically loads required components and its dependencies. This method is a coroutine. """ start = time() if enable_log: async_enable_logging(hass, verbose, log_rotate_days, log_file, log_no_color) core_config = config.get(core.DOMAIN, {}) has_api_password = bool((config.get('http') or {}).get('api_password')) has_trusted_networks = bool((config.get('http') or {}).get('trusted_networks')) try: await conf_util.async_process_ha_core_config(hass, core_config, has_api_password, has_trusted_networks) except vol.Invalid as config_err: conf_util.async_log_exception(config_err, 'homeassistant', core_config, hass) return None except HomeAssistantError: _LOGGER.error("Home Assistant core failed to initialize. " "Further initialization aborted") return None await hass.async_add_executor_job(conf_util.process_ha_config_upgrade, hass) hass.config.skip_pip = skip_pip if skip_pip: _LOGGER.warning("Skipping pip installation of required modules. " "This may cause issues") # Make a copy because we are mutating it. config = OrderedDict(config) # Merge packages conf_util.merge_packages_config( hass, config, core_config.get(conf_util.CONF_PACKAGES, {})) # Ensure we have no None values after merge for key, value in config.items(): if not value: config[key] = {} hass.config_entries = config_entries.ConfigEntries(hass, config) await hass.config_entries.async_load() # Filter out the repeating and common config section [homeassistant] components = set( key.split(' ')[0] for key in config.keys() if key != core.DOMAIN) components.update(hass.config_entries.async_domains()) # setup components res = await core_components.async_setup(hass, config) if not res: _LOGGER.error("Home Assistant core failed to initialize. " "Further initialization aborted") return hass await persistent_notification.async_setup(hass, config) _LOGGER.info("Home Assistant core initialized") # stage 1 for component in components: if component not in FIRST_INIT_COMPONENT: continue hass.async_create_task(async_setup_component(hass, component, config)) await hass.async_block_till_done() # stage 2 for component in components: if component in FIRST_INIT_COMPONENT: continue hass.async_create_task(async_setup_component(hass, component, config)) await hass.async_block_till_done() stop = time() _LOGGER.info("Home Assistant initialized in %.2fs", stop - start) return hass
async def async_from_config_dict(config: Dict[str, Any], hass: core.HomeAssistant, config_dir: Optional[str] = None, enable_log: bool = True, verbose: bool = False, skip_pip: bool = False, log_rotate_days: Any = None, log_file: Any = None, log_no_color: bool = False) \ -> Optional[core.HomeAssistant]: """Try to configure Home Assistant from a configuration dictionary. Dynamically loads required components and its dependencies. This method is a coroutine. """ start = time() if enable_log: async_enable_logging(hass, verbose, log_rotate_days, log_file, log_no_color) hass.config.skip_pip = skip_pip if skip_pip: _LOGGER.warning("Skipping pip installation of required modules. " "This may cause issues") core_config = config.get(core.DOMAIN, {}) api_password = config.get('http', {}).get('api_password') trusted_networks = config.get('http', {}).get('trusted_networks') try: await conf_util.async_process_ha_core_config(hass, core_config, api_password, trusted_networks) except vol.Invalid as config_err: conf_util.async_log_exception(config_err, 'homeassistant', core_config, hass) return None except HomeAssistantError: _LOGGER.error("Home Assistant core failed to initialize. " "Further initialization aborted") return None # Make a copy because we are mutating it. config = OrderedDict(config) # Merge packages await conf_util.merge_packages_config( hass, config, core_config.get(conf_util.CONF_PACKAGES, {})) hass.config_entries = config_entries.ConfigEntries(hass, config) await hass.config_entries.async_initialize() await _async_set_up_integrations(hass, config) stop = time() _LOGGER.info("Home Assistant initialized in %.2fs", stop - start) if sys.version_info[:3] < (3, 6, 0): hass.components.persistent_notification.async_create( "Python 3.5 support is deprecated and will " "be removed in the first release after August 1. Please " "upgrade Python.", "Python version", "python_version") return hass
async def async_from_config_dict(config: Dict[str, Any], hass: core.HomeAssistant, config_dir: Optional[str] = None, enable_log: bool = True, verbose: bool = False, skip_pip: bool = False, log_rotate_days: Any = None, log_file: Any = None, log_no_color: bool = False) \ -> Optional[core.HomeAssistant]: """Try to configure Home Assistant from a configuration dictionary. Dynamically loads required components and its dependencies. This method is a coroutine. """ start = time() if enable_log: async_enable_logging(hass, verbose, log_rotate_days, log_file, log_no_color) core_config = config.get(core.DOMAIN, {}) try: await conf_util.async_process_ha_core_config(hass, core_config) except vol.Invalid as ex: conf_util.async_log_exception(ex, 'homeassistant', core_config, hass) return None await hass.async_add_executor_job( conf_util.process_ha_config_upgrade, hass) hass.config.skip_pip = skip_pip if skip_pip: _LOGGER.warning("Skipping pip installation of required modules. " "This may cause issues") # Make a copy because we are mutating it. config = OrderedDict(config) # Merge packages conf_util.merge_packages_config( hass, config, core_config.get(conf_util.CONF_PACKAGES, {})) # Ensure we have no None values after merge for key, value in config.items(): if not value: config[key] = {} hass.config_entries = config_entries.ConfigEntries(hass, config) await hass.config_entries.async_load() # Filter out the repeating and common config section [homeassistant] components = set(key.split(' ')[0] for key in config.keys() if key != core.DOMAIN) components.update(hass.config_entries.async_domains()) # setup components res = await core_components.async_setup(hass, config) if not res: _LOGGER.error("Home Assistant core failed to initialize. " "further initialization aborted") return hass await persistent_notification.async_setup(hass, config) _LOGGER.info("Home Assistant core initialized") # stage 1 for component in components: if component not in FIRST_INIT_COMPONENT: continue hass.async_create_task(async_setup_component(hass, component, config)) await hass.async_block_till_done() # stage 2 for component in components: if component in FIRST_INIT_COMPONENT: continue hass.async_create_task(async_setup_component(hass, component, config)) await hass.async_block_till_done() stop = time() _LOGGER.info("Home Assistant initialized in %.2fs", stop-start) async_register_signal_handling(hass) return hass
async def async_from_config_dict( config: ConfigType, hass: core.HomeAssistant) -> core.HomeAssistant | None: """Try to configure Home Assistant from a configuration dictionary. Dynamically loads required components and its dependencies. This method is a coroutine. """ start = monotonic() hass.config_entries = config_entries.ConfigEntries(hass, config) await hass.config_entries.async_initialize() # Set up core. _LOGGER.debug("Setting up %s", CORE_INTEGRATIONS) if not all(await asyncio.gather(*(async_setup_component(hass, domain, config) for domain in CORE_INTEGRATIONS))): _LOGGER.error("Home Assistant core failed to initialize. ") return None _LOGGER.debug("Home Assistant core initialized") core_config = config.get(core.DOMAIN, {}) try: await conf_util.async_process_ha_core_config(hass, core_config) except vol.Invalid as config_err: conf_util.async_log_exception(config_err, "homeassistant", core_config, hass) return None except HomeAssistantError: _LOGGER.error("Home Assistant core failed to initialize. " "Further initialization aborted") return None await _async_set_up_integrations(hass, config) stop = monotonic() _LOGGER.info("Home Assistant initialized in %.2fs", stop - start) from homeassistant.components.ais_dom import ais_global ais_global.set_ais_android_id_dom_file_path( hass.config.config_dir + "/.dom/.ais_secure_android_id_dom") await ais_global.async_say_direct( hass, "Asystent domowy, inicjalizacja: %.2f sekundy. Trwa uruchamianie konfiguracji. Poczekaj..." % (stop - start), ) if (REQUIRED_NEXT_PYTHON_HA_RELEASE and sys.version_info[:3] < REQUIRED_NEXT_PYTHON_VER): msg = ( "Support for the running Python version " f"{'.'.join(str(x) for x in sys.version_info[:3])} is deprecated and will " f"be removed in Home Assistant {REQUIRED_NEXT_PYTHON_HA_RELEASE}. " "Please upgrade Python to " f"{'.'.join(str(x) for x in REQUIRED_NEXT_PYTHON_VER[:2])}.") _LOGGER.warning(msg) hass.components.persistent_notification.async_create( msg, "Python version", "python_version") return hass
async def async_from_config_dict(config: Dict[str, Any], hass: core.HomeAssistant, config_dir: Optional[str] = None, enable_log: bool = True, verbose: bool = False, skip_pip: bool = False, log_rotate_days: Any = None, log_file: Any = None, log_no_color: bool = False) \ -> Optional[core.HomeAssistant]: """Try to configure Home Assistant from a configuration dictionary. Dynamically loads required components and its dependencies. This method is a coroutine. """ start = time() if enable_log: async_enable_logging(hass, verbose, log_rotate_days, log_file, log_no_color) hass.config.skip_pip = skip_pip if skip_pip: _LOGGER.warning("Skipping pip installation of required modules. " "This may cause issues") core_config = config.get(core.DOMAIN, {}) api_password = config.get('http', {}).get('api_password') trusted_networks = config.get('http', {}).get('trusted_networks') try: await conf_util.async_process_ha_core_config( hass, core_config, api_password, trusted_networks) except vol.Invalid as config_err: conf_util.async_log_exception( config_err, 'homeassistant', core_config, hass) return None except HomeAssistantError: _LOGGER.error("Home Assistant core failed to initialize. " "Further initialization aborted") return None # Make a copy because we are mutating it. config = OrderedDict(config) # Merge packages await conf_util.merge_packages_config( hass, config, core_config.get(conf_util.CONF_PACKAGES, {})) hass.config_entries = config_entries.ConfigEntries(hass, config) await hass.config_entries.async_initialize() await _async_set_up_integrations(hass, config) stop = time() _LOGGER.info("Home Assistant initialized in %.2fs", stop-start) # TEMP: warn users for invalid slugs # Remove after 0.94 or 1.0 if cv.INVALID_SLUGS_FOUND or cv.INVALID_ENTITY_IDS_FOUND: msg = [] if cv.INVALID_ENTITY_IDS_FOUND: msg.append( "Your configuration contains invalid entity ID references. " "Please find and update the following. " "This will become a breaking change." ) msg.append('\n'.join('- {} -> {}'.format(*item) for item in cv.INVALID_ENTITY_IDS_FOUND.items())) if cv.INVALID_SLUGS_FOUND: msg.append( "Your configuration contains invalid slugs. " "Please find and update the following. " "This will become a breaking change." ) msg.append('\n'.join('- {} -> {}'.format(*item) for item in cv.INVALID_SLUGS_FOUND.items())) hass.components.persistent_notification.async_create( '\n\n'.join(msg), "Config Warning", "config_warning" ) # TEMP: warn users of invalid extra keys # Remove after 0.92 if cv.INVALID_EXTRA_KEYS_FOUND: msg = [] msg.append( "Your configuration contains extra keys " "that the platform does not support (but were silently " "accepted before 0.88). Please find and remove the following." "This will become a breaking change." ) msg.append('\n'.join('- {}'.format(it) for it in cv.INVALID_EXTRA_KEYS_FOUND)) hass.components.persistent_notification.async_create( '\n\n'.join(msg), "Config Warning", "config_warning" ) return hass
async def async_from_config_dict(config: Dict[str, Any], hass: core.HomeAssistant, config_dir: Optional[str] = None, enable_log: bool = True, verbose: bool = False, skip_pip: bool = False, log_rotate_days: Any = None, log_file: Any = None, log_no_color: bool = False) \ -> Optional[core.HomeAssistant]: """Try to configure Home Assistant from a configuration dictionary. Dynamically loads required components and its dependencies. This method is a coroutine. """ start = time() if enable_log: async_enable_logging(hass, verbose, log_rotate_days, log_file, log_no_color) hass.config.skip_pip = skip_pip if skip_pip: _LOGGER.warning("Skipping pip installation of required modules. " "This may cause issues") core_config = config.get(core.DOMAIN, {}) api_password = config.get('http', {}).get('api_password') trusted_networks = config.get('http', {}).get('trusted_networks') try: await conf_util.async_process_ha_core_config(hass, core_config, api_password, trusted_networks) except vol.Invalid as config_err: conf_util.async_log_exception(config_err, 'homeassistant', core_config, hass) return None except HomeAssistantError: _LOGGER.error("Home Assistant core failed to initialize. " "Further initialization aborted") return None # Make a copy because we are mutating it. config = OrderedDict(config) # Merge packages await conf_util.merge_packages_config( hass, config, core_config.get(conf_util.CONF_PACKAGES, {})) hass.config_entries = config_entries.ConfigEntries(hass, config) await hass.config_entries.async_initialize() await _async_set_up_integrations(hass, config) stop = time() _LOGGER.info("Home Assistant initialized in %.2fs", stop - start) if sys.version_info[:3] < (3, 6, 0): hass.components.persistent_notification.async_create( "Python 3.5 support is deprecated and will " "be removed in the first release after August 1. Please " "upgrade Python.", "Python version", "python_version") # TEMP: warn users for invalid slugs # Remove after 0.94 or 1.0 if cv.INVALID_SLUGS_FOUND or cv.INVALID_ENTITY_IDS_FOUND: msg = [] if cv.INVALID_ENTITY_IDS_FOUND: msg.append( "Your configuration contains invalid entity ID references. " "Please find and update the following. " "This will become a breaking change.") msg.append('\n'.join( '- {} -> {}'.format(*item) for item in cv.INVALID_ENTITY_IDS_FOUND.items())) if cv.INVALID_SLUGS_FOUND: msg.append("Your configuration contains invalid slugs. " "Please find and update the following. " "This will become a breaking change.") msg.append('\n'.join('- {} -> {}'.format(*item) for item in cv.INVALID_SLUGS_FOUND.items())) hass.components.persistent_notification.async_create( '\n\n'.join(msg), "Config Warning", "config_warning") # TEMP: warn users of invalid extra keys # Remove after 0.92 if cv.INVALID_EXTRA_KEYS_FOUND: msg = [] msg.append( "Your configuration contains extra keys " "that the platform does not support (but were silently " "accepted before 0.88). Please find and remove the following." "This will become a breaking change.") msg.append('\n'.join('- {}'.format(it) for it in cv.INVALID_EXTRA_KEYS_FOUND)) hass.components.persistent_notification.async_create( '\n\n'.join(msg), "Config Warning", "config_warning") return hass