I was hoping to have a new Open-Zwave LightsControl disk image to upload today but work took over the weekend.  I still have some bugs to work out with Lightscontrol before I can feel good about putting it up.  For those of you wanting to compile you own version, here are my notes on how to get it working on a fresh copy of Raspbian with the lastest Open-Zwave (r628).

Open-Zwave Build

  1. Make sure you have the latest updates to Raspbian.  You will also want to get the latest firmware release and have your Pi running in whatever overclock / memory combination you would like.  I used modest and 16mb for GPU.
  2. You will need to install the following packages: subversion, libudev-dev, make, build-essential, git-core and whatever webserver you want (I use nginx as an example below.
    > sudo apt-get install subversion libudev-dev make build-essential git-core
  3. Download the latest Open-Zwave source (go with a fresh copy – things changed in December that are not backwards compatible)
    > svn checkout http://open-zwave.googlecode.com/svn/trunk/ open-zwave-read-only
  4. Building it should be easy but not quick on the Pi.
    ~/open-zwave-read-only/cpp/build/linux $ make
  5. Easiest way to check that everything is working is to build the MinOZW example
    ~/open-zwave-read-only/cpp/examples/linux/MinOZW $ make
  6. Then run the MinOZW application
    > ./test
  7. If everything is wonderful you can move on to the TCP Open-Zwave Socket Server. Start by putting the server files in a new directory in the linux example folder, for example, ~/open-zwave-read-only/cpp/examples/linux/basicServer.  You will need the newest version for it to compile.
  8. I need to update the make file to include building the socket library but for now, the following will work:
    > g++    -c -o ServerSocket.o ServerSocket.cpp
    >g++    -c -o Socket.o Socket.cpp
    > make
    > g++ -o test -g Main.o ../../../lib/linux/libopenzwave.a ServerSocket.o Socket.o -pthread -ludev
  9. You can run it with ./test and you should see that /dev/ttyUSB0 is opened and devices are being polled.  The initial start up of Open-Zwave is slow (time varies based on several factors – distance, device type, number of devices).
  10.  You should be able to connect to the socket server from terminal with “telnet localhost 6004” and if you send “ALIST” + enter, you should receive a list of your devices.  You might have to install telnet.
  11. If everything is working it is web server time.  Apache2 and php5 work fine and basically have no configuration – just drop the client files in the /var/www directory.  Another option is nginx.
    >sudo apt-get install nginx php5-fpm
  12. Then you have to update the configuration file to allow the server to respond to requests on ipv4 port 80 by uncommenting the appropriate line.  You have to add index.php to the list of default pages served: index index.php index.html index.htm.  And the last step is to add:
    location ~ \.php$ {
    fastcgi_pass unix:/var/run/php5-fpm.sock;
    fastcgi_index index.php;
    include fastcgi_params;
    }

    >sudo nano /etc/nginx/sites-available/default

  13. Then you have to start the nginx server:
    >sudo /etc/init.d/nginx start
  14. You can test it by making a sample php file putting it the /usr/share/nginx/www directory and try loading the newly created page (say index.php) from your browser – http://yourpiip/index.php
  15. If all is well, the last step is to add ‘client’ files to the /usr/share/nginx/www directory.  With the socket server you compiled running, you should be able to see any devices that you have already added.

Sorry for the rush on this – I will try to clean it up in the next few days.


Comments

  1. Conrad Vassallo -

    Hi Thomas,

    Glad to see you are still supporting my work! I did some more updates to the Lights Control PHP files to sort out some bugs and a minor feature to read Logs which will commit on svn hopefully soon. In the meantime I would like to find some time to update the Andriod client software (due to quite a number of requests) – but time is lacking atm.

    Conrad

    Reply
  2. Eric -

    Thomas I love your work… Trying to get my zwave dimmer light switches to work… But they just pulse on off I suspect since just on off light setup how could I make dimmer work ?

    Reply
    • Thomas -

      You can send value 0-255 to set the dimming levels.

      Reply
  3. brian -

    Struggling with this, although I’m very close and I find your blog invaluable in this effort to get my pi to communicate with my z-wave devices. I can’t seem to get past step 8 – I try to do make but it throws several errors as follows:

    Main.o: In function `main’:
    /home/pi/open-zwave-read-only/cpp/examples/linux/basicServer/Main.cpp:318: undefined reference to `ServerSocket::ServerSocket(int)’
    /home/pi/open-zwave-read-only/cpp/examples/linux/basicServer/Main.cpp:323: undefined reference to `ServerSocket::accept(ServerSocket&)’
    /home/pi/open-zwave-read-only/cpp/examples/linux/basicServer/Main.cpp:329: undefined reference to `ServerSocket::operator>>(std::basic_string<char, std::char_traits, std::allocator >&) const’
    /home/pi/open-zwave-read-only/cpp/examples/linux/basicServer/Main.cpp:377: undefined reference to `ServerSocket::operator<<(std::basic_string<char, std::char_traits, std::allocator > const&) const’
    /home/pi/open-zwave-read-only/cpp/examples/linux/basicServer/Main.cpp:435: undefined reference to `ServerSocket::operator<<(std::basic_string<char, std::char_traits, std::allocator > const&) const’
    /home/pi/open-zwave-read-only/cpp/examples/linux/basicServer/Main.cpp:458: undefined reference to `ServerSocket::operator<<(std::basic_string<char, std::char_traits, std::allocator > const&) const’
    /home/pi/open-zwave-read-only/cpp/examples/linux/basicServer/Main.cpp:473: undefined reference to `ServerSocket::~ServerSocket()’
    /home/pi/open-zwave-read-only/cpp/examples/linux/basicServer/Main.cpp:473: undefined reference to `ServerSocket::~ServerSocket()’
    /home/pi/open-zwave-read-only/cpp/examples/linux/basicServer/Main.cpp:473: undefined reference to `ServerSocket::~ServerSocket()’
    Main.o: In function `ServerSocket’:
    /home/pi/open-zwave-read-only/cpp/examples/linux/basicServer/ServerSocket.h:14: undefined reference to `Socket::Socket()’
    /home/pi/open-zwave-read-only/cpp/examples/linux/basicServer/ServerSocket.h:14: undefined reference to `vtable for ServerSocket’
    collect2: ld returned 1 exit status
    make: *** [test] Error 1

    The open-zwave original project builds and runs well for me, as well as openzwave-control-panel. I can poll my devices and control them in the control panel. But your patched server just does not build.

    Brian

    Reply
    • Thomas -

      If you are getting that error right after running make, it is normal – the make file is messed up. Running “g++ -o test -g Main.o ../../../lib/linux/libopenzwave.a ServerSocket.o Socket.o -pthread -ludev” should properly generate the ./test server. Or are you getting the problem later in the after running the last command?

      Reply
  4. brian -

    Hmmmm. My udev was wacked in a bad update which might have something to do with it. I reformatted the SD and started over. I’m hobbling myself by trying to get this working on a pi running Raspbmc and it’s possible that the stripped-down version of Raspian it runs is causing dependency problems. I have another running full Wheezy I use for development and I’ll try it on that. Thanks for the quick reply!

    Reply
  5. brian -

    On another pi running current Wheezy it works! Thanks!

    Reply
  6. GoneCrazy -

    Just an FYI for anyone rolling their own and compiling this. The newest version of open-zwave seems to have made some changes to the “Basic” class which is causing a lot of headaches for people as is evident in the discussion group. I could not get my switch to turn on and off until I rolled back to Revision 640 of open-zwave which is where these changes took place, not sure why it doesn’t work in the newer versions, and could be something to do with the server code as I didn’t dig into it very far, but you can make it work with 640.

    Reply
  7. Issam -

    Hi Thomas,
    You have a great page, thank you for the valuable information.
    I have had the problem with the latest releases of openzwave. I want to ask you about the Raspberry pi setup and unreliable performance.
    all works well I have a small Zwave network of 10 nodes. however one of the rooms is in the back of the apartment and it is not always responsive and the system decides to put it as dead. 🙁 .
    what I don’t understand is that Node 10 is far from the raspberry pi however there are nodes 7,8,9 that are in between and 7,8,9 are working perfectly, except for the annoying Queueing delays.

    Any Idea why this might be happening, given that Zwave should have a mesh network and all the bla bla ..

    thanks Again, have a good weekend.

    IK

    Reply
    • Thomas -

      I have had this same problem before. Are you sure that your all your adapters are working as repeaters? Some of the cheaper one do not. What type of adapters are you using?

      Reply
  8. Issam -

    I am using Aeon Micro smart switches 2nd generation. however I do have a hybrid network (Duwi in-wall switces and homepro plugin switches.). I noticed that one or two act as only slaves. however all the other are routing slaves (‘LBR’).
    What is strange is the inconsistency.
    Thank you for your feedback, I will have to test some more.

    Reply
  9. Mike -

    Hi! Is it possible for your project to communicate with rasberry daughter gpio card instead of usb stick?

    Reply
  10. Thomas Terence -

    Hi, first of all, really nice job done here!
    I’m going through some problems with the basic-server’s communication, I don’t know what command to send in order to switch a node.

    Reply

Leave a Reply