Creates a sensor that reports the the number of days until an annual date. It can be used for holidays, birthdays, or anniversaries.
FYI, there are many other methods to automate based on dates:
- Calendar integration
- Easy Time Macros
- Anniversaries custom integration
blueprint:
author: Didgeridrew
homeassistant:
min_version: 2025.10.4
name: Days until Annual Date
description: |
Creates a sensor which returns the number of days until a defined
date. This may be used for things like Holidays, Birthdays, or Anniversaries.
Optionally, the number of years since the date can be tracked for birthdays, anniversaries, etc.
domain: template
input:
date:
name: Date
description: |
Select the date you want to track. If you want to track the years since
the date occurred, make sure to select the original year.
selector:
date:
track_years:
name: Track Years
default: false
description: |
Toggle ON to track the number of years since the date.
selector:
boolean:
variables:
input_track_years: !input track_years
input_date: !input date
spl_date: "{{ input_date.split('-')|map('int',0)|list }}"
t_month: "{{ spl_date[1] }}"
t_day: "{{ spl_date[2] }}"
passed: "{{ 1 if (now().month, now().day) > (t_month,t_day) else 0 }}"
target_year: "{{ now().year + passed }}"
target_dt: |
{{ strptime(target_year~t_month~t_day,"%Y%m%d")|as_local }}
days_until: "{{ (target_dt|as_datetime - today_at()).days }}"
trigger:
- trigger: homeassistant
event: start
- trigger: time_pattern
hours: /12
sensor:
state: "{{ days_until }}"
availability: "{{true}}"
attributes:
next_date: "{{ target_dt }}"
years: |
{{ none if not input_track_years else target_year - spl_date[0] }}