diff --git a/src/components/entity/ha-entity-attribute-picker.ts b/src/components/entity/ha-entity-attribute-picker.ts index 2468f6fe71..7e08060e33 100644 --- a/src/components/entity/ha-entity-attribute-picker.ts +++ b/src/components/entity/ha-entity-attribute-picker.ts @@ -73,16 +73,20 @@ class HaEntityAttributePicker extends LitElement { return nothing; } + const stateObj = this.hass.states[this.entityId!] as HassEntity | undefined; + return html` @@ -988,12 +1003,14 @@ const tryDescribeCondition = ( ); const attribute = condition.attribute - ? computeAttributeNameDisplay( - hass.localize, - stateObj, - hass.entities, - condition.attribute - ) + ? stateObj + ? computeAttributeNameDisplay( + hass.localize, + stateObj, + hass.entities, + condition.attribute + ) + : condition.attribute : undefined; if (condition.above !== undefined && condition.below !== undefined) { @@ -1187,7 +1204,9 @@ const tryDescribeCondition = ( if (localized) { return localized; } - const stateObj = hass.states[config.entity_id as string]; + const stateObj = hass.states[config.entity_id as string] as + | HassEntity + | undefined; return `${stateObj ? computeStateName(stateObj) : config.entity_id} ${ config.type }`;