Jump to content

- - - - -

Controlling Your Home Automation Controller with Tasker

Android Remote

NOTE: This tutorial/project is extremely simple to do.  Since I took the time to explain and detail all the steps, the tutorial looks much longer than it really is.  If you are technical minded, you will be able to do all of this in just a few minutes, and if you need help, just post in the comments.
Whenever you ask about the must-have apps for Android, Tasker is a name which appears frequently on this list (and I do highly recommend it myself).  Tasker allows you to automate every aspect of your Android device, such as your phone or tablet, making it easy to turn on/off features of your device based on conditions and variables.
  • Turn WiFi of when you arrive at home.
  • remind you every 60 seconds that you missed an important call, while turning the ringer volume up every time it reminds you.
  • Save your battery by turning the screen brightness down at night (or whenever you put your house into night mode, tutorial coming soon!)
  • Automatically back up your phone when connected to your home network
  • Announce SMS/E-mail messages using TTS when driving.
  • Start music playback as soon as you get into your car.
Now that Tasker has repeatedly been mentioned in a home automation context, I thought it was time to create a simple tutorial showing how you can create a widget to execute a simple automation task, or turn on/off a device such as your lights, using the built-in web server of your home automation controller.
Tasker can emulate a web browser in order to retrieve data.  This is the feature we will be using for this tutorial.  I will show you how you can figure out the correct commands you have to send, in case you have a home automation controller with an undocumented web server, or are trying to do something which no one else has tried before.
There are 3 major steps to this process:
  • Learn: We need to figure out what command is sent whenever we click that 'on' button when accessing the home automation controller webserver.
  • Create: We need to create a task in Tasker, and link it to a widget, using the data we learned in step 1.
  • Execute: We now should be able to control the light/event/task by pushing the Widget installed on your Android desktop.
  • A home automation controller with web services enabled (such as HomeSeer, CQC, Vera, etc.).
  • Tasker.  I'm going to assume you are already familiar with this app, if you aren't, feel free to ask for more help in the comments section, or use your favorite search engine to find the many Tasker tutorials.  There is a trial version, and the screenshots should offer plenty of assistance with helping you start from scratch.
  • Access to the network which is running the web server.  Do NOT expose your home automation server to the internet, especially for this tutorial.  I will create another guide soon, covering multiple ways of securely controlling your setup while not at home.
  • If possible, create a separate account for use with Tasker only.  This makes it easier to kill remote access should the account become compromised, and might help with troubleshooting any problems.
In order to figure out what URL & data is sent whenever you activate a light/task via your home automation web server, we need to monitor these requests coming from your browser.  But before that, I need to quickly explain (in a simplified way) the types of requests your browser sends to a web server.  There are 2 types/methods, and in this example, let's assume we are trying to control a light with an ID # of 4, and we are trying to turn it on.  The URL is the string found in the address bar of your browser.
  • GET: The browser sends any variables as part of the URL.
    Example: http ://
    This is a fictional example which controls a light with ID # 4, and turns it on.  Extremely simple, and if this is how your home automation system works, simply save the URL you see once you click the on/off button, and you can move on to the next step.
  • POST: The browser sends the variables in the background.
    Example: http ://
    As you can tell, the variables are not visible to the casual observer.  A POST command is a little bit more secure, because your browser caches URLs (and appended variables).  This is also the reason that almost every site relies on POST for authentication, so your credentials won't be exposed via the browser history, or proxy servers logging URLs.  Imagine if your bank used ://my.bankurl.com/givememoney.php?user=john&pass=foobar. This would obviously get ugly really fast.  POST requests are also not cached, and aren't restricted in length, while the length of a URL (GET) is limited.
Like I said, this is an extremely simplified way of explaining things, but if you are interested in the details, check out the W3Schools.com article or this Wikipedia entry.

If your web server relies on GET for control, just note the URL and proceed to the next step.  If your web server uses POST, then we need to install a tool which can display the variables we are sending to the web server whenever we activate a light/task.
To make this process easy, I recommend you install Fiddler, which is a web debugging proxy, and should work with your preferred browser.  There are other tools, such as Tamper DataFirebug & Live HTTP Headers for FireFox, or Chrome's internal Developer Tools (use F12 to activate).  In order to keep this tutorial browser-agnostic and simple, I will be using Fiddler to capture the POST data, and HomeSeer as my home automation controller, but the concept is the same for any other home automation controller.
Start up the Fiddler software, wait for it to finish loading, and proceed with activating a task/device via the web interface.
Fiddler logs all data your web browser sends out and receives, so you should be able to catch the POST data, including the required variables.  Just pay attention to the URL you see in your browser's address bar, and look for the server address and path in the Fiddler window (Inspectors > WebForms tab).
The screenshots below show the data transmitted when I issued the ON command, an OFF command, and when I executed an event via the HomeSeer web server.
Attached Image: tasker-automation-tutorial-device-on.png Attached Image: tasker-automation-tutorial-device-off.png Attached Image: tasker-automation-tutorial-execute-event.png
Once you have this data, you can move on to the next step, where we will create a Tasker task & widget.  If you have problems with this step, don't hesitate to post in the comments below.
Note: The Rover plugin for Homeseer uses the GET method, so if you want to skip the 'difficult' part, just point your Tasker widget to the Rover plugin instead.
It's now time to create the Tasker task & widget.  Let's start with the task, as the widget is just a shortcut which points to this task.
  • Select the 'Tasks' tab on your Tasker screen.
  • Add a task by clicking the green + symbol.
  • Enter a name.  Keep in mind that this is the name which will appear under the icon on your Android home screen.  For this tutorial, I am entering 'LightOn'.
  • You should now be in the Action screen.
  • Since a widget requires an icon, let's select an icon for this task by clicking the last button at the bottm, next to the 'tools icon', and above the icon with the play button. 
  • We now have to add an action to this task.  Select the button with the blue plus symbol.
  • We are looking for the HTTP Get or HTTP Post action, which can be found in the 'Net' category.
  • If your home automation controller uses GET, then select HTTP Get, otherwise, select HTTP Post.  For this tutorial, I am selecting HTTP Post, but I will include an HTTP Get example in the screenshots.
  • You should now be seeing the screen which allows you to configure the HTTP Post parameters.
  • Under 'Server:Port', specify the credentials and IP address of your server.  Example: http ://user:[email protected]
  • Under 'Path', specify the rest of the URL as you see it in your browser.  In this example, I will specify '/stif' as this is what HomeSeer uses.
  • 'Data/File' are the variables you want to send to the server.  In this HomeSeer based example, we need to send the device ID, and the type of action, both variables can be found with Fiddler in the previous step.  I also included an example for the OFF command, and an event execution in the screenshots below.  The variables we are adding are:
  • You don't have to fill out any of the other fields, unless you want to process the server response, or adjust other connectivity parameters.
  • That's it! Use the green check mark button to save your work.  I also recommend you test the action by pressing the button with the blue play symbol.  This will verify the tasks works before we move to the next step.
Attached Image: TaskerAddTask.png Attached Image: TaskerAddTaskName.png Attached Image: TaskerAddTaskAction.png Attached Image: TaskerCreateWidgetIconGallery.png Attached Image: TaskerAddTaskActionType.png Attached Image: TaskerAddTaskActionNetSelection.png Attached Image: TaskerAddTaskActionDeviceOn.png Attached Image: TaskerAddTaskActionExecuteEvent.png Attached Image: TaskerGetDeviceOn.png
All we have to do now is create the widget (a clickable icon in the Android world) now that we have created the task.
There are 2 types of Android Tasker widgets: 'Widget' and 'Shortcut'.  For more information about the differences, check out the Tasker site.  In this tutorial, I am going to select the standard shortcut (Task Cut).
Add a widget via the Android Widget screen (sometimes, you can press & hold on the home screen to activate this screen, or in the newer Android releases, go to the screen which lists your applications, and select the 'WIDGETS' tab on top.
  • Select the 'Task Cut' widget.
  • A 'Task Selection' windows should now appear, and list all the tasks you have defined.  Select the task we created earlier, 'LightOn' in my example.
  • Once selected, you should now see the actions associated with your task.  Confirm the details by pressing the button with the green check mark.
  • That's it.  You should now see an icon on your home screen.
Attached Image: TaskerCreateWidget.png Attached Image: TaskerCreateWidgetSelectTask.png Attached Image: TaskerCreateWidgetIconSelected.png 
Tapping the icon should activate the task you defined earlier.  I highly recommend you put these widgets in a 'folder' on your home screen, to avoid accidental activation, plus it gives you quick access to all your home automation widgets.
Attached Image: TaskerDesktopWidget.png
This is an extremely simple example of how to interact with your home automation system.  You could take it a step further now, and process the web server response, or change the widget icon based on the state of the device.
You could use this widget to open your garage door (do this via an event, so you can do some safety checks, etc.), turn on your outside lights, reboot your cable modem or internet router, anything you can think of, as long as it comes with a web server.
As mentioned earlier, you really shouldn't expose your web server directly to the internet.   I will publish a guide soon which will show several ways of accessing your system remotely, in a more secure fashion. 
If you have any questions or comments, post them below, I will answer them as soon as possible.
In an attempt to make this process easier, I would like to ask the community to share the 'Path' and a 'Data' example for their home automation controller if it isn't covered by this tutorial already (host/port isn't needed).  Whenever someone posts a new Path/Data in the comments, I will add it to this article (with proper credit if desired).  This should make it really easy for anyone to get this working without having to analyze the HTTP Post data.
Dynamic data (such as the ID of a device) is underlined, make sure to replace this with the actual value.  Only data in green should be added to your Tasker Action.

HomeSeer (2.x) - Control Device
Path: /stif
  • ON:
  • OFF:
Comment: The Reference_ID value can be found by clicking the 'Additional Info' button when viewing a device's properties in HomeSeer.
HomeSeer (2.x) - Execute Event
Path: /evls
  • run_event=EVENTNAME
Comment: N/A


How would one toggle the state of a lamp (with Homeseer)? I saw a pretty cool Tasker demonstration online and he was toggling the state of lamps as opposed to turning them on/off (the idea being that if you are voice controlling a lamp in a room you won't ask to turn the light on if it already is).



I proposed something similar to a leading mobile client for the ElkM1g on September of last year:

"My top priority enhancement would be the ability to control the M1g via Tasker (without having to log into the application), or using widgets. It would be awesome to have the ability to Arm/disarm, launch tasks, and control outputs/lights with a quick touch without waiting for the app to launch and query all the zones."

The author was enthusiastic, but the app has not been updated yet.