From fd431f36f7beaa8d526eff9b973dfd39fb2170f3 Mon Sep 17 00:00:00 2001 From: Bram Kragten Date: Wed, 7 Sep 2022 16:43:04 +0200 Subject: [PATCH] Fix state picker (#13644) --- src/common/entity/get_states.ts | 9 ++++++--- src/components/entity/ha-entity-state-picker.ts | 14 +++----------- 2 files changed, 9 insertions(+), 14 deletions(-) diff --git a/src/common/entity/get_states.ts b/src/common/entity/get_states.ts index 7adddf87e1..f79cc1a4d0 100644 --- a/src/common/entity/get_states.ts +++ b/src/common/entity/get_states.ts @@ -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": diff --git a/src/components/entity/ha-entity-state-picker.ts b/src/components/entity/ha-entity-state-picker.ts index c9c8965e94..21f83ae948 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 { 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`