DEVTOME.COM HOSTING COSTS HAVE BEGUN TO EXCEED 115$ MONTHLY. THE ADMINISTRATION IS NO LONGER ABLE TO HANDLE THE COST WITHOUT ASSISTANCE DUE TO THE RISING COST. THIS HAS BEEN OCCURRING FOR ALMOST A YEAR, BUT WE HAVE BEEN HANDLING IT FROM OUR OWN POCKETS. HOWEVER, WITH LITERALLY NO DONATIONS FOR THE PAST 2+ YEARS IT HAS DEPLETED THE BUDGET IN SHORT ORDER WITH THE INCREASE IN ACTIVITY ON THE SITE IN THE PAST 6 MONTHS. OUR CPU USAGE HAS BECOME TOO HIGH TO REMAIN ON A REASONABLE COSTING PLAN THAT WE COULD MAINTAIN. IF YOU WOULD LIKE TO SUPPORT THE DEVTOME PROJECT AND KEEP THE SITE UP/ALIVE PLEASE DONATE (EVEN IF ITS A SATOSHI) TO OUR DEVCOIN 1M4PCuMXvpWX6LHPkBEf3LJ2z1boZv4EQa OR OUR BTC WALLET 16eqEcqfw4zHUh2znvMcmRzGVwCn7CJLxR TO ALLOW US TO AFFORD THE HOSTING.

THE DEVCOIN AND DEVTOME PROJECTS ARE BOTH VERY IMPORTANT TO THE COMMUNITY. PLEASE CONTRIBUTE TO ITS FURTHER SUCCESS FOR ANOTHER 5 OR MORE YEARS!

A journey in Home Automation

A while ago, after dabbling into automating some of my chores and looking into the possibilities, I stumbled into the domain of home automation. It grew on me quickly and soon I found myself sourcing parts in different countries and splicing them together in various ways as means to various ends. And it was fun, too! I then decided to put all my ideas into one place, to document the process and make a sort of work log of it, so I could recover from failure quickly. Remember that setting you just ‘’had to’’ get right in order for your system to work just right, that you looked for online for over two hours? Well, you sure won’t in a couple of months. Better write it down somewhere! Or so the reasoning went.

However, between deciding to do something and actually doing it there is sometimes that period of time that goes by when you have to do other things, not necessarily more important but more urgent. And so my ideas went on hold. I read, I experimented and I failed, then I read again and tried again and in the end I decided I could do more than just a worklog, and actually write some articles about the whole shebang. Sure, I’m no expert, but I believe those who are keep the knowledge to themselves because this business is quite lucrative. I do have some experience with microcontrollers though, and with setting up various control systems, as well as a background in telecommunications and software programming, and this is what I’d be doing if I could do whatever I wanted, so why not take a crack at it? So the idea stuck and I decided to write and post the articles on devtome so people could actually see them.

So without further ado, here is an introduction and an outline of Home Automation for the not-necessarily-technically-inclined. Chapter 2 deals with the technical overview and cloud security issues, as well as an overview of current technology and how it fits into the theoretical schema. Chapter 3 compares a couple of simple, off the shelf light control systems while Chapter 4 takes steps further and designs a simple home automation system from parts.

As day jobs are notorious in gobbling up time, though, and the realm of home automation is but a hobby to the author, the following information will arrive in sets which will be linked below as they are written. Bookmarking this page and checking back often is highly recommended!

Table of contents:

Chapter 1 - Overview, state of things and possibilities

Chapter 2 - Basic theory, cloud security and examples

Chapter 3 - A (theoretical) home automation system

Chapter 4 - A simple home automation system

Chapter 5 - A practical example using Tasker

You Are Here:

Chapter 5 - A practical example using Tasker

In my previous articles I wrote about Home Automation in general, an overview of the terms and the technology, a security overview of basic home automation systems and I presented a simple light control system made with off the shelf parts (actually, it can be bought entirely off the shelf) and a comparison between two systems: the Philips Hue and the LIFX . We also delved into building a beginner’s Home Automation system by using a little known USB stick transceiver called the Telldus.

In this article I will expand this system by using an always on Raspberry Pi, which has all the advantages of running (a flavor of) Linux, and is low power to boot. Right now my Pi has been on for about a year, give or take, and is still going strong. A whole article might be written about the Pi itself and how it took the world by storm, as it has a huge following and very active community that has made it into various projects that go from school-grade learning computers for programming and gaming to small business applications like Network Attached Storage or web servers. Suffice to say that for our project it will serve as the command and control server because it is always on, low (and I mean LOW) power consumption (Raspberry Pi B+ uses 1.21 Watts with just a keyboard dongle vs 1.89 Watts for the model B ) 1), runs Linux AND there’s already an image out there that knows how to talk to the Tellstick.

The setup

First, get a raspberry Pi. It’s easy, they’re all over the ‘net and cost about $35 depending on where you are, shipping and Pi variant you want to use. The model B should be fine (don’t buy the model A, it has less memory and the software won’t fit.) Then, get a Telldus Tellstick and some remote controlled sockets. Check my previous article in this series (home_automation_chapter_4) if you want some tips there.

Bill of materials

Name Quantity Price Availability in US Get it from
1 TellStick 1 $73 YES http://www.m.nu
2 TellStick Shipping 1 $8.15 YES http://www.m.nu
3 Remote Switch 3x2300W White / Silver - Nexa PB-3-WHITE 1 $30 NO http://www.m.nu
4 Raspberry Pi B 1 $35 YES http://www.raspberrypi.org/products/
5 SD Card 1 $ 6 YES http://newegg.com/
Total $152.15

The programming part is already done - just get and install the Automagically ISO file from http://automagically.weebly.com/. This is a special file (a Linux image, actually) that tells the Raspberry Pi what to do. It’s like burning an Ubuntu version for your PC, except this time it’s on a SD card for your Pi. The following instructions are loosely based on the information available on the Raspberry Pi page for Windows.

What you need to do is get a SD card reader, insert the SD card into it and the reader into your Windows PC or Laptop. Check and make sure of the drive letter (you don’t want to format the wrong hard disk!). Then, download the Win32DiskImager utility - which is a piece of software that writes your ISO file byte for byte on the SD card. It is found on Sourceforge. Open the program, choose your automagically ISO and the SD card drive letter (make sure you’re not selecting the wrong thing as this will DESTROY your data!). Hit the Write button once you’re sure and wait. When it’s done, exit the imager and eject the card. That’s it!

Now plug the SD card into the Pi, plug the Tellstick into one of the USB ports and plug the whole thing into a power outlet. The Raspberry Pi should boot now. Make sure you connect the Raspberry Pi to the router via an Ethernet cable and you set the router to DHCP for the local area network (LAN) to give the Raspberry an IP. This is the usual setup - your mileage may vary, but the Pi expects a DHCP server to get its first IP. You can see what the IP is on the router’s setup page, it should list all the active DHCP clients somewhere.

If all works correctly, the Pi should boot, and its IP should respond to PING requests. When it starts replying to PING requests, you can point a browser at the <IP>/admin ( just write the IP in the address bar and hit Enter) and you should see this page. (Example: If you Raspberry has the 192.168.0.2 IP, go to http://192.168.0.1/admin/ in the browser)

admin.jpg

Controlling the setup

Automagically is a command and control system developed by David Karlsson for the Raspberry Pi that allows the user to define controllable objects, variables and events, schedule said events or condition them on some variable, all from a web page. It is a little heavy on the little Pi, as it uses Apache, MySQL, Python and the load is a bit high, but it is very useful. Sometimes it lags behind the commands given, but being able to turn the lights on and off from anywhere inside the house for just $35 is worth it. After perusing the Automagically site for a bit, you should know that what this does is allow the Pi to communicate with the sockets via the Tellstick (though just one way right now. The Raspberry Pi sends commands, and hopefully, if you’ve done everything as in the previous tutorial, the sockets execute). What might not be immediately apparent is that the ISO you’ve just burned and ran on the Pi opens the possibility to send commands to the Pi via HTTP requests!

That’s right, the Automagically ISO has a RESTful interface which means that you can send commands and receive responses from the Pi by creating certain HTTP GET and POST requests! This opens the Pi and allows you to send commands from places that are not directly connected to the Pi, like your home computer (via a web browser) or your phone! The REST interface is documented online on the Automagically site, here and also by going to the Pi’s address (which we’ll call URL for now) and going to URL:/rest. Continuing the example from before, if the Raspberry’s URL is 192.168.0.1, then the full URL to use would be http://192.168.0.1/rest.

This comes in handy because for the most part, using a browser to control the lights is great, and having the lights go on or off at sunset or dawn is impressive, especially since the system can be made aware of its location by entering its latitude and longitude in the Settings area. This way, it can “follow the sun” and via one small setting you can ensure the lights go on later and later as spring turns into summer, with no user adjustment at all. This and other settings will be added later to this article, as part of an “hands on” tutorial for Automagically since none seem to exist at the moment online.

However, as I said, this setup only goes so far in usability, as we are still stuck in front of a computer - or using a browser on a mobile device. However, there is another way to control the system that will be detailed below.

Going mobile

Another way to control the Pi and thus your lights is by using a smartphone. All of them have browsers, and you could go to your Pi’s URL and controlling the setup from there, but it is a bit awkward, especially pressing buttons on that small screen. However, for Android phones there is an app that allows you create shortcuts that send HTTP requests and react to the responses. This app is called Tasker and while it’s not free, it’s worth every penny. It too might be the subject of another article or ten, because it allows the user to do so much more than just set shortcuts for HTTP requests! It can control almost every part of your smartphone, set profiles and react to different sensors and conditions and it is especially useful if you don’t own the latest and the greatest, since most of the extra options flagship smartphones have can be emulated by Tasker. For example, you could set your phone in such a way that at night, when plugged in, if you touch the screen it says the current time using low volume. This works for me because sometimes at night I don’t want the light to come on, but I still want to know the time, and Tasker and the text-to-speech engine on the phone come to the rescue. This is just one of the many ways Tasker can help, and it helps here too!

Using Tasker and the REST api of Automagically, we can set a shortcut on the phone that sets a socket to ON, and another one to set it OFF. If instead of a socket you choose to control a group, you can set all ligths to ON or OFF this way.

For example (a more thorough tutorial will follow in time, so check again soon!) we need to set a HTTP POST request to the Pi’s URL like this:

POST request to 192.168.0.1/rest/do

Parameters:

  • type=“COMMAND” - Mandatory
  • commandid=[Command ID] - Mandatory. In our case CommandID is the command for ON or OFF. Example Commandid=101 (for ON)
  • deviceid=[Device ID] - Mandatory - ID of the device to execute the command.

In our case the device ID you can get by going to 192.168.0.1/rest/devices/ . For this example say it is 115, which happens to be my ALL DEVICES Group ID.

Create a task in Tasker, called “Lights ON”. Then add an Action and choose Net→HTTP Post.

In this screen, set the IP to the raspberry Pi’s IP (in this example, it’s 192.168.0.1) and the parameters as above. See picture for help.

Figure 1 - Tasker HTTP POST Action Screen

Then save the Task, and set a Task Shortcut to it.

Repeat the steps but choose commandid=102 (for OFF). Set another Task Shortcut, name it accordingly and that’s it! Now, whenever you’re in the same WLAN as the Raspberry Pi, you’ll be able to switch the lights on and off just by using your phone. Neat, huh?

For more Tasker goodness and profile hints, check my article about it here Tasker Automation

Disclaimer

This information is for educational purposes only. Readers need to do their due diligence and read up more on the subject before committing money and time to this (or any) project. I will not be held liable if anything happens while trying to execute the steps outlined in this or any of my articles. These are my experiences and the information I know to be true at the moment, and I stand by them, but your mileage may vary. Be careful. Also, I am not affiliated with any of the companies or websites in this article and I have not received any compensation for mentioning their products although I do own a TellStick and appreciate it and what the company is trying to build.


Home | Technology | How To


QR Code
QR Code home_automation_chapter_5 (generated for current page)
 

Advertise with Anonymous Ads