- Use Tasker to disable WiFi if not connected
- 2 Answers 2
- step 1
- step 2
- step 3
- Related
- Hot Network Questions
- Subscribe to RSS
- WiFi sharing with Tasker
- Tasker: If variable — not connected to Wifi
- 1 Answer 1
- If wifi on tasker
- Can I program Tasker-like programs to do stuff if specific WiFi network is in range?
- 2 Answers 2
Use Tasker to disable WiFi if not connected
I want to use Tasker to turn WiFi OFF IF it is not connected to my home network. How can I do that with a variable? Thanks.
2 Answers 2
Is there any particular reason you need to use variable for that? This can be easily achieved without variables.
step 1
set a profile with a State -> Net -> Wifi connected
in a task add action set variable name it wifiConnected and set it to «yes» or «true» or whatever you want, but keep in mind that variable name must contain at least one capital letter, to be public (be visible in all tasks)
step 2
set a second profile with a State -> Net -> Wifi connected but this time select option invert (so the profile will become active, when wifi disconnected)
in a task use set variable and set it’s value to «no» or «false» or whatever you want
step 3
create profile with a state -> variables -> variable value
in the left field type in variable name wifiConnected
in the right one type «no» or «false» or whatever you set it to on disconnecting
as a task for this profile use net -> WiFi -> Off
I’d really suggest you on reading some more about Tasker and how it works, as such things are the very basics
to do the same without setting variable, just do a profile from step 2, but instead of setting variable, use task from step 3, to disable wifi
Sorry, but I think what you wrote above does what it’s supposed to do only the first time, then it needs something to trigger it automatically like a builtin variable or so. in my opinion that doesn’t work as intended. no offence 🙂 Well, you will need something that will trigger the task for the first time, it’s about the task that verifies what’s the wificonnected’s value. If it is «no», that means you don’t have any SSIDs to connect to.You will add a wait task, let’s say 2 minutes and net-wifi-off, because you will want to disable wifi if, after a specific period of time when your phone wasn’t able to connect to any network. But, you will want something continuous, in loop so you will have to add a task/goto action, like this! Let’s say you have this action: A1: task/wait-2 minutes A2: if %wifiConnected ~no then set WIFI off goto A2 This way you’ll phone will scan for %wifiConnected’s value, continuously. As an alternative, you may cancel that loop once your wifi has already set to off because you don’t need that value anymore. I mean, your screen on-> task activated->elapsed 2 minutes-> no ssids to connect to-> wifi off Then, you manually or not necessarly turn your wifi back on, but the task won’t be triggered anymore because the screen is already on, this is why you will have to use that goto action 🙂 Or, you could go and disable/enable tasker such that your task( that checks for wifiConnected’s value) being triggered again :). hope that helped. my profile works like smooth 🙂
Related
Hot Network Questions
Subscribe to RSS
To subscribe to this RSS feed, copy and paste this URL into your RSS reader.
Site design / logo © 2023 Stack Exchange Inc; user contributions licensed under CC BY-SA . rev 2023.7.14.43533
By clicking “Accept all cookies”, you agree Stack Exchange can store cookies on your device and disclose information in accordance with our Cookie Policy.
WiFi sharing with Tasker
Here is short manual how to automatically enable WiFi sharing when connecting to your WLAN, using Tasker app.
Download and install Tasker, and start it.
Switch to Tasks tab, you need to create two tasks there, one for WiFi sharing on, other for off.
For this, click the + button at bottom, type a name (such as “WiFi sharing on”) and confirm. Then click + to add an Action, and choose System, then Send Intent. In following screen, fill these fields:
Click back button, the action will be saved and you’re back in Task Edit screen. At this point, you can test the action by clicking launch arrow at bottom left. If written correctly, X-plore’s WiFi sharing should become enabled.
Now go back to Tasks, and repeat steps above to create task for disabling WiFi sharing, except for Action you will write “off” instead of “on”. You can also use copy/paste to copy the “Send Intent” item to save some typing.
Again you can test the task to check if X-plore’s WiFi sharing will be disabled.
Now that you have both On/Off tasks created, switch to the Profiles tab in Tasker. You have to create condition when those tasks will be run.
Click + at bottom of screen, and select State, then select Net, and WiFi Connected. Now setup desired parameters, mostly you may want to setup SSID, which you can select from a list by clicking on Search button. But you may also protect it with MAC so that it really works only on your WLAN. Finally click back button, and the action will be saved.
Now pick task to be run when WiFi network connects, this would be your “WiFi sharing on” task you created.
To add the “off” task, long-click on right side of the action where you see the “on” task, and from popup menu choose Add Exit Task, and pick your defined “WiFi sharing off” task.
If all done correctly, you can test it all by enabling/disabling WiFi on device, or switching WLAN on/off. X-plore’s WiFi sharing should be enabled/disabled automatically.
Following are few screenshots from Tasker to show the results.
Tasker: If variable — not connected to Wifi
I want my display brightness only to rise if not connected to any Wifi network (doesn’t mean Wifi has to be turned off) but I can’t figure out how exactly the Wifi variables work. The official documentation is very general and technical. Edit: The problem is that my Wifi is instable which means Android doesn’t have Wifi for about 2-3 seconds and then catches it back. So I added a 5 seconds Wait Action so that my display brightness doesn’t change every 15 minutes but it happens anyway, only now 5 seconds later. I think to finally make it work a «If variable» is necessary.
1 Answer 1
You’re going about this the wrong way.
Go to Profiles → (New profile) → State → Net → Wifi Connected. Leave SSID blank and tick «Invert». Link this profile to a task which changes brightness.
Edit — Okay, I think I’ve found the solution. In the task which changes brightness, do this:
Explanation: The %WIFII (WiFi info) variable not only gives the name of the WiFi that you are connected to, but also miscellanous information such as Mac and IP address and contains the phrase «>>> CONNECTED >> SCAN
- Waits for 5 seconds (adjust accordingly!)
- Checks if the %WIFII variable contains the word «SCAN» by means of a regular expression
- If it contains «SCAN» it means that the device is NOT connected to a specific WiFi (if was connected, it would have the word «CONNECTED» in it).
- Increases brightness accordingly
Note: Might cause problems if there are WiFis with the word «SCAN» in them! You can always change the if condition to something else such as if %WIFII (doesn’t match regex) \bCONNECTION\b , or make it more specific for the phrase «>>> SCAN
If wifi on tasker
So you want to use Tasker to control your device’s Wifi or Bluetooth status? Via on/off or toggle?
Well for many years — that was as simple as using Tasker’s built-in Wifi or Bluetooth Actions. However Google, in its infinite wisdom, has since put up roadblocks to those features, so Tasker can’t do it natively anymore.
But despair not! There is a solution. It’s an app named «Tasker Settings». And yes it’s created by Joao, but it can’t be on the Play Store because it targets an older version of the Android API and a bunch of other technical stuff. (More technical details at the bottom of this post.)
Anyways, to keep the ability for Tasker to control Wifi and Bluetooth go here to Joao’s Github and you can read all about the techinical details, and of course find the direct link to download the «Tasker Settings» apk in there as well.
(UPDATE — 05/2023 — the Tasker Settings app is now required for Tasker to be able to toggle Bluetooth on most devices in addition to Wifi)
THE MOST IMPORTANT STEP to get this working though is after you download the «Tasker Settings» apk and install it — go to your device’s settings for «Battery Optimization» and exempt «Tasker Settings» (not just Tasker) from optimization.
Notice in this image that both sliders are in the off position in regards to optimization. Also you may want to check out this website for additional device-specific optimization tips.
(UPDATE — 06/2022 — On some devices (in this case Samsung) the battery optimization setting is now found in each app’s individual details screen in your device’s «Apps» settings. So to configure this — go into the main «Apps» settings on your device, choose «Tasker Settings» from the list of all your apps, then click «Battery» , and choose «Unrestricted» from the list.)
This «exempting battery optimization» step will allow it to function all the time, so you can now toggle Wifi and Bluetooth all you want again with Tasker, just like the good old days!
TLDR Version: Want to toggle Wifi and/or Bluetooth using Tasker again? Go here and download and install this .
Tell me again — why can’t Tasker do this natively anymore — more details: Newer apps on the Play Store have to target at least API 29 ( check here to learn what «targetting» an API means) which is what made Tasker not able to toggle Wifi anymore. Apps that target a lower API level can still do it, and that’s why the Tasker Settings app (along with other non-updated plugins) still work to perform this function.
What other features and functions does this «Tasker Settings» app enable? — The app assists the main Tasker app in all of the following:
● Change any non-public System Setting with the native «Custom Setting» action
● Toggle Camera
● Toggle Wifi
● Toggle Bluetooth
● Execute the «Display Size» action
Can I program Tasker-like programs to do stuff if specific WiFi network is in range?
I’d like to try out Tasker, Llama or some such automated program. However, I do NOT want to program events based on GPS or other location information (for a variety of reasons not germane to this question). Is there a way to trigger tasks in Tasker or some equivalent program based on the fact that a WiFi network with a specific SSID (or other signature) is in range or goes out of range? To clarify: one of the main tasks is to turn on/off my WiFi when I float in/out of the range of known networks. Therefore, merely being in range should be the trigger, NOT connected to the network.
2 Answers 2
- In Tasker create a new State based context and choose Net as state category.
- Then choose Wifi Near as net action:
This will bring a screen where you can input data about the WiFi access point you are interested in. If you are near the desired WiFi access point then you could just press the scan button (the button with lens symbol at left end of the text SSID ).
This scans the near by access points and lists its details. Simply select the one which you are interested in. Now you are good to go to add an entry task and exit task to whatever you want.