1 """Handle Cloud assist pipelines."""
7 async_create_default_pipeline,
9 async_setup_pipeline_store,
10 async_update_pipeline,
28 """Create a cloud assist pipeline."""
31 platforms_setup = hass.data[DATA_PLATFORMS_SETUP]
32 await asyncio.gather(*(event.wait()
for event
in platforms_setup.values()))
37 entity_registry = er.async_get(hass)
38 new_stt_engine_id = entity_registry.async_get_entity_id(
39 STT_DOMAIN, DOMAIN, STT_ENTITY_UNIQUE_ID
41 new_tts_engine_id = entity_registry.async_get_entity_id(
42 TTS_DOMAIN, DOMAIN, TTS_ENTITY_UNIQUE_ID
44 if new_stt_engine_id
is None or new_tts_engine_id
is None:
48 def cloud_assist_pipeline(hass: HomeAssistant) -> str |
None:
49 """Return the ID of a cloud-enabled assist pipeline or None.
51 Check if a cloud pipeline already exists with either
52 legacy or current cloud engine ids.
56 pipeline.conversation_engine == HOME_ASSISTANT_AGENT
57 and pipeline.stt_engine
in (DOMAIN, new_stt_engine_id)
58 and pipeline.tts_engine
in (DOMAIN, new_tts_engine_id)
63 if (cloud_assist_pipeline(hass))
is not None or (
66 stt_engine_id=new_stt_engine_id,
67 tts_engine_id=new_tts_engine_id,
68 pipeline_name=
"Home Assistant Cloud",
73 return cloud_pipeline.id
77 hass: HomeAssistant, platform: Platform, engine_id: str
79 """Migrate the pipeline engines in the cloud assist pipeline."""
86 if platform == Platform.STT:
87 wait_for_platform = Platform.TTS
88 pipeline_attribute =
"stt_engine"
89 elif platform == Platform.TTS:
90 wait_for_platform = Platform.STT
91 pipeline_attribute =
"tts_engine"
93 raise ValueError(f
"Invalid platform {platform}")
95 platforms_setup = hass.data[DATA_PLATFORMS_SETUP]
96 await platforms_setup[wait_for_platform].wait()
102 kwargs: dict[str, Any] = {pipeline_attribute: engine_id}
104 for pipeline
in pipelines:
105 if getattr(pipeline, pipeline_attribute) == DOMAIN:
Pipeline|None async_create_default_pipeline(HomeAssistant hass, str stt_engine_id, str tts_engine_id, str pipeline_name)
None async_update_pipeline(HomeAssistant hass, Pipeline pipeline, *str|UndefinedType conversation_engine=UNDEFINED, str|UndefinedType conversation_language=UNDEFINED, str|UndefinedType language=UNDEFINED, str|UndefinedType name=UNDEFINED, str|None|UndefinedType stt_engine=UNDEFINED, str|None|UndefinedType stt_language=UNDEFINED, str|None|UndefinedType tts_engine=UNDEFINED, str|None|UndefinedType tts_language=UNDEFINED, str|None|UndefinedType tts_voice=UNDEFINED, str|None|UndefinedType wake_word_entity=UNDEFINED, str|None|UndefinedType wake_word_id=UNDEFINED, bool|UndefinedType prefer_local_intents=UNDEFINED)
PipelineData async_setup_pipeline_store(HomeAssistant hass)
list[Pipeline] async_get_pipelines(HomeAssistant hass)
str|None async_create_cloud_pipeline(HomeAssistant hass)
None async_migrate_cloud_pipeline_engine(HomeAssistant hass, Platform platform, str engine_id)