• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Help with Tasker

Mekanikz

Newbie
Hey guys, I was wondering if anyone can walk me through making profiles that accomplish the following:


- Screen off for 10 secs -- Wifi/Data off
Details: If the screen is off for 10 seconds (either times out or I hit the home button to turn it off manually), Wifi and Data (3G) will turn off.
If possible, keep Data (3G) and Wifi (if it was already on) on while there is traffic (e.g. If screen turns off while my internet browser is loading a page, or while I'm connected to MSN, etc.)

- Screen turned on -- Wifi/Data turns on after 5 secs (wifi stays off if was off before)
Details: If the screen is on for a minimum of 5 seconds, Wifi and Data (3G) will turn back on (Wifi will not turn on if it was not on prior to the screen turning off).
Note: If possible, if I unlock the lock screen I would then like Data (3G) and Wifi to activate again right away (no 5 second wait).
If possible, I would like to keep Wifi/Data off if the screen turns on for more than 5 seconds for an incoming call.



I'm using version 1.2u2 if that matters. Thanks to anyone who's willing to take the time to help me.
 
While not as detailed as you're looking for, this should get you started:

Profile 1: Screen Off
Context: Display Off
Task:
Wait 10 seconds
If %SCREEN ~ off
Wifi Off
Mobile Data Off
End If

Profile 2: Screen On
Context: Display On
Wait 5 seconds
If %SCREEN ~ on
Wifi On
Mobile Data On
Wait 10 seconds
If %WIFI !~ *connection*
Wifi Off
End If
End If

Collision handling for the above tasks should be "Abort Existing Task".

Profile 1: If the screen turns off and remains off for 10 seconds, Mobile Data and Wifi will both be turned off. Tasker has no ability to know if data is being used, so there's no way to account for that when determining if Mobile Data and Wifi should be turned off. You could optionally add an Application context for "Not Browser", but that would only mean that the browser is not the current app - data could still be being used.

Profile 2: If the screen turns on and remains on for 5 seconds, Mobile Data and Wifi are both turned on. If there is no Wifi connection 10 seconds later (meaning probably no known networks available), Wifi is turned off.
 
While not as detailed as you're looking for, this should get you started:

Profile 1: Screen Off
Context: Display Off
Task:
Wait 10 seconds
If %SCREEN ~ off
Wifi Off
Mobile Data Off
End If

Profile 2: Screen On
Context: Display On
Wait 5 seconds
If %SCREEN ~ on
Wifi On
Mobile Data On
Wait 10 seconds
If %WIFI !~ *connection*
Wifi Off
End If
End If

Collision handling for the above tasks should be "Abort Existing Task".

Profile 1: If the screen turns off and remains off for 10 seconds, Mobile Data and Wifi will both be turned off. Tasker has no ability to know if data is being used, so there's no way to account for that when determining if Mobile Data and Wifi should be turned off. You could optionally add an Application context for "Not Browser", but that would only mean that the browser is not the current app - data could still be being used.

Profile 2: If the screen turns on and remains on for 5 seconds, Mobile Data and Wifi are both turned on. If there is no Wifi connection 10 seconds later (meaning probably no known networks available), Wifi is turned off.
Thanks a lot, that was worked perfectly :D

What would I have to do so that data (3G) won't turn off if the browser is running?

Also, what do I have to type for the End If tasks?
 
Thanks a lot, that was worked perfectly :D

What would I have to do so that data (3G) won't turn off if the browser is running?

Also, what do I have to type for the End If tasks?

You would have to add an Application context to the first profile, specifying "Not Browser". When adding the Application context, select the Browser (and any other apps that should prevent data/wifi from turning off), and then select Not at the lower right.
 
You would have to add an Application context to the first profile, specifying "Not Browser". When adding the Application context, select the Browser (and any other apps that should prevent data/wifi from turning off), and then select Not at the lower right.
Thanks for the quick reply, but I have no idea how to do what you just said. If you don't mind, could you break it down like you did in your first post?

Thanks for any help.

Edit: Actually, I think I got it. Thanks again for all the help.

Edit 2: Would you happen to know what the variable would be for If Mobile Data off?
 
lol I know that part, but what would I have to select to create a new variable to use under the 'If' option (such as %SCREEN ~ off)?
Yeah, as I said before, tap on the right-most tab (Variables) and then tap on the green plus sign at the bottom. That will add a variable. Call it whatever you want. Assign it a value. Then it'll appear as an if option.
 

Attachments

  • tasker variables.png
    tasker variables.png
    33.3 KB · Views: 71
Yeah, as I said before, tap on the right-most tab (Variables) and then tap on the green plus sign at the bottom. That will add a variable. Call it whatever you want. Assign it a value. Then it'll appear as an if option.
Thanks for clearing that up. Isn't that only for placing a value with that variable though, like on or off? Would simply typing '%DATA ~ on' suffice under the 'If' option?
 
Once you create the variable, it should appear in the list of available variables for if statements. If it doesn't, you can just put in
Code:
%DATA
manually instead.
 
Once you create the variable, it should appear in the list of available variables for if statements. If it doesn't, you can just put in
Code:
%DATA
manually instead.
Okay, thanks a lot. Will the variable still work if I don't add it via the Variables tab?

And one last question, what is the purpose of the 'End If' task, and do I need to add one for every 'If' option I add? (e.g. If I choose the Mobile Data On task, then check the 'If' box and input a variable, would I have to add an 'End If' task at the end?)
 
Right, but for the value of that variable to accurately reflect the current state of mobile data, the value must be set as part if any task that manipulates mobile data.
 
This is my setup so far:


Screen off for 10 secs -- Wifi/Data off
iT7c3mw4J43HE.JPG




Screen turned on -- Wifi/Data turns on after 12 secs
iXMCG0mutM4un.JPG



I also have a profile that is simply
Code:
Context: Event - Display Unlocked
Task: Mobile Data On
That I setup to try and implement the "If possible, if I unlock the lock screen I would then like Data (3G) and Wifi to activate again right away (no 12 second wait)" part. This profile isn't really dependable (works on and off) for some reason.

Is there anything that should be changed, added or removed?

Note: I've switched over to the 1.0.12 version of Tasker (1.2u2 was not working on my phone for whatever reason).
Collision handling for all the above tasks is "Abort Existing Task".
 
I always use End If. I think it's just cleaner that way. Truthfully, I've never tried an If statement without ending it. Not sure if it'd create errors or not.

If you're going to set up a %DATA variable, you need to use it every time you turn mobile data on or off. So SET VARIABLE %DATA to off or SET VARIABLE %DATA to on.
 
While I was trying to figure out why this wouldn't work, I started to wonder if it made sense. Do you really want data turned on if the display is on but hasn't been unlocked? I think you can probably ignore the "display on" context completely. Doing so may make the "display unlocked" profile more reliable.
 
I always use End If. I think it's just cleaner that way. Truthfully, I've never tried an If statement without ending it. Not sure if it'd create errors or not.

If you're going to set up a %DATA variable, you need to use it every time you turn mobile data on or off. So SET VARIABLE %DATA to off or SET VARIABLE %DATA to on.
Would I have to add 2 'End If' tasks to the Screen Turned On profile, and 4 'End If' tasks at the end off the Screen Turned Off profile (the 4th task Wifi off also reads "If %SCREEN ~ off" on the bottom right like the others but it's been cut off)?


While I was trying to figure out why this wouldn't work, I started to wonder if it made sense. Do you really want data turned on if the display is on but hasn't been unlocked? I think you can probably ignore the "display on" context completely. Doing so may make the "display unlocked" profile more reliable.
I would prefer to have it, but if it's going to make Display Unlock only work 1/3 of the time, then I guess I'll have to get rid of it. Is there any way to keep both profiles working and functioning properly? I'm also using WidgetLocker for my lockscreen if that changes anything.

Edit: I did some more testing with the Display On and Display Unlocked profiles, and it seems that the WidgetLocker lockscreen tricks Tasker into thinking the screen is unlocked when it's not, causing the task to be executed without unlocking the screen.
 
Sorry. I read your tasks incorrectly. I think if the If statement is embedded with each task, then it's not necessary to have an End If.
 
Back
Top Bottom