This is what I have and it works great but I’m trying to change the color of the text depending on integer that returns… it’s part of a sentence so I only want to change the color of the integer and not the words if that makes any sense… It only returns an integer with no other things like degree symbol… just a number like 29…etc.
I did try to change the value_template but I get errors so not really sure what direction to go into. [ie if temp is below 32F then return 32 colored blue, etc]
- type: custom:stack-in-card
cards:
- type: markdown
tap_action:
action: navigate
navigation_path: weather
card_mod:
style:
.: |
ha-card {
background-color: rgba(0,0,0,0) !important;
box-shadow: none;
margin-left:0rem;
font-size: 22px !important;
width: auto !important;
}
content: >
###{% if now().hour < 5 %} {{'\U0001F31B'}} Good Night
{% elif now().hour < 12 %} {{'\U0001f60e'}} Good Morning
{% elif now().hour < 18 %} {{ '\U0001F913' }}Good Afternoon
{% else %} {{'\U0001F603'}} Good Evening
{% endif %} {{user}}.
<br/> Temperature {{states('sensor.round_temp_outside') }}°, {{states('weather.accuweather') }}
<br/> {{ states ('sensor.next_holiday') }} in {{ states ('sensor.holiday_time')}}
<br/> Air Filter has {{ states('sensor.mi_air_purifier_3_3h_filter_life_remaining') }}% left!
The picture below is the number I’m trying to change…depending on the integer returned in the sensor… [Circled in red]
I’ve tried a couple things but just not sure how to get that one thing to do what I want it to… if that makes any sense… I can be unclear at times… I know this LOL
Thank you!
Perfect. The only thing missing is the HTML tag I had mentioned.
Here’s the basic principle for setting text color with the <font> tag.
{% set t = states('sensor.round_temp_outside') | float(0) -%}
{% set c = iif(t < 32, 'blue', 'black') -%}
###{% if now().hour < 5 %} {{'\U0001F31B'}} Good Night
{% elif now().hour < 12 %} {{'\U0001f60e'}} Good Morning
{% elif now().hour < 18 %} {{ '\U0001F913' }} Good Afternoon
{% else %} {{'\U0001F603'}} Good Evening {% endif %} {{user}}.
<br/> Temperature <font color='{{c}}'>{{ t }}°</font>, {{states('weather.accuweather') }}
<br/> {{ states ('sensor.next_holiday') }} in {{ states ('sensor.holiday_time')}}
<br/> Air Filter has {{ states('sensor.mi_air_purifier_3_3h_filter_life_remaining') }}% left!
Obviously you will need to set the colors to whatever you prefer.
EDIT
Correction. Added missing closing parenthesis on second line.
Awwwwwwwwww yes you are correct and Thank you again!!!
{% set t = states('sensor.round_temp_outside') | float -%}
{% set c = {
t < 32: 'lightblue',
32 <= t < 50: 'darkorange',
50 <= t < 70: 'orangered',
70 <= t < 80: 'red' }.get(true, 'white') -%}
###{% if now().hour < 5 %} {{'\U0001F31B'}} Good Night
{% elif now().hour < 12 %} {{'\U0001f60e'}} Good Morning
{% elif now().hour < 18 %} {{ '\U0001F913' }} Good Afternoon
{% else %} {{'\U0001F603'}} Good Evening {% endif %} {{user}}.
<br/> Temperature <font color='{{c}}'>{{ t }}°</font>, {{states('weather.accuweather') }}
<br/> {{ states ('sensor.next_holiday') }} in {{ states ('sensor.holiday_time')}}
<br/> Air Filter has {{ states('sensor.mi_air_purifier_3_3h_filter_life_remaining') }}% left!