Days Until Annual Date Sensor

Creates a sensor that reports the the number of days until an annual date. It can be used for holidays, birthdays, or anniversaries.

Open your Home Assistant instance and show the blueprint import dialog with a specific blueprint pre-filled.

FYI, there are many other methods to automate based on dates:

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] }}
1 Like

Template Blueprints are currently (October 2025) only available through YAML configuration. You can find more details about how to use them at:

HA Docs - Templates - Using Blueprints

Once you have installed the blueprint, use the following examples to help set up your own Sensors in your configuration files.


Configuration Examples:

template:
  - name: Days Until Home Assistant's Birthday
    unique_id: bp_ha_birthday_days_0001
    use_blueprint: 
      path: Didgeridrew/days-until-annual-date-sensor.yaml
      input:
        date: "2013-09-17"
        track_years: true
template:
  - name: Days Until Halloween
    unique_id: bp_halloween_days_0001
    use_blueprint: 
      path: Didgeridrew/days-until-annual-date-sensor.yaml
      input:
        date: "2025-10-31"

Usage Examples:

alias: It's Halloween and I probably forgot to buy candy
triggers:
  - trigger: sun
    event: sunset
    offset: "-00:15:00"
conditions:
  - condition: state
    entity_id: sensor.days_until_halloween
    state: "0"
actions:
  - action: light.turn_off
    target:
      entity_id: light.front_porch

  • This Post has been set to Wiki Mode. Please feel free edit this post to add configuration examples if you think they are needed
1 Like