Erates
August 20, 2019, 11:49am
1
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
petro
(Petro)
August 20, 2019, 11:58am
2
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?
Erates
August 20, 2019, 12:06pm
3
Hi Petro,
Yes, I’ve tried that as well, but it does not help. It still shows [[[ return stat...
as name.
petro
(Petro)
August 20, 2019, 1:00pm
4
try making a single line template.
name: '[[[return states["cover.rol_living"].attributes.current_position;]]]'
Erates
August 20, 2019, 1:12pm
5
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
Kr,
Erates