1. Check out our app, Forums for Android! Download and leave feedback here!

tasker help

Discussion in 'Android Apps & Games' started by opflame, Dec 5, 2010.

  1. opflame

    opflame Member
    Thread Starter
    15

    Nov 20, 2010
    24
    0
    15
    Canada
    Hi im hoping someone whose a tasker expert can help me out.

    When wifi is enabled, want to try to get tasker to turn off wifi when the screen turns off and turns it back on when you turn the screen back on. But ignores the setting when wifi is disabled
     

    Advertisement

  2. Xyro

    Xyro 4 8 15 16 23 42
    Moderator
    1,413

    Dec 1, 2009
    12,847
    9,129
    1,413
    UK
    How about using tasker to make a wifi toggle button? Then you could have Screen on and Wifi Toggle widget on as contexts to turn it on.
     
  3. akazabam

    akazabam Well-Known Member
    313

    Jun 7, 2010
    4,418
    1,387
    313
    Near Los Angeles
    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.
     
  4. lifeonmtv

    lifeonmtv Well-Known Member
    43

    Jun 5, 2010
    256
    49
    43
    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
     
  5. akazabam

    akazabam Well-Known Member
    313

    Jun 7, 2010
    4,418
    1,387
    313
    Near Los Angeles
    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.
     
  6. lifeonmtv

    lifeonmtv Well-Known Member
    43

    Jun 5, 2010
    256
    49
    43
    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 :)
     
  7. akazabam

    akazabam Well-Known Member
    313

    Jun 7, 2010
    4,418
    1,387
    313
    Near Los Angeles
    I revised the profiles to something that should work.
     
  8. amlothi

    amlothi Well-Known Member
    143

    Jul 23, 2010
    1,185
    201
    143
    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.
     
    akazabam likes this.
  9. akazabam

    akazabam Well-Known Member
    313

    Jun 7, 2010
    4,418
    1,387
    313
    Near Los Angeles
    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.
     
  10. amlothi

    amlothi Well-Known Member
    143

    Jul 23, 2010
    1,185
    201
    143
    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.
     
  11. BookLover

    BookLover Well-Known Member
    113

    Oct 11, 2010
    977
    114
    113
    USA
    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.
     
  12. takeshi

    takeshi Well-Known Member
    163

    Dec 6, 2009
    3,354
    282
    163
    Anyone setting up location-based contexts should read "Location Without Tears" on the Tasker site.
     
  13. akazabam

    akazabam Well-Known Member
    313

    Jun 7, 2010
    4,418
    1,387
    313
    Near Los Angeles
    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.

    That doesn't seem to be available anymore. It works well enough as long as you use variables correctly.
     
  14. amlothi

    amlothi Well-Known Member
    143

    Jul 23, 2010
    1,185
    201
    143
    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.
     

Share This Page

Loading...