Local Holiday Countdowns in Home Assistant with Python and Codex

Replace Wolfram Alpha holiday lookups with local Python calculations while keeping Home Assistant countdown sensors, personalized speech, and seasonal lighting.

My Home Assistant holiday countdowns still feed the same speech announcements and seasonal lighting. The dates now come from a local Python script. I retired the Wolfram Alpha requests, removed the old API secrets, and kept the existing sensor names so the rest of the house could carry on using them.

Cloud to local: holiday countdowns in Home Assistant

This is an update to my 2019 Wolfram Alpha sensor setup. That was a clever shortcut: ask a question, get a number, and turn it into a Home Assistant sensor. The free API allowance was enough for my use, but a calendar question still needed an internet request.

Floating holidays have rules

A moving date can look unpredictable when you are keeping a list by hand. Most of these holidays follow a weekday rule or an established calendar calculation. Here is how the local calculator handles the different cases:

Date typeExamplesLocal calculation
Fixed Gregorian dateHalloween, ChristmasSame month and day each year
Weekday ruleMother’s Day, Thanksgiving, Memorial DaySecond Sunday in May, fourth Thursday in November, last Monday in May
Gregorian EasterEaster and related observancespython-dateutil calculates Easter; Mardi Gras is 47 days earlier
Hebrew calendarHanukkahhdate converts 25 Kislev to the Gregorian date

Python could do this before LLMs existed. Codex helped me write the replacement, follow the existing entity references, and check the awkward boundaries. Once installed, ordinary Python and its calendar libraries calculate the dates. An LLM is not deciding when Easter happens.

Keep the sensors that everything already uses

The migration replaces the date source behind all nine countdowns: Halloween, Christmas, Easter, Mother’s Day, Father’s Day, Labor Day, Memorial Day, Thanksgiving, and Hanukkah. Existing IDs stay intact, including the older sensor.chanukkah_countdown spelling.

The holiday package calls the local calculator through command-line sensors. It also keeps sensor.holiday and sensor.flag, with their existing calendar attributes. The links point to the exact implementation used for this video.

The package refreshes at Home Assistant startup and at 00:00:05 local time. The calculator includes today when it finds the next occurrence, then subtracts calendar dates. Tomorrow’s holiday should stay one day away even when daylight-saving time changes the number of hours in the day.

A few details worth checking in your own setup

Hanukkah needs a clear convention. The countdown targets the daytime date of 25 Kislev; the first candle-lighting evening is the preceding Gregorian date. The lighting logic covers eight evenings and preserves the package’s existing flag-day priority. Those are deliberate household rules, rather than something to leave to a generic countdown answer.

Fixed household dates remain in JSON, with optional one-off dated additions. Floating events are generated for a rolling three-year window, so there is no annual date table to extend. The code retains event names when two generated events share a date. It uses actual holiday dates, rather than substitute weekdays for time off work.

Before copying the package, check that your Home Assistant runtime has python-dateutil and hdate, and that its local timezone is correct. The script has a preview option for inspecting dates without changing a live sensor:

python3 holiday_countdowns.py easter --date 2027-03-27
# 1

python3 holiday_countdowns.py easter --date 2027-03-28
# 0

We checked the calendar rules through 2040, including leap years and year rollovers. The review also corrected the old Memorial Day and Mardi Gras handling. If you adapt this, check your own observances, date boundaries, and scene priorities too.

Dates give the house a little personality

The countdown is useful because other automations can react to it. A speech briefing can add spooky days before Halloween or merry days before Christmas. Zero means today, one means tomorrow, and an unavailable value stays out of the announcement.

The same calendar state selects seasonal themes and lighting scenes. My older holiday-lighting walkthrough shows the indoor decorations and exterior colors this supports. The flag-sensor article explains another part of that original date-driven setup.

This update makes the calendar calculations independent of a remote date service and its quota. Any cloud services used elsewhere for speech or notification delivery still have their own requirements.

Watch the cloud-to-local update

The short video connects the original Wolfram setup to the local replacement and shows where the dates turn into speech and lighting. If you use holidays to give your house some personality, I would love to hear what you have it do.

Advertisement
TAGS