Fallback to preferred pipeline if the pipeline doesn't exist (#25404)

pull/25407/head
Paul Bottein 2025-05-09 16:01:03 +02:00 committed by GitHub
parent 15ae37d077
commit d6ebd9bfc4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 7 additions and 1 deletions

View File

@ -57,16 +57,22 @@ export class HaVoiceCommandDialog extends LitElement {
public async showDialog(
params: Required<VoiceCommandDialogParams>
): Promise<void> {
await this._loadPipelines();
const pipelinesIds = this._pipelines?.map((pipeline) => pipeline.id) || [];
if (
params.pipeline_id === "preferred" ||
(params.pipeline_id === "last_used" && !this._pipelineId)
) {
await this._loadPipelines();
this._pipelineId = this._preferredPipeline;
} else if (!["last_used", "preferred"].includes(params.pipeline_id)) {
this._pipelineId = params.pipeline_id;
}
// If the pipeline id is not in the list of pipelines, set it to preferred
if (this._pipelineId && !pipelinesIds.includes(this._pipelineId)) {
this._pipelineId = this._preferredPipeline;
}
this._startListening = params.start_listening;
this._opened = true;
}