Add a timer to each trigger

Post your feature requets for new triggers, conditions, actions and other improvements.

Moderator: Martin

User avatar
Posts: 2
Joined: 10 May 2019 15:59

Add a timer to each trigger

Post by MickCox » 10 May 2019 20:10

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.

User avatar
Posts: 2709
Joined: 21 Jul 2017 17:50

Re: Add a timer to each trigger

Post by Desmanto » 11 May 2019 07:34

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")
Index of Automagic useful thread List of my other useful posts (and others')
Xiaomi Redmi Note 5 (whyred), AOSP Extended v6.7 build 20200310 Official, Android Pie 9.0, Rooted.