async def setup_and_run_hass(config_dir: str, args: argparse.Namespace) -> int: """Set up HASS and run.""" # pylint: disable=redefined-outer-name from homeassistant import bootstrap, core hass = core.HomeAssistant() if args.demo_mode: config = {"frontend": {}, "demo": {}} # type: Dict[str, Any] bootstrap.async_from_config_dict( config, hass, config_dir=config_dir, verbose=args.verbose, skip_pip=args.skip_pip, log_rotate_days=args.log_rotate_days, log_file=args.log_file, log_no_color=args.log_no_color, ) else: config_file = await ensure_config_file(hass, config_dir) print("Config directory:", config_dir) await bootstrap.async_from_config_file( config_file, hass, verbose=args.verbose, skip_pip=args.skip_pip, log_rotate_days=args.log_rotate_days, log_file=args.log_file, log_no_color=args.log_no_color, ) if args.open_ui: # Imported here to avoid importing asyncio before monkey patch from homeassistant.util.async_ import run_callback_threadsafe def open_browser(_: Any) -> None: """Open the web interface in a browser.""" if hass.config.api is not None: import webbrowser webbrowser.open(hass.config.api.base_url) run_callback_threadsafe( hass.loop, hass.bus.async_listen_once, EVENT_HOMEASSISTANT_START, open_browser, ) return await hass.async_run()
def test_home_assistant_core_config_validation(hass): """Test if we pass in wrong information for HA conf.""" # Extensive HA conf validation testing is done result = yield from bootstrap.async_from_config_dict( {"homeassistant": { "latitude": "some string" }}, hass) assert result is None
def test_home_assistant_core_config_validation(hass): """Test if we pass in wrong information for HA conf.""" # Extensive HA conf validation testing is done result = yield from bootstrap.async_from_config_dict({ 'homeassistant': { 'latitude': 'some string' } }, hass) assert result is None
def test_component_cannot_depend_config(hass): """Test config is not allowed to be a dependency.""" loader.set_component( 'test_component1', MockModule('test_component1', dependencies=['config'])) with pytest.raises(HomeAssistantError): yield from bootstrap.async_from_config_dict( {'test_component1': None}, hass)
async def setup_and_run_hass(config_dir: str, args: argparse.Namespace) -> int: """Set up HASS and run.""" # pylint: disable=redefined-outer-name from homeassistant import bootstrap, core hass = core.HomeAssistant() if args.demo_mode: config = { 'frontend': {}, 'demo': {} } # type: Dict[str, Any] bootstrap.async_from_config_dict( config, hass, config_dir=config_dir, verbose=args.verbose, skip_pip=args.skip_pip, log_rotate_days=args.log_rotate_days, log_file=args.log_file, log_no_color=args.log_no_color) else: config_file = await ensure_config_file(hass, config_dir) print('Config directory:', config_dir) await bootstrap.async_from_config_file( config_file, hass, verbose=args.verbose, skip_pip=args.skip_pip, log_rotate_days=args.log_rotate_days, log_file=args.log_file, log_no_color=args.log_no_color) if args.open_ui: # Imported here to avoid importing asyncio before monkey patch from homeassistant.util.async_ import run_callback_threadsafe def open_browser(_: Any) -> None: """Open the web interface in a browser.""" if hass.config.api is not None: import webbrowser webbrowser.open(hass.config.api.base_url) run_callback_threadsafe( hass.loop, hass.bus.async_listen_once, EVENT_HOMEASSISTANT_START, open_browser ) return await hass.async_run()
async def setup_and_run_hass(config_dir: str, args: argparse.Namespace) -> int: """Set up HASS and run.""" # pylint: disable=redefined-outer-name from homeassistant import bootstrap, core hass = core.HomeAssistant() if args.demo_mode: config: Dict[str, Any] = {"frontend": {}, "demo": {}} bootstrap.async_from_config_dict( config, hass, config_dir=config_dir, verbose=args.verbose, skip_pip=args.skip_pip, log_rotate_days=args.log_rotate_days, log_file=args.log_file, log_no_color=args.log_no_color, ) else: config_file = await ensure_config_file(hass, config_dir) print("Config directory:", config_dir) await bootstrap.async_from_config_file( config_file, hass, verbose=args.verbose, skip_pip=args.skip_pip, log_rotate_days=args.log_rotate_days, log_file=args.log_file, log_no_color=args.log_no_color, ) if args.open_ui and hass.config.api is not None: import webbrowser hass.add_job(webbrowser.open, hass.config.api.base_url) return await hass.async_run()