Neat way to add a delay before performing an exit task

1,308 views
Skip to first unread message

Michael White

unread,
Dec 19, 2012, 5:08:21 PM12/19/12
to tas...@googlegroups.com
Hi,
This is useful for profiles like : set phone to silent when you meet a context (wifi near, gsm, etc), disable silent if you have left the context for more than X minutes.
After having messed quite a bit, using long waits in exit tasks, which I quite dislike, I came up with the following template, which is very straight forward, lightweight battery-wise and works fine. It doesn't wait for a precise number of minutes, but rather a value that is in a bracket (3-5 minutes in example).
Even though this might seem an obvious way for lots of you, I figured I'd post it as it might help some, as with my own experience, I didn't find any precise information on the net (maybe I did bad google searches...)

Here is the 2 profiles it requires, I'll add a little description further down :

Profile: Near Work Test (191)
        State: Variable Value [ Name:%Test Op:Matches Value:1 ]
Enter: Anon (192)
        A1: Silent Mode [ Mode:Vibrate ]
        A2: Variable Set [ Name:%Leavework To:0 Do Maths:Off Append:Off ]

Exit: Anon (193)
        A1: Variable Set [ Name:%Leavework To:1 Do Maths:Off Append:Off ]


Profile: Leave Work Test (194)
        State: Variable Value [ Name:%Leavework Op:Maths: Greater Than Value:0 ]
        Time:  Every 2m
Enter: Anon (195)
        A1: Variable Add [ Name:%Leavework Value:1 Wrap Around:0 ]
        A2: If [ %Leavework ~ 4 ]
        A3: Variable Set [ Name:%Leavework To:0 Do Maths:Off Append:Off ]
        A4: Silent Mode [ Mode:Off ]
        A5: End If



Description :
State: Variable Value [ Name:%Test Op:Matches Value:1 ] ---> set this condition in 1st profile for what you want to test (I essentially use Cell Near in my profiles as they don't use up battery)

As to set the time you want to wait before performing exit task, you can change the Time : Every 2m increment, and play with the value of A2: If [ %Leavework ~ 4 ]
As said before, this example sets a delay that is somewhere between 3 and 5 minutes, depending when the profile is triggered. Setting Time : Every 3m would make the bracket 4-8 minutes for example.

I hope this solution can help some of you.
Mike

Matt R

unread,
Dec 19, 2012, 6:50:40 PM12/19/12
to tas...@googlegroups.com
Interesting idea!  I use long-ish waits in some exit tasks and haven't had any problems.  What benefits does this have for you or what problems does it solve?  Getting an explanation of that in the thread might also help others find this in the future if they have a similar problem.

Matt

Michael White

unread,
Dec 19, 2012, 7:46:11 PM12/19/12
to tas...@googlegroups.com
Well first off, if your phone reboots, it won't cancel the waiting action.

Then before I found it was a real pain to restart the waiting action. For example say you want to cancel silent mode if you haven't had a Cell near for 10 minutes. At t=0, signal stops. At t=5 mins it comes back. At t=6 min it goes off again. If you have a standard waiting task for 10 min, you can't (at least i've had many problems with trying to do it) stop the action at t=5 mins, to restart it at t=6mins. A work around is to have a loop waiting for x seconds at a time, but that involves an action every x seconds and therefore seems to me (maybe this is incorrect) more battery consuming. This solution has none of that.

Last and most important for meg, I can get up to quite a lot of Tasker actions working at the same time, and when it comes to priority in actions, the wait task is really weird. That's the main reason I try to avoid as much as I can wait actions longer than 2-3 seconds.

As a side note, you can you this "exit profile" for more than 1 "enter profile", as long as you are sure the enter profiles won't happen at the same time, choosing a different exit delay and exit action according to the enter profile.

Matt R

unread,
Dec 20, 2012, 12:17:00 PM12/20/12
to tas...@googlegroups.com
Good points.  Phone reboots and waits are definitely an issue to be considered.  Restarting the timer isn't too bad (at least for my uses) with proper collision handling (abort existing task and checking if the profile is active when the timer expires).  I've also noticed some weird behavior with lower priority waits seemingly blocking higher priority tasks, but only sometimes.  Is this the kind of weird behavior your noticing?  I've tried to make a set of tasks with waits and different priorities to try to reproduce the issue, but haven't been able to.  If this is also the kind of problem you are (were) having, maybe I'll look into getting something repeatable that Pent can look into sometime.

Matt

Michael White

unread,
Dec 21, 2012, 8:52:27 AM12/21/12
to tas...@googlegroups.com
I can't remember exactly what problems I encountered, but it had to do with that.
I think Pent already knows about the problem, he once wrote :

There's some voodoo goes on when scheduling Wait actions to make things generally better in Tasker's one-action-executing-at-once model. 
Unfortunately, it can have the effect of causing waits to be inaccurate if you've got a lot going on at once. 


Since i read this, I tried to avoid wait actions longer than 2-3 seconds.
Reply all
Reply to author
Forward
0 new messages