Fix open-ui cli arg (#26091)
* Fix open-ui cli command * Align add_job typing with async_add_jobpull/26097/head
parent
f34b84a5cf
commit
5c91a6cd48
|
@ -10,12 +10,7 @@ import threading
|
|||
from typing import List, Dict, Any, TYPE_CHECKING # noqa pylint: disable=unused-import
|
||||
|
||||
from homeassistant import monkey_patch
|
||||
from homeassistant.const import (
|
||||
__version__,
|
||||
EVENT_HOMEASSISTANT_START,
|
||||
REQUIRED_PYTHON_VER,
|
||||
RESTART_EXIT_CODE,
|
||||
)
|
||||
from homeassistant.const import __version__, REQUIRED_PYTHON_VER, RESTART_EXIT_CODE
|
||||
|
||||
if TYPE_CHECKING:
|
||||
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,
|
||||
)
|
||||
|
||||
if args.open_ui:
|
||||
# Imported here to avoid importing asyncio before monkey patch
|
||||
from homeassistant.util.async_ import run_callback_threadsafe
|
||||
if args.open_ui and hass.config.api is not None:
|
||||
import webbrowser
|
||||
|
||||
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,
|
||||
)
|
||||
hass.add_job(webbrowser.open, hass.config.api.base_url)
|
||||
|
||||
return await hass.async_run()
|
||||
|
||||
|
|
|
@ -276,7 +276,7 @@ class HomeAssistant:
|
|||
self.state = CoreState.running
|
||||
_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.
|
||||
|
||||
target: target to call.
|
||||
|
|
Loading…
Reference in New Issue