Automating your world with Tasker

The best part of Android is the ability to make it do exactly what you want it to do, rather than what someone else thinks you want it to do.  Android by itself does a pretty good job of allowing customization, but to accomplish complete customization and automation of your mobile world, we’re going to need a little bit of help.  Enter Tasker, a handy little app filled with triggers and actions to allow you to perform almost any task when almost anything happens.

Imagine the possibilities:

  1. You walk into the office:
    1. Your phone instantly switches to vibrate.
    2. Your Google Talk status changes to invisible (or busy).
    3. Your phone’s Tasker state is set to “Work”, so:
      1. Your out of office response is turned off.
      2. Your Google Talk status is changed to busy.
      3. You enter a meeting:
        1. Your phone switches from vibrate to silent.
        2. Any incoming text messages are replied to indicating you’re in a meeting.
  2. You leave the office:
    1. Your phone sounds return to normal.
    2. Any incoming e-mails from clients receive a generic out of office response.
    3. Your Google Talk status is changed to available.
    4. Your wife receives a text message indicating that you’re on your way home.
  3. You get in the car:
    1. GPS is turned on and you’re signed into Latitude
    2. Your favorite music begins playing over your car’s bluetooth
    3. Incoming text messages or emails pause your music, are read aloud, then music resumes.
  4. You get home:
    1. Your phone turns on WiFi and connects to your home network
    2. Your phone’s tasker state is set to “Home”, so …. the possibilities are endless.
  5. You go to bed:
    1. Your phone mutes all sounds
    2. The notification LED is turned off
    3. If someone calls, they receive a text message back indicating that you are sleeping, but if there is an emergency, they are instructed to simply call right back.
    4. If the same number calls back, all sounds are unmuted and the phone rings.

Too good to be true? It’s not. All of this and almost everything imaginable is possible with the help of Tasker. However, because Tasker is so powerful, it also has a pretty steep learning curve.  In this article, I will walk through the process of creating a few simple profiles to help begin the process of learning how to take advantage of this powerful tool.

Terminology

Tasker uses many different terms to describe different things.  The following is a list of terms and a basic description of what is is or what is does.

  1. Profiles – a profile is the main part of a tasker configuration.  The profile contains the “Contexts” (event, state, etc) which trigger an action, and the associated actions that should occur.  Profiles can be nameless, however I generally name all of my profiles to keep things organized.
  2. Context – the trigger of a profile.  This could be:
    1. Application – an application (one or more) is launched
    2. Time – a single time of day or a range from->to
    3. Day – a single day, or a day of the week, month, year, etc.
    4. Location – a GPS location (within X distance of this location)
    5. State – state of the device (wifi connected for example)
    6. Event – Some sort of event that occurred (the phone ringing for example)
  3. Task – a set of actions to perform.  Tasks can be triggered by a profile or another task.  Tasks can be nameless, but this affects how you can use them:
    1. A named task can be referred from multiple profiles, or can be executed from a different task
    2. An unnamed task can only be executed from the profile where it is defined.  This option is nice, however, if you only need this task for a single profile, if you don’t name it, then it won’t clutter up your “Task Selection” list.
  4. Action – something to do (turn on silent mode for example)
  5. Variable – stores information based on the current state of the device.  All variables start with “%”, for example:  %WIFII  is the variable for “Wifi Info”.  There are two types of variables:
    1. User variables – variables defined in a task by you.  In our example below, %HOME and %WORK are user variables.
    2. System variables – variables defined and maintained by Tasker.  %WIFII is a system variable.  When connected to Wifi, this variable will contain information about the network.  See the full System Variable list in the Tasker documentation.

Profiles

Profiles make up the meat of Tasker automation.  A profile is a set of Contexts (criteria) that when met will perform a task.  Profiles can consist of one context or a combination of multiple contexts that all have to be met before the task will occur.  In order to do anything with Tasker, you first must have the profile that should trigger the task.  Lets start by making a simple profile.

To create a profile, open Tasker.  Then we’ll need to turn off “Beginner Mode”:

  1. Menu -> Preferences
  2. In the UI tab, uncheck “Beginner Mode”
  3. Snoop around and set any other preferences to your liking.
  4. Touch the green checkbox

Now you may continue by following the sequence of events in the screenshots below.  We’ll go through an example of creating a profile to detect whether you’re at work or at home based on wifi connectivity.  A description of each step is below the image.

Part #1:

Tasker profile - Where am I - 1

Details:

  1. First, if you don’t have the tabs available on top, place your finger at the top of the screen and drag down.  This will enable display of a tabbed view of your profiles which will ease in organization of them as you build or import more.
  2. To create your first profile, click “+”.  It will prompt you for a profile name.  In this example, we’re going to create a profile named “Where am I?”, so enter the profile name in the box and click the green check.
  3. Next is the “Context” selection that will trigger our action.  Since we’re building on wifi connectivity, choose “State”
  4. Next are the different categories of contexts for “State”.  Choose “Net” for networking related State contexts.
  5. Choose “Wifi Connected” context
  6. In the wifi connected context, there is configuration that will cause it only to fire under certain circumstances like:
    1. Only when connected to “X” wifi name (SSID)
    2. Only when a device with “X” MAC address connects
    3. Only when the IP provided by the wifi network is “X”
    4. In our case, however, we simply want to execute when any network is connected, so leave everything empty and click the green checkmark.
  7. Next you will be prompted for the task to execute when this context is triggered.  Choose “New Task”
  8. Decide whether or not to name this task.  For the purpose of this profile, this task can probably be unnamed (as I don’t know why it would be called from anywhere else), so you can leave the name blank and click the green checkmark.
  9. Now we need to set the actions that occur as part of this task, click the “+” to add the first action to this task.

Part #2:

Tasker profile - Where am I - 2

Details:

  1. Select action category “Task” which contains control flow items for a task like “IF”, “ELSE”, “STOP”, etc.
  2. Choose “IF” for a conditional block
  3. Configure the IF.
    1. Choose the comparison to use, in this case “~” which performs a “LIKE” or “Contains” operation where wild cards (in Tasker’s case, *) can be used.
    2. In the compare-to box (on the right) type in “*<your network ID>*” without the quotes.  Example:  *My network*
    3. Select the little label-looking icon for a list of available variables to compare against, see next image.
  4. Scroll in the variable list to “Wifi Info” which provides information about the connected wifi network.
  5. Continue adding actions to create one or more if/else blocks.
    1. “Variable Set” is available under the “Variable” action category
    2. Make up meaningful names for the variables you create here.  For example, I used %HOME and %WORK (values of 0 or 1 to indicate whether I’m one place or the other)
    3. Long-clicking on an action in the task allows you to insert an action above, or to cut an existing action to paste it somewhere else or delete it.
    4. When complete in creating your task, click the green checkmark.
  6. Now you should see your profile and the associated task.
    1. If you didn’t name your task, you will see the beginning few actions of your task summarized where the name shows up in my screenshot.
    2. Now we want to add an “Exit task” which is another task that is executed when the profile’s context is no longer active (IE – you’re no longer connected to wifi).  Long-press on the task box where I’ve marked the red box.
  7. Choose “Add Exit Task” from this menu item.  You can also name an unnamed task here, select a different task, etc.
  8. Create the exit task, probably unnamed again.
    1. Use my example to create the actions for the task.
    2. The purpose of the “Wait” step is to pause the task execution in case your wifi temporarily dropped but is reconnected again within 5 minutes.
    3. The “Stop” will stop execution of this task IF wifi is connected again.
      1. Done by checking the “IF” option in the “Stop” action, then doing: %WIFII ~ *CONNECTION*
  9. The resulting profile “Where am I?” will now set the variables %HOME and %WORK to 1 or 0 based on whether or not you’re at home or work.
    1. You can now trigger new profiles based on the variable %HOME or %WORK being set:  Event -> Variable -> Variable Set context.  Then a task something like:
      1. IF %WORK = 1
        1. Audio -> Silent Mode -> Vibrate
      2. ELSE
        1. Audio -> Silent Mode -> Off
      3. End If
    2. You could also perform actions inside the begin #14 and end #17 tasks instead of setting variables.  However, I find that triggering on the variables is nicer, because the variables can be checked from multiple profiles and/or tasks to give you ultimate control over how things act based on your location.

Tasks

By choosing the “Tasks” tab, you can create and manage your existing tasks.  These tasks can be called from a profile or from other tasks.  Named tasks will show up here and in task selection lists, unnamed tasks will only show in the profile in which they were created.

Variables

User variable values can be monitored by the “Variables” tab.  Any variables related to profiles in your current tab will be listed, and their currently assigned values will be displayed.  System variables (those provided by Tasker itself) are not shown here, only variables created by you.

Conclusion

Hopefully this article has been helpful in giving you a very basic understanding of how Tasker works and how to create a basic profile.

I will periodically share additional profiles I have created, or have found by others.  In future articles, I will share the exported XML for the profile to allow you to easily import the profile (and related tasks) into your Tasker.