At the moment I’m using the code below to see the state of my iPhone battery. Is there anyone that can help to adjust it have a between color. So if the battery is above 60% the color is green, between 30 and 60% orange and below 30% red.
- badges:
- entity: sensor.iphone_battery_level
icon: null
name: null
style: |
:host {
—label-badge-blue: {% if is_state(‘sensor.iphone_battery_level’, ‘> 60’) %} green {% else %} red {% endif %};
}
Just add a second condition element. In the example below I am checking for different brightness values. You can adopt the same approach for your condition. You can easily test your adjusted template in the HA dev tools.
{% if state_attr('light.office_ceiling', 'brightness') > 125 %} green {% elif state_attr('light.office_ceiling', 'brightness') > 70 %} orange {% else %} red {% endif %}