Dont show voice wizard for voip (#24050)

dont show voice wizard for voip
This commit is contained in:
Bram Kragten 2025-02-04 13:38:03 +01:00
parent a26701808f
commit 849922f7be
5 changed files with 98 additions and 71 deletions

View File

@ -65,7 +65,8 @@ class StepFlowCreateEntry extends LitElement {
if ( if (
devices.length !== 1 || devices.length !== 1 ||
devices[0].primary_config_entry !== this.step.result?.entry_id devices[0].primary_config_entry !== this.step.result?.entry_id ||
this.step.result.domain === "voip"
) { ) {
return; return;
} }

View File

@ -47,6 +47,8 @@ export class HaVoiceAssistantSetupDialog extends LitElement {
@state() private _assistConfiguration?: AssistSatelliteConfiguration; @state() private _assistConfiguration?: AssistSatelliteConfiguration;
@state() private _error?: string;
private _previousSteps: STEP[] = []; private _previousSteps: STEP[] = [];
private _nextStep?: STEP; private _nextStep?: STEP;
@ -165,79 +167,86 @@ export class HaVoiceAssistantSetupDialog extends LitElement {
"update" "update"
)} )}
></ha-voice-assistant-setup-step-update>` ></ha-voice-assistant-setup-step-update>`
: assistEntityState?.state === UNAVAILABLE : this._error
? this.hass.localize( ? html`<ha-alert alert-type="error">${this._error}</ha-alert>`
"ui.panel.config.voice_assistants.satellite_wizard.not_available" : assistEntityState?.state === UNAVAILABLE
) ? html`<ha-alert alert-type="error"
: this._step === STEP.CHECK >${this.hass.localize(
? html`<ha-voice-assistant-setup-step-check "ui.panel.config.voice_assistants.satellite_wizard.not_available"
.hass=${this.hass} )}</ha-alert
.assistEntityId=${assistSatelliteEntityId} >`
></ha-voice-assistant-setup-step-check>` : this._step === STEP.CHECK
: this._step === STEP.WAKEWORD ? html`<ha-voice-assistant-setup-step-check
? html`<ha-voice-assistant-setup-step-wake-word
.hass=${this.hass} .hass=${this.hass}
.assistConfiguration=${this._assistConfiguration}
.assistEntityId=${assistSatelliteEntityId} .assistEntityId=${assistSatelliteEntityId}
.deviceEntities=${this._deviceEntities( ></ha-voice-assistant-setup-step-check>`
this._params.deviceId, : this._step === STEP.WAKEWORD
this.hass.entities ? html`<ha-voice-assistant-setup-step-wake-word
)} .hass=${this.hass}
></ha-voice-assistant-setup-step-wake-word>` .assistConfiguration=${this._assistConfiguration}
: this._step === STEP.CHANGE_WAKEWORD .assistEntityId=${assistSatelliteEntityId}
? html` .deviceEntities=${this._deviceEntities(
<ha-voice-assistant-setup-step-change-wake-word this._params.deviceId,
.hass=${this.hass} this.hass.entities
.assistConfiguration=${this._assistConfiguration} )}
.assistEntityId=${assistSatelliteEntityId} ></ha-voice-assistant-setup-step-wake-word>`
></ha-voice-assistant-setup-step-change-wake-word> : this._step === STEP.CHANGE_WAKEWORD
`
: this._step === STEP.AREA
? html` ? html`
<ha-voice-assistant-setup-step-area <ha-voice-assistant-setup-step-change-wake-word
.hass=${this.hass}
.deviceId=${this._params.deviceId}
></ha-voice-assistant-setup-step-area>
`
: this._step === STEP.PIPELINE
? html`<ha-voice-assistant-setup-step-pipeline
.hass=${this.hass} .hass=${this.hass}
.assistConfiguration=${this._assistConfiguration} .assistConfiguration=${this._assistConfiguration}
.assistEntityId=${assistSatelliteEntityId} .assistEntityId=${assistSatelliteEntityId}
></ha-voice-assistant-setup-step-pipeline>` ></ha-voice-assistant-setup-step-change-wake-word>
: this._step === STEP.CLOUD `
? html`<ha-voice-assistant-setup-step-cloud : this._step === STEP.AREA
? html`
<ha-voice-assistant-setup-step-area
.hass=${this.hass} .hass=${this.hass}
></ha-voice-assistant-setup-step-cloud>` .deviceId=${this._params.deviceId}
: this._step === STEP.LOCAL ></ha-voice-assistant-setup-step-area>
? html`<ha-voice-assistant-setup-step-local `
: this._step === STEP.PIPELINE
? html`<ha-voice-assistant-setup-step-pipeline
.hass=${this.hass}
.assistConfiguration=${this._assistConfiguration}
.assistEntityId=${assistSatelliteEntityId}
></ha-voice-assistant-setup-step-pipeline>`
: this._step === STEP.CLOUD
? html`<ha-voice-assistant-setup-step-cloud
.hass=${this.hass} .hass=${this.hass}
.assistConfiguration=${this ></ha-voice-assistant-setup-step-cloud>`
._assistConfiguration} : this._step === STEP.LOCAL
></ha-voice-assistant-setup-step-local>` ? html`<ha-voice-assistant-setup-step-local
: this._step === STEP.SUCCESS
? html`<ha-voice-assistant-setup-step-success
.hass=${this.hass} .hass=${this.hass}
.assistConfiguration=${this .assistConfiguration=${this
._assistConfiguration} ._assistConfiguration}
.assistEntityId=${assistSatelliteEntityId} ></ha-voice-assistant-setup-step-local>`
></ha-voice-assistant-setup-step-success>` : this._step === STEP.SUCCESS
: nothing} ? html`<ha-voice-assistant-setup-step-success
.hass=${this.hass}
.assistConfiguration=${this
._assistConfiguration}
.assistEntityId=${assistSatelliteEntityId}
></ha-voice-assistant-setup-step-success>`
: nothing}
</div> </div>
</ha-dialog> </ha-dialog>
`; `;
} }
private async _fetchAssistConfiguration() { private async _fetchAssistConfiguration() {
this._assistConfiguration = await fetchAssistSatelliteConfiguration( try {
this.hass, this._assistConfiguration = await fetchAssistSatelliteConfiguration(
this._findDomainEntityId( this.hass,
this._params!.deviceId, this._findDomainEntityId(
this.hass.entities, this._params!.deviceId,
"assist_satellite" this.hass.entities,
)! "assist_satellite"
); )!
return this._assistConfiguration; );
} catch (err: any) {
this._error = err.message;
}
} }
private _goToPreviousStep() { private _goToPreviousStep() {
@ -293,6 +302,10 @@ export class HaVoiceAssistantSetupDialog extends LitElement {
.skip-btn { .skip-btn {
margin-top: 6px; margin-top: 6px;
} }
ha-alert {
margin: 24px;
display: block;
}
`, `,
]; ];
} }

View File

@ -85,7 +85,7 @@ export class HaVoiceAssistantSetupStepSuccess extends LitElement {
<div class="rows"> <div class="rows">
${this.assistConfiguration && ${this.assistConfiguration &&
this.assistConfiguration.available_wake_words.length > 1 this.assistConfiguration.available_wake_words.length > 1
? html` <div class="row"> ? html`<div class="row">
<ha-select <ha-select
.label=${"Wake word"} .label=${"Wake word"}
@closed=${stopPropagation} @closed=${stopPropagation}

View File

@ -44,6 +44,15 @@ export class HaVoiceAssistantSetupStepWakeWord extends LitElement {
protected override willUpdate(changedProperties: PropertyValues) { protected override willUpdate(changedProperties: PropertyValues) {
super.willUpdate(changedProperties); super.willUpdate(changedProperties);
if (changedProperties.has("assistConfiguration")) {
if (
this.assistConfiguration &&
!this.assistConfiguration.available_wake_words.length
) {
this._nextStep();
}
}
if (changedProperties.has("assistEntityId")) { if (changedProperties.has("assistEntityId")) {
this._detected = false; this._detected = false;
this._muteSwitchEntity = this.deviceEntities?.find( this._muteSwitchEntity = this.deviceEntities?.find(
@ -135,13 +144,16 @@ export class HaVoiceAssistantSetupStepWakeWord extends LitElement {
>` >`
: nothing} : nothing}
</div> </div>
<div class="footer centered"> ${this.assistConfiguration &&
<ha-button @click=${this._changeWakeWord} this.assistConfiguration.available_wake_words.length > 1
>${this.hass.localize( ? html`<div class="footer centered">
"ui.panel.config.voice_assistants.satellite_wizard.wake_word.change_wake_word" <ha-button @click=${this._changeWakeWord}
)}</ha-button >${this.hass.localize(
> "ui.panel.config.voice_assistants.satellite_wizard.wake_word.change_wake_word"
</div>`; )}</ha-button
>
</div>`
: nothing}`;
} }
private async _listenWakeWord() { private async _listenWakeWord() {

View File

@ -1073,7 +1073,14 @@ export class HaConfigDevicePage extends LitElement {
(ent) => computeDomain(ent.entity_id) === "assist_satellite" (ent) => computeDomain(ent.entity_id) === "assist_satellite"
); );
const domains = this._integrations(
device,
this.entries,
this.manifests
).map((int) => int.domain);
if ( if (
!domains.includes("voip") &&
assistSatellite && assistSatellite &&
assistSatelliteSupportsSetupFlow( assistSatelliteSupportsSetupFlow(
this.hass.states[assistSatellite.entity_id] this.hass.states[assistSatellite.entity_id]
@ -1088,12 +1095,6 @@ export class HaConfigDevicePage extends LitElement {
}); });
} }
const domains = this._integrations(
device,
this.entries,
this.manifests
).map((int) => int.domain);
if (domains.includes("mqtt")) { if (domains.includes("mqtt")) {
const mqtt = await import( const mqtt = await import(
"./device-detail/integration-elements/mqtt/device-actions" "./device-detail/integration-elements/mqtt/device-actions"