Friday, January 21, 2011

XBMC and home automation

XBMC short for Xbox Media Center has been the premier open source home entertainment system for a while now. It was originally released to be run on original Microsoft Xboxes that had been soft moded. That seems like so long ago. These days the XBMC dev team are still hard at work, and while recently support for xbmc on the original xbox has stopped (the original xbox really wasn't designed for 1080p quailty video) many other platforms are now supported: 1st gen apple tv, linux, OS X, and windows are the big ones. The team even has a comercial version of their software called BOXEE. And while XBMC can play almost any media you can throw at it, AND has a host of community supported plugins available, the coolest feature is its API. With this we can remotely control a running instance of XBMC from some other device. There are remote control programs for the sony psp, iphone/ipod touch and droid platforms. But we can write our own too.

The first thing we will need to do is get a copy of xbmc up and running. There are plenty of guides for various platforms. I currently run XBMC on an acer revo hooked up to the down stairs TV, on an apple-TV in the bed room, and on the linux server in the office. for simplicities sake, to install xbmc on ubuntu its as easy as

sudo apt-get install xbmc

but for our purposes you'll also want to

sudo apt-get install xbmc-send

xbmc-send is a stand alone command line program that can send commands to a running instance of XBMC.

NOTE: before trying this you will first need to allow you XBMC to recieve remote commands.
System->Network->Services->Allow control of xbmc via HTTP and or UPNP

you also want to enable the option that says "Allow program on other systems to control XBMC"

after you get XBMC installed and configured to your liking grab a terminal and try something like

xbmc-send --host="your host by name or ip" --action="Notification(title, my message)"

and you should see a little notification box pop up in the lower right hand corner(depending on which skin you are using).


there are other ways of gettings these sorts of thing to happen. If you are using a recent version of xbmc you can check out the JSON remote control protocoll. If you are you using versions of xbmc old enough to run on the original xboc you can check out the deperciated http api, for a list of all built in functions take a look at

http://wiki.xbmc.org/?title=List_of_Built_In_Functions

the commands on this list are what we will use with the xbmc-send program.


so where does x10 fit in with all this? Last post I talked up one of the new features of the python driver, that it can recieve commands from other remotes AND sensors

like the one here, for example
http://www.thehomeautomationstore.com/ms14a-w.html
(they are much cheaper on ebay!!!!)

So, lets say you purchased one of these guys and programmed it to be a13

assuming you are redirecting out put from your x10 python driver like we talked about last post you might do something like this...

tail -f liveHouse.log | while read a ;
do [[ if "$a" == +a13* ]] ; then
#put anything you want to happen as a result of tripping the motion sensor, like sending an IM or email or desktop/xbmc notification
xbmc-send --host='my xbmc IP or HostName' --action="Notification(Activity, Motion detected)" ;
fi ;
done

then make some motion in front of your sensor (or you could just turn on a13 from an x10 remote, essentially thats all the sensor does)

and you should see your little message box on the XBMC screen. AWESOME!

you of course don't need XBMC to enjoy this kind of early warning. Mac users have Growl (though I've never played with the API for growl) ubuntu users have a built in notification system called notify-osd. you can access the ubuntu system directly from the command line by doing

sudo apt-get install libnotify-bin

after which you can run a command like

notify-send 'TITLE", "My message"



No comments:

Post a Comment