Card-button configuration help

Hi,

I’m trying to place a few buttons on my screen using the custom card-button card. But it seems like lovelace is not parsing the code I pass it to alter the color of the card. To get it working, I’ve reverted to using the name attribute to change the value depending on the state of the entity.

This is my config:

- type: custom:button-card
  entity: cover.rol_living
  name: >
    [[[
      return states['cover.rol_living'].attributes.current_position
    ]]]
  show_label: true
  tap_action:
    action: call-service
    service: cover.set_cover_position
    service_data: { "entity_id": "cover.rol_living", "position": 0 }

But instead of showing 0 or 100 as the name of the card, it just shows [[[ return stat... as name. It seems like it just is not parsing the code.

Surely I am doing something wrong here, but I can not find what.

(When I get this code to work, I will change the background color depending on the current position of the cover and leave the name for a fixed value)

Can somebody help me with this? Thanks!

Kr,
Erates

you need to terminate the line of js code

  name: >
    [[[
      return states['cover.rol_living'].attributes.current_position;
    ]]]

Notice the semi-colon at the end?

Hi Petro,

Yes, I’ve tried that as well, but it does not help. It still shows [[[ return stat... as name.

try making a single line template.

  name: '[[[return states["cover.rol_living"].attributes.current_position;]]]'

Hi Petro,

Thanks for helping! But I’ve made an even bigger rookie mistake than I could have guessed.

I recently installed HACS and added the button-card to HACS, including the new resource. With this configuration as a result:

resources:
  - url: /local/lovelace-components/button-card.js?track=true
    type: module
  - url: /local/lovelace-components/layout-card.js?track=true
    type: module
  - url: /local/lovelace-components/card-tools.js?track=true
    type: module
  - url: /local/lovelace-components/mini-graph-card-bundle.js?v=0.4.3
    type: module
  - url: /community_plugin/button-card/button-card.js
    type: module

I have commented out the first button-card js and it’s fixed now.

Thanks for the effort and a big sorry for this rookie mistake. I feel deeply ashamed :frowning:

Kr,
Erates