04 February 2014

Installing Raspbian and openHAB on my Raspberry Pi

So, my smart house project has just begun. Luckily I had an unused Raspberry Pi lying around waiting to be used. I stopped using it earlier 'cause the SD card got corrupted all the time, and I forgot to backup it up after doing the final configurations. But now it's time to try again.

I assume you got a Raspberry Pi and an SD-card. What you'll also need is a keyboard and a connected monitor/TV. Then, let's get started:

To install Raspbian I downloaded NOOB, if your SD card is 4 gb or less (less is not recommended) you should download the NOOBS Lite, otherwise the install might not have enough disk space available. Follow the instructions on the page, including the formatting of the SD card.

If you have bought a Razberry card to talk to your Z-Wave components as I have, you should connect it now, before inserting the SD card and powering up your Raspberry Pi. My plan is to write a review of the Razberry card when I've tested it for some weeks.

Once the SD card is formatted and NOOBS-files have been copied over, insert it into your Raspberry Pi and install Raspbian from the menu.

When you have logged in to your raspberry (via ssh or directly) there are a couple of things you should do before installing openHAB or Z-Wave software:

To avoid corruption of your SD card, please follow this step-by-step guide

When you've finished this, you'll currently (when this was written) have to downgrade Raspbian to 3.6.11+ to get the Razberry-card working. On the Razberry site the recommend you to run a command to downgrade the kernel, but for me this only got me into trouble as my wireless USB-dongle stopped working, so I'll recommend that you do the following to downgrade:

  1. Install rpi-update (from the command line):

    sudo apt-get install rpi-update

  2. Let rpi-update install the correct version (hash found in the git repository on github, last commit on 3.6.11+)
    sudo rpi-update 8234d5148aded657760e9ecd622f324d140ae891

Now that this is done you can install your wireless USB-dongle, if you have one, please follow this guide:

The next steps are based on a blog-post i found earlier

    1. Install Z-way:

      wget -q -O - http://razberry.z-wave.me/install | sudo bash

    2. Start a browser on a another machine and go to http://raspberry-ip:8083
    3. Add your Z-Wave devices, and write down the node-numbers (if you have trouble doing this, check out the documentation here: http://razberry.z-wave.me/index.php?id=5)
      1. Select Network management under the Network tab
      2. Click on (Re-)include device (make sure the devices are close and powered)
      3. Repeat to include all your devices
    4. Stop Z-way as it cannot run at the same time as openHAB:
      sudo service Z-Way stop && sudo update-rc.d Z-Way disable
    5. Java should already be installed, check it by typing
       java -version

      - if it is not installed, please google it and install the newest version

    6. Now download openHAB, I got the newest version available from here . But if 1.4 is out, you should find the link to it here. Download runtime, addons and demo-configuration
    7. Download by using wget, for example
      wget https://openhab.ci.cloudbees.com/job/openHAB/lastSuccessfulBuild/artifact/distribution/target/distribution-1.4.0-SNAPSHOT-runtime.zip
    8. create a folder called openhab in your home-folder
    9. unzip the runtime file to this folder
    10. unzip the addons to a different folder an copy only the z-wave binding into the openhab/addon-folder
    11. unzip the demo-configurations into the openhab-folder
    12. create the file openhab/configurations/openhab.cfg with the following content:
      <br />
      ################################ Z-Wave  Binding ######################################<br />
      # The Z-Wave controller port. Valid values are e.g. COM1 for Windows and /dev/ttyS0 or<br />
      # /dev/ttyUSB0 for Linux<br />
      zwave:port=/dev/ttyAMA0# Z-Wave binding refresh value (optional, defaults to 10000)<br />
      #zwave:refresh=<br />
      # Z-Wave binding refresh interval threshold (optional, defaults to every 6 times)<br />
      #zwave:refreshThreshold=<br />
    13. add the following to the openhab/start.sh script (line starting with java, not at the end, but somewhere in the middle:
       -Dgnu.io.rxtx.SerialPorts=/dev/ttyAMA0 
    14. Move the openhab/configurations/rules/demo.rules out of the openhab folder, or remove all the rules that include "say" (not yet implemented)
    15. Make sure the openhab/start.sh is runnable:
      chmod ug+x start.sh
    16. Make sure the user starting openHAB is in the dialout-group:
      sudo usermod -a -G dialout pi
    17. Start openHAB by running
      ./start.sh
    18. If something goes wrong, look at the post i refer to at bullet points 12 to 14
    19. Open a web browser and go to http://raspberry-ip:8080/openhab.app?sitemap=demo

That should be it. The Raspberry should be up and running with your Razberry card and openHAB. Next up is configuring the nodes, stay tuned.