How to Automate Your Home with Tasker

 

Introduction

 

Android enthusiasts have been tinkering with Tasker for years- and with good reason. Tasker is a versatile app that is capable of creating a personalized Android experience like no other. It’s described as a way to automate your phone, but when you consider the sheer amount of plugins available, it’s way more than just that. Tasker can use your phone’s apps, files, sensors, and network signals to automatically make your phone behave a certain way- adjust the volume, turn WiFi/Bluetooth/GPS on or off, control the screen brightness, etc. Plugins can extend this functionality, allowing you to use your phone to control other things too, like controlling your home’s lights . It works best with root, but there are a lot of things you can do without root too. None of my devices are rooted, and there’s still plenty I can do with Tasker.

This post is focused on how you can use Tasker on an unrooted Android phone or tablet to control your smart home devices using SmartThings. This will require two apps, Tasker ($2.99 Google Play Store) and a Tasker plugin called Sharp Tools (free to download from the Google Play store, but SmartThings integration will cost $2.49 – $3.49).

If you’ve never used Tasker before, it can be a little overwhelming at first. This post will offer an introduction to pseudo-programming using Tasker, and a step-by-step tutorial to integrate your SmartThings devices.

Before we get to that, we need to discuss what I’m trying to accomplish. I have a wireless charger for a Samsung S7 Edge that I use to charge my phone while I sleep. If my phone is on that particular charger, then I assume I’m going to bed. Thus, I should turn off all the lights in the house, turn off the TV, make sure doors are shut/locked, set my home security alarm, etc. Likewise, when I wake up, I want to turn on lights and unset my alarm. We’ll see how easy it is to use Tasker to do this.





Understanding Tasker

 

There are plenty of Tasker tutorials out there, such as Pocketable’s Tasker Beginner Tutorials . Basically, you need to create a profile based on a context. A context is a trigger that causes the profile to run. Profiles are made up of tasks. When all the tasks are completed, the profile is done running and it waits on the next trigger before it will run again.

Tasker allows the use of variables. There are two types of variables: system variables and user-created variables. System variables are things like battery level, display brightness, and bluetooth status. You cannot set a system variable, you can only read its value. However, system variables can be copied to user-created variables and manipulated that way.

All variables in Tasker are preceded by a % sign. System variables are in all caps, such as %BRIGHT for display brightness. You could also make a user-created variable called %Bright, but you might want to avoid reusing system variable names so you don’t get confused. Also, variables are case-sensitive, so %BRIGHT, %Bright, and %briGHT are all different variables. A variable in all lower-case, %bright, means the variable is a local variable visible only to the current task. In other words, it won’t be able to be used in another task.

By default, Tasker starts in “Beginner Mode”. Beginner mode makes Tasker easier to work with, but you will be prevented from using variables to change parameters. See below for a demonstration:


Slideshow- Tap or click to view

To change that, go to the main Tasker page and tap the menu icon in the top right. Tap on Preferences.

Uncheck Beginner Mode. Tap the back arrow in the upper left.

Now if we go back to the parameter we want to set, we’ll see a new icon. Tap it.

The slider and arrows will be replaced with a text box. You have two options: type in the name of the variable or tap the tag icon.

Tapping the tag icon brings up a list of all user-created variables, as well as all system variables.



Now that you have a feel for the basics of Tasker, let’s see how we can use it with SmartThings.

Using SharpTools with SmartThings

 

Although you can control individual devices using SharpTools, I’d recommend that you create routines in SmartThings instead. This is for simplicity, and things generally work a little better overall. In this example, I use two routines that I created called “Going To Bed!” and “I’m Awake!”. If you don’t the use default SmartThings routines of “Good Night!” and “Good Morning!” for anything else, you could use those just as well.


Slideshow- Tap or click to view

Next, tap Authorize Things.

Enter your SmartThings’ credentials and tap the Sign in button.

Choose the individual devices you want to use with Tasker. If no devices are selected, you will still have access to routines using the plugin.

Tap Authorize and you’re done with SharpTools.

You’ll see your list of devices on the Things page in SharpTools.



Creating With Tasker

 

Now that you have SharpTools set up, open up the Tasker app to get started. Here’s the gist of what we’ll be doing:

  • Wrap everything in an If statement that only allows the task to run between the hours of 10 p.m. – 2 a.m. (just in case I need to go to sleep earlier than normal).
  • Add the routine that we want using the SharpTools plugin.
  • Extra stuff that doesn’t relate to SmartThings, but is nice to have while sleeping- set the phone to Interrupt/Do Not Disturb mode and lower the screen brightness after capturing the current brightness level and saving it to a variable.

Slideshow- Tap or click to view

Next you’ll see some basic Tasker info about profiles and contexts, and some links to get you started using Tasker. Tap OK.

Tap the + button to add a profile.

Choose a context (trigger) to make this profile run. Select State.

Tap Power.

Tap Power again.

Choose the power source. We’ll use Wireless. Tap the back button in the upper left.

Now that we have a profile with a context set up, Tasker will prompt you to add a task. Tap New Task.

A text box will open up. Name your task then tap the check mark.

You’ll switch to the task page. Tap the + button.

Scroll down to Task and tap it.

Choose If.

Since I only want this profile to run when I go to bed at night, I am going to use a conditional statement based on the time of day using the %TIME system variable. Tap on the operator button.

Choose Maths: Greater Than.

Notice the time on the right is in 24-hr format with a period between the hours and minutes (22.00). Click the + icon.

You’ll see a logical AND connecting the two statements. Tap on it to change it.

We’ll change it to Or.

Change the operator to = and set the time to 22.00. These two statements are the equivalent of greater than or equal to 10 p.m.

Next we’ll set the rest of the times using a logical AND. So if the time is between 10 p.m. and 2 a.m., then allow the inner task to run. Tap the back button.

Now, tap the + button to add the next task step.

Choose Plugin.

And then SharpTools.

Select A Routine.

Tap the Configuration edit icon.

Choose your routine from the dropdown menu then tap Apply.

You’ll now see your routine show up under Configuration. Tap the back button to save the task step.

Tap the + button to add the next task. Although the next steps really aren’t needed for SmartThings, they come in handy when trying to sleep!

Scroll down to and select Task.

Tap Wait.

Set Seconds to 1. This will cause a 1 second delay to ensure the previous step is completed.

Tap the + button again.

This time choose Audio.

Select Interrupt Mode (on Android 5.0, Android 6.0+ you’ll see Do Not Disturb instead).

Use the dropdown menu to select None to silence all sounds (setting it to Alarms should be sufficient if you have Android 6.0+).

If you receive this notice you will need to give Tasker notification access. Tap OK.

Check the box next to Tasker.

Tap OK again.

Tasker now has notification access. Use the back button or Recent Apps to return to Tasker.

Tap the back button to save the task step.

Tap the + button to add the next task step.

Go ahead and add another Wait 1 second delay. Tap the + button.

Now tap Variables.

Tap Variable Set.

We’re going to save the system variable %BRIGHT to a user-created variable %OldDisplayBrightness. Tap the back arrow.

Press the + button.

Select Display.

Tap Auto Brightness.

Set Auto Brightness to Off. In the next step we will lower the screen brightness so we need to disable auto brightness.

Tap the + button to add the next step.

Choose Display again.

This time select Display Brightness.

Set the Level to 0. Tap the back button.

Tasker will alert you that auto brightness is enabled. We took care of that problem already. Tap OK.

Tap the + button again.

Scroll down to Task and select it.

Tap End If.

That’s it. Here’s the complete task. Tap the back button to save it.

Press and hold the task listed in the profile. A menu should pop up. Tap Add Exit Task.

Give the exit task a name then tap the check mark.

I won’t be going through each step since they are similar to everything we just did. I added a Wait 10 seconds here to give me time to unlock my phone after I wake up.

Next set your routine using the SharpTools plugin.

Turn Interrupt Mode or Do Not Disturb off by setting it to All.

Next we’ll set the display brightness to what we captured in the variable %OldDisplayBrightness.

Finally we’ll turn auto brightness back on.

Tap the back button to save the exit task.

If you ever decide that you want to temporarily disable a profile, just use the switch to turn it off.







Conclusion

 

Tasker is a very useful, very powerful Android app that can be used in the home automation sphere. It’s just plain fun to mess around with, too. Combined with the SharpTools plugin, you can use it to activate a variety of smart home devices based on conditions unique to your phone. Tasker isn’t just for home automation either. One of the more frequent profiles I run with Tasker automatically lowers my phone’s volume when I play a game. It’s simple but effective!

Related topics:


 

About Adam Bollmeyer

I'm a home technology enthusiast with a penchant for home automation, networking, and computers. My goal is to help others improve their knowledge of how available technology can be used at home.