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

Help with Wi-Fi variables

Hello Everyone!

I just registered, and this is my first post. Please bear with me if I seem too much like the novice I am, and do not be afraid to correct me if you feel I've overstepped any boundaries.

I am trying to create a profile which enables mobile data when certain apps are run, but only when wi-fi is not available. The enabling mobile data is easy, setting the condition that wi-fi must be disconnected is the tricky part.
I am a total novice to Tasker, I've only created a few very simple power saving features, so I don't know anything about variables. However, googling has hinted to me that I might need to use them to accomplish this.

Is anyone willing to take the trouble of guiding me through how I would set up the "enable Mobile Data" action so that it skips the action if wi-fi is connected? I'm afraid I have only my gratitude to offer in return.
 
Wi-Fi can be on, but if you're not in range it doesn't help.

So it's better to substitute
%WIFII ~ *connect*
In place of %WIFI ~ on

Then the condition is only satisfied when Wi-Fi is on and connected.

Note the extra I is intentional...it's a different variable: wifi information
 
Last edited:
  • Like
Reactions: Thom
Upvote 0
so thanks for your effort, and sorry that I bothered you, I shouldn't have asked when I don't understand the answers at all
No worries. No harm to ask questions. Some people at some times enjoy being able to help or explain things. If people are too busy to answer, they won't. If they are interested in helping, they will.
Is anyone willing to take the trouble of guiding me through how I would set up the "enable Mobile Data" action so that it skips the action if wi-fi is connected?
Again, you simply have to test the condition %WIFII !~ *connect* to test if wifi is connected (don’t bother with testing %WIFI on or off in this case).

If you look at the contents of the Tasker built-in WIFI Information variable %WIFII while you are connected, then you will see it contains a lot of stuff including CONNECTION or something like that (it doesn’t contain that string when not connected).

The condition %WIFII !~ *connect* tests that used pattern matching operators….
~ means “matches”
!~ means “does not match”
The pattern can use wildcards like asterisk (*) to match anything.
If you use lowercase on the RHS of the matching operator, you don’t have to worry about what case the matched string is.
For more info, google: Tasker pattern matching

To add this logic your action might be done in three ways:
1 – as one (of several) contexts for your profile
2 – within the task, precede the action by IF… and follow it by end if
3 – in the action options, click the “+” next to IF and fill in the fields below it.

Option #3 is usually the simplest and I demonstrated it here:
https://drive.google.com/file/d/0B3ePa0Zibh6UWUpOY3FsTHVteEU/view?usp=sharing
At the linked video above, I created a profile that is active when chrome browser is active (application context)
It turns on data IF that condition (%WIFII !~ *connect*) is met (option 3 within action options)
Afterwards I turn wifi off, exit the task and go back in… you can see the sidebar has turned from red to green meaning the condition is met.


Application contexts can be tricky. Specifically, I don’t recall exactly how they work when an app goes to the background. I manage my own data pretty closely, but I don't use application profile. Instead I use a profile to simply turn data off when screen goes off (and stays off for awhile). The logic is shown in a video I created here (although the Tasker UI is an old version):
With the screen off / data off profile, you still have to manually turn data on when you need it (that’s not hard to remember because your content doesn’t show if you forget… I also have a handy widget to make it easy to get to). The good thing is you never have to worry about leaving it on... it will always turn itself off after the screen times out. For me that works out fine. I'm not discouraging you from pursuing your profile though... different things suit different people.
 
Last edited:
  • Like
Reactions: MadBigMadBoatMan
Upvote 0
Wow, electricpete, if Tasker isn't paying you, they damn well should be. My sincerest thanks for your informative and incredibly helpful reply.

What I meant previously, was that I probably should respect the knowledge base in here to the extent that I do some basic learning on my own before I start expecting people to teach me. And I have done now, although my focus has broadened a lot, to plugins/automation etc, so variables, although not entirely unfamiliar anymore, still hasn't been a focus area for me. So your post is much appreciated also on a strictly learning level.

I also use the screen profile, but I am creating a library of different profiles for battery control that work on their own (in addition to lots of other stuff), Partly for learning purposes, but I'm also the only one in the family interested in learning this (everybody wants to use it.t), so I'm planning to make the implement different parts of that library on my family's phones. We're talking a lot of devices.
 
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