Schedules that mean “15 October through 15 April” do not fit a weekday helper. The range wraps the new year, and it should flip by itself next year. This pack is two template blueprints. One is a binary sensor that is on inside a month/day range. The other is a sensor that counts days until the next month/day. Two automations use them: one for whatever should run only in season, and one that fires when the countdown reaches today.
No extra hardware. The sensors are templates.
A reminder that is a weekday bin, not a date range, is bin day reminder. A device that should follow a daily on/off schedule is daily device scheduler.
What problem it solves
You want heating, holiday lights, or a once-a-year chore to follow the calendar without editing the automation every January.
How it works
- Date range. You set a start month, start day, end month, and end day. The sensor compares month × 100 + day. If the start number is less than or equal to the end, the range sits inside one year (1 June through 31 August). If the start is after the end, the range wraps (15 October through 15 April): on from the start through December, and from 1 January through the end. Both ends are inclusive.
- Days that are not real. The comparison uses the numbers you typed. An end day of 31 in February does not exist, and every real February day is still less than or equal to that number, so the whole month stays inside the range. Pick a day that exists if you want the switch on a real date.
- Countdown. You set a month and a day. The sensor walks forward from today and stops on the next date in that month whose day matches, clamped to the last real day of the month. 29 February in a non-leap year becomes 28 February. The state is the number of days, and 0 means today.
- In season. The load automation runs the “when on” action when the binary sensor turns on, and again after a restart if it is already on. It runs the “when off” action when the sensor turns off. Put
climate.set_temperatureorlight.turn_onin those actions yourself. The pack does not guess the entity. - Reminder. The countdown automation runs when the days sensor crosses below 0.5. That is the morning it becomes 0, if the sensor updates. A restart while it is already 0 can run it again. Put the notification in the action.
docs/example-package.yaml shows both template entities and both automations with generic entity ids. It is an example, not a helper package, so it is not loaded for you.
Snippet
The range sensor, trimmed. Inputs land in variables on the template entity.
binary_sensor:
name: In season
variables:
start_month: !input start_month
start_day: !input start_day
end_month: !input end_month
end_day: !input end_day
state: >
{% set today = now().month * 100 + now().day %}
{% set start = (start_month | int) * 100 + (start_day | int) %}
{% set end = (end_month | int) * 100 + (end_day | int) %}
{% if start <= end %}
{{ start <= today <= end }}
{% else %}
{{ today >= start or today <= end }}
{% endif %}
A heating action you would put in the load blueprint:
when_on:
- action: climate.set_temperature
target:
entity_id: climate.example
data:
temperature: 20
Setup outline
- Copy the two files from
blueprints/template/intoconfig/blueprints/template/edotdev/, and the two files fromblueprints/automation/intoconfig/blueprints/automation/edotdev/. Reload blueprints. - Create a template entity from Seasonal date range. Name it, and set the month and day. For a wrap, the start is the autumn date and the end is the spring date.
- Create a template entity from Days until a yearly date for the chore date.
- Create an automation from Run actions from a seasonal sensor. Select the binary sensor. Put the in-season action and the out-of-season action in the two action inputs.
- Create an automation from Remind when a yearly countdown hits zero. Select the days sensor and a notify action.
- Check Developer tools → States. Inside the range, the binary sensor is
on. The days sensor is a number, 0 on the day itself.
Troubleshooting
- The winter range is off in January. Start and end are in calendar order (January end listed first). Swap them. Wrapping only happens when the start month-day number is greater than the end.
- It flips a day early or late. The end day is inclusive, and the comparison uses local
now(). A sensor that looks one day off is usually the Home Assistant time zone, not the template. - 29 February became 28. That is the clamp, in a year that has no 29 February. The range sensor does not clamp. The countdown does.
- The reminder fired on restart. The days sensor was already 0, and a numeric state below 0.5 can match again when the entity reloads. Clear the notification, or add a condition in your action if you need it to be stricter.
- Nothing runs on the first day you add it. A state trigger does not fire for a sensor that was already on. The load blueprint also listens for Home Assistant start and runs the on action if the sensor is on. Restart, or toggle the template by reloading template entities.
- The example package did not create entities. It lives under
docs/so it is not apackages/file. Create the entities from the blueprints, or paste the pieces into your own config after you change the entity ids.
Credits
The two template shapes come from Annual date range binary sensor and Days until annual date sensor.