Hi,
For the last week I have been trying to get this if statement to work to change the text colour. The idea is if the cars road tax due within 30 days the text will change to red, if not the text will be green.
I’ve tried in the Template editor to get the code to work but I am unsure if I have the dates correctly formatted to compare them.
The sensor.dvlataxduedate data is formatted like this → 2025-02-01
style: |
:host {
color :
{% if ((now().date() + timedelta(days=-30)).isoformat() <= 'sensor.taxduedate' and 'sensor.dvlataxduedate' <= now().date().isoformat() ) %}
Red
{% else %}
limeGreen
{% endif %}
;
}
Can anyone point out where I am going wrong?
Regards