Sunday 9 August 2015

X10 listener TIP10RF emulator for HEYU and Linux

This is a little script that I wrote, basically because I was looking for a smartphone application (On my HTC One m8 Android phone) that I could use to simply control my X10 devices around the house.
I'd already setup a web interface, but this was a pain, when I just wanted to turn a light on or off without getting up (lazy I know), opening a web browser, navigating, authenticating then clicking ON or OFF, it's a pain! So I looked for apps already written. There are a few but they are all either chargeable or specific for a particular development.
I then found the TIP10RF application from Marmitek/Haibrain (Haibrain is the new name for Marmitek). This seems to do what I want, you add in your devices to the app and you can then click ON or OFF for each of them. However, this application uses a piece of hardware, the TIP10RF device which I've shown below:
The small hardware device simply plugs into your home router (RF45 ethernet connection, no WIFI) and will convert he commands from the APP to RF messages that are sent to your X10 devices. This device also assumes you have a wireless transceiver such as TM13, CM15Pro or the SC9000 alarm system.
So, based on this I downloaded the free app and set about working out how it communicated. Luckily it lets you set a specific IP and port to communicate with their hardware, so I set this to my linux box, set the traffic to be sniffed and started analysing the data. This was straight forward so I knocked together a small PHP cli script to handle it.
This script simply sits listening on a specific TCP port and will respond to the codes received from the application. When it gets a recognised code, it uses the HEYU application on my linux server to send the X10 commands around the house..

If anyone wants to try it, I've uploaded it to github so you can grab the code at:
https://github.com/andyb2000/x10listener

And please do get in touch if there are some extra features you'd like or if you spot a simpler way of optimising my code! This was quickly knocked together and does work just for what I wanted.