Skip to content

Help understanding task.create() #684

Answered by IgnusG
ben-kenney asked this question in Q&A
Discussion options

You must be logged in to vote

Hey @ben-kenney 👋

Tasks are meant for parallel programming eg. when you want to start multiple flows that run all at the same time or separately from the rest of your function - they don't accept any triggers (they just pass the args and kwargs to your function which you provided as the first arg).

If you'd like to run your automation with a delay you can make use of the state_trigger and state_hold property (it will only run your function if the condition you put in the string remains True for the specified amount of time - then it runs):

@state_trigger("cover.garage_door == 'open'", state_hold=15 * 60) # garage door must stay open for 15 minutes otherwise function doesn't run
@task_unique(

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@ben-kenney
Comment options

@IgnusG
Comment options

Answer selected by ben-kenney
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants