Repository navigation
fix run_at when the next occurrence is tomorrow - #2516
Merged
Merged
Conversation
cebtenzzre
force-pushed
the
fix-next-is-tomorrow
branch
from
December 28, 2025 20:39
e936b48 to
a27817c
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
appdaemon 4.3.0b1 in commit fb6a150 ("run_at() support for times that have already passed") introduced a feature to allow run_at to be passed times that have already passed on the current day (so the next occurrence would be tomorrow). And run_daily had always worked that way. It seems like by 4.5.0, this behavior of run_at had been broken in a refactor.
run_at()on the latest release executes callbacks immediately when given a time in the past, instead of scheduling them for the next day as documented.Problem
When calling
run_at()with a time that has already passed today, the callback would fire immediately instead of being scheduled for tomorrow:This contradicts the documented behavior which states: "If the time specified is in the past, the callback will occur the next day at the specified time."
Root Cause
This is a regression introduced in version 4.5.0 by commit ccf7b18 ("positional argument support and fixed sunrise/sunset calculations").
Old behavior (pre-4.5.0):
New behavior (4.5.0+):
The refactor delegated time parsing to
parse_datetime()but didn't explicitly tell it thatrun_at()needs times to always be in the future. Thetodayparameter defaults toNone, which allows times to be in the past (appropriate for elevation events, but not forrun_at()).Solution
Updated
run_at()to explicitly passtoday=Falsewhen callingparse_datetime():Fixes #2491