Remove cloud assist pipeline setup from cloud client (#92056)

This commit is contained in:
Erik Montnemery 2023-04-26 12:53:58 +02:00 committed by GitHub
parent 6b931b208f
commit ed737f306b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 119 additions and 133 deletions

View file

@ -2,7 +2,6 @@
from __future__ import annotations
import asyncio
from collections.abc import Callable, Coroutine
from http import HTTPStatus
import logging
from pathlib import Path
@ -11,13 +10,7 @@ from typing import Any
import aiohttp
from hass_nabucasa.client import CloudClient as Interface
from homeassistant.components import (
assist_pipeline,
conversation,
google_assistant,
persistent_notification,
webhook,
)
from homeassistant.components import google_assistant, persistent_notification, webhook
from homeassistant.components.alexa import (
errors as alexa_errors,
smart_home as alexa_smart_home,
@ -43,7 +36,6 @@ class CloudClient(Interface):
websession: aiohttp.ClientSession,
alexa_user_config: dict[str, Any],
google_user_config: dict[str, Any],
on_started_cb: Callable[[], Coroutine[Any, Any, None]],
) -> None:
"""Initialize client interface to Cloud."""
self._hass = hass
@ -56,10 +48,6 @@ class CloudClient(Interface):
self._alexa_config_init_lock = asyncio.Lock()
self._google_config_init_lock = asyncio.Lock()
self._relayer_region: str | None = None
self._on_started_cb = on_started_cb
self.cloud_pipeline = self._cloud_assist_pipeline()
self.stt_platform_loaded = asyncio.Event()
self.tts_platform_loaded = asyncio.Event()
@property
def base_path(self) -> Path:
@ -148,22 +136,6 @@ class CloudClient(Interface):
return self._google_config
def _cloud_assist_pipeline(self) -> str | None:
"""Return the ID of a cloud-enabled assist pipeline or None."""
for pipeline in assist_pipeline.async_get_pipelines(self._hass):
if (
pipeline.conversation_engine == conversation.HOME_ASSISTANT_AGENT
and pipeline.stt_engine == DOMAIN
and pipeline.tts_engine == DOMAIN
):
return pipeline.id
return None
async def create_cloud_assist_pipeline(self) -> None:
"""Create a cloud-enabled assist pipeline."""
await assist_pipeline.async_create_default_pipeline(self._hass, DOMAIN, DOMAIN)
self.cloud_pipeline = self._cloud_assist_pipeline()
async def on_cloud_connected(self) -> None:
"""When cloud is connected."""
is_new_user = await self.prefs.async_set_username(self.cloud.username)
@ -211,11 +183,6 @@ class CloudClient(Interface):
async def cloud_started(self) -> None:
"""When cloud is started."""
await self._on_started_cb()
await asyncio.gather(
self.stt_platform_loaded.wait(),
self.tts_platform_loaded.wait(),
)
async def cloud_stopped(self) -> None:
"""When the cloud is stopped."""