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

tasker help

That basically what the wifi sleep policy does; it's just not instant on/of, and it will use 3g instead during the time wifi is off. Are you talking about turning off all data or just wifi? In any case, I'm sure you can do exactly what you're asking with tasker, but it might involve a couple of profiles. I can mess around with it later, and try to come up with something.
 
Upvote 0
State: wifi connected
Net -> Wifi -> set off IF %SCREEN off
Net ->Wifi -> set on IF %SCREEN on

you can do the same for mobile data if that's what you're after

edit: haven't tested or tried this, just off the top of my head

I think it's a little more complicated than that. It should turn off wifi when the screen goes off without an issue, but once that happens, the "wifi connected" context is no longer true. Once that happens, the "set on IF %SCREEN on" can never happen because wifi is no longer connected. I would try something like this:

Profile 1:
Context: Wifi connected
Task: Variable Set %WifiOn to 1
Exit Task: Variable subtract %WifiOn by 1

Profile 2:
Context: State->Varbiable Value %WifiOn = 1
Context: Event->Display Off
Task: Wifi off
Task: Variable Set %WifiDisplay = 1

Profile 3:
Context: State->Variable Value %WifiDisplay = 1
Context: Event->Dislpay On
Task: Wifi on

You may or may not need that third profile. Tasker will revert changes that it made when entering a profile once it exits the profile, but I'm not positive with the event context. Also, this might be possible with fewer profiles, but the concept is the same. EDIT - ignore this, it made sense with my original profiles before I edited it.

EDIT: wait, there might be a problem with this, let me go through it again.

EDIT2: Okay, revised it. It should do what you want, with one issue - If you are connected to wifi, turn the screen off, then leave wifi range, when you turn the screen back on, wifi will turn back on, and stay on. What you could do is add more tasks to the third profile that sleeps for a few seconds, then shuts off wifi if it can't connect.
 
Upvote 0
good point, you will need to create the extra variable (wifion)

the problem with the above one (i think) is that you need to implement a clear variable (for wifion) at some point, unless you always want to keep wifi 'on' in settings.

i would work on it too if i wasn't at work lol :)

I revised the profiles to something that should work.
 
Upvote 0
I think your solution is overly complex. Why don't you just do this?

Context:
1) Wifi Near (you can set specific parameters, or you can just leave them blank. If blank, ANY Wifi access point that is nearby will satisfy this criteria)
2) Variable %Screen = on

Task: Wifi On

Exit Task: Wifi Off



You can't use Wifi Connected, without an elaborate workaround, because when the screen turns off, the Wifi will turn off and Wifi Connected is no longer valid.
 
  • Like
Reactions: akazabam
Upvote 0
I think your solution is overly complex. Why don't you just do this?

Context:
1) Wifi Near (you can set specific parameters, or you can just leave them blank. If blank, ANY Wifi access point that is nearby will satisfy this criteria)
2) Variable %Screen = on

Task: Wifi On

Exit Task: Wifi Off



You can't use Wifi Connected, without an elaborate workaround, because when the screen turns off, the Wifi will turn off and Wifi Connected is no longer valid.

Yeah, that probably would work, actually. You'd have to set it up for polling instead of constantly on (since that would defeat the purpose). Typically, you set a polling frequency in the settings, but it *should* poll as soon as the screen turns on. That being the case, that should work. Keep in the mind, though that every time you turn the screen on, whether you're near wifi or not, it's going to poll wifi however often you set it to for every time you have the screen on. So, you should probably add a location context to this. The profiles I set up assume you're going to either turn wifi on/off yourself or you have some other tasker profiles set up for turning wifi/on off when you need them (ie location based). Go with this option first, for sure, since it's simpler. If it works, great. Stick with it.
 
Upvote 0
I actually use Wifi Near for all my contexts that need a location now. I ditched Network location because it doesn't work in areas where there is low signal and it's hard to get a location fix. GPS uses too much power.

I get good battery life using Wifi Near, set to poll every 10 minutes, at all times (no other contexts).

Anyway, the OP just said he wants Wifi on when the screen is on, and off when it's off. So, he technically doesn't need the Wifi Near context to do that. I just added it in to save his battery :)

I think this will be very battery friendly because, as you said, it should only poll whenever the screen is on, and only however X minutes are in the settings.
 
Upvote 0
I actually use Wifi Near for all my contexts that need a location now. I ditched Network location because it doesn't work in areas where there is low signal and it's hard to get a location fix. GPS uses too much power.

I get good battery life using Wifi Near, set to poll every 10 minutes, at all times (no other contexts).

Anyway, the OP just said he wants Wifi on when the screen is on, and off when it's off. So, he technically doesn't need the Wifi Near context to do that. I just added it in to save his battery :)

I think this will be very battery friendly because, as you said, it should only poll whenever the screen is on, and only however X minutes are in the settings.

I set my network location for 1km to turn on my wifi, so that by the time I pull into my driveway, wifi is on on the phone, and usually connected by the time I walk through the door.

Then I have set my home profile to keep wifi on as long as Wifi Near is active. Has worked well so far.

When I leave the 1km radius, wifi turns off. I tried to lower the 1km to about 500m, but that is too specific for the network, so 1km works well for me.

I used the Autoprofiles Tasker profile(s) from wikidot to do create the Wifi Near context for turning on Wifi and also doctored the corresponding profiles to suit my needs.
 
Upvote 0
I set my network location for 1km to turn on my wifi, so that by the time I pull into my driveway, wifi is on on the phone, and usually connected by the time I walk through the door.

Then I have set my home profile to keep wifi on as long as Wifi Near is active. Has worked well so far.

When I leave the 1km radius, wifi turns off. I tried to lower the 1km to about 500m, but that is too specific for the network, so 1km works well for me.

I used the Autoprofiles Tasker profile(s) from wikidot to do create the Wifi Near context for turning on Wifi and also doctored the corresponding profiles to suit my needs.

That's about what I do, except I have wifi polling set with wifi near so that wifi doesn't stay on the whole time I'm within the radius, but not at home.

Anyone setting up location-based contexts should read "Location Without Tears" on the Tasker site.

That doesn't seem to be available anymore. It works well enough as long as you use variables correctly.
 
Upvote 0
I've read the location without tears previously. I get it. I know what I'm doing in that regard.


The problem is that, at home, I find my phone sometimes fails to get a location lock (using Network location) due to some sort of issue with the signal.

So, I get home, it turns Wifi on. Then, while still at home, during one of Tasker's polling intervals, it fails to get a Network location.

This causes the profile to drop, and my Wifi to turn off, even though I am right next to my Wifi Router.

Yeah, there are ways to work around this using a variable, but deleting the location and using only Wifi Near is much simpler and cleaner.
 
Upvote 0

BEST TECH IN 2023

We've been tracking upcoming products and ranking the best tech since 2007. Thanks for trusting our opinion: we get rewarded through affiliate links that earn us a commission and we invite you to learn more about us.

Smartphones