diff --git a/src/components/entity/ha-entity-state-picker.ts b/src/components/entity/ha-entity-state-picker.ts
index 4648d0c057..c6cf91691c 100644
--- a/src/components/entity/ha-entity-state-picker.ts
+++ b/src/components/entity/ha-entity-state-picker.ts
@@ -7,6 +7,7 @@ import { getStates } from "../../common/entity/get_states";
import type { HomeAssistant, ValueChangedEvent } from "../../types";
import "../ha-generic-picker";
import type { PickerComboBoxItem } from "../ha-picker-combo-box";
+import type { PickerValueRenderer } from "../ha-picker-field";
@customElement("ha-entity-state-picker")
export class HaEntityStatePicker extends LitElement {
@@ -108,6 +109,12 @@ export class HaEntityStatePicker extends LitElement {
this.extraOptions
);
+ private _valueRenderer: PickerValueRenderer = (value: string) => {
+ const items = this._getFilteredItems();
+ const item = items.find((option) => option.id === value);
+ return html`${item?.primary ?? value}`;
+ };
+
protected render() {
if (!this.hass) {
return nothing;
@@ -125,6 +132,7 @@ export class HaEntityStatePicker extends LitElement {
.helper=${this.helper}
.value=${this.value}
.getItems=${this._getFilteredItems}
+ .valueRenderer=${this._valueRenderer}
.notFoundLabel=${this.hass.localize("ui.components.combo-box.no_match")}
.customValueLabel=${this.hass.localize(
"ui.components.entity.entity-state-picker.add_custom_state"
diff --git a/src/components/ha-selector/ha-selector-state.ts b/src/components/ha-selector/ha-selector-state.ts
index 539eff3185..8d7c8b1b5a 100644
--- a/src/components/ha-selector/ha-selector-state.ts
+++ b/src/components/ha-selector/ha-selector-state.ts
@@ -1,10 +1,12 @@
import type { HassServiceTarget } from "home-assistant-js-websocket";
import { html, LitElement } from "lit";
import { customElement, property, state } from "lit/decorators";
+import memoizeOne from "memoize-one";
import type { StateSelector } from "../../data/selector";
import { extractFromTarget } from "../../data/target";
import { SubscribeMixin } from "../../mixins/subscribe-mixin";
import type { HomeAssistant } from "../../types";
+import type { PickerComboBoxItem } from "../ha-picker-combo-box";
import "../entity/ha-entity-state-picker";
import "../entity/ha-entity-states-picker";
@@ -32,6 +34,21 @@ export class HaSelectorState extends SubscribeMixin(LitElement) {
@state() private _entityIds?: string | string[];
+ private _convertExtraOptions = memoizeOne(
+ (
+ extraOptions?: { label: string; value: any }[]
+ ): PickerComboBoxItem[] | undefined => {
+ if (!extraOptions) {
+ return undefined;
+ }
+ return extraOptions.map((option) => ({
+ id: option.value,
+ primary: option.label,
+ sorting_label: option.label,
+ }));
+ }
+ );
+
willUpdate(changedProps) {
if (changedProps.has("selector") || changedProps.has("context")) {
this._resolveEntityIds(
@@ -45,6 +62,9 @@ export class HaSelectorState extends SubscribeMixin(LitElement) {
}
protected render() {
+ const extraOptions = this._convertExtraOptions(
+ this.selector.state?.extra_options
+ );
if (this.selector.state?.multiple) {
return html`