Page 1 of 1

Add a timer to each trigger

Posted: 10 May 2019 20:10
by MickCox
Hi, I think a useful feature to add to triggers would be a timer. I have on several occasions wanted to use a trigger, but not as an instantaneous activation of a flow. Rather, have the trigger to be true for a selectable length of time before it activates the flow. For example, the trigger for speed must be less than 10mph for 30 seconds before the flow is active. If the the speed increases above 10mph before the 30 seconds is up, the flow is not active.
If there is a way to do this already, please can someone let me know how. Thanks.

Re: Add a timer to each trigger

Posted: 11 May 2019 07:34
by Desmanto
Trigger acts on event, so the event must be immediate, not across a time span. What you want is something act like event and combine with state buffer. You can achieve this using the trigger and another action/condition which will query the same data. Some trigger has the condition counter part, example Trigger Power Source has the similar condition Power Source Connected. You can loop check the power source connected and put some sleep (example 500ms or 1s) until the desired timeout, using execution count.

For speed, there is no condition speed, which you have requested in another thread. But you can use action Init Variable Location, which will provide the same variable {location_speed}. Check this value using expression

Code: Select all

location_speed < 10.0
False, do nothing (flow stop). True, go to Condition execution count 30. False, go to sleep 1s, then loop back to the same Init Variable location. True, continue to the main execution branch of your flow (example : speech output, "speed has decline to less than 10 mph in the last 30 seconds")