Remove cloud assist pipeline setup from cloud client (#92056)
This commit is contained in:
parent
6b931b208f
commit
ed737f306b
9 changed files with 119 additions and 133 deletions
|
@ -15,7 +15,7 @@ from hass_nabucasa.const import STATE_DISCONNECTED
|
|||
from hass_nabucasa.voice import MAP_VOICE
|
||||
import voluptuous as vol
|
||||
|
||||
from homeassistant.components import websocket_api
|
||||
from homeassistant.components import assist_pipeline, conversation, websocket_api
|
||||
from homeassistant.components.alexa import (
|
||||
entities as alexa_entities,
|
||||
errors as alexa_errors,
|
||||
|
@ -182,15 +182,28 @@ class CloudLoginView(HomeAssistantView):
|
|||
)
|
||||
async def post(self, request, data):
|
||||
"""Handle login request."""
|
||||
|
||||
def cloud_assist_pipeline(hass: HomeAssistant) -> str | None:
|
||||
"""Return the ID of a cloud-enabled assist pipeline or None."""
|
||||
for pipeline in assist_pipeline.async_get_pipelines(hass):
|
||||
if (
|
||||
pipeline.conversation_engine == conversation.HOME_ASSISTANT_AGENT
|
||||
and pipeline.stt_engine == DOMAIN
|
||||
and pipeline.tts_engine == DOMAIN
|
||||
):
|
||||
return pipeline.id
|
||||
return None
|
||||
|
||||
hass = request.app["hass"]
|
||||
cloud = hass.data[DOMAIN]
|
||||
await cloud.login(data["email"], data["password"])
|
||||
|
||||
if cloud.client.cloud_pipeline is None:
|
||||
await cloud.client.create_cloud_assist_pipeline()
|
||||
return self.json(
|
||||
{"success": True, "cloud_pipeline": cloud.client.cloud_pipeline}
|
||||
)
|
||||
if (cloud_pipeline_id := cloud_assist_pipeline(hass)) is None:
|
||||
if cloud_pipeline := await assist_pipeline.async_create_default_pipeline(
|
||||
hass, DOMAIN, DOMAIN
|
||||
):
|
||||
cloud_pipeline_id = cloud_pipeline.id
|
||||
return self.json({"success": True, "cloud_pipeline": cloud_pipeline_id})
|
||||
|
||||
|
||||
class CloudLogoutView(HomeAssistantView):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue