I`m using google calendar integration for Garbage Days and would like to create a template which would show remaining number of days untill Recycle date starts.
{% set midnight = today_at() %}
{% set event = state_attr('calendar.recycling', 'start_time') | as_datetime | as_local %}
{% set delta = event - midnight %}
{% if delta.days == 0 %}
Today
{% elif delta.days == 1 %}
Tomorrow
{% elif delta.days == 2 %}
Day After Tomorrow
{% else %}
In {{ delta.days }} Days
{% endif %}
1 Like
If you’re interested, you can use a dictionary to reduce the template.
{% set delta = state_attr('calendar.recycling', 'start_time') | as_datetime | as_local - today_at() %}
{{ {0: 'Today', 1: 'Tomorrow', 2: 'Day After Tomorrow'}.get(delta.days, 'In ' ~ delta.days ~ ' Days') }}
2 Likes
And if less techy… there are cards in HACS that countdown too