Dynamic name for a button card?

Hi! Is it somehow possible to add a dynamic label to the button? I’d want my play/pause button to show the current position of my media:

type: button
    entity: media_player.plex_plex_media_player_foo
    icon: hass:play-pause
    # This value is not evaluated and just displays the template as text:
    name: "{{state_attr(''media_player.plex_plex_media_player_llama', 'media_position')}}" work

Most built-in cards don’t support templates, and if the docs don’t say the card does support them, it probably doesn’t. Check out GitHub - custom-cards/button-card: ❇️ Lovelace button-card for home assistant for more flexible button card.

1 Like

I know this is an relatively old thread but i’ll leave the solution to the OP question, so it can help others.

On button-card you can use the following to change the name dinamicaly:

name: |
  [[[
    if (states['domain.your_entity'].state == 'something')
      return "One Thing";
    return "Another Thing";
  ]]]

Hope it helps.

5 Likes

Thanks! Although I went for using the custom button component, it actually answers the question directly :slight_smile:

1 Like