Template sensor color

Hello,
have an ‘issue’ with template sensor, i’d like to make my sensor colorized like a switch power on
i’d like to have my sensor ‘on’ on 2 day only : Lundi & Jeudi

- platform: template
   sensors:
     jour_poubelles:
       friendly_name: "jour_poubelles"
       value_template: " {{ is_state('sensor.current_day', 'Jeudi') or is_state('sensor.current_day', 'Jeudi') }} "
       icon_template: >-
         {% if is_state("sensor.current_day", "Lundi") %}
            mdi:delete
         {% elif is_state("sensor.current_day", "Jeudi") %}
            mdi:recycle
         {% else %}
            mdi:delete-off-outline
         {% endif %}

my current_day sensor is :

 - platform: template
   sensors:
     current_day:
       value_template: " {{  ['Lundi','Mardi','Mercredi','Jeudi','Vendredi','Samedi','Dimanche'] [now().weekday()] }} "
       friendly_name: "current_day"

someone can help me ? thanks :slight_smile:

You can change icon colors in the lovelace ui yaml by adding the card-mod customization and then adding the following style to your entity in the yaml like the example below. The code below will change the icon color for a group displayed in the ui if the group is ‘on’

          - entity: group.lights_inside
            name: Inside
            style: |
              :host { 
                --paper-item-icon-color:
                  {% if states('group.lights_inside') == 'on' %}
                    var(--paper-item-icon-active-color)
                  {% endif %};
              }
            tap_action:
              action: toggle
 

or just

- entity: group.lights_inside
  name: Inside
  style: >-
    {% if is_state('group.lights_inside', 'on') %}
      :host { --paper-item-icon-color: var(--paper-item-icon-active-color) }
    {% endif %}
  tap_action:
    action: toggle

1 Like

thanks for answer, seem not works with button card
no style: parameter

the example above was for Entity card, try it there.