Living Outside The Box Born-Again Techo-Geek Renaissance Man


Tasker And Flowcharts

In my quest to simplify, I've ventured into the territory of Information Automation. Since I discovered the app  Tasker, I've challenged myself to find new ways to exploit it to automate tasks that I really shouldn't be wasting time on.

Tasker basically is an automation programming language for your Android device. It allows you to take any number of trigger inputs (GPS position, battery state, apps, network status, emails, RSS feeds, etc.) and then perform any series of tasks you program it to. It has the capability to be a full-fledged programming language, with conditional logic, variables, and so on, which lets you make some incredibly complex "tasks" for it to run.

It also has the capability of using almost anything your device can do as an "action" or output, which means you can automate just about anything your phone/tablet can do. Take pictures, play audio, send texts, run programs, share to social media, control the device's functions, or even speak and listen to voice commands.

So, sometimes I geek out on stuff like flowcharts and such, and programming is the perfect place for it. Flowcharts! Graphs! Logic! Here's how it works.


I'm using Dia, an open-source flowchart program (similar to Microsoft Visio). Yes, this is the portable Windows version (I'm also a huge fan of Portable Apps, which lets you install self-contained software to a thumb drive and carry it with you, useful for work or public computers). Dia is also free and available for Linux and OSX.

So for us to come up with more complex tasks for Tasker to do, we're going to want to use some sort of way to keep track of what's happening. We can also use user-made variable to do workflow, as they're faster than polling stuff every time we need to know something.

Let's say I'm working on correcting my sleep deprivation, and I want to use a program like SleepBot to track how many hours I sleep, and how well I'm sleeping. SleepBot has Tasker integration, which means you can use Tasker to start and stop the sleep timer. I pretty much only sleep in my bed, and I also usually plug my tablet in to charge there. So those are two conditions I know I can start with. It will look something like this:


When I plug the tablet in, it runs a task I'll call "Plug" and when I unplug it, it runs a task called (amazingly enough) "Unplug". Now we create an empty task, so we can start filling it with commands. I don't always sleep when I plug my tablet in, so I do want to add some conditions to it. And what if I decide to charge my tablet somewhere besides my bedroom? I'll add a simple and fun way to choose whether or not I'm going to sleep.

Misc -> Say

This makes the tablet speak (using TTS) anything you type in the blank. So the first thing it will do is say "Do you want to sleep?" I also have to be sure it's audible, I might have the volume turned up or down, so I make a command before that sets the speaker volume to about 4. So now we have this:

Now we have to make the actual work. We want Tasker to listen and do different tasks based on what I said. We use the "Input -> Get Voice" function, and anything you say to it gets returned as the variable %VOICE. Now we make an IF/THEN statement.

IF %VOICE = *yes*


(The "THEN" is assumed) Anything we put in between these will _only_ be done if you say something containing the word "yes." Pretty slick! So what do we want to accomplish? First, we'll open the SleepBot app. Then we'll wait a few seconds for it to load, and then we'll "punch in" to start recording sleep. We don't want other things disturbing me while I sleep, so we'll also set the notification volume to zero.

What if I'm taking a nap in the afternoon, and I want to put some music on to drown out household noises? Hmm.... Tasker can do that easily. We'll add another IF loop _inside_ the existing one. Like so:

IF %TIME < 21.00
App -> Pandora

Tasker stores the current time in a human-readable decimal, so 21.00 is 9:00 PM. This allows you to use simple math functions with time, like Less Than. Now, if it's before 9:00 PM, Tasker loads Pandora, which begins playing automatically. I can also add a timer to shut Pandora off after a set time, too.

We add in a few things, and our flowchart looks like this:


Making this is Tasker looks like this: (click on the pic to enlarge)


We're not quite done. We still have to make an "Exit Task" to run when I *unplug* the tablet, that kills Pandora (if it's running) and punches out on SleepBot. But what if I'm not sleeping when I unplug it? I don't want it to do anything unless I'm actually waking up, so we'll add a few variables to our SleepBot task to help our flow.

You may have noticed I added a "Set Variable" command in our original IF loop, so that we'll know it's active outside the task.

SET Variable %SLEEPING = true

Now when we make our Exit task, it will look like this:

SleepBot - punch out
Kill App - SleepBot
Kill App - Pandora

By now, you get the idea. The cool think about Tasker is that it has practically no limitations. When you start using third-party plugins to extend its capabilities, Tasker truly becomes an automation do-it-all tool.

Posted by Jeff Hendricks

Comments (0) Trackbacks (0)

No comments yet.

Leave a Reply

No trackbacks yet.