have another issue using this sensor:
dark_sky_temp_color:
value_template: >
{% set temp = states('sensor.dark_sky_temperature')|float %}
{% if temp < -5 %} rgb(30, 255, 255)
{% elif temp < 0 %} rgb(30, 144, 255)
{% elif temp < 10 %} rgb(255, 255, 0)
{% elif temp < 15 %} rgb(255, 211, 30)
{% elif temp < 20 %} rgb(0, 128, 0)
{% elif temp < 25 %} rgb(255, 165, 0)
{% elif temp < 30 %} rgb(255, 105, 0)
{% else %} rgb(255, 80, 0)
{% endif %}
I can’t use it to set the color of the text replacing this:
content: >
**Weersverwachting:**
<img src = {{state_attr('sensor.weather_animated_icon','entity_picture')}} >
<font color= {% if states('sensor.dark_sky_temperature')|float >= 20 %} #f00
{% else %} #008000 {% endif %} >
{{ states('sensor.dark_sky_daily_summary')}} </font>
which works alright, to:
content: >
**Weersverwachting:**
<img src = {{state_attr('sensor.weather_animated_icon','entity_picture')}} >
<font color= {{states('sensor.dark_sky_temp_color')}} >
{{ states('sensor.dark_sky_daily_summary')}} </font>
Ive tried all spaces, and even taking all out won’t show the collored text. Is there a special setting necessary for rgb colors maybe?
using it in the styles for the background color works alright:
- type: markdown
style: |
ha-card {
background: {{states('sensor.dark_sky_temp_color')}};
border-radius: 6px;
}
the sensor is used elsewhere (in my dark sky custom card to color the temp, working as designed…
since this template works in other places I didn’t think it to be useful, but the only thing left I could think of is deleting the spaces in the sensor itself maybe?
dark_sky_temp_color:
value_template: >
{% set temp = states('sensor.dark_sky_temperature')|float %}
{%- if temp < -5 %} rgb(30, 255, 255)
{%- elif temp < 0 %} rgb(30, 144, 255)
{%- elif temp < 10 %} rgb(255, 255, 0)
{%- elif temp < 15 %} rgb(255, 211, 30)
{%- elif temp < 20 %} rgb(0, 128, 0)
{%- elif temp < 25 %} rgb(255, 165, 0)
{%- elif temp < 30 %} rgb(255, 105, 0)
{%- else %} rgb(255, 80, 0)
{% endif %}
could that be it?
update
nope:
while the temp here is colored nicely using the same sensor:
now what…