Sleep vs Wait

Post your questions and help other users.

Moderator: Martin

Post Reply
julian.colombo
Posts: 8
Joined: 21 Jan 2017 10:18

Sleep vs Wait

Post by julian.colombo » 07 Feb 2017 09:18

Hi,

The 'sleep' action pauses the entire flow, but I wish to 'wait'! Is there such an action already avaliable? If not, is it possible to implement this feature?

Thanks.

Julian

User avatar
fagci
Posts: 75
Joined: 03 Feb 2017 13:06
Location: Novosibirsk, RU
Contact:

Re: Sleep vs Wait

Post by fagci » 07 Feb 2017 09:38

If interval so huge, you can set interval trigger and wait for needeed date difference
All systems nominal.

julian.colombo
Posts: 8
Joined: 21 Jan 2017 10:18

Re: Sleep vs Wait

Post by julian.colombo » 07 Feb 2017 09:42

Trigger will not help!

Pepy
Posts: 39
Joined: 31 Oct 2018 10:53
Location: Canada

Re: Sleep vs Wait

Post by Pepy » 13 Jun 2019 21:15

I know this thread is pretty old, but you should be able to just use a sleep() function in the Control UI action. Another way would be to create another flow with a Sleep action and then use the Execute Flows action with the Wait for called flows to finish option checked.
Newbie to device automation! Hope my post was helpful :D
Device Status: OnePlus 5T (Dumpling) running crDroid 5.x, rooted with Magisk.

User avatar
Desmanto
Posts: 1810
Joined: 21 Jul 2017 17:50

Re: Sleep vs Wait

Post by Desmanto » 15 Jun 2019 16:33

The wait mentioned here probably refer a condition that wait for certain value to become true, before continuing. In that case, the better way is to use the trigger counterpart of the condititon. Or else, the solution is to use looped condition check over interval sleep. So maybe the flow run, check if condition fulfilled. If not, go to sleep 5 seconds, loop back to the condition, check again. This will make the flow run forever, creating a long wakelock and killing the battery.
Index of Automagic useful thread List of my other useful posts (and others')
Xiaomi Redmi Note 5 (whyred), Resurrection Remix Official 7.0.2 20190512, Pie 9.0, Rooted.

Pepy
Posts: 39
Joined: 31 Oct 2018 10:53
Location: Canada

Re: Sleep vs Wait

Post by Pepy » 17 Jun 2019 04:44

Desmanto wrote:
15 Jun 2019 16:33
In that case, the better way is to use the trigger counterpart of the condititon.
That's true, but unless it were to be a setting like auto rotate, it would require a global variable. I guess another way to do this is to just separate it into another flow and use action Execute Flows once the wait is over.
Desmanto wrote:
15 Jun 2019 16:33
Or else, the solution is to use looped condition check over interval sleep. So maybe the flow run, check if condition fulfilled. If not, go to sleep 5 seconds, loop back to the condition, check again. This will make the flow run forever, creating a long wakelock and killing the battery.
I did use this method to continuously check every few seconds if the screen was on AND the keyguard was unlocked but now, I just use a Keyguard Unlocked condition because as you said, it can drain the battery. Whenever I use this loop method, I would create a variable to count down from to limit the amount of "retries".
Newbie to device automation! Hope my post was helpful :D
Device Status: OnePlus 5T (Dumpling) running crDroid 5.x, rooted with Magisk.

User avatar
Desmanto
Posts: 1810
Joined: 21 Jul 2017 17:50

Re: Sleep vs Wait

Post by Desmanto » 17 Jun 2019 17:06

Auto rotate state can be detected using Trigger System Setting Changed : [System] accelerometer_rotation : 0 >>> 1
Other state probably can be detected using the same trigger, but with different value.

If the loop wait-check is short, less than 1 minute, then you can loop several times and use the counter to limit number of check, so it doesn't loop forever. But if the wait is longer than 1 minute, better utilize global variable datetime (glovardt) trigger to implement the loop. Add the glovardt everytime the condition is false.
Index of Automagic useful thread List of my other useful posts (and others')
Xiaomi Redmi Note 5 (whyred), Resurrection Remix Official 7.0.2 20190512, Pie 9.0, Rooted.

Post Reply