Fix hui-select-entity-row restoring old state (#28918)

This commit is contained in:
Eduardo Tsen 2026-01-12 10:43:31 +01:00 committed by GitHub
parent 65d046132d
commit f37241c84c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -112,7 +112,20 @@ class HuiSelectEntityRow extends LitElement implements LovelaceRow {
forwardHaptic(this, "light");
setSelectOption(this.hass!, stateObj.entity_id, option);
setSelectOption(this.hass!, stateObj.entity_id, option)
.catch((_err) => {
// silently swallow exception
})
.finally(() =>
setTimeout(() => {
const newStateObj = this.hass!.states[this._config!.entity];
if (newStateObj === stateObj) {
const select = this.shadowRoot?.querySelector("ha-select");
const index = select?.options.indexOf(stateObj.state) ?? -1;
select?.select(index);
}
}, 2000)
);
}
}