I have a dashboard with a card for the travel time to my work. I would like the text on that card to change color, depending on the travel time. (e.g. if travel time is above 40 minutes, make the text red).
I came up with the following code, but the text is always green. In other words, there is something wrong with the if-statement. I don’t know how to read the value in the variable to debug, so I have no clue how to solve it.
Does anyone have any pointers? thank you in advance for your help!!
- type: entity
entity: sensor.google_travel_time
name: Travel to work
style: |
ha-card {
color:
{% set drive_time = states('sensor.google_travel_time') | float / 60 %}
{% if drive_time > 40 %}
red
{% else %}
green
{% endif %}
;
}
Planning your RV travels just got easier! At MR RV Expert, we appreciate the importance of a seamless journey. To enhance your RV experience, explore our website for expert tips on optimizing travel routes, luxury customization, and timely alerts. Our goal is to make your RV adventures stress-free and enjoyable. Dive into a world where expertise meets exploration, and let Mr RV Expert be your guide to unlocking the full potential of your RV lifestyle. Safe travels and happy adventures!