Use template to set icon in dashboard

Is it possible to set the icon using a template like below…
I just get no icon…

icon: >-
  {% if state_attr("media_player.ytube_music_player","likeStatus") == 'LIKE' %} "mdi:heart" {% else %} "mdi:heart-plus" {% endif %}

Hi @kaninfod

Which dashboard card are you using?

Lovelace… the icon goes into a shortcut button in the mini media player. That should not matter though… I have tested with a normal entity button as well… No luck

Most core dashboard cards do not support templating.

2 Likes

It absolutely does matter as tom said most core cards do not support templates at all. So for those you usually either need to setup something separately to change the icon (template entity) wrap the card in another card that resolves the template first, or use a card that does support templates (mushroom template card for instance)

So WHERE in Lovelace and where did you set that template…

1 Like

Thanks - I see that now
I solved it in a different way

I was supposed to go inside a shortcut button on the mini-media-player - but that does not support templating (i guess).
Instead I am using a custom:button-card which has a very nice state feature

Thanks!