Hello,
I have a badge that represents my upcoming refuse collection bin (as I’m terrible at remembering which is next due!).This is populated by a file that is created by a screenscrape into a file which is then brought into an entity.
All that works fine and I use the mdi:delete-empty icon for the badge.
I would like to dynamically change the color of the icon to match the bin to be emptied but am failing to work out what to do and I’m sure I’m close!
My code is…
type: entity
show_name: false
show_state: true
show_icon: true
entity: sensor.file
icon: mdi:delete-empty
show_entity_picture: false
color: |-
{% if 'brown' in states('sensor.file') %}
yellow
{% elif 'blue' in states('sensor.file') %}
blue
{% else %}
red
{% endif %}
state_content: state
tap_action:
action: none
and doesn’t work.
This section
{% if 'brown' in states('sensor.file') %}
yellow
{% elif 'blue' in states('sensor.file') %}
blue
{% else %}
red
{% endif %}
outputs what I think is required when I test it in the Developt Tools Template editor so now I’m stuck.
Is what I’d like to do possible with badges or is this a fool’s errand?
Thanks for any help you can offer!
AR