UPDATE: I upload my hacked Z-wave controller code to: https://github.com/tagroup/open-zwave-tcp-socket-server-and-client

Decided to try some easy home automation with my Raspberry Pi using the Aeon Labs Z-Stick S2, GE Wireless Outdoor Module (45604)open-zwave interface, and the openzwave-control-panel.  The goal was simple.  I wanted to turn a light on and off without leaving my chair or moving my arms (finger movement, I find acceptable at this time).


UPDATE: New Raspbian Disk Image with Open-Zwave and Instructions


My Pi is set up with the Raspberry Pi Arm Debian image on a 8gb SanDisk Extreme III card and a Belkin powered USB hub.  The instructions below should be the same for non-Pi installations on Debian/Ubuntu/Mint.

1. You will have to have build-essentials, make, subversion applications installed (maybe others).
sudo apt-get install build-essential make subversion

2. Plug in Z-Stick S2

3. Installed open-zwave:

svn checkout http://open-zwave.googlecode.com/svn/trunk/ open-zwave
cd open-zwave/cpp/build/linux
make

4. <<optional>>  If compiling on Pi, Go get some food. This step took a while.

5. Pair your device (unplug Z-Stick, press button on z-stick, press button on switch/sensor, when light changes, press button on Z-stick controller)

6. Build the open-zwave example to test all is well.

cd ../examples/linux/MinOZW
(change Makefile if your device is not at /dev/ttyUSB0)
make
./test

While this is running – hit the button on the switch/sensor and it should react and write a config file – zwcf_yourhome.xml.  I just opened this saw that my device was in it and jumped to openzwave-controller.  More info can be found on the open-zwave project wiki.

7. Install openzwave-control-panel.

So I download that:
svn checkout http://openzwave-control-panel.googlecode.com/svn/trunk/ openzwave-control-panel

8. But before I get started I need to install libmicrohttpd.  I think the one in the repository is too old and causes issues, so I downloaded the latest version with:

wget ftp://ftp.gnu.org/gnu/libmicrohttpd/libmicrohttpd-0.9.20.tar.gz
tar -xzvf libmicrohttpd-0.9.20.tar.gz
cd libm*
./configure
make
sudo make install 
/*you don’t have to do this – I was in a rhythm and couldn’t stop*/

7. So then I went to back to openzwave-controller
cd ~/openzwave*

Check the Makefile -  (actually read it)

the path to libmicrohttpd and open-zwave should be updated to the appropriate paths

For me (yours could be different):

OPENZWAVE := ../open-zwave
LIBMICROHTTPD := /usr/local/lib/libmicrohttpd.a

You also have to uncomment two lines depending on if you are running on mac or linux.  Since I was using the pi,

# for Linux uncomment out next two lines
LIBZWAVE := $(wildcard $(OPENZWAVE)/cpp/lib/linux/*.a)
LIBUSB := -ludev

Then compile.
make

9. Time to test (the number after p is port number):
./ozwcp -p 55555

Then cruise to your favorite browser and type in http://ip_connected_to_z-wave:55555/.

Notes:  When I use my iPad to access the control panel it, everything gets messed up and I have to hit the reset button in the web GUI then repair the device.

The openzwave-controller is far from perfect but it is an awesome way to get up, running and testing your devices in under 10 minutes.  Much praise to them.

The next plan is to connect directly to the open-zwave interface and create a socket server or simple REST API for handling basic commands and schedules.

UPDATES: I found http://conradvassallo.com/2012/03/14/lights-control-open-zwave/ project and after finding the right socket libraries I was off.  I made a couple updates so I don’t lose the most current status of a notification event and built a quick little web page to turn on and off my light.  More switches should be coming this week as well as a EtherRain sprinkler controller.    The Pi will tie all the pieces together and give me one protocol to communicate to the switches.

CHRISTMAS UPDATE: Time to control the outdoor lights!


Comments

  1. Conrad Vassallo -

    Hi Thomas,

    Great to see this project and that you managed to find my work useful. This is the next step I have to do, to run the project on Raspberry Pi but still waiting to receive mine :(

    Conrad

    Reply
  2. Dhruv -

    You Sir, are a life saver. :) You’ve provided a good starting point for my z-wave adventures :)

    Reply
  3. Conrad Vassallo -

    Hi Thomas,

    Finally got my Pi and thanks to your tutorial, I managed to compile and got my code working fine. I wanted to ask you about your socket server. Did you use the code of the openzwave-control-panel or you wrote your own. My main concern is about reading the status of the devices. Can you please shed some light about this?

    Thanks
    Conrad

    Reply
    • Thomas -

      Hi Conrad,

      I ended up expanding on your example. I did a couple quick changes to keep/get the current status. I updated the onChange notification function to remove and add the updated values (‘basic=on’ being the important one). I returned all the values as a string I can parse by the client (wasn’t sure what I would need at the time). I also added a call to Manager::Get()->RefreshNodeInfo(g_homeId, nodeInfo->m_nodeId) to re-poll for a status update (rather than constantly polling).

      If you would like the code, I can email it.

      Thanks,

      Thomas

      Reply
  4. Steven -

    Happy I found this post, was looking for a starting point to install some lighting either via z-wave or GPIOs on the Raspberry Pi. Don’t have the PI yet, but for now planning on using a standard install of Debian or Ubuntu on a laptop to test out options.
    The only thing that kind of annoys me is every GUI seems to be web-based. Has anyone seen/found a way to use something other than a web based client/server?
    Anyway good post, and I hope to be able to built on it.

    Reply
  5. Giancarlo -

    I followed all your instructions to configure my raspberry, but after I used the Z-stick Lite (bridge) V3_47 EU 20111111.zip my Z-stick does not turn on the light.
    is that correct?
    Thanks for your cooperation

    Reply
    • Thomas -

      Best bet is to try the new img (the one I messed up the link for). I am not very familiar with the z-stick lite but I will send an email and get some more information that we can post for all.

      Reply
  6. Giancarlo -

    Hi Thomas,
    thank you for the corrected link, I will try the soonest. I am confused about the firewall to be used on the z-stick. Following your instructions I downloaded the firmware Z-stick Lite (bridge) V3_47 EU 20111111.zip but after having applied it my stick does not light any longer. On the Aeotec web site all the links related to the firmware downloads are broken so I have found the following firmware “Windows-Static-Library-5-02-P3-EU” and with this my stick is now lighted again but I have no idea whether it will work along with your instructions. I will try to follow both ways: following your old instructions and the new image and I will be back to you. In case you know where I can find a valid EU firmware I will appreciate your help.
    Best regards
    Giancarlo

    Reply
  7. Enrico -

    Thanks Thomas for your support. I’m using windows applications zwave and compatible applications for iPhone and Android. There are applications for these mobile devices compatible with your software?

    Reply
  8. brian -

    Looking forward to trying this when my Z-Stick comes from Amazon. I did have an issue however. You write:
    sudo apt-get install build-essentials

    The package is:
    sudo apt-get install build-essential

    Caused a lot of problems for me at the first step until I googled it. Otherwise, thanks for the post — I hope to implement this in my dedicated Raspmc system.

    Reply
    • Thomas -

      Thanks, I will make the correction.

      Reply
  9. jl -

    Can’t mount my ZStick as ttyUSB0 on my cubieboard :(

    Reply
  10. Kul -

    not sure if it is the os I installed on my raspberry pi, but I also had to install the libudev-dev package.

    sudo apt-get install libudev-dev

    Reply
  11. cag -

    you have to copy config folder to inside of openzwave-control-panel folder

    Reply
  12. manish -

    in the end i get the messege : server starting at port 0, and keeps telling the same message.
    then i can’t view the page, dom you know what is going wrong?

    Reply
    • Thomas -

      If you are talking about the openz-wave control panel, you have to specify a port (-p 55555) for example.

      Reply
  13. Marko I -

    Why i dont have a switch button in control panel, my device is lsited but how to control it

    Reply
    • Thomas -

      Can you send me a screen shot? If I remember correctly the control panel is not friendly in all browsers or if other errors occur on the page.

      Reply
        • Thomas -

          It appears that only your controller is showing. Did you go through the pairing process with your controller (I am assuming it is the Raspberry Pi Zwave.me Daughter controller)?

          Reply
          • Marko I -

            I have Z-StickC
            which one pairing process? as u did with ur Zstick, i didnt do.
            as in your guide, i did testing. But my Stick doesnt have button.

            I really dont know why i dont have button, mby i did wrong pairing*but i dont know how*, mby its because of drivers or software.

            I have Fibaro Realy switch 2×1,5kW and Z-StickC

            PS: when i installed z-cloud server on windows, i couldn’t pair my Fibaro realy switch

            Sry for my english, i just want to end this project

          • Thomas -

            Sorry for the delay in the response. I have not seen the ZStick-c before – looks interesting. The link, http://www.vesternet.com/downloads/dl/file/id/8/z_wave_me_usb_stickc_manual.pdf, goes to their manual but you probably already have that. It looks like it follows the same serial protocol as the daughter controller card and my guess would be to start by installing their software and making sure you have the latest firmware.

            When I paired my daughter card, I had to be very close to the device I was trying to pair. It was tricky and I complained about the process here: http://thomasloughlin.com/z-wave-me-razberry-daughter-card-for-the-raspberry-pi/. Hopefully, it is easier now.

            Let me know if you are still stuck in the same spot and I can do some digging over the weekend.

          • Marko I -

            thx for reply, i tried before to isntall new software and drivers but had problems and didnt finish!
            Now i will try harder and inform you what does changed

  14. Marko I -

    Hello Thomas,

    how i could control my device via Open Zwave ? in Control Panel web itnerface i dont have switch button on the bottom like you.

    Reply
  15. Marko I -

    or where do i need to search, to find that mistake

    Reply
  16. Marko I -

    any ideas?

    Reply
  17. Marko I -

    When i try to update software on Raspberry i get this error
    Traceback (most recent call last):
    File “ZStickUpdater/ZStickUpdater.py”, line 24, in
    import SerialAPI
    File “/home/pi/ZStickUpdater/SerialAPI.py”, line 1
    ../../SerialAPI.py
    ^
    I did edit that file and change to /home/pi/ZStickUpdater/SerialAPI.py and other different way.
    The path have to be right, but idk wats the problem could be

    Reply
  18. Floriano -

    Hi Thomas,
    do you know the RaZberry product to transform our Raspberry PI in Z-Waves home center?

    What are the differences with the Z-Stick

    What you would suggest?

    Ciao
    Floriano

    Reply
    • Thomas -

      I am familiar with the RaZberry Daughter card for the Pi. Personally, I am a big fan of the Z-sticks.

      Reply
  19. Marko I -

    managed to update software

    Reply
  20. Marko I -

    Trying to use z Cloud, but cant add device :S i push that button on switch 3-5-6 times but nothing happens

    Reply
  21. Marko I -

    Problem solved, did wrong firmware upgrade from sources, found new one :D
    gonna try OzwCP

    Reply

Leave a Reply