mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 05:07:41 +00:00
Fix open-ui cli arg (#26091)
* Fix open-ui cli command * Align add_job typing with async_add_job
This commit is contained in:
parent
f34b84a5cf
commit
5c91a6cd48
@ -10,12 +10,7 @@ import threading
|
|||||||
from typing import List, Dict, Any, TYPE_CHECKING # noqa pylint: disable=unused-import
|
from typing import List, Dict, Any, TYPE_CHECKING # noqa pylint: disable=unused-import
|
||||||
|
|
||||||
from homeassistant import monkey_patch
|
from homeassistant import monkey_patch
|
||||||
from homeassistant.const import (
|
from homeassistant.const import __version__, REQUIRED_PYTHON_VER, RESTART_EXIT_CODE
|
||||||
__version__,
|
|
||||||
EVENT_HOMEASSISTANT_START,
|
|
||||||
REQUIRED_PYTHON_VER,
|
|
||||||
RESTART_EXIT_CODE,
|
|
||||||
)
|
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
from homeassistant import core
|
from homeassistant import core
|
||||||
@ -309,23 +304,10 @@ async def setup_and_run_hass(config_dir: str, args: argparse.Namespace) -> int:
|
|||||||
log_no_color=args.log_no_color,
|
log_no_color=args.log_no_color,
|
||||||
)
|
)
|
||||||
|
|
||||||
if args.open_ui:
|
if args.open_ui and hass.config.api is not None:
|
||||||
# Imported here to avoid importing asyncio before monkey patch
|
import webbrowser
|
||||||
from homeassistant.util.async_ import run_callback_threadsafe
|
|
||||||
|
|
||||||
def open_browser(_: Any) -> None:
|
hass.add_job(webbrowser.open, hass.config.api.base_url)
|
||||||
"""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()
|
return await hass.async_run()
|
||||||
|
|
||||||
|
@ -276,7 +276,7 @@ class HomeAssistant:
|
|||||||
self.state = CoreState.running
|
self.state = CoreState.running
|
||||||
_async_create_timer(self)
|
_async_create_timer(self)
|
||||||
|
|
||||||
def add_job(self, target: Callable[..., None], *args: Any) -> None:
|
def add_job(self, target: Callable[..., Any], *args: Any) -> None:
|
||||||
"""Add job to the executor pool.
|
"""Add job to the executor pool.
|
||||||
|
|
||||||
target: target to call.
|
target: target to call.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user