Skip to content

Commit 3efe2d0

Browse files
committed
patch for get_next_period and start == "now"
1 parent 943eadd commit 3efe2d0

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

appdaemon/scheduler.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -483,6 +483,8 @@ async def get_next_period(
483483
self,
484484
interval: TimeDeltaLike,
485485
start: time | datetime | str | None = None,
486+
*,
487+
immediate: bool = False,
486488
) -> datetime:
487489
interval = utils.parse_timedelta(interval)
488490
start = "now" if start is None else start
@@ -493,7 +495,7 @@ async def get_next_period(
493495
assert isinstance(aware_start, datetime) and aware_start.tzinfo is not None
494496

495497
# Skip forward to the next period if start is in the past
496-
while aware_start < now:
498+
while aware_start < now or (immediate and aware_start <= now):
497499
aware_start += interval
498500

499501
return aware_start
@@ -901,7 +903,7 @@ async def parse_datetime(
901903
# Need to force timezone during time-travel mode
902904
if now is None:
903905
now = await self.get_now()
904-
now = now.astimezone(self.AD.tz)
906+
now = utils.ensure_timezone(now, self.AD.tz)
905907
return parse.parse_datetime(
906908
input_=input_,
907909
now=now,

0 commit comments

Comments
 (0)