Use action instead of selected for select entity row (#23135)

This commit is contained in:
Bram Kragten 2024-12-04 13:57:55 +01:00
parent 8f4e65d392
commit fbff95345c
3 changed files with 4 additions and 13 deletions

View File

@ -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 {
@ -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(
@ -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",

View File

@ -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 {
@ -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(

View File

@ -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}
>
@ -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)