Add get_url helper, deprecate base_url (#35224)

This commit is contained in:
Franck Nijhof
2020-05-08 02:29:47 +02:00
committed by GitHub
parent 7e4aa2409f
commit 2223592486
51 changed files with 1416 additions and 198 deletions

View File

@@ -8,6 +8,8 @@ import sys
import threading
from typing import List
import yarl
from homeassistant.const import REQUIRED_PYTHON_VER, RESTART_EXIT_CODE, __version__
@@ -256,10 +258,17 @@ async def setup_and_run_hass(config_dir: str, args: argparse.Namespace) -> int:
if hass is None:
return 1
if args.open_ui and hass.config.api is not None:
if args.open_ui:
import webbrowser # pylint: disable=import-outside-toplevel
hass.add_job(webbrowser.open, hass.config.api.base_url)
if hass.config.api is not None:
scheme = "https" if hass.config.api.use_ssl else "http"
url = str(
yarl.URL.build(
scheme=scheme, host="127.0.0.1", port=hass.config.api.port
)
)
hass.add_job(webbrowser.open, url)
return await hass.async_run()