Skip to content

run_every with start="now" doesn't run immediately #2384

@Big4SMK

Description

@Big4SMK

What happened?

With the introduction of version 4.5.0 the run_every function changed in behavior regarding the start parameter

before 4.5.0:

start – A Python datetime object that specifies when the initial callback will occur, or can take the now string alongside an added offset. If given in the past, it will be executed in the next interval time.

when passing "now" for start and e.g. a 10 minute interval, the callback would run immediately, and then 10 minutes later, another 10 minutes later, etc.

4.5.0+:

start (str, datetime.time, datetime.datetime, optional) –
Start time for the interval calculation. If this is in the future, this will be the first time the callback is triggered. If this is in the past, the intervals will be calculated forward from the start time, and the first trigger will be the first interval in the future.

If this is a str it will be parsed with parse_time().

If this is a datetime.time object, the current date will be assumed.

If this is a datetime.datetime object, it will be used as is.

If you pass the same "now" for start and a 10 minute interval, the first callback run would be in 10 minutes, and then 10 minutes after that, etc. Basically missing the expected immediate run.

Version

4.5.0+

Installation type

Home Assistant add-on

Relevant log output

Relevant code in the app or config file that caused the issue

Anything else?

No response

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions