Tasker collision handling question

643 views
Skip to first unread message

Mike Kramer

unread,
Feb 18, 2015, 5:35:44 AM2/18/15
to tas...@googlegroups.com
I have a profile, which triggers when exiting a geofence (via autolocation). When exiting, it triggers a task 'Away', and as a exit task (when I enter the geofence) it triggers 'Home'. I have set collision handling to abort new task, and have a 5 minute wait at the end of each task to eliminate or reduce false triggers. I do still get a lot of false triggers, 'away' being triggered and followed by the 'home' task being triggered. The question I have, if autolocation triggers within that wait period, the exit task should not trigger as I have the collision handling set to abort. But, is it possible that it would trigger the exit task when the wait is over, even if the profile then is not true ? Or can I assume if the exit task is triggered, that the profile is not true at that time ? Not sure if I explained well enough what I mean...

Rich D

unread,
Feb 18, 2015, 6:19:19 AM2/18/15
to Tasker Google Groups Post


This is sometimes referred to as bouncing, you can search this group for other approaches but this is the one I use. It will stop both the enter task and exit task from running when the context bounces.  

Profile: Cell on
Context: cell near
Enter Task: Start
1. Enter task stuff

<put the following actions as the first actions in you exit task>

Exit task:stop
1. Wait 5 sec <whatever time you need>
2. Stop  <enter task> ;Start
3 Stop if %PACTIVE ~ *,Cell on,*
4. Rest of exit task

Hopefully this will shed some light on the situation for you

https://groups.google.com/forum/m/#!topic/tasker/qInYbV1L2Jo

Mike Kramer

unread,
Feb 18, 2015, 8:37:12 AM2/18/15
to tas...@googlegroups.com
That is a very good hint, still trying to digest it all. I think I sort of understand it. But, what I would like to achieve is if my profile switches quickly from true to false and back to true, to ignore the false.
So I do not want the exit task to run then at all. That was why I put the wait in. From what I read in the link you posted, and from what I understand (which probably equals 0 or is near 0) I think I can influence the order the tasks are run, but it would not stop the exit task running ?
I would want the exit task to run if after the wait of the enter task the profile is still false. If the profile is true again though, so if it was just a short true/false/true switch, I do not want the exit task to run. If that is possible somehow
 
This is my profile:
 

Profile: Home (39)

                State: AutoLocation Geofences [ Configuration:Geofence Name: home

Status: Inside ]

Enter: Home (6)

                A1: Wait Until [ MS:0 Seconds:2 Minutes:0 Hours:0 Days:0 ] If [ %Mdata ~ 1 ]

                A2: If [ %Home eq 0 ]

                A3: AutoVera Devices [ Configuration:Vera: Vera 3

Device: (*)Mike's phone

State: Turn On

Action: State

Service: Power Switch Package:com.joaomgcd.autovera Name:AutoVera Devices Timeout (Seconds):30 ]

                A4: AutHomationHD Device [ Configuration:(*)Mike's phone Package:com.garrettpower.authomationhd Name:AutHomationHD Device Timeout

(Seconds):0 ]

                A5: Variable Set [ Name:%Home To:1 Do Maths:Off Append:Off ]

                A6: Perform Task [ Name:Secure Place Priority:%priority Parameter 1

(%par1): Parameter 2 (%par2): Return Value Variable: Stop:Off ]

                A7: Email Me Pro [ Configuration:To: xxx@gmail.com, Subject: Home tasker Package:com.caramellabs.emailmepro Name:Email Me Pro Timeout

(Seconds):0 ]

                A8: Wait [ MS:0 Seconds:0 Minutes:3 Hours:0 Days:0 ]

 

Exit: Away (65)

                A1: Wait Until [ MS:0 Seconds:2 Minutes:0 Hours:0 Days:0 ] If [ %Mdata ~ 1 ]

                A2: If [ %PACTIVE !~ *,Home Wifi,* ]

                A3: AutoVera Devices [ Configuration:Vera: Vera 3

Device: (*)Mike's phone

Action: Set Target

New Target Value: 0

Service: V Switch Package:com.joaomgcd.autovera Name:AutoVera Devices Timeout (Seconds):30 ]

                A4: Variable Set [ Name:%Home To:0 Do Maths:Off Append:Off ]

                A5: Wait [ MS:0 Seconds:0 Minutes:3 Hours:0 Days:0 ]

 

Mike Kramer

unread,
Feb 18, 2015, 9:09:57 AM2/18/15
to tas...@googlegroups.com
The problem is normally that I am away and the home profile is triggered. The other way round I have sort of solved by stopping the 'away' task running when I am logged into my home wifi

Rich D

unread,
Feb 18, 2015, 12:21:42 PM2/18/15
to Tasker Google Groups Post


> That is a very good hint, still trying to digest it all. I think I sort of understand it.

Keep going back to it..  you will get it..   feel free to ask any questions about it.

But, what I would like to achieve is if my profile switches quickly from true to false and back to true, to ignore the false.

This is exactly what the approach I gave is used for. I do not have time just now to give a break down of how it works but i will get back to you.  You can eliminate all of the waits and wait until's in you existing and just replace with what I listed.  The enforce task order should be checked and the collision should be set to 'abort new task'  which is the default; settings.

This will prevent the enter task and the exit task from running if your profile short cycles for less then the wait time you pick. 

Rich D

unread,
Feb 18, 2015, 6:49:15 PM2/18/15
to Tasker Google Groups Post

Tasker tutorial 101...

Hopefully you have looked up 'enforce task order' and task collision settings in the user guide. One of  the easiest way to find things in the user guide is to use the menu / search tasker option in the UI.

So, when  enforce task order is enabled this will ensure the exit task will not run until the enter task  has finished or been stopped (for the same profile activation)

Using the following example this is how the flow will work when the profile short cycles or (bounces)

1. Profile goes active
2. Enter task starts and runs
3. Profile goes inactive.
4. Exit task starts and the 5 second wait starts
5. Profile goes active 1 second after dectivation
6. A new enter task starts but does not run because the exit task is still running. . Which means the enter task has been entered into the task queue but can not run until the previous exit task completes or is stopped.
7. 5 second wait expires.
8. Action 2 of the exit task now stops (kills) the enter task that is in the queue. (If you did not do this the enter task would run for a second time.)
9. Action 3 of the exit task stops the exit task because the profile is active.

So the profile short cycled and neither  the exit task or the enter task ran.

Now for extra credit lets cycle it 2 times .. before the wait expires.

1. Profile goes active
2. Enter task starts and runs
3. Profile goes inactive.
4. Exit task starts and the 5 second wait starts
5. Profile goes active 1 second after deactivation
6. A new enter task starts but does not run because the exit task is still running. . Which means the enter task has been entered into the task queue but can not run until the previous exit task completes or is stopped.
7. Profile goes inactive 1 second after activation.
8. A exit task will start from the deactivation of the profile, but will be aborted because there is already one iteration of the exit task running and the collision properties are set to ' abort new task'
9. Profile activates 1 second after deactivation
10. A enter task will start and be aborted because there is already one iteration of the enter task already running and the collision properties are set to 'abort new task'

So no matter how many times the profile cycles within the wait time the enter or exit task will not run. 

The floor is now open for questions.....  :)



Mike Kramer

unread,
Feb 19, 2015, 7:49:17 AM2/19/15
to tas...@googlegroups.com
OK thanks for that, it is now a lot clearer. I did read the user guide, but could not make sense of it. But I think I am 90% there now. I had abort new task, and enforce task order ticked already, so I now added your suggestions to my profile. I eliminated the Wait at the end of my tasks. I wonder if I should put the 2 stop actions in the enter task too. I had the wait in both tasks as it can happen both ways. So when I am coming home, it activates home, but then if it switches to away again that should be stopped now. Now I have to find a solution for when I leave, the away activates, but if it then quickly switches to home and back to away. I could put Stop 'away' in there. Maybe I should also leave the 'wait' action in the home task.
 

Profile: Home Main (39)

                State: AutoLocation Geofences [ Configuration:Geofence Name: home

Status: Inside ]

Enter: Home (6)

                A1: Wait Until [ MS:0 Seconds:2 Minutes:0 Hours:0 Days:0 ] If [ %Mdata ~ 1 ]

                A2: If [ %Home eq 0 ]

                A3: AutoVera Devices [ Configuration:Vera: Vera 3

Device: (*)Mike's phone

State: Turn On

Action: State

Service: Power Switch Package:com.joaomgcd.autovera Name:AutoVera Devices Timeout (Seconds):30 ]

                A4: AutHomationHD Device [ Configuration:(*)Mike's phone Package:com.garrettpower.authomationhd Name:AutHomationHD Device Timeout

(Seconds):0 ]

                A5: Variable Set [ Name:%Home To:1 Do Maths:Off Append:Off ]

                A6: Perform Task [ Name:Secure Place Priority:%priority Parameter 1

(%par1): Parameter 2 (%par2): Return Value Variable: Stop:Off ]

                A7: Email Me Pro [ Configuration:To: xxx@gmail.com, Subject: Home tasker Package:com.caramellabs.emailmepro Name:Email Me Pro Timeout

(Seconds):0 ]

 

Exit: Away (65)

                A1: Wait Until [ MS:0 Seconds:2 Minutes:0 Hours:0 Days:0 ] If [ %Mdata ~ 1 ]

                A2: If [ %PACTIVE !~ *,Home Wifi,* ]

                A3: Stop [ With Error:Off Task:Home ]

                A4: Stop [ With Error:Off Task: ] If [ %PACTIVE ~ *,Home Main,* ]

                A5: AutoVera Devices [ Configuration:Vera: Vera 3

Device: (*)Mike's phone

Action: Set Target

New Target Value: 0

Service: V Switch Package:com.joaomgcd.autovera Name:AutoVera Devices Timeout (Seconds):30 ]

                A6: Variable Set [ Name:%Home To:0 Do Maths:Off Append:Off ]

 

Rich D

unread,
Feb 19, 2015, 10:19:49 AM2/19/15
to Tasker Google Groups Post


>                 A1: Wait Until [ MS:0 Seconds:2 Minutes:0 Hours:0 Days:0 ] If [ %Mdata ~ 1 ]
>

What is the purpose of this?   When does %Mdata get set?

Mike Kramer

unread,
Feb 19, 2015, 10:46:07 AM2/19/15
to tas...@googlegroups.com
Mdata is set to 1 when I have some sort of data connection, either 3g or wifi. I do not want to send data to my home automation system when there is no data connection, otherwise the command gets lost.
On the exit task, I check to see if I am logged into my home wifi A2: If [ %PACTIVE !~ *,Home Wifi,* ]
If I am, I cannot be away so I stop the task there. All trying to eliminate flase triggers and in general make it more reliable

Mike Kramer

unread,
Feb 19, 2015, 5:35:16 PM2/19/15
to tas...@googlegroups.com
I have thought about this a bit more. What I want is have a 'time out' for the tasks for lets say 3 minutes. So that means, within 3 minutes of away firing I do not want home to fire, or the other way round. I am not sure the way I have it at the moment that to be the case, i think I do need a wait still in there to achieve that. That gives me another problem. I do want home to fire as quickly as possible, as that turns the lights on when I come home in the dark. If that would happen 3 minutes after home is fired, I would long be through the door. Making the geofence big enough to catch that is not an option, as it would be too big for my setup.
The other problem is, the last few times it was the home task 'misfiring' when leaving the house. So I changed the logic of the profile, made the profile true when outside the geofence, have the away as enter task, and home as exit task.
But now I am stuck with the 3 minute time out....

Rich D

unread,
Feb 19, 2015, 6:00:28 PM2/19/15
to Tasker Google Groups Post


;> I have thought about this a bit more. What I want is have a 'time out' for the tasks for lets say 3 minutes. So that means, within 3 minutes of away firing I do not want home to fire, or the other way round. I am not sure the way I have it at the moment that to be the case,

Correct for this to work as you want you would need a 3 min wait as the first action in both tasks then you can do the wait until. I addition you would need to add the
if %Pactive !~ 'profile name'
Stop exit task
Stop enter task
To the enter task....

. That gives me another problem. I do want home to fire as quickly as possible, as that turns the lights on when I come home in the dark. If that would happen 3 minutes after home is fired, I would long be through the door. Making the geofence big enough to catch that is not an option, as it would be too big for my setup.

Now that's a problem... could you add a cell near context?

> The other problem is, the last few times it was the home task 'misfiring' when leaving the house.

I believe this is because you did not have the 3 min wait.  The wait until is not sufficient to do the debouncing..

So I changed the logic of the profile, made the profile true when outside the geofence, have the away as enter task, and home as exit task.

Either way will work if you debounce both the enter and exit task. 

> But now I am stuck with the 3 minute time out....

Yes. That is a issue.  Do you need 3 min?  How long does the goefence typically show a false positive?

Rich D

unread,
Feb 19, 2015, 11:05:16 PM2/19/15
to Tasker Google Groups Post

I found Geo fences  far to unreliable for my home context.  I believe the issue is I am in a very remote location. If Geo fences does not enough data IE. Local wifi's  and whatever else it monitors it becomes unreliable. That is just my opinion.  I opted   to just use a cell near context.

I think for your lights on you will need additional information to confirm you are approaching home and leaving home. 

Leaving you could probably use your home wifi.  Something? like check how long its been since you were connected.

Approaching -  perhaps get a few locations and see if you are getting closer to home. 

Just some thoughts... 

Mike Kramer

unread,
Feb 20, 2015, 5:45:07 AM2/20/15
to tas...@googlegroups.com
Where I am GPS is normally very good. I will look into the cell near and see how I can incorporate it possibly. Any idea of what the radius is for detecting a tower ? A few hundred meters ? What is your experience with that ? The other one I already thought about is using when wifi has not been connected for x minutes. I can do that on my home automation system, but I'd rather do that on the phone. But not sure how I can achieve that in tasker, I will have to search the forums and see how a conditionality depending on something being true or false for x amount of time can be done. In the meantime, I will try to debounce both tasks.
With that I have another question... (sorry about that). If my enter task starts, it stops the exit task, but after stopping the exit task while the enter task runs, what happens then when I get a exit task signal then ? That should be aborted ? So if I leave the 3 minute wait at the end, maybe that'll work ?

Rich D

unread,
Feb 20, 2015, 6:26:21 AM2/20/15
to Tasker Google Groups Post


> With that I have another question... (sorry about that). If my enter task starts, it stops the exit task, but after stopping the exit task while the enter task runs, what happens then when I get a exit task signal then ? That should be aborted ?

There is a flaw in logic. But even if we fix it I think you will end up with a six minute wait if it bounces in the enter task then stays inactive, becouse now the exit task will run its wait.

     But thinking about it now if we are going to debounce both enter and exit tasks and you want the same wait until action in both I "Think" you should just use the same task for enter and exit. Put a 3min wait then your wait untill and then check if the profile is active.  If it is active then run your enter task actions if it is inactive then run your ext task actions.  This will mean no matter if it is activating or deactivating  you will only wait the 3 min.

Mike Kramer

unread,
Feb 20, 2015, 8:19:03 AM2/20/15
to tas...@googlegroups.com
Its worth thinking about putting it in one task, I never thought about that. Not sure it'll work, but at the moment I cant see why it shouldn't... I think I'll try with the wait and the debouncing first on both, see how I get on. I will give the one task option a try too, see which works better. And maybe look into the cell near and wifi not connected for x minutes too...

Rich D

unread,
Feb 20, 2015, 4:10:14 PM2/20/15
to Tasker Google Groups Post


> Its worth thinking about putting it in one task, I never thought about that. Not sure it'll work, but at the moment I cant see why it shouldn't... I think I'll try with the wait and the debouncing first on both, see how I get on.

To do the de-bounce on both tasks I think you want the 3 min wait at the beginning of both tasks and do the enter task like this.

1. 3min wait
2. Wait until
4. Stop. : If %PACTIVE !~ 'name of profile'
5. Stop exit task
6. Enter task stuff... 

I will give the one task option a try too, see which works better. And maybe look into the cell near and wifi not connected for x minutes too...
>

And for the exit task

Exit: Away (65)

1. 3min wait
2. If %PACTIVE~*Home Main,*/*,Home Wifi,*
3.    Stop enter task
4.     Stop
5. Exit task stuff..


                A1: Wait Until [ MS:0 Seconds:2 Minutes:0 Hours:0 Days:0 ] If [ %Mdata ~ 1 ]

**********

                A2: If [ %PACTIVE !~ *,Home Wifi,* ]

I think you had this one backwards.  You would want to stop the exit task from running if you are connected to home wifi...  correct?

****************

Rich D

unread,
Feb 20, 2015, 5:09:32 PM2/20/15
to Tasker Google Groups Post


Correction.  The original concept for the enter task was correct and should work in all situations. You need to kill the exit task before the %PACTIVE. 'If' 

>
> 1. 3min wait
> 2. Wait until

   4. Stop exit task.
> 5. Stop. : If %PACTIVE !~ 'name of profile'


> 6. Enter task stuff... 
>
> I will give the one task option a try too, see which works better. And maybe look into the cell near and wifi not connected for x minutes too...
> >
>
> And for the exit task
>
> Exit: Away (65)
>
> 1. 3min wait

   2. Wait until
   3. Stop enter task
> 4. Stop.  :If %PACTIVE~*Home Main,*/*,Home Wifi,*
> 5. Exit task stuff..
>

To check how this is working you will want to enable and check the run log. It is the best way to see the flow.

Menu / more / run log

Mike Kramer

unread,
Feb 21, 2015, 7:03:47 AM2/21/15
to tas...@googlegroups.com
I will need the 3 minute wait at the end of the task. otherwise it'll switch too late. Apart from that, I think thats the way I have it at the moment. Lets see how I get on....
Reply all
Reply to author
Forward
0 new messages