Make assist_pipeline an after dependency of cloud (#92057)
parent
ed737f306b
commit
2750a5c3e6
|
@ -23,6 +23,7 @@ from homeassistant.helpers.collection import (
|
|||
StorageCollection,
|
||||
StorageCollectionWebsocket,
|
||||
)
|
||||
from homeassistant.helpers.singleton import singleton
|
||||
from homeassistant.helpers.storage import Store
|
||||
from homeassistant.util import (
|
||||
dt as dt_util,
|
||||
|
@ -956,7 +957,8 @@ class PipelineRunDebug:
|
|||
)
|
||||
|
||||
|
||||
async def async_setup_pipeline_store(hass: HomeAssistant) -> None:
|
||||
@singleton(DOMAIN)
|
||||
async def async_setup_pipeline_store(hass: HomeAssistant) -> PipelineData:
|
||||
"""Set up the pipeline storage collection."""
|
||||
pipeline_store = PipelineStorageCollection(
|
||||
Store(hass, STORAGE_VERSION, STORAGE_KEY)
|
||||
|
@ -969,4 +971,4 @@ async def async_setup_pipeline_store(hass: HomeAssistant) -> None:
|
|||
PIPELINE_FIELDS,
|
||||
PIPELINE_FIELDS,
|
||||
).async_setup(hass)
|
||||
hass.data[DOMAIN] = PipelineData({}, pipeline_store)
|
||||
return PipelineData({}, pipeline_store)
|
||||
|
|
|
@ -198,6 +198,9 @@ class CloudLoginView(HomeAssistantView):
|
|||
cloud = hass.data[DOMAIN]
|
||||
await cloud.login(data["email"], data["password"])
|
||||
|
||||
# Make sure the pipeline store is loaded, needed because assist_pipeline
|
||||
# is an after dependency of cloud
|
||||
await assist_pipeline.async_setup_pipeline_store(hass)
|
||||
if (cloud_pipeline_id := cloud_assist_pipeline(hass)) is None:
|
||||
if cloud_pipeline := await assist_pipeline.async_create_default_pipeline(
|
||||
hass, DOMAIN, DOMAIN
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
{
|
||||
"domain": "cloud",
|
||||
"name": "Home Assistant Cloud",
|
||||
"after_dependencies": ["google_assistant", "alexa"],
|
||||
"after_dependencies": ["assist_pipeline", "google_assistant", "alexa"],
|
||||
"codeowners": ["@home-assistant/cloud"],
|
||||
"dependencies": ["assist_pipeline", "homeassistant", "http", "webhook"],
|
||||
"dependencies": ["homeassistant", "http", "webhook"],
|
||||
"documentation": "https://www.home-assistant.io/integrations/cloud",
|
||||
"integration_type": "system",
|
||||
"iot_class": "cloud_push",
|
||||
|
|
|
@ -16,6 +16,7 @@ from homeassistant.components.cloud.const import DOMAIN
|
|||
from homeassistant.components.google_assistant.helpers import GoogleEntity
|
||||
from homeassistant.core import HomeAssistant, State
|
||||
from homeassistant.helpers import entity_registry as er
|
||||
from homeassistant.setup import async_setup_component
|
||||
from homeassistant.util.location import LocationInfo
|
||||
|
||||
from . import mock_cloud, mock_cloud_prefs
|
||||
|
@ -106,6 +107,8 @@ async def test_google_actions_sync_fails(
|
|||
async def test_login_view(hass: HomeAssistant, cloud_client) -> None:
|
||||
"""Test logging in when an assist pipeline is available."""
|
||||
hass.data["cloud"] = MagicMock(login=AsyncMock())
|
||||
await async_setup_component(hass, "stt", {})
|
||||
await async_setup_component(hass, "tts", {})
|
||||
|
||||
with patch(
|
||||
"homeassistant.components.cloud.http_api.assist_pipeline.async_get_pipelines",
|
||||
|
@ -133,6 +136,8 @@ async def test_login_view(hass: HomeAssistant, cloud_client) -> None:
|
|||
async def test_login_view_create_pipeline(hass: HomeAssistant, cloud_client) -> None:
|
||||
"""Test logging in when no assist pipeline is available."""
|
||||
hass.data["cloud"] = MagicMock(login=AsyncMock())
|
||||
await async_setup_component(hass, "stt", {})
|
||||
await async_setup_component(hass, "tts", {})
|
||||
|
||||
with patch(
|
||||
"homeassistant.components.cloud.http_api.assist_pipeline.async_create_default_pipeline",
|
||||
|
@ -153,6 +158,8 @@ async def test_login_view_create_pipeline_fail(
|
|||
) -> None:
|
||||
"""Test logging in when no assist pipeline is available."""
|
||||
hass.data["cloud"] = MagicMock(login=AsyncMock())
|
||||
await async_setup_component(hass, "stt", {})
|
||||
await async_setup_component(hass, "tts", {})
|
||||
|
||||
with patch(
|
||||
"homeassistant.components.cloud.http_api.assist_pipeline.async_create_default_pipeline",
|
||||
|
|
Loading…
Reference in New Issue