I have an automation which creates a custom color loop.
on my dashboard a glance card with an entity for that automation with the tap action to toggle the automation on or off.
This is the glance card entry which works fine
- entity: automation.office_color_loop
name: Office colorloop
tap_action:
action: call-service
service: automation.toggle
service_data:
entity_id: automation.office_color_loop
I am trying to change the picture in the glance card based upon the state on or off of the automation. I used the code below in customize.yaml but to no avail.
automation.office_color_loop:
data_template:
entity_picture: >
{% if is_state('automation.office_color_loop', 'true') %}
/local/img/colorloop.png
{% else %}
/local/img/colorloop_off.png
{% endif %}
any input is appreciated
tom_l
May 5, 2019, 8:10am
2
The glance card doesn’t not natively support changing backgrounds dependent on an entity state. However you can use this:
thanks for the advice.
Are there any card types natively allowing changing entity icon?
tom_l
May 5, 2019, 9:12am
4
The picture entity card lets you change the background image:
OK. So I installed card-modder: works great.
I am unclear however where I should configure the entity-picture now. As in my question above based upon the state of the entity.
tom_l
May 5, 2019, 10:14am
6
Ah sorry I thought you wanted to change the card background.
Try this instead:
Lovelace Templates
I’ve gone and made a crazy card that allows you to pretty much template anything in Lovelace for your card configurations using any information available on the frontend; states, attributes, user, etc.
Want state/attribute-based icons? DONE!
Want dynamic stacks; vertical vs horizontal based on user? DONE!
Want OR conditionals? DONE!
The list is pretty much endless and I’m sure you all will come up with some crazy stuff. Be sure to share.
Go nuts! Enjoy!
Thanks. I keep trying but no success. Config-template-card installed and works but code
type: ‘custom:config-template-card’
entities:
automation.office_color_loop
card:
type: custom:hui-glance-card
entities:
entity: automation.office_color_loop
entity_picture: “${ states[‘automation.office_color_loop’].state === ‘on’ ? ‘/local/img/colorloop_off.png’ : ‘/local/img/colorloop.png’}”
does not yiels expected result. it uses default entity picture