Sensor Icon Colour based on State

Hi all,

How can I add the yellow for this sensor when it is opened like the other sensors?

   - platform: template
     sensors:
       roof:
         friendly_name: "Roof"
         value_template: "{% if is_state('input_boolean.roof_open', 'on') %}
         Open
         {% elif is_state('input_boolean.roof_open', 'off') %}
         Closed
         {% endif %}"
         icon_template: "{% if states.input_boolean.roof_open.state == 'on' %}
          mdi:door-open
         {% elif states.input_boolean.roof_open.state == 'off' %}
          mdi:door-closed
         {% endif %}"

image

Why are you using a sensor instead of binary sensor with an appropriate device class (door in this case)?

binary_sensor:
  - platform: template
    sensors:
      roof:
        friendly_name: "Roof"
        value_template: "{{ is_state('input_boolean.roof_open', 'on') }}"
        device_class: door

This will change colour and icon with state.

That did it :slight_smile: