How to prevent quick toggling of "wifi connected" state?

74 views
Skip to first unread message

Tim

unread,
Dec 5, 2013, 1:02:20 PM12/5/13
to tas...@googlegroups.com
I have a profile that becomes active when "wifi connected" state, with an entry task to set a variable to 1 (to indicate wifi connected) and an exit task to set the same variable to 0 (to indicate wifi disconnected). The variable is then checked by other profiles to do various things based on the wifi state.

The problem is when I am on the "edge" of an wifi connection the state can toggle quickly between connected and disconnected which in theory is correct but in practice it is annoying.

I'm used to Llama that has a feature to delay the actions for a period of time (e.g. 1 min.) when all conditions become true and cancel running them if the conditions are no longer true after the delay period.

How can I do the same thing in Tasker without the entry and exit task setting my variable to the wrong value? I basically want to toggle the state of my "wifi connected" variable only if wifi has been connected for 1 min or disconnected for 1 min. (yes I realize that my Llama test above doesn't quite exactly do that as the wifi state can still change a lot during the 1 min. period and it may just happen to be in the same state at the end of the 1 min. but in practice it works well).

Thanks for your help.

Scott Lyle

unread,
Dec 5, 2013, 1:16:07 PM12/5/13
to tas...@googlegroups.com
You can put a 1 minute "wait" in your exit task and have the first item in your entry task be an action to kill the exit task.  That way if you exit the WiFi area it will start the wait timer.  If you enter the WiFi area before that wait timer is done the entry task will kill the exit task and your variable will never change.

Tim

unread,
Dec 5, 2013, 1:26:45 PM12/5/13
to tas...@googlegroups.com
Thank you for your reply. Will the "2nd" entry task run if the exit task is still waiting? From the documentation I read that by default a 2nd task is ignored if the same task is active, but in this case I'm not sure if it's the pair entry/exit task that's considered active or it truly means there are no 2 entry tasks running at the same time but you can have an exit task in a wait state and an entry task starting again.

I also need to do the same thing for the case when wifi is disconnected and it toggles to a connected state, e.g. I come home and while in the garage wifi coverage is spotty which causes the phone to connect/disconnect from wifi quickly. If I also put a wait in the entry task I have not really achieved anything.

Is there another way/variable that I can check how long wifi has been connected for or disconnected for?

Tim

unread,
Dec 5, 2013, 2:09:06 PM12/5/13
to tas...@googlegroups.com
And another question: how do I kill an entry or exit task? Stop action with a named task which means that I have to name the entry and exit tasks rather than use anonymous tasks? Or is there a different way to reference (or kill) the exit task from the entry task and vice versa?

Tim

unread,
Dec 5, 2013, 2:20:58 PM12/5/13
to tas...@googlegroups.com
Let's see if this will work:

---> Entry Task:
Stop Exit Task
Wait 1 min.
Set Var WIFI_CONNECTED=1

<--- Exit Task:
Stop Entry Task
Wait 1 min.
Set Var WIFI_CONNECTED=0

Bob Hansen

unread,
Dec 5, 2013, 3:13:47 PM12/5/13
to tas...@googlegroups.com
Try this:
For this to work your wifi connected profile must be named. 

Profile name: Wifi_State
Enter Task
---> Entry Task:
Set Var WIFI_CONNECTED=1

<--- Exit Task:
Stop Entry Task
Wait 1 min.
Set Var WIFI_CONNECTED=0  If %PACTIVE !~ *,Wifi_State,*  

Explanation: %PACTIVE is a Tasker built-in variable that has all active profile names in it. This If statement looks to see if your profile named "Wifi_State" does not match (!~) any of the names contained in the list. If it is not in the list, after the wait, then it sets you WIFI_CONNECTED=0. If it is in the list it does not set it.

The *, and ,* are needed for the search parameter to work. No spaces between them and the profile name.

Scott Lyle

unread,
Dec 5, 2013, 3:21:28 PM12/5/13
to tas...@googlegroups.com
Here's what I was suggesting.  It defaults to you being connected to WiFi if you're going in and out of service in less than 1 minute intervals.  So you'll be counted as connected to WiFi immediately after connecting, but it will take one minute of not being connected to be counted as not connected.

---> Entry Task:

Stop Exit Task
Set Var WIFI_CONNECTED=1

<--- Exit Task:
Wait 1 min.
Set Var WIFI_CONNECTED=0

Tim

unread,
Dec 5, 2013, 3:50:22 PM12/5/13
to tas...@googlegroups.com
Nice %PACTIVE trick!
I'm not sure about the purpose of that "Stop Entry Task" though, maybe it was just left behind from the cut & paste, I think it would be the same without it and it would save the trouble of using a named entry task (so I can stop it by name).

How about this alternative?

Profile name: Wifi_State
---> Entry Task:
Wait 1 min.
Set Var WIFI_CONNECTED=1 If %PACTIVE ~ *,Wifi_State,*

<--- Exit Task:
Wait 1 min.
Set Var WIFI_CONNECTED=0  If %PACTIVE !~ *,Wifi_State,*

Named profile is fine, I name them all anyway, but I kinda like anonymous tasks where possible and this would give me that plus the symmetric 1 min. wait before toggling the variable.

Bob Hansen

unread,
Dec 5, 2013, 3:58:20 PM12/5/13
to tas...@googlegroups.com
Your right - I forgot to delete it :>)
Reply all
Reply to author
Forward
0 new messages