Creates a binary sensor whose state is “on” between the defined start and end dates.
This can be used to define your own custom “seasons” to use as conditions for lighting effects, electricity tariffs, holidays, sports seasons, etc. Date spans that cross over New Year are supported.
blueprint:
author: Didgeridrew
homeassistant:
min_version: 2025.10.4
name: Annual Date Range Binary Sensor
description: |
Creates a sensor whose state is "on" when the current date is between two static dates. Crossing the new year is supported.
domain: template
input:
start_date:
name: Start Date
description: |
Select the date you want to be the first day of your range.
The resulting binary sensor will turn "on" at 0:00:00 on this date.
The year will not be used for this binary sensor.
selector:
date:
end_date:
name: End Date
description: |
Select the date you want to be the last day of your range.
The resulting binary sensor will turn "off" after 23:59:59 on this date.
The year will not be used for this binary sensor.
selector:
date:
variables:
_start_date: !input start_date
start_l: "{{ (_start_date.split('-')|map('int',0)|list)[1:3] }}"
_end_date: !input end_date
end_l: "{{ (_end_date.split('-')|map('int',0)|list)[1:3] }}"
crosses_year: "{{ start_l > end_l }}"
current_l: "{{ [now().month, now().day] }}"
trigger:
- trigger: homeassistant
event: start
- trigger: time_pattern
hours: /12
binary_sensor:
state: |
{% if crosses_year %}
{{ start_l <= current_l or current_l <= end_l }}
{% else %}
{{ start_l <= current_l <= end_l }}
{% endif %}
availability: "{{true}}"