Add get_url helper, deprecate base_url (#35224)
This commit is contained in:
@@ -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()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user