Original URL: https://www.theregister.com/2013/09/16/zwave_pi_its_time_the_raspberry_pi_took_control/

How to get a Raspberry Pi to take over your Robot House

Mouthwatering nerdy possibilities - use ANY gadget to bring darkness or light

By Bill Ray

Posted in Personal Tech, 16th September 2013 07:00 GMT

Behold: The RaZberry is a daughter board which snaps onto a Raspberry Pi, turning it into a Z-Wave controller capable of integrating, and controlling, a home automation network though a web, or JSON, interface.

We all love the Raspberry Pi, don't we? It could have been built for home automation, offering low power consumption and enough processing power to handle the most complex of residential instructions, and the RaZBerry provides the connectivity it lacks in a very simple package. The hardware is a dream, and the provided software comprehensive if incomplete: if only the documentation were ready for prime time this would be enough to make Z-Wave the only home automation choice for the discerning geek.

The daughter board

It even fits inside most cases, including this one

There is competition: Zigbee would like to provide that functionality and has the advantage of being an IEEE standard (802.15.4), but while Zigbee devices from the same manufacturer will talk (and mesh) happily together the protocol stops short of mandating the interoperability demanded by the Z-Wave standard. Z-Wave has a greater presence in the US, where home automation is better established, but it's pushing into Europe and innovations like the RaZberry will only help.

Setting up the RaZberry is disarmingly easy. Just slot the board onto the GPIO pins and download the Z-Way application using the syntax suggested on the single page of documentation. Once rebooted the Pi will kick off a Z-Way web server allowing integration and control of existing Z-Wave devices as well as getting them to communicate with each other.

We didn't have an existing network, but Z-Wave Europe was kind enough to lend us a mains-controlling switch and a keyfob with which we could control it, all via the Raspberry Pi.

A list if devices

We only had two devices, but there are lots of options for grouping them if you have more

Z-Wave requires that devices are "included" before they can managed, a process which proved trivial with the mains switch. From the Network interface one just selects "(Re)Include Device" and presses the only button on the switch (the same button operates as a physical override). The Z-Way software integrates the device and immediately the lights are turning on and off with a click of the mouse.

At last, the ability to turn stuff on and off no matter what gadget I happen to be holding at the time

That was nice, but not quite what we were after, so we delved into the JSON interface for device control. There's a cut-down version of the Z-Way client which comes with HTML and JavaScript source code and one can stick it in a browser and see how it works. The interface just asks the IP address of the Raspberry Pi concerned and kicks off a JavaScript client which one can muck about with to find the commands being sent - in our limited experience this worked better than using the manual, and established that we could turn on our light by loading the URL:

http://192.168.1.75:8083/ZWaveAPI/Run/devices[2].instances[0].commandclasses[37].Set(255)

... which returns a null but also switches on the light. Replacing the last number with zero switches it off again and we have a mains switch we can control from any app capable of opening a socket and sending a String.

A device

Less successful was the Keyfob. Including it seemed a very hit-and-miss affair, and we never managed to exclude it at all. But once included the fob worked as promised - we were able to link it up to the mains switch for remote controlled lights - however the manual proved fiddly and control over the flexible arrangement of buttons (which can be double or single tapped, and toggle or be absolute) was far from intuitive.

We did eventually get it "wired" to the switch, and it even worked when the Raspberry Pi was powered down. Z-Wave devices can be instructed to work together, but without the Pi to route the communications it did take up to six seconds for the button push to trigger the switch - not what one would want at the top of the basement stairs. When the Pi was running the same instruction took less than a second, which seems worthwhile.

The meshed nature of Z-Wave means each node is also a relay, allowing every corner of the home to be reached, and the Z-Way interface provides a live table of which devices are speaking directly to each other which is fascinating in itself.

What we really wanted, of course, was to tie the keyfob buttons into our Raspberry Pi music system. Buttons one and three would switch the amplifier on and off, while buttons two and four would start and pause payback, reducing the need to boot up a web browser every time one wants to pause the music (worktop touch-controls not withstanding). But sadly it wasn't to be.

The Z-Way application is all written in C, and while Z-Wave Europe can provide APIs there's no easy way to hitch it to a Python app like our music player. Apparently there was a Python version, but it couldn't achieve the performance necessary to maintain Z-Wave compatibility, which indicates that a second Raspberry Pi is probably in order to keep the music playback smooth.

Sadly catching keyfob actions over the JSON interface isn't possible with this version of Z-Way, so the two-Pi solution is also out for the moment at least. A new version of Z-Way is promised within a few weeks, along with better documentation and and an "automation engine" to facilitate triggered actions.

El Reg readers will likely be more interested in the JSON interface and ability to hook a controlling Pi to a home network capable of managing thermostats, heaters, motion detectors and door locks, rather than an automation engine providing drag-and-drop controls of existing devices. For that the next version of Z-Way looks very exciting, but the existing product still provides a fun introduction to Z-Wave and could make some of those Pi's sitting in cupboards and corners a little more productive. ®