Keep the pending sunrise-off from being cancelled at midnight (#106) #107
No reviewers
Labels
No labels
area/ai
area/backend
area/frontend
area/infra
area/scheduler
area/wled
good-first-issue
priority/high
priority/low
priority/medium
type/bug
type/chore
type/ci-cd
type/docs
type/feature
type/qa
v1.0.0
v1.1.0
v1.2.0
v2.0.0
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
rbrooks/Iris-WLED!107
Loading…
Reference in a new issue
No description provided.
Delete branch "fix/pending-off-survives-reschedule"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Fixes #106. Iris never turned the lights off. They came on and dimmed on schedule, then stayed lit through the following day.
Cause
A lighting day runs sunset→sunrise, but the schedule was computed from the calendar date.
_solar_timescorrectly returns the next day's sunrise as the off — so the 00:01 reschedule, recomputing for the new calendar date, produced an off ~24 hours out and, because every run writes the singleoff_jobid withreplace_existing=True, discarded the one due a few hours later.on_jobanddim_jobare immune: their values always land on the same calendar day as the reschedule.off_jobis the only one whose correct time belongs to the next day.The failure was silent. A job that never runs writes no
schedule_logrow, and every job that did run reported success.The fix — and why it isn't the one I first proposed
On the issue I recommended moving
reschedule_dailyoff midnight to local noon. That would have been incomplete, and I only noticed while implementing it: a container restart between midnight and sunrise loses the pending off exactly the same way, because startup callsschedule_today_jobs()too. Moving the cron would have fixed the scheduled path and left the restart path broken — arguably worse, because it would have looked fixed.So the fix goes where the wrong assumption is. New
get_active_times()carries a still-pending off forward from the previous cycle:get_today_times(for_date)is untouched — it's a well-tested pure date→times function, including the DST cases — so the cycle awareness sits above it./schedule/statususesget_active_times()too. Otherwise the UI would report tomorrow's sunrise while the pending job was today's.Verification against real solar data
Dev site coordinates, real
astral:Row 3 is the case the cron-move fix would have missed.
ruff,ruff format,mypyclean.Still to do before #7 closes
This needs one real unattended night on the dev deployment, with
off_jobpresent inschedule-logand the controller actually off after sunrise. The Home Assistant automation that masked the original failure has been disabled, so nothing external can stand in for it this time.🤖 Generated with Claude Code