If the date in 'input-datetime.sprinklers_last_run is the same as todays date, I would like text to say “Today”.
If the date was yesterday, “Yesterday”
Any other date, just list the date.
Heres the current code that just shows the date.
Last run {{ states('input_datetime.sprinkler_last_run') }}
And heres a very rudimentary idea of what the code should be but clearly I dont know what to put in.
{% if is_state("input_datetime.sprinkler_last_run", "Check to see if date matches today") %}
Last run today
{% elif is_state("input_datetime.sprinkler_last_run", "Check to see if date matches yesterday") %}
Last run yesterday
{% elif is_state("input_datetime.sprinkler_last_run", "???") %}
Last run {{ states('input_datetime.sprinkler_last_run') }}
{% endif %}
Spoke too soon. “TODAY” works but when i changed the helper to yesterdays date, this is what happens. Im only entering a date, not time into the helper. Trying to understand your code for yesterday, it appears to be looking for time?
{% set days = {timedelta(days=-1): 'yesterday', timedelta(days=0): 'today'} %}
{% set t = states('input_datetime.sprinkler_last_run') %}
Last run {{ days.get(t | as_datetime | as_local - today_at(), t) }}