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
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 ]
> 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.
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..... :)
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 ]
> 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?
;> 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?
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...
> 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.
> 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?
****************
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