Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

period time triggers with now and endtime #714

Unanswered
DivusJulius asked this question in Q&A
Discussion options

I want to use a period time trigger that starts at definition time and ends at a specified time but the function still triggers even after the time has passed.

@time_trigger("period(now, 1min, 10:15:00)") 

When I specify a specific time as the start time it works.

@time_trigger("period(10:00:00, 1min, 10:15:00)") 

It also works when the end time includes the date

@time_trigger("period(now, 1min, 2025年04月08日 10:22:00)") 

This might be a bug but I wanted to ask here first just in case I am doing something wrong.

This is the function I used to test this.

@time_trigger("period(now, 1min, 10:15:00)") 
def period_trigger_test(trigger_time: datetime):
 task.unique("period_trigger_test")
 log.warning("trigger_time %s", trigger_time)
You must be logged in to vote

Replies: 1 comment

Comment options

You're not doing anything wrong. I don't think it's a bug, but an unexpected consequence of how pyscript interprets times without dates. When a date isn't specified, several checks are done by trying yesterday, today and tomorrow. This is to allow the convenience of a start time > end time (without dates) to mean the evening period spanning midnight - the ending time is considered to be tomorrow. If now > end time, the end time is considered to be tomorrow. A couple of solutions are (untested):

  • don't use now, instead use '0:0' or midnight. Then the trigger will happen from midnight to 10:15am every day, or from whenever you start. However, you might only want to trigger on the start day, not on subsequent days.
  • To trigger just on a startup day, keep the now start, and today 10:15:00 for the end time. That should disable the attempts to try tomorrow or yesterday. Then the trigger will only happen on the day of startup before 10:15am.

Hmm - I just tested the 2nd suggestion, and it doesn't work correctly - it triggers once at now, even if it's after end time. It doesn't trigger again though. That does look like a bug.

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet

AltStyle によって変換されたページ (->オリジナル) /