Read personal calendar dates from private configuration

master
Carlo Costanzo 2 days ago committed by GitHub
parent 0d2a0dfcc2
commit bfb9cca3a1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -12,7 +12,7 @@
# Dashboard theming video: https://youtu.be/qawvBd8_RJ0
# Dashboard theming blog: https://www.vcloudinfo.com/2026/11/home-assistant-holiday-dashboard-theming.html
# Notes: holiday_countdowns.py calculates floating dates and all nine countdowns locally.
# Notes: config/www/json_data holds fixed household dates and optional one-off additions.
# Notes: Public holidays live in www/json_data. Private recurring dates use secrets/household_holidays.json.
# Notes: Existing IDs stay stable; calendars/countdowns refresh at startup and local midnight.
# Notes: Hanukkah lighting spans eight evenings, beginning before 25 Kislev; flag days retain priority.
######################################################################
@ -206,4 +206,4 @@ template:
mode: "{{ states('sensor.holiday_lighting_mode') }}"
holiday: "{{ states('sensor.holiday') }}"
flag_day: "{{ states('sensor.flag') }}"
source: local calendar rules plus config/www/json_data household dates
source: local calendar rules and configured holiday dates

@ -27,7 +27,7 @@ Longer-running shell helpers referenced by automations, packages, or cron. Anyth
| File | Why it matters |
| --- | --- |
| [HAUpdate.sh](HAUpdate.sh) | One-command Home Assistant update helper. |
| [`holiday_countdowns.py`](holiday_countdowns.py) | Local countdowns and perpetual holiday/flag calendars using weekday rules, python-dateutil for Gregorian Easter, and hdate for 25 Kislev. Reads fixed household dates and optional one-off `dynamic` additions from `www/json_data`; preserves colliding event names. Uses the container's local timezone and installed libraries; no API key or network call. Actual dates are used, rather than substitute workdays. Preview with `python3 holiday_countdowns.py chanukkah --date 2026-10-15`. [Watch local holiday countdowns](https://youtu.be/QzrfDFA7htc) [Local holiday countdowns blog](https://www.vcloudinfo.com/2026/10/home-assistant-local-holiday-countdowns-python-codex.html) |
| [`holiday_countdowns.py`](holiday_countdowns.py) | Local countdowns and perpetual holiday/flag calendars using weekday rules, python-dateutil for Gregorian Easter, and hdate for 25 Kislev. Reads public events from `www/json_data` and optional private recurring dates from `secrets/household_holidays.json`. Uses the container's local timezone and installed libraries; no API key or network call. Actual dates are used, rather than substitute workdays. Preview with `python3 holiday_countdowns.py chanukkah --date 2026-10-15`. [Watch local holiday countdowns](https://youtu.be/QzrfDFA7htc) [Local holiday countdowns blog](https://www.vcloudinfo.com/2026/10/home-assistant-local-holiday-countdowns-python-codex.html) |
| [apt_pending_check.sh](apt_pending_check.sh) | On-demand, read-only APT pending-count reporter for the Docker host maintenance dashboard. |
| [apt_weekly.sh](apt_weekly.sh) | Daily APT check-then-update workflow that posts webhook status and can schedule reboot when needed. |
| [apt_reboot_report.sh](apt_reboot_report.sh) | Boot-time and 15-minute reboot-state reconciliation through the existing webhook. Clears a verified obsolete reboot flag while preserving pending packages, failures and maintenance timestamps. The companion timer recovers missed reports after HA restarts. |
@ -36,7 +36,7 @@ Longer-running shell helpers referenced by automations, packages, or cron. Anyth
| [`basketball.yaml`](basketball.yaml) | ESPN stat scraping helper used by sensors. |
| [Jinja Code.py](Jinja Code.py) | Reference Jinja snippets for templating. |
The holiday calculator uses actual calendar dates, rather than substitute weekdays for work holidays. In `www/json_data/holidays.json` and `www/json_data/flag_days.json`, `static` maps `M/D` to fixed household dates; `dynamic` accepts optional one-off `MM/DD/YYYY` additions. Floating events come from the calculator and appear in the existing sensor attributes. Calendar, lighting-boundary, and speech checks run in the existing holiday validation gate.
The holiday calculator uses actual calendar dates, rather than substitute weekdays for work holidays. In the public files under `www/json_data`, `static` maps `M/D` to recurring public holidays and `dynamic` accepts one-off public events keyed by `MM/DD/YYYY`. Put personal recurring events in `config/secrets/household_holidays.json` as a JSON object such as `{"6/1": "Example occasion"}`. This optional, Git-ignored file stays outside the web directory. A personal occasion takes precedence when it shares a date with a public holiday. Floating events come from the calculator and appear in the existing sensor attributes. Calendar, lighting-boundary, and speech checks run in the existing holiday validation gate.
### Tips

@ -3,8 +3,8 @@
Uses python-dateutil and hdate from the Home Assistant container. The container's
local timezone supplies today's date; --date supports operator previews.
Reads fixed dates and one-off additions from www/json_data; floating dates never
need an annual table update. Chanukkah targets the first daytime date (25 Kislev).
Reads public calendar data from www/json_data and optional private recurring dates
from secrets/household_holidays.json. Floating dates need no annual table update. Chanukkah targets the first daytime date (25 Kislev).
Its first candle-lighting evening is the preceding Gregorian date.
"""
@ -95,6 +95,14 @@ def calendar_data(kind: str, today: date, data_dir: Path | None = None) -> dict:
else ("flag_days.json", "Flag_Days_US", FLAG_RULES)
)
source = json.loads((data_dir / filename).read_text(encoding="utf-8"))[attribute]
if kind == "holiday":
private_path = data_dir.parent.parent / "secrets" / "household_holidays.json"
try:
private_dates = private_path.read_text(encoding="utf-8")
except FileNotFoundError:
pass # Public-only installations use the built-in calendar.
else:
source["static"].update(json.loads(private_dates))
events: dict[date, list[str]] = {}
for year in range(today.year - 1, today.year + 2):
for name, rule in rules.items():

@ -3,23 +3,18 @@
"static": {
"1/1": "New Years Day",
"2/2": "Groundhog Day",
"2/3": "Staceys Birthday",
"2/14": "Valentines Day",
"3/14": "Pi Day",
"3/17": "St. Patricks Day",
"3/26": "Justins Birthday",
"4/1": "April Fools Day",
"4/22": "Earth Day",
"5/4": "Star Wars Day",
"5/5": "Cinco de Mayo",
"6/14": "Flag Day",
"7/4": "Independence Day",
"8/30": "Paiges Birthday",
"9/10": "Mom and Dads Wedding Anniversary",
"9/11": "Patriot Day",
"10/31": "Halloween",
"11/11": "Veterans Day",
"11/16": "Carlos Birthday",
"12/7": "Pearl Harbor Day",
"12/24": "Christmas Eve",
"12/25": "Christmas Day",

Loading…
Cancel
Save

Powered by TurnKey Linux.