Skip to content

Commit

Permalink
Use action instead of selected for select entity row (#23135)
Browse files Browse the repository at this point in the history
  • Loading branch information
bramkragten authored Dec 4, 2024
1 parent 2c604ff commit 64e8b63
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import type { HomeAssistant } from "../../types";
import { documentationUrl } from "../../util/documentation-url";
import { AssistantSetupStyles } from "./styles";
import { STEP } from "./voice-assistant-setup-dialog";
import { nextRender } from "../../common/util/render-status";

@customElement("ha-voice-assistant-setup-step-local")
export class HaVoiceAssistantSetupStepLocal extends LitElement {
Expand Down Expand Up @@ -253,9 +252,6 @@ export class HaVoiceAssistantSetupStepLocal extends LitElement {
this._localTts[0].entity_id,
this._localStt[0].entity_id
);

// wait a render so the `hui-select-entity-row` is also updated and doesn't undo the select action
await nextRender();
}

await this.hass.callService(
Expand Down Expand Up @@ -337,9 +333,6 @@ export class HaVoiceAssistantSetupStepLocal extends LitElement {
this._localStt[0].entity_id
);

// wait a render so the `hui-select-entity-row` is also updated and doesn't undo the select action
await nextRender();

await this.hass.callService(
"select",
"select_option",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import type { HomeAssistant } from "../../types";
import { AssistantSetupStyles } from "./styles";
import { STEP } from "./voice-assistant-setup-dialog";
import { documentationUrl } from "../../util/documentation-url";
import { nextRender } from "../../common/util/render-status";

@customElement("ha-voice-assistant-setup-step-pipeline")
export class HaVoiceAssistantSetupStepPipeline extends LitElement {
Expand Down Expand Up @@ -241,9 +240,6 @@ export class HaVoiceAssistantSetupStepPipeline extends LitElement {
wake_word_entity: null,
wake_word_id: null,
});

// wait a render so the `hui-select-entity-row` is also updated and doesn't undo the select action
await nextRender();
}

await this.hass.callService(
Expand Down
6 changes: 4 additions & 2 deletions src/panels/lovelace/entity-rows/hui-select-entity-row.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ class HuiSelectEntityRow extends LitElement implements LovelaceRow {
.value=${stateObj.state}
.disabled=${stateObj.state === UNAVAILABLE}
naturalMenuWidth
@selected=${this._selectedChanged}
@action=${this._handleAction}
@click=${stopPropagation}
@closed=${stopPropagation}
>
Expand Down Expand Up @@ -94,11 +94,13 @@ class HuiSelectEntityRow extends LitElement implements LovelaceRow {
`;
}

private _selectedChanged(ev): void {
private _handleAction(ev): void {
const stateObj = this.hass!.states[
this._config!.entity
] as InputSelectEntity;

const option = ev.target.value;

if (
option === stateObj.state ||
!stateObj.attributes.options.includes(option)
Expand Down

0 comments on commit 64e8b63

Please sign in to comment.