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
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 14 deletions

View File

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

View File

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