Skip to content

Commit

Permalink
Add add-on installation to voice setup flow (#23018)
Browse files Browse the repository at this point in the history
  • Loading branch information
bramkragten authored Nov 27, 2024
1 parent 2782b2f commit 0a954cf
Show file tree
Hide file tree
Showing 4 changed files with 419 additions and 44 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ export class CloudStepIntro extends LitElement {
<a
href="https://www.nabucasa.com"
target="_blank"
rel="noreferrer noopenner"
rel="noreferrer noopener"
>
<ha-button>
<ha-svg-icon .path=${mdiOpenInNew} slot="icon"></ha-svg-icon>
Expand Down
63 changes: 39 additions & 24 deletions src/dialogs/voice-assistant-setup/voice-assistant-setup-dialog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import "./voice-assistant-setup-step-pipeline";
import "./voice-assistant-setup-step-success";
import "./voice-assistant-setup-step-update";
import "./voice-assistant-setup-step-wake-word";
import "./voice-assistant-setup-step-local";

export const enum STEP {
INIT,
Expand All @@ -32,6 +33,7 @@ export const enum STEP {
PIPELINE,
SUCCESS,
CLOUD,
LOCAL,
CHANGE_WAKEWORD,
}

Expand Down Expand Up @@ -118,22 +120,24 @@ export class HaVoiceAssistantSetupDialog extends LitElement {
scrimClickAction
>
<ha-dialog-header slot="heading">
${this._previousSteps.length
? html`<ha-icon-button
slot="navigationIcon"
.label=${this.hass.localize("ui.common.back") ?? "Back"}
.path=${mdiChevronLeft}
@click=${this._goToPreviousStep}
></ha-icon-button>`
: this._step !== STEP.UPDATE
${this._step === STEP.LOCAL
? nothing
: this._previousSteps.length
? html`<ha-icon-button
slot="navigationIcon"
.label=${this.hass.localize("ui.dialogs.generic.close") ??
"Close"}
.path=${mdiClose}
@click=${this.closeDialog}
.label=${this.hass.localize("ui.common.back") ?? "Back"}
.path=${mdiChevronLeft}
@click=${this._goToPreviousStep}
></ha-icon-button>`
: nothing}
: this._step !== STEP.UPDATE
? html`<ha-icon-button
slot="navigationIcon"
.label=${this.hass.localize("ui.dialogs.generic.close") ??
"Close"}
.path=${mdiClose}
@click=${this.closeDialog}
></ha-icon-button>`
: nothing}
${this._step === STEP.WAKEWORD ||
this._step === STEP.AREA ||
this._step === STEP.PIPELINE
Expand All @@ -145,7 +149,11 @@ export class HaVoiceAssistantSetupDialog extends LitElement {
>`
: nothing}
</ha-dialog-header>
<div class="content" @next-step=${this._goToNextStep}>
<div
class="content"
@next-step=${this._goToNextStep}
@prev-step=${this._goToPreviousStep}
>
${this._step === STEP.UPDATE
? html`<ha-voice-assistant-setup-step-update
.hass=${this.hass}
Expand Down Expand Up @@ -197,14 +205,20 @@ export class HaVoiceAssistantSetupDialog extends LitElement {
? html`<ha-voice-assistant-setup-step-cloud
.hass=${this.hass}
></ha-voice-assistant-setup-step-cloud>`
: this._step === STEP.SUCCESS
? html`<ha-voice-assistant-setup-step-success
: this._step === STEP.LOCAL
? html`<ha-voice-assistant-setup-step-local
.hass=${this.hass}
.assistConfiguration=${this
._assistConfiguration}
.assistEntityId=${assistSatelliteEntityId}
></ha-voice-assistant-setup-step-success>`
: nothing}
></ha-voice-assistant-setup-step-local>`
: this._step === STEP.SUCCESS
? html`<ha-voice-assistant-setup-step-success
.hass=${this.hass}
.assistConfiguration=${this
._assistConfiguration}
.assistEntityId=${assistSatelliteEntityId}
></ha-voice-assistant-setup-step-success>`
: nothing}
</div>
</ha-dialog>
`;
Expand All @@ -229,17 +243,17 @@ export class HaVoiceAssistantSetupDialog extends LitElement {
this._step = this._previousSteps.pop()!;
}

private _goToNextStep(ev) {
if (ev.detail?.updateConfig) {
private _goToNextStep(ev?: CustomEvent) {
if (ev?.detail?.updateConfig) {
this._fetchAssistConfiguration();
}
if (ev.detail?.nextStep) {
if (ev?.detail?.nextStep) {
this._nextStep = ev.detail.nextStep;
}
if (!ev.detail?.noPrevious) {
if (!ev?.detail?.noPrevious) {
this._previousSteps.push(this._step);
}
if (ev.detail?.step) {
if (ev?.detail?.step) {
this._step = ev.detail.step;
} else if (this._nextStep) {
this._step = this._nextStep;
Expand Down Expand Up @@ -294,5 +308,6 @@ declare global {
nextStep?: STEP;
}
| undefined;
"prev-step": undefined;
}
}
Loading

0 comments on commit 0a954cf

Please sign in to comment.