'entity' variable in Lovelace card not working!

Hi,

I am using the entity variable in lovelance card for templating:

e.g.

type: custom:mushroom-template-card
primary: |-
  {% if states(config.entity) =='off'%}
    {{as_timestamp(states.switch.gh_a01_k0.last_changed)|timestamp_custom('%H:%M')}} Uhr
  {%endif%}
secondary: How are you?
icon: mdi:home
entity: switch.gh_a01_k0

This code is working, but how can I use the entity variable instead of the entity name in this line?
{{as_timestamp(states.ENTITY.last_changed)|timestamp_custom('%H:%M')}} Uhr

I do not find a way to, the variable is ignored.
Spartacus

Try states[config.entity].last_changed

Hi @Ildar_Gabdullin,

thank you very much! I see now, what was going wrong! I tried states.[config.entity].last_changed. What a small dot can cause! :slight_smile:

Thanks,
Spartacus