Auto Away

One of the new features in version 0.3 of the Android Thermostat software is Away mode, which includes the option for ‘occupancy detection’ so that your thermostat can automatically be set in Away mode when you leave the house and be set back to Home mode when you are on your way home. This feature will work with multiple people.  This video shows how it works.

Before you get started you will need to choose set your desired away mode settings from the Set Temperature page. You will also need to purchase the program Tasker from the Play Store.  Tasker runs in the background on your phone and checks for conditions like the cell tower you are connected to changing and lets you take action on them.

Step 1 – Make your thermostat API accessible from the Internet.

By default your thermostat can only be access from your local network.  In order to send commands to it when you are not on your local WiFi, you will need to make it Internet accessible.  The first thing you need to do is go into the General Settings tab and set a password.

Next you will need to go into the port forwarding section of your router and enable port 8080 to forward to the IP address of your thermostat.

Step 2 – Create the Tasker tasks

Click on the Tasks tab in Tasker and click the plus to add a new task.  Give it a name such as “Thermostat Home” and then click the plus button to add an Action.  For the action type choose Net, then HTTP Get.  For the server/port enter your public IP address, followed by :8080.  In the path field enter:

/utils/away?password=[password]&name=[name]&away=0

You will need to swap out the content in brackets [] with your information.  Click the green checkbox to save and then repeat this process to create a new task for “Thermostat Away”.  The values will be exactly the same with the exception of &away=1 instead of 0.

Step 3 – Create the Tasker Profiles

From the Profiles tab, click the plus to add a new profile and name it ‘Home’.  For the first context, choose State, then Phone and Cell Near to tell Tasker to execute this rule when you are within range of the cell towers near your house.

Press the Scan button to locate near by cell towers.  You may want to get in your car and drive a square mile around your house to be sure it picks up all of the nearby towers and to increase the range that is considered ‘home’ so your thermostat returns to home mode a few minutes before you arrive.  When you are done, press the button to stop scanning and click and hold in the text box and choose Copy All.  We’re going to need this list of cell towers for a second profile.

Click the green checkbox and on the Task Selection popup, choose the Thermostat Home task.  This has associated the rule of being near these cell towers with sending the command to your thermostat to place it in Home mode.

Repeat this process to create an Away mode.  You can paste in the list of cell towers instead of re-scanning.  You will also need to choose the option to Invert the rule so it executes when you are not near these cell towers.  When you are done creating the profiles, make sure the On button is checked in the bottom right corner so the rules execute.  That’s it, your thermostat will automatically go in away mode when you leave the house now.

A Few Notes

Will work with multiple people?  Yes!  The name parameter in the url is used to determine when each device comes and goes.  If any of the devices are reporting as being home, the thermostat will remain in home mode.  It will only switch to away mode when all thermostats are away.

Why is Tasker needed?  I realize the $6 app is not ideal and I had considered building this into the client, but opted not to.  The main reason is to avoid having yet another process running in the background on phones.  Tasker is well tested and already used by a number of people to automate other tasks and I think it makes sense to piggyback off of it rather than writing something new.