thomasloven / lovelace-auto-entities

🔹Automatically populate the entities-list of lovelace cards
MIT License
1.2k stars 111 forks source link

Name as attribute of entity #340

Open ghallford opened 1 year ago

ghallford commented 1 year ago

Is it possible to make the name on the card, an attribute of the entity as opposed to the friendly_name? This is for the mini-media-player card. Is there a variable for the "target" or something? Was thinking something like {{ state_attr('target','username') }}


type: vertical-stack
cards:
  - type: markdown
    content: '# PLEX MEDIA PLAYERS'
  - type: custom:auto-entities
    card:
      type: entities
    entities: []
    filter:
      include:
        - entity_id: media_player.plex*
          state: playing
          options:
            type: custom:mini-media-player
            name: <<<CAN I MAKE THIS AN ATTRIBUTE OF THE MEDIA_PLAYER ENTITY?>>>
            artwork: material
            hide:
              controls: true
              volume: true
              power: true
              icon: true
        - entity_id: media_player.plex*
          state: paused
          options:
            type: custom:mini-media-player
            name: <<<CAN I MAKE THIS AN ATTRIBUTE OF THE MEDIA_PLAYER ENTITY?>>>
            artwork: material
            hide:
              controls: true
              volume: true
              power: true
              icon: true
      exclude: []
    sort:
      method: none
      show_empty: false
    show_empty: false
ildar170975 commented 1 year ago

This may only be done by using a "template" option. https://github.com/thomasloven/lovelace-auto-entities#template-filter

ghallford commented 1 year ago

Thanks. Do you mean trying something like this?

name: "{{ state_attr('this.entity_id','username') }}"

It doesn't work unfortunately.

ildar170975 commented 1 year ago

@ghallford No, options DO NOT support templates - except the "template" option mentioned above. Go to Community thread, there are many examples of building cards with this option.