mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-17 14:26:35 +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
|
: this._step === STEP.CHECK
|
||||||
? html`<ha-voice-assistant-setup-step-check
|
? html`<ha-voice-assistant-setup-step-check
|
||||||
.hass=${this.hass}
|
.hass=${this.hass}
|
||||||
.assistEntityId=${this._findDomainEntityId(
|
.assistEntityId=${assistSatelliteEntityId}
|
||||||
this._params.deviceId,
|
|
||||||
this.hass.entities,
|
|
||||||
"assist_satellite"
|
|
||||||
)}
|
|
||||||
></ha-voice-assistant-setup-step-check>`
|
></ha-voice-assistant-setup-step-check>`
|
||||||
: this._step === STEP.WAKEWORD
|
: this._step === STEP.WAKEWORD
|
||||||
? html`<ha-voice-assistant-setup-step-wake-word
|
? html`<ha-voice-assistant-setup-step-wake-word
|
||||||
.hass=${this.hass}
|
.hass=${this.hass}
|
||||||
.assistConfiguration=${this._assistConfiguration}
|
.assistConfiguration=${this._assistConfiguration}
|
||||||
.assistEntityId=${this._findDomainEntityId(
|
.assistEntityId=${assistSatelliteEntityId}
|
||||||
|
.deviceEntities=${this._deviceEntities(
|
||||||
this._params.deviceId,
|
this._params.deviceId,
|
||||||
this.hass.entities,
|
this.hass.entities
|
||||||
"assist_satellite"
|
|
||||||
)}
|
)}
|
||||||
></ha-voice-assistant-setup-step-wake-word>`
|
></ha-voice-assistant-setup-step-wake-word>`
|
||||||
: this._step === STEP.CHANGE_WAKEWORD
|
: this._step === STEP.CHANGE_WAKEWORD
|
||||||
@ -181,11 +177,7 @@ export class HaVoiceAssistantSetupDialog extends LitElement {
|
|||||||
<ha-voice-assistant-setup-step-change-wake-word
|
<ha-voice-assistant-setup-step-change-wake-word
|
||||||
.hass=${this.hass}
|
.hass=${this.hass}
|
||||||
.assistConfiguration=${this._assistConfiguration}
|
.assistConfiguration=${this._assistConfiguration}
|
||||||
.assistEntityId=${this._findDomainEntityId(
|
.assistEntityId=${assistSatelliteEntityId}
|
||||||
this._params.deviceId,
|
|
||||||
this.hass.entities,
|
|
||||||
"assist_satellite"
|
|
||||||
)}
|
|
||||||
></ha-voice-assistant-setup-step-change-wake-word>
|
></ha-voice-assistant-setup-step-change-wake-word>
|
||||||
`
|
`
|
||||||
: this._step === STEP.AREA
|
: this._step === STEP.AREA
|
||||||
@ -199,11 +191,7 @@ export class HaVoiceAssistantSetupDialog extends LitElement {
|
|||||||
? html`<ha-voice-assistant-setup-step-pipeline
|
? html`<ha-voice-assistant-setup-step-pipeline
|
||||||
.hass=${this.hass}
|
.hass=${this.hass}
|
||||||
.assistConfiguration=${this._assistConfiguration}
|
.assistConfiguration=${this._assistConfiguration}
|
||||||
.assistEntityId=${this._findDomainEntityId(
|
.assistEntityId=${assistSatelliteEntityId}
|
||||||
this._params.deviceId,
|
|
||||||
this.hass.entities,
|
|
||||||
"assist_satellite"
|
|
||||||
)}
|
|
||||||
></ha-voice-assistant-setup-step-pipeline>`
|
></ha-voice-assistant-setup-step-pipeline>`
|
||||||
: this._step === STEP.CLOUD
|
: this._step === STEP.CLOUD
|
||||||
? html`<ha-voice-assistant-setup-step-cloud
|
? html`<ha-voice-assistant-setup-step-cloud
|
||||||
@ -214,11 +202,7 @@ export class HaVoiceAssistantSetupDialog extends LitElement {
|
|||||||
.hass=${this.hass}
|
.hass=${this.hass}
|
||||||
.assistConfiguration=${this
|
.assistConfiguration=${this
|
||||||
._assistConfiguration}
|
._assistConfiguration}
|
||||||
.assistEntityId=${this._findDomainEntityId(
|
.assistEntityId=${assistSatelliteEntityId}
|
||||||
this._params.deviceId,
|
|
||||||
this.hass.entities,
|
|
||||||
"assist_satellite"
|
|
||||||
)}
|
|
||||||
></ha-voice-assistant-setup-step-success>`
|
></ha-voice-assistant-setup-step-success>`
|
||||||
: nothing}
|
: nothing}
|
||||||
</div>
|
</div>
|
||||||
|
@ -11,6 +11,8 @@ import { interceptWakeWord } from "../../data/assist_satellite";
|
|||||||
import type { HomeAssistant } from "../../types";
|
import type { HomeAssistant } from "../../types";
|
||||||
import { AssistantSetupStyles } from "./styles";
|
import { AssistantSetupStyles } from "./styles";
|
||||||
import { STEP } from "./voice-assistant-setup-dialog";
|
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")
|
@customElement("ha-voice-assistant-setup-step-wake-word")
|
||||||
export class HaVoiceAssistantSetupStepWakeWord extends LitElement {
|
export class HaVoiceAssistantSetupStepWakeWord extends LitElement {
|
||||||
@ -21,10 +23,19 @@ export class HaVoiceAssistantSetupStepWakeWord extends LitElement {
|
|||||||
|
|
||||||
@property() public assistEntityId?: string;
|
@property() public assistEntityId?: string;
|
||||||
|
|
||||||
|
@property({ attribute: false })
|
||||||
|
public deviceEntities?: EntityRegistryDisplayEntry[];
|
||||||
|
|
||||||
|
@state() public _muteSwitchEntity?: string;
|
||||||
|
|
||||||
@state() private _detected = false;
|
@state() private _detected = false;
|
||||||
|
|
||||||
|
@state() private _timedout = false;
|
||||||
|
|
||||||
private _sub?: Promise<UnsubscribeFunc>;
|
private _sub?: Promise<UnsubscribeFunc>;
|
||||||
|
|
||||||
|
private _timeout?: number;
|
||||||
|
|
||||||
disconnectedCallback(): void {
|
disconnectedCallback(): void {
|
||||||
super.disconnectedCallback();
|
super.disconnectedCallback();
|
||||||
this._stopListeningWakeWord();
|
this._stopListeningWakeWord();
|
||||||
@ -35,10 +46,25 @@ export class HaVoiceAssistantSetupStepWakeWord extends LitElement {
|
|||||||
|
|
||||||
if (changedProperties.has("assistEntityId")) {
|
if (changedProperties.has("assistEntityId")) {
|
||||||
this._detected = false;
|
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();
|
this._listenWakeWord();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private _startTimeOut() {
|
||||||
|
this._timeout = window.setTimeout(() => {
|
||||||
|
this._timeout = undefined;
|
||||||
|
this._timedout = true;
|
||||||
|
}, 15000);
|
||||||
|
}
|
||||||
|
|
||||||
private _activeWakeWord = memoizeOne(
|
private _activeWakeWord = memoizeOne(
|
||||||
(config: AssistSatelliteConfiguration | undefined) => {
|
(config: AssistSatelliteConfiguration | undefined) => {
|
||||||
if (!config) {
|
if (!config) {
|
||||||
@ -78,6 +104,16 @@ export class HaVoiceAssistantSetupStepWakeWord extends LitElement {
|
|||||||
<p class="secondary">
|
<p class="secondary">
|
||||||
To make sure the wake word works for you.
|
To make sure the wake word works for you.
|
||||||
</p>`}
|
</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>
|
||||||
<div class="footer centered">
|
<div class="footer centered">
|
||||||
<ha-button @click=${this._changeWakeWord}>Change wake word</ha-button>
|
<ha-button @click=${this._changeWakeWord}>Change wake word</ha-button>
|
||||||
@ -91,6 +127,8 @@ export class HaVoiceAssistantSetupStepWakeWord extends LitElement {
|
|||||||
}
|
}
|
||||||
await this._stopListeningWakeWord();
|
await this._stopListeningWakeWord();
|
||||||
this._sub = interceptWakeWord(this.hass, entityId, () => {
|
this._sub = interceptWakeWord(this.hass, entityId, () => {
|
||||||
|
this._timedout = false;
|
||||||
|
clearTimeout(this._timeout);
|
||||||
this._stopListeningWakeWord();
|
this._stopListeningWakeWord();
|
||||||
if (this._detected) {
|
if (this._detected) {
|
||||||
this._nextStep();
|
this._nextStep();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user