mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-15 21:36:36 +00:00
Add warning for muted voice assistant or when not heard wakeword in 1… (#22934)
Add warning for muted voice assistant or when not heard wakeword in 15 secs
This commit is contained in:
parent
b82d880bfd
commit
79c7cf59ee
@ -160,20 +160,16 @@ export class HaVoiceAssistantSetupDialog extends LitElement {
|
||||
: this._step === STEP.CHECK
|
||||
? html`<ha-voice-assistant-setup-step-check
|
||||
.hass=${this.hass}
|
||||
.assistEntityId=${this._findDomainEntityId(
|
||||
this._params.deviceId,
|
||||
this.hass.entities,
|
||||
"assist_satellite"
|
||||
)}
|
||||
.assistEntityId=${assistSatelliteEntityId}
|
||||
></ha-voice-assistant-setup-step-check>`
|
||||
: this._step === STEP.WAKEWORD
|
||||
? html`<ha-voice-assistant-setup-step-wake-word
|
||||
.hass=${this.hass}
|
||||
.assistConfiguration=${this._assistConfiguration}
|
||||
.assistEntityId=${this._findDomainEntityId(
|
||||
.assistEntityId=${assistSatelliteEntityId}
|
||||
.deviceEntities=${this._deviceEntities(
|
||||
this._params.deviceId,
|
||||
this.hass.entities,
|
||||
"assist_satellite"
|
||||
this.hass.entities
|
||||
)}
|
||||
></ha-voice-assistant-setup-step-wake-word>`
|
||||
: this._step === STEP.CHANGE_WAKEWORD
|
||||
@ -181,11 +177,7 @@ export class HaVoiceAssistantSetupDialog extends LitElement {
|
||||
<ha-voice-assistant-setup-step-change-wake-word
|
||||
.hass=${this.hass}
|
||||
.assistConfiguration=${this._assistConfiguration}
|
||||
.assistEntityId=${this._findDomainEntityId(
|
||||
this._params.deviceId,
|
||||
this.hass.entities,
|
||||
"assist_satellite"
|
||||
)}
|
||||
.assistEntityId=${assistSatelliteEntityId}
|
||||
></ha-voice-assistant-setup-step-change-wake-word>
|
||||
`
|
||||
: this._step === STEP.AREA
|
||||
@ -199,11 +191,7 @@ export class HaVoiceAssistantSetupDialog extends LitElement {
|
||||
? html`<ha-voice-assistant-setup-step-pipeline
|
||||
.hass=${this.hass}
|
||||
.assistConfiguration=${this._assistConfiguration}
|
||||
.assistEntityId=${this._findDomainEntityId(
|
||||
this._params.deviceId,
|
||||
this.hass.entities,
|
||||
"assist_satellite"
|
||||
)}
|
||||
.assistEntityId=${assistSatelliteEntityId}
|
||||
></ha-voice-assistant-setup-step-pipeline>`
|
||||
: this._step === STEP.CLOUD
|
||||
? html`<ha-voice-assistant-setup-step-cloud
|
||||
@ -214,11 +202,7 @@ export class HaVoiceAssistantSetupDialog extends LitElement {
|
||||
.hass=${this.hass}
|
||||
.assistConfiguration=${this
|
||||
._assistConfiguration}
|
||||
.assistEntityId=${this._findDomainEntityId(
|
||||
this._params.deviceId,
|
||||
this.hass.entities,
|
||||
"assist_satellite"
|
||||
)}
|
||||
.assistEntityId=${assistSatelliteEntityId}
|
||||
></ha-voice-assistant-setup-step-success>`
|
||||
: nothing}
|
||||
</div>
|
||||
|
@ -11,6 +11,8 @@ import { interceptWakeWord } from "../../data/assist_satellite";
|
||||
import type { HomeAssistant } from "../../types";
|
||||
import { AssistantSetupStyles } from "./styles";
|
||||
import { STEP } from "./voice-assistant-setup-dialog";
|
||||
import type { EntityRegistryDisplayEntry } from "../../data/entity_registry";
|
||||
import { computeDomain } from "../../common/entity/compute_domain";
|
||||
|
||||
@customElement("ha-voice-assistant-setup-step-wake-word")
|
||||
export class HaVoiceAssistantSetupStepWakeWord extends LitElement {
|
||||
@ -21,10 +23,19 @@ export class HaVoiceAssistantSetupStepWakeWord extends LitElement {
|
||||
|
||||
@property() public assistEntityId?: string;
|
||||
|
||||
@property({ attribute: false })
|
||||
public deviceEntities?: EntityRegistryDisplayEntry[];
|
||||
|
||||
@state() public _muteSwitchEntity?: string;
|
||||
|
||||
@state() private _detected = false;
|
||||
|
||||
@state() private _timedout = false;
|
||||
|
||||
private _sub?: Promise<UnsubscribeFunc>;
|
||||
|
||||
private _timeout?: number;
|
||||
|
||||
disconnectedCallback(): void {
|
||||
super.disconnectedCallback();
|
||||
this._stopListeningWakeWord();
|
||||
@ -35,10 +46,25 @@ export class HaVoiceAssistantSetupStepWakeWord extends LitElement {
|
||||
|
||||
if (changedProperties.has("assistEntityId")) {
|
||||
this._detected = false;
|
||||
this._muteSwitchEntity = this.deviceEntities?.find(
|
||||
(ent) =>
|
||||
computeDomain(ent.entity_id) === "switch" &&
|
||||
ent.entity_id.includes("mute")
|
||||
)?.entity_id;
|
||||
if (!this._muteSwitchEntity) {
|
||||
this._startTimeOut();
|
||||
}
|
||||
this._listenWakeWord();
|
||||
}
|
||||
}
|
||||
|
||||
private _startTimeOut() {
|
||||
this._timeout = window.setTimeout(() => {
|
||||
this._timeout = undefined;
|
||||
this._timedout = true;
|
||||
}, 15000);
|
||||
}
|
||||
|
||||
private _activeWakeWord = memoizeOne(
|
||||
(config: AssistSatelliteConfiguration | undefined) => {
|
||||
if (!config) {
|
||||
@ -78,6 +104,16 @@ export class HaVoiceAssistantSetupStepWakeWord extends LitElement {
|
||||
<p class="secondary">
|
||||
To make sure the wake word works for you.
|
||||
</p>`}
|
||||
${this._timedout
|
||||
? html`<ha-alert alert-type="warning"
|
||||
>We have not heard the wake word, is your device muted?</ha-alert
|
||||
>`
|
||||
: this._muteSwitchEntity &&
|
||||
this.hass.states[this._muteSwitchEntity].state === "on"
|
||||
? html`<ha-alert alert-type="warning" title="Your device is muted"
|
||||
>Please unmute your device to continue.</ha-alert
|
||||
>`
|
||||
: nothing}
|
||||
</div>
|
||||
<div class="footer centered">
|
||||
<ha-button @click=${this._changeWakeWord}>Change wake word</ha-button>
|
||||
@ -91,6 +127,8 @@ export class HaVoiceAssistantSetupStepWakeWord extends LitElement {
|
||||
}
|
||||
await this._stopListeningWakeWord();
|
||||
this._sub = interceptWakeWord(this.hass, entityId, () => {
|
||||
this._timedout = false;
|
||||
clearTimeout(this._timeout);
|
||||
this._stopListeningWakeWord();
|
||||
if (this._detected) {
|
||||
this._nextStep();
|
||||
|
Loading…
x
Reference in New Issue
Block a user