Well, you asked. Here's a post that explains the high-level stuff. It's long.
Basically, I buy hardware that I can control through standard TCP/IP commands. For example:
Then I either use the published API for those products, or I reverse-engineer the commands sent between the mobile app and the hardware. I wrap those up into PHP scripts, that I can simply call with script.php?temp=74&mode=cool as an example for the thermostat to set A/C to 74 degrees, or for the lighting I have some preset colors, brightness levels, etc which I can call through various settings I have pre-scripted.
For the TV
, I also built an arduino device with an IR
transmitter. I built a similar device with a 38khz IR
receiver. So, to figure out what the IR
command is when I press the power button on the remote, I aim the remote at the receiver, press the power button, and then record the output. I save the output on all the buttons, then write a PHP script to map those into simple calls, for example: ir.php?c=power&device=tv. The PHP script then sends a WGET to the arduino with the transmitter, and basically sends the hex code for the IR
command to the arduino, which then outputs it onto the IR LED
. There's some additional logic for input changing - for example, the TV
will skip "dead" inputs, but if I turn on the Apple TV
and the bluray player, I can't press the input button once to cycle to Apple TV
, because now there's another device. So, basically I have the IR
receiver "listening" to all commands, and updates a database so it knows what is on and what channel, device, etc, and can help process some logic.
For music, I have a dedicated laptop, hooked up to the sound system, that runs music player daemon. It is controllable via command line, and plays music. It is the audio player, and I can use different devices to connect in to change playlists, tracks, etc. If I wanted to play the track "Beautiful Day" by U2
, I could issue a command like "mpc clear && mpc search artist U2
track "Beautiful Day" && mpc add && mpc play", and it would clear the current playlist, add the song, and play it.
Finally, I also have various cameras, IR
sensors to sense human presence, bluetooth 'beacons' that have short enough range that they are only visible in certain parts of the home, etc. These are all miscellaneous sensors to help with location and logic processing.
Next up: logic processing. I have a beefy server that I run VMware ESXi on. I have two servers on here that are used for automation. The first one has a public static IP address assigned to it, so it is accessible around the world. I have business class cable internet, and this was an add-on cost. This server just acts as, essentially, a reverse proxy to allow access to automation functions. It runs on HTTPS and has a valid SSL cert. It also houses a jQuery-powered page that shows system status, such as current temperature, outside weather, etc. It also shows an icon if I have an unread text, missed call, VM
. This screen also dims when I leave the house, brightens when I return, and the same for when I'm asleep, just to prevent burn-in and also keep ambient light levels down. I use the above-noted audio server to show this page in full-screen onto a spare LCD
by the TV
The brains of the operation is on the second server. It has a database, cron jobs, and houses the PHP scripts that wrap the devices I listed above. The database is constantly updated whenever anything happens. Lights on, off, music on, off, track change, A/C temp, you name it. The jQuery-powered page I noted above constantly polls this database and then displays things based off of its status. If an IR
sensor sees IR
light, it outputs a higher voltage to arduino, and arduino then sends that voltage to the DB
. High voltage = person present, low voltage = person not present. I have complete IR
coverage of my place, so if all voltages = low, nobody home. If one or more = high, then somebody is home. You get the idea.
So, the last thing: I want this stuff to work based off of me. If do x, home should do y. It really boils down to one very simple thing: I need the system to know where I am. If it knows I am home, then it can deduce that the IR
sensors are seeing me. If I am not home, but the IR
sensors see somebody, then maybe I should know somebody is in my house? The only electronic device I have on me at all times is my phone. It is an Android phone, which means I can run the tasker app. This is essentially a "if x, do y" for the phone. So... if I'm connected to my home wifi on my phone, tell my home that I am home. If I disconnect from the wifi, *AND
* connect to cell towers not near my home, then I am not home. So, set home to away mode. If I start connecting to cell towers near my home, and then connect to wifi, that means I just came home... so turn the lights on, play some music, etc.
Everything else is just logic built based off of my phone's position.
Downside: yes, if I lose my phone, things can get interesting. If my phone's battery dies, I have to do things myself (oh the horror).
That's it in a nutshell. I need to write this up on a blog, with command snippets, pics, etc - I've had a blast building this out since mid-summer. I've got even more things that I didn't go over, such as I can call a phone number and use interactive voice response to turn lights on and off, etc. That's another server I'm hosting, it runs asterisk which is a common voice over IP server. I've had some interesting problems as well - such as the "I'm home" and "I'm not home" logic getting reversed in one odd turn of events, so when I got home everything turned off, when I left everything turned on. Wasn't hard to fix, but... if you don't have some patience to work through stuff like that every few months, it could get annoying.
Future plans include network-controlled appliances, window shades, and support for multiple people being residents. Right now it's just me that lives here... but if somebody else were to move in, then I'd need to figure out how to set things so the logic is "if one or more people present, do x", and then add in personal preferences for each user.
[Edited 2013-01-01 11:33:33]
The above post is my opinion. Don't like it? Don't read it.