Now that I have quite a few Lightwave devices, I wanted to get into controlling them from somewhere. Of course.
I explored the idea of getting an RFXCOM device, as they offer the ability to interface with a huge range of wireless protocols. But in the end I thought I’d err on the side of simplicity and plumped for the WiFi Link from Lightwave themselves.
I have no idea why it’s called the WiFi Link, as it doesn’t actually do any WiFi at all. It connects via Ethernet to your router and sends and receives it’s network traffic from there. There’s an iOS app available for free that you can use to send commands from an iPhone or iPad (and I believe an Android app too). But it leaves quite a bit to be desired in terms of both design and function. The interface looks very primitive for an iPhone app, and the controls are grouped into rooms with no ‘master’ control easily implementable.
There’s an enterprising chap called Steven over at http://blog.networkedsolutions.co.uk/?p=149 who listened to the network traffic generated by his WiFi Link and worked out what it was transmitting when certain commands were sent. Knowing this, he was able to write some PHP code to send the commands himself.
I’ve taken his code and expanded on it somewhat to include the use of ‘moods’ in each room. And allow some broader control of the house. I did this by using, for instance, ‘all’ as the room identifier, so you can switch lights for the whole house on or off using just one button. This logic also allows the use of smaller group names, with devices included to your own specification such as ‘1st’ floor or ‘garden’.
I initially set a one second delay between the mood commands sent for each room, thinking I would trim it down later to find the optimum timing between transmissions. But I actually like the slow gradual fade up across the house, so I left it like that. But you may want to experiment to see how close they could be. Or indeed, if you can send them at the same time.
I also did some optimisation to make things as efficient as possible. Mainly wrapping the socket control stuff in functions, and putting the main code sequence into a switch block.
The code is available here, should you wish to tinker with it yourself. Just let me know of any improvements you make!
I’m currently writing an iOS dashboard app that I can use to send commands to this script, so I’ll post the fruits of my labours here once that’s in a better state.