From 48593eee0d28b0cb0fdc94d004d28b1e17ef7105 Mon Sep 17 00:00:00 2001 From: Bram Kragten Date: Thu, 5 Oct 2023 11:30:05 +0200 Subject: [PATCH] fix setting wake word to first option everytime (#18121) --- .../assist-pipeline-detail-wakeword.ts | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/panels/config/voice-assistants/assist-pipeline-detail/assist-pipeline-detail-wakeword.ts b/src/panels/config/voice-assistants/assist-pipeline-detail/assist-pipeline-detail-wakeword.ts index 518f3f02e6fe..5e23835ad495 100644 --- a/src/panels/config/voice-assistants/assist-pipeline-detail/assist-pipeline-detail-wakeword.ts +++ b/src/panels/config/voice-assistants/assist-pipeline-detail/assist-pipeline-detail-wakeword.ts @@ -72,7 +72,10 @@ export class AssistPipelineDetailWakeWord extends LitElement { changedProps.has("data") && changedProps.get("data")?.wake_word_entity !== this.data?.wake_word_entity ) { - if (this.data?.wake_word_id) { + if ( + changedProps.get("data")?.wake_word_entity && + this.data?.wake_word_id + ) { fireEvent(this, "value-changed", { value: { ...this.data, wake_word_id: undefined }, }); @@ -140,8 +143,9 @@ export class AssistPipelineDetailWakeWord extends LitElement { } this._wakeWords = wakewordInfo.wake_words; if ( - !this.data?.wake_word_id || - !this._wakeWords.some((ww) => ww.id === this.data!.wake_word_id) + this.data && + (!this.data?.wake_word_id || + !this._wakeWords.some((ww) => ww.id === this.data!.wake_word_id)) ) { fireEvent(this, "value-changed", { value: { ...this.data, wake_word_id: this._wakeWords[0]?.id },