mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-26 18:56:39 +00:00
Clear wake word when new engine is picked, select first wake word. by… (#18058)
* Clear wake word when new engine is picked, select first wake word. by default * Update assist-pipeline-detail-wakeword.ts
This commit is contained in:
parent
8daff17d6a
commit
5914a6c1a4
@ -14,6 +14,7 @@ import { AssistPipeline } from "../../../../data/assist_pipeline";
|
|||||||
import { HomeAssistant } from "../../../../types";
|
import { HomeAssistant } from "../../../../types";
|
||||||
import { fetchWakeWordInfo, WakeWord } from "../../../../data/wake_word";
|
import { fetchWakeWordInfo, WakeWord } from "../../../../data/wake_word";
|
||||||
import { documentationUrl } from "../../../../util/documentation-url";
|
import { documentationUrl } from "../../../../util/documentation-url";
|
||||||
|
import { fireEvent } from "../../../../common/dom/fire_event";
|
||||||
|
|
||||||
@customElement("assist-pipeline-detail-wakeword")
|
@customElement("assist-pipeline-detail-wakeword")
|
||||||
export class AssistPipelineDetailWakeWord extends LitElement {
|
export class AssistPipelineDetailWakeWord extends LitElement {
|
||||||
@ -71,6 +72,11 @@ export class AssistPipelineDetailWakeWord extends LitElement {
|
|||||||
changedProps.has("data") &&
|
changedProps.has("data") &&
|
||||||
changedProps.get("data")?.wake_word_entity !== this.data?.wake_word_entity
|
changedProps.get("data")?.wake_word_entity !== this.data?.wake_word_entity
|
||||||
) {
|
) {
|
||||||
|
if (this.data?.wake_word_id) {
|
||||||
|
fireEvent(this, "value-changed", {
|
||||||
|
value: { ...this.data, wake_word_id: undefined },
|
||||||
|
});
|
||||||
|
}
|
||||||
this._fetchWakeWords();
|
this._fetchWakeWords();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -122,13 +128,20 @@ export class AssistPipelineDetailWakeWord extends LitElement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private async _fetchWakeWords() {
|
private async _fetchWakeWords() {
|
||||||
if (!this.data?.wake_word_entity) {
|
|
||||||
this._wakeWords = undefined;
|
this._wakeWords = undefined;
|
||||||
|
if (!this.data?.wake_word_entity) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this._wakeWords = (
|
const wakeWordEntity = this.data.wake_word_entity;
|
||||||
await fetchWakeWordInfo(this.hass, this.data.wake_word_entity)
|
const wakewordInfo = await fetchWakeWordInfo(this.hass, wakeWordEntity);
|
||||||
).wake_words;
|
if (this.data.wake_word_entity !== wakeWordEntity) {
|
||||||
|
// wake word entity changed while we were fetching
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this._wakeWords = wakewordInfo.wake_words;
|
||||||
|
fireEvent(this, "value-changed", {
|
||||||
|
value: { ...this.data, wake_word_id: this._wakeWords[0]?.id },
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
static get styles(): CSSResultGroup {
|
static get styles(): CSSResultGroup {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user