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

Tasker if statements

lambed3

Lurker
Aug 23, 2010
2
0
I have been using tasker for a few days now in the trial period and I love it. It may be the best app I have used so far. I am getting a a point though where I am at my limit in terms of being able to get it to add additional conditions which primarily relate to if statements. I am hoping folks on this forum can help as I searched and did not see anything to guide me with my specific issues.

Problem #1. When I leave home zone, I turn on GPS which I want to put a condition in that says wait 30 minutes and if Navigation is not on, turn GPS off so as to save battery. Most times I will enter the work zone in that timeframe which will turn it off anyway but on the odd chance I am taking a 2 hour road trip and not using GPS, I don't want to kill the battery.

Problem #2. How can I use the profiles in the if statement? If not in home zone (circle on the map), do xyz or if not in home zone or work zone, do abc. Is this possible?

Problem #3. Can I get tasker to run a widget from the phone, not an app but an actual widget related to an app?

I have everything else working great but this fine tuning will make it work even better.

Thanks.
 
If statements in Tasker can't refer to contexts. You could simulate doing so by setting a variables:

Context: Location <home>
Enter Task: Variable Set %WHEREAMI = home
Exit Task: Variable Clear %WHEREAMI

Context: Location <work>
Enter Task: Variable Set %WHEREAMI = work
Exit Task: Variable Clear %WHEREAMI


And then in some task use an if statement like:

If $WHEREAMI Matches home/work


As for running a non-Tasker widget from a Tasker task... you might be able to do it using "intents" in Tasker, but I'm not sure (or even optimistic).

And for turning GPS off with a 30 minute delay after leaving home, you could use an exit task on your home profile, with a Wait followed by GPS Off, but you would need to set the task to keep the device awake in order for the task to complete as intended. This is because the Wait (as currently implemented) doesn't keep counting once the device goes to sleep. So in the long run it may be more battery efficient to just leave GPS on and let the device sleep.
 
Upvote 0
If statements in Tasker can't refer to contexts. You could simulate doing so by setting a variables:

Context: Location <home>
Enter Task: Variable Set %WHEREAMI = home
Exit Task: Variable Clear %WHEREAMI

Context: Location <work>
Enter Task: Variable Set %WHEREAMI = work
Exit Task: Variable Clear %WHEREAMI


And then in some task use an if statement like:

If $WHEREAMI Matches home/work


As for running a non-Tasker widget from a Tasker task... you might be able to do it using "intents" in Tasker, but I'm not sure (or even optimistic).

And for turning GPS off with a 30 minute delay after leaving home, you could use an exit task on your home profile, with a Wait followed by GPS Off, but you would need to set the task to keep the device awake in order for the task to complete as intended. This is because the Wait (as currently implemented) doesn't keep counting once the device goes to sleep. So in the long run it may be more battery efficient to just leave GPS on and let the device sleep.

I was just wondering this very thing today about using a profile as a context, thanks for this great explanation.
 
Upvote 0
Definitely late to this thread, but regarding the GPS, Map, navigation needs, this could be done pretty simply via the App context using the Secure Settings plug in. Just add the GPS apps you want to the context, then create a task using the Secure Settings plugin to enable GPS when the app is opened.

Adding an exit task, again using the Secure Settings plugin to turn GPS etc. off when exiting. Works great! No need for location or time contexts (apologies if this is already covered).
 
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