Tasker if statements

Last Updated:

  1. lambed3

    lambed3 New Member

    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.


  2. UncleMike

    UncleMike Well-Known Member

    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.
    lambed3 and chrlswltrs like this.
  3. lambed3

    lambed3 New Member

    thanks. Very helpful.
  4. chrlswltrs

    chrlswltrs Well-Known Member

    I was just wondering this very thing today about using a profile as a context, thanks for this great explanation.
  5. BobMan

    BobMan New Member

    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).

Share This Page