1
0
mirror of https://github.com/home-assistant/frontend.git synced 2025-12-20 10:48:44 +00:00

Fix state picker (#13644)

This commit is contained in:
Bram Kragten
2022-09-07 16:43:04 +02:00
committed by GitHub
parent 7acf3a049e
commit fd431f36f7
2 changed files with 9 additions and 14 deletions

View File

@@ -239,10 +239,13 @@ export const getStates = (
} }
break; break;
case "light": case "light":
if (attribute === "effect") { if (attribute === "effect" && state.attributes.effect_list) {
result.push(...state.attributes.effect_list); result.push(...state.attributes.effect_list);
} else if (attribute === "color_mode") { } else if (
result.push(...state.attributes.color_modes); attribute === "color_mode" &&
state.attributes.supported_color_modes
) {
result.push(...state.attributes.supported_color_modes);
} }
break; break;
case "media_player": case "media_player":

View File

@@ -7,6 +7,7 @@ import { getStates } from "../../common/entity/get_states";
import { HomeAssistant } from "../../types"; import { HomeAssistant } from "../../types";
import "../ha-combo-box"; import "../ha-combo-box";
import type { HaComboBox } from "../ha-combo-box"; import type { HaComboBox } from "../ha-combo-box";
import { formatAttributeValue } from "../../data/entity_attributes";
export type HaEntityPickerEntityFilterFunc = (entityId: HassEntity) => boolean; export type HaEntityPickerEntityFilterFunc = (entityId: HassEntity) => boolean;
@@ -55,7 +56,7 @@ class HaEntityStatePicker extends LitElement {
this.hass.locale, this.hass.locale,
key key
) )
: key, : formatAttributeValue(this.hass, key),
})) }))
: []; : [];
} }
@@ -69,16 +70,7 @@ class HaEntityStatePicker extends LitElement {
return html` return html`
<ha-combo-box <ha-combo-box
.hass=${this.hass} .hass=${this.hass}
.value=${this.value .value=${this.value}
? this.entityId && this.hass.states[this.entityId]
? computeStateDisplay(
this.hass.localize,
this.hass.states[this.entityId],
this.hass.locale,
this.value
)
: this.value
: ""}
.autofocus=${this.autofocus} .autofocus=${this.autofocus}
.label=${this.label ?? .label=${this.label ??
this.hass.localize("ui.components.entity.entity-state-picker.state")} this.hass.localize("ui.components.entity.entity-state-picker.state")}