From d392bb4c831a0942ad5a9162aeda63fa80ff7b7f Mon Sep 17 00:00:00 2001 From: Paul Bottein Date: Fri, 9 May 2025 16:01:03 +0200 Subject: [PATCH] Fallback to preferred pipeline if the pipeline doesn't exist (#25404) --- .../voice-command-dialog/ha-voice-command-dialog.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/dialogs/voice-command-dialog/ha-voice-command-dialog.ts b/src/dialogs/voice-command-dialog/ha-voice-command-dialog.ts index 1b2a0e88a0..a9f1a8d771 100644 --- a/src/dialogs/voice-command-dialog/ha-voice-command-dialog.ts +++ b/src/dialogs/voice-command-dialog/ha-voice-command-dialog.ts @@ -57,16 +57,22 @@ export class HaVoiceCommandDialog extends LitElement { public async showDialog( params: Required ): Promise { + 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; }