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.
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.
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 :)
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:
http://www.pommepause.com/blog/2009/07/remote-controlled-air-conditioning-using-mac-os-x-and-shion/
Good luck on your project.