Add WS command integration/wait (#142040)

* Add WS command integration/wait

* Add test

* Update homeassistant/components/websocket_api/commands.py

Co-authored-by: Martin Hjelmare <marhje52@gmail.com>

* Use helper setup.async_wait_component

* Add onboarding view

* Revert "Add onboarding view"

This reverts commit df3a1a0580.

---------

Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
This commit is contained in:
Erik Montnemery
2025-04-11 16:09:15 +02:00
committed by GitHub
parent 4aca9cd66b
commit 0105332476
2 changed files with 107 additions and 2 deletions

View File

@ -59,7 +59,11 @@ from homeassistant.loader import (
async_get_integration_descriptions,
async_get_integrations,
)
from homeassistant.setup import async_get_loaded_integrations, async_get_setup_timings
from homeassistant.setup import (
async_get_loaded_integrations,
async_get_setup_timings,
async_wait_component,
)
from homeassistant.util.json import format_unserializable_data
from . import const, decorators, messages
@ -98,6 +102,7 @@ def async_register_commands(
async_reg(hass, handle_subscribe_entities)
async_reg(hass, handle_supported_features)
async_reg(hass, handle_integration_descriptions)
async_reg(hass, handle_integration_wait)
def pong_message(iden: int) -> dict[str, Any]:
@ -923,3 +928,21 @@ async def handle_integration_descriptions(
) -> None:
"""Get metadata for all brands and integrations."""
connection.send_result(msg["id"], await async_get_integration_descriptions(hass))
@decorators.websocket_command(
{
vol.Required("type"): "integration/wait",
vol.Required("domain"): str,
}
)
@decorators.async_response
async def handle_integration_wait(
hass: HomeAssistant, connection: ActiveConnection, msg: dict[str, Any]
) -> None:
"""Handle wait for integration command."""
domain: str = msg["domain"]
connection.send_result(
msg["id"], {"integration_loaded": await async_wait_component(hass, domain)}
)