iPad & X10: The Ultimate Home Automation Controller?

Since Startrek TNG I've been eagerly awaiting delivery of my PADD. Disappointed for years and whilst not perfect, my newly acquired iPad is prettty damn cool. A little on the heavy side and terrible in sunlight, but otherwise fantastic.

When I blogged about X10 in February I mentioned that I thought iPad would make a "stunning HA remote control".

Other than general reliability, since starting with X10 in 2007 I've been most disappointed by the terrible remote controls. I've 2 Logitech Harmony remotes which whilst marginally better than the 6 official remote types I've tried, still fall far short of my ideal.

X10 Commander, the iPhone app which has gotten coverage including prime time TV ads is, for me, not a lot better. Certainly not something I'd pay for, especially as if using a mac you have to pay for the serverside portion as well.

So, for a while now I've been planning on writing an iPad web app interface. I'm going to share with you how and what I've achieved so far.

Shion + Mac Mini + CM15Pro

A couple of weeks back I started looking at what free software there was available for Mac OSX for interfacing with my CM15Pro (aka CM15a). At first I found nothing, only trial software which claimed to be fully functional but turned out not to be.

Eventually I found Shion about a week ago, which whilst basic does seem to do what I need. It's currently free if you email for a license.

All you need to do is set up an X10 device for each that you have. I've currently 17 physical devices and many macros over 2 house codes.

Annoyingly and after much hair pulling I discovered that only Shion 2.0 is compatible with CM15Pro - whilst 2.1 detects the controller it doesn't work as it should.

One massively annoying thing I should mention - my mac mini absorbs X10. It's the only device in the house that does. I'm going to have to buy a filter for it shortly, which are overpriced at £30.

Apache + PHP + AppleScript

I was rather hoping to find software with a web interface, but Shion has the next best thing - the ability to interface with it by AppleScript. I'd not come across AppleScript previously (I've only been using a mac for a couple of months), but it's super simple and easy to pick up.

OSX comes with Apache and PHP preinstalled, it's just a case of enabling them. I had to edit the httpd.conf to run apache as a standard user, as otherwise it wouldn't be able to call exec() and run applescript. This isn't generally adviseable for use on the Internet, but on a secure home network it's fine.

I set about designing an iPad interface and whilst am writing it with re-usability in mind it's not ready for any sort of public release. The good part is that the actual code you need to interface PHP -> X10 is 1 line:

exec("osascript -e 'tell application \"Shion\"' -e 'activate device named \"$device\"' -e 'end tell'");

For example:

if($action == "on") {
    exec("osascript -e 'tell application \"Shion\"' -e 'activate device named \"$device\"' -e 'end tell'");
elseif($action == "off") {
    exec("osascript -e 'tell application \"Shion\"' -e 'deactivate device named \"$device\"' -e 'end tell'");

Simple huh?

Interface Design

The best part about being able to write your own PHP is that you can make an interface that ideally suits your house and how you naturally want a remote to look.

I thought at first about making an iPad version of Domia's 10" PictureTouch using photographs and imagemaps, but I decided to make it a bit more advanced than this.

I wanted it to look vaguely like a native iPad app and whilst I thought about using a framework (if I had several weeks to kill I'd reverse engineer AdLib) I decided it'd be quicker to make up my own interface with images and text.

I designed it on Firefox a couple of days before getting my iPad, then did some final tweaking when it arrived. I wanted an interface that would fill the entire browser but not require scrolling.

I wrote the initial interface for landscape mode, which I plan to be in most of the time whilst using the device. Annoyingly Apple decided not to make the screen 16:9, but I came up with a way of fitting everything on.

Inspired by other apps I choose to display a list of rooms down the right hand side of the screen, along with some information about each. Clicking on a room's picture changes the left hand side of the screen, showing a photograph then controls bellow.

I found that I had space for 12 devices / macros, divided into 3 tables each with a header. It suits my house to have a table for lighting, one for appliances and one for macros. I created images to place around the table, giving it a rounded corners look. Finally I created some buttons in Gimp - big enough to be pressable but not so big as to take over the display.

Where to from here?

What I have so far represents only a few hours work.

Next step is to have the interface change when the screen is turned through 90 degrees, to show all available devices / macros.

I believe in Open Source, so if I've time and effort available I'll create a reusable package for others to play with. In the meantime hopefully what I've described here will give anyone with a basic understanding of PHP enough to get going with.

Being HTML it can be used on our PCs, but I plan to make both an iPhone version and 10 foot version for use on TV.

Finally I plan to make the icon on my home screen point not to the web interface, but a public IP that redirects either to the internal address if I'm at home or a passworded public interface (connected via a tunnel) when I'm out and about.

Any thoughts are appreciated :)


  1. Hi,

    Nice DIY project.

    I did something quite similar (I recognized your calls to the Shion AppleScript from my own code!), but with less devices. In fact, I'm only controlling my secondary air conditioning unit.

    There's a part, running on my Mac, that automates the starts and stops, according to the selected schedules.

    You can see my blog post about it here:

    Good luck on your project.

  1. Anonymous said...:

    keep us posted! I really like to read more, I've been wanting to do the exact same thing for a while now

  1. Anonymous said...:

    Especially the details about how exactly you went about to create the website, would interest me

  1. Anonymous said...:

    I am really confused as to why you would use that x10 (No confirmation/maybe it worked maybe it didn't) crap automation in the first place? Z-WAVE... I can lay my head on the pillow knowing my lights turned off downstairs without looking! And another thing mControl or Vera available today completly functional in a browser ...NEWBS!

  1. Steven said...:

    Guillaume: Thanks! I saw your project a few days ago - looks good. May have to pick your brains about iphone interface.

    Anonymous 1-2: Will do. Shall probably create a sourceforge project page when I have a few hours to spare (this week as been a little busy).

    Anonymous 3: I've absolutely no doubt that Z-Wave is a superior technology, however in the UK at least it costs 2-3x the price, with very little on the second hand market. Therefore it wasn't a viable option for me. Neither of the softwares you mention are either free or have specific iPad support, so am not sure where you're going with your NEWBs comment ;)

  1. tlh523 said...:

    my x10 network is solid especially at the price point. however their software interface have not been updated. Z-wave and other have a better tech approach but the ROI just isn't there.

  1. Clax said...:

    Your interface looks sweet. Have you seen jQTouch (http://www.jqtouch.com)? Not sure what it looks like on the iPad (haven't bought one yet) but it looks great on the iPhone/iPod Touch.

  1. Anonymous said...:

    Perceptive Automation (http://www.perceptiveautomation.com/), maker of Indigo (which is not free) and Indigo Touch (which is a free Indigo client app), just released Indigo Touch 1.6 which supports the iPad, full rotation, etc. It also has full AppleScript support as well as a RESTful API and a built-in web server.

  1. Gary said...:

    You project looks great. Would be very interest to know how you're progressing as am starting to explore both iPad development and installing home automation in my home. This ties the two together nicely and would make a great hobby project to work on. Feel free to get in touch if you want any input.

  1. Home automation is about the security you have knowing that you can look in on your home remotely from anywhere in the world, or that your home will phone you if anything is amiss, or that a fire will alert your home to wake you, shut down the gas and ventilation system, turn on a lighting path for your escape, and automatically phone the fire departmen

  1. Dallas said...:

    It can be hard finding a new dentist. If you need cosmetic dentistry before and after then this is where you should turn.

  1. Brian said...:

    My company needed a dynamics sl and we had to find someone who knew the best steps to take, these guys were the best!

  1. Brian said...:

    Great technology post, thanks. I found some ipad home control that were better than most!

  1. Anna Swiderski said...:

    I am so happy to read your article here. Very refreshing and new to me!keep going.
    top home alarm systems

  1. David Beals said...:

    I would like to thank you for the efforts you've put in writing this blog. I'm hoping the same high-grade web site post from you in the future also. In fact your creative writing skills has inspired me to get my own web site going now. Actually blogging is spreading its wings and growing quickly. Your write up is a great example.
    security systems reviews

  1. Niccolo Alley said...:

    Indeed, at certain times of day will be the same length, when night and day. But sometimes it also happens that the night is shorter than in the daytime.
    protect america reviews

  1. Thanks for review, it was excellent and very informative.
    thank you :)

Post a Comment