DIY Smart Home

Getting Started with OpenHAB Home Automation on Raspberry Pi

James Bruce 04-09-2015

OpenHAB is a mature, open source home automation platform that runs on a variety of hardware and is protocol agnostic, meaning it can connect to nearly any home automation hardware on the market today. If you’ve been frustrated with the number of manufacturer specific apps you need to run just to control your lights, then I’ve got great news for you: OpenHAB is the solution you’ve been looking for – it’s the most flexible smart home hub Which Smart Hub for Home Automation Is Best for You? For a while, people thought of the idea as nothing more than a gimmick, but recent product releases have shown that smart home automation is starting to live up to its promises. Read More you’ll ever find.

This guide is available to download as a free PDF. Download Getting Started with OpenHAB Home Automation on Raspberry Pi now. Feel free to copy and share this with your friends and family.

Unfortunately, it’s about as far as you can get from consumer friendly – but as ever, that’s where MakeUseOf comes in: we’ll show you how to get up and running with the ultimate smart home system money needn’t buy (because OpenHAB is 100% free – just supply the hardware).

The first part of this guide focuses specifically on how to get OpenHAB setup with a Raspberry Pi 2, but further on, the tutorials and advice can be applied to anywhere OpenHAB is installed.

This guide covers three introductory topics, and one slightly more advanced.

  • Getting OpenHAB up and running on the Pi, and installing the demo house configuration to check core systems are working.
  • How to add bindings, and profiles for devices. I’ll be working with Philips Hue.
  • Enabling remote access, and connecting to IFTTT.
  • Adding a DIY presence sensor using Bluetooth, and an introduction to the REST interface.
  • Configuring the OpenHAB mobile app.

What You’ll Need

At the very least, you’ll need a Raspberry Pi (v2, preferably), and an Ethernet or wireless adapter (Ethernet preferred, this guide won’t include instructions on making your Wi-Fi adaptor work Setting Up Wireless Networking on Your Raspberry Pi Virtually every Raspberry Pi project will require a network connection, and considerable flexibility can be gained by ignoring the Ethernet port in favour of a wireless USB dongle. Read More ). Everything else is optional. Note that OpenHAB will run on the original Raspberry Pi too, but there’s a known issue with slower processing and Z-Wave devices. If you have no need of Z-Wave, you can safely ignore this warning and go ahead with a Raspberry Pi model B or B+, because everything else seems to work fine. You can always upgrade to the latest Pi if and when you do add Z-Wave.

Photo of Raspberry Pi 2 being used as OpenHAB controller
This little thing can be the best smart home hub you’ve ever had!


At the time of writing, the latest stable version of OpenHAB is version 1.71; version 1.8 is expected soon, and everything in this guide should still be relevant, though certain bindings may have more features. Version 2 is also currently available as a very early alpha preview, but adopts a dramatically different architecture to the OpenHAB 1 series: this guide is not compatible with version 2.

I strongly suggest you follow this guide through slowly and methodically – do not attempt to jump in at the deep end and add everything at once. Yes, it’s a long guide – OpenHAB is a difficult system that often requires tweaking for your needs, and the best way to ensure success is to work slowly and complete one piece at a time.

The good news is that once it’s working, it’s a rock solid experience and incredibly rewarding.

Installing OpenHAB

There’s no pre-configured image for OpenHAB, so installation is done the old fashioned way via a command line. I suggest you work headless on the RPi – the overhead of managing a GUI which you’ll rarely use isn’t worth it.


Start with the latest (full) Raspbian SD image (not the “lite” version, these don’t include the Java Virtual Machine). Get your network cable plugged in, then boot up, and navigate through SSH. Run:

sudo raspi-config

Expand the filesystem; and from the advanced menu, change the memory split to 16. When you’re done, restart, and as good practice, run a full update

sudo apt-get update
sudo apt-get upgrade

The easier way to install the OpenHAB runtime is via apt-get, but first we need to add a secure key and the new repository:

wget -qO - '' |sudo apt-key add -
echo "deb stable main" | sudo tee /etc/apt/sources.list.d/openhab.list
sudo apt-get update
sudo apt-get install openhab-runtime
sudo update-rc.d openhab defaults

Curiously, everything was installed as owned by “root”. We need to fix that with the following commands.

sudo chown -hR openhab:openhab /etc/openhab
sudo chown -hR openhab:openhab /usr/share/openhab

Next, we’ll install Samba and share the configuration and user folders – this will make it easier to install add-ons and change the sitemap remotely.

sudo apt-get install samba samba-common-bin
sudo nano /etc/samba/smb.conf

Change the workgroup name if needed, but otherwise enable WINS support:

wins support = yes

(you’ll need to uncomment the line, and change no to yes)

then add the following to the share definitions section (scroll all the way down to the bottom of the long file):

[OpenHAB Home]
 comment= OpenHAB Home
 only guest=no
 create mask=0777
 directory mask=0777
[OpenHAB Config]
 comment= OpenHAB Site Config
 only guest=no
 create mask=0777
 directory mask=0777

I also commented out the Printers section. I’ve made two shares, since the configuration files are actually stored separately to the add-ons.

Save and exit. We finally need to set a Samba password for the openhab user:

sudo smbpasswd -a openhab

I’d suggest “openhab” as the password just for ease of use, but it doesn’t really matter.

Thanks to reader David L – it appears the method of restarting Samba has changed in the latest Raspian. Here’s the updated instructions:

sudo update-rc.d smbd enable
sudo update-rc.d nmbd enable
sudo service smbd restart

After restarting Samba (older installs use sudo service samba restart), test you can access the shared drive. It might not be auto-discovered on a Mac; but you can use the Finder -> Go -> Connect to Server and the address


Authenticate with username openhab and your chosen password, then open up both your shares to have a look around. You should even be able to open http://raspberrypi.local:8080/ in your web browser, but you’ll be met with an error because we haven’t create a sitemap yet. That’s normal.

error on first launch openhab

Now would be a good time to learn the command to tail the OpenHAB log so you can keep an eye on errors.

tail -f /var/log/openhab/openhab.log

Keep that running and open in a separate SSH window at all times while you continue with the guide.

Install the Demo House

Before we delve into the intricacies of configuration files, adding devices and bindings etc; let’s check everything is working by adding the demo content. You’ll find “Demo Setup” under the downloads section of

Once you’ve unzipped it, there’s two folders: addons and configurations.

openhab demo content

Using the network shares, copy configurations to the OpenHAB Config share and overwrite the existing folder. Copy addons to the other OpenHAB Home share, again, overwriting the existing folders. If you aren’t prompted to overwrite something, you’re doing it wrong. If you’ve got your eye on the debug log file, you should see a flutter of activity as it notices the new bindings and whirs into action. Open raspberrypi.local:8080/ to see the demo.

OpenHAB demo house web interface screenshot

It’s a little basic looking at the moment, but the open nature of OpenHAB means we can install a lovely new theme later or an alternative interface entirely. For now, we just needed to know it’s all working. Note that what we’re looking at is called a sitemap (nothing to do with a website site map). A sitemap describes the user interface – not the actual devices on your network or sensors – just the interface to view them. Every part of it is completely customizable. To have a look at how this one has been created, open up the sitemaps/demo.sitemap file on the OpenHAB Config share.

sitemap demo example file

It’s pretty daunting, but for the most part you’ll be copy pasting code fragments from examples elsewhere to create your own custom interface. Here’s the technical overview of all possible sitemap elements, but for now it will suffice just to start thinking about what kind of interface you want to build and what information you want to display.

While you’re in there, open up items/demo.items too. Again, looks scary, but this is where you create items to control and define sensors to track.

So How Does OpenHAB Work?

Now that you’ve had a quick peruse of the sitemap and items folder, let’s break down exactly what these files are and the other main components of OpenHAB that combine to create your complete smart home. You’ll find subdirectories for each of these in the OpenHAB Config shared folder.

Items is an inventory of every control device, sensor, or information element you want in your system. It needn’t be a physical device either – you might define a web source such as weather or stock prices. Each item can be named, assigned multiple groups (or none), and connected to specific binding. (Beginner tip: Capitalization is important when it comes to bindings. I spent a long time trying to work out why my “Hue” bulbs weren’t working; it was because they should have been “hue” instead).

Sitemaps is concerned only with the interface you’ll see when you open the OpenHAB mobile or web app. You can control precisely how you want the buttons laid out and information presented. You could define top level groups for each room of your house; clicking on each would show you a list of every device in that room. Or you might prefer to show groups for each type of device: a button for lights, another for electrical outlets. There might be some devices you use so often that you just want a switch for them right on the home screen.

Rules is where the home automation aspect comes into play, where you can define schedules or conditions for an action to happen. Simple events like turning on the bedroom lights at 10pm to a warm red color; or more complex logic like turning on a space heater if the temperature is less than 0 and someone is present in that room. You’ll also find a scripts folder, which offers similar functionality to rules but at a more complex level of programmable logic.

Persistence is an advanced topic that we won’t be covering in this guide, but persistence defines data you want to keep a record of. By default, OpenHAB is only going to show the current state of something; if you want to track that value over time, you need to setup a persistence definition for that data source. In this you’ll specify things like how often a data point should be measured, or when to discard old data points – you’ll also need to tell it what kind of persistence engine to use, such as MySQL or simple logging to a file.

Transform contains mappings for data values to labels. For instance, the humidex.scale file defines a range of humidity index values and how they should be shown in English:  29-38 is “some discomfort”.

The sitemap and items files are essential for OpenHAB to run; the rest are optional. You can have multiple sitemaps and items, so you can keep the demo content and refer back to it at any time, or try out a new layout for your home control interface. Don’t worry if this all seems a bit overwhelming right now, we’ll break it down into manageable pieces and I promise by the end of this guide you’ll have confidence to create your own OpenHAB setup.

Next up, we’ll walk you through adding some common smart home kit, starting from scratch in a new sitemap. Each one will introduce some core concepts such as how to install bindings and item definitions, so I’d strongly encourage you to read through these instructions even if you don’t own those particular devices.

Start by creating a new (blank) home.items file, and a new home.sitemap file in the relevant directories. Open up home.sitemap and paste in the following code. This just acts as a basic skeleton to which we’ll be adding bits later.

sitemap home label="My Home"

You should see a notice to report that OpenHAB has identified a new sitemap and items file.

openhab new sitemap and items

Enable Debug Mode

While you’re still trying to get OpenHAB working correctly, it can be useful to enable a more verbose debug log that lists everything, and not just the important stuff. To enable this mode, open up the OpenHAB Config shared folder, and edit the logback.xml. On line 40, change the following line to read DEBUG instead of INFO. You’ll need to restart after changing this.

<logger name="org.openhab" level="INFO"/>

This is a global change, so you’ll be getting a lot more info once you tail the log file.

Adding Philips Hue

I’m going to start with Philips Hue. Like most things you’ll want to interact with in OpenHAB, Hue bulbs require the you to install a binding – think of bindings as like a device driver. At the time of writing, there’s around 160 bindings available for OpenHAB 1, which is why OpenHAB is such a powerful system – it can interface with anything, combining all of those disparate control systems into a single unified interface. Here’s a demo and quick overview of the steps involved.

Bindings must first be downloaded, and the easiest way to do this on the Pi is using apt-get, then force ownership to the openhab user.

sudo apt-get install openhab-addon-binding-hue
sudo chown -hR openhab:openhab /usr/share/openhab

Next you need to tell OpenHAB to load in that binding, and configure any variables needed. Browse to the configurations folder and make a copy of openhab-default.cfg, naming it openhab.cfg. Open that up, search for HUE and replace the whole section with the following code. The only thing you need to change is the IP value of your bridge – if you don’t already know it, try the online discovery tool. The secret value doesn’t really matter, it’s just a kind of username that OpenHAB will use to identify itself to the bridge.

Quick tip: to enable a line, just remove the # from the start. By default, the line specifying the IP address of the bridge is disabled (or technically, “commented out”). Also, if you’re trying an alternative configuration out, it can be useful to just copy the existing line and put a # at the start to mark it as a comment, so you can revert easily if things go wrong. 

################################ HUE Binding #########################################
# IP of the Hue bridge

openhab binding config

Save and exit. Like any third party Hue application, you’ll need to approve OpenHAB on the Hue Bridge by pressing the button on the front – you only need to do this once. You’ll see a message about waiting to be paired if you’re tailing the log file, but if you’ve forgotten or missed the count down, just reset the Pi – you’ll get a 100 second timer from when the Hue binding is initiated. Make sure you’ve successfully paired before you continue.

Next, open up the home.items file, to which we’ll add some Hue bulbs. Here’s an example item definition:

Color Bedroom_Hue "Bedroom Hue" <hue> (Bedroom) {hue="1"}
  • The Color word specifies what kind of control we have over this item. RGB Hue bulbs are “Color”, since we have full color control of them. Other lights may just be a Switch.
  • Next is the codename of the item: I chose Bedroom_Hue, but literally anything is fine – just something descriptive that feels natural to you, because you’ll need to remember it later when making the sitemap. The codename should have no spaces.
  • Between the quote marks is the label. Ours is simple in this case, but for some items like temperature or something that reports a value, you’ll add some special code that tells it how to display that value or using what transform. The label is for the interface, and it can have spaces.
  • Between the angle brackets is the name of the icon. You’ll find all the available icons in the OpenHAB share, under the webapps/images directory. There’s actually a whole range of hue icons that represent different brightnesses or on/off. Just specify the base icon name – OpenHAB will know to automatically look for the different on/off icons if this is a switched item.  This is optional.
  • In the round brackets, we tell it which groups to be a part of – in this case, just the Bedroom group.
  • Finally and crucially, we connect the item to the appropriate binding with any variables needed. In this case, the hue binding, and the number of the bulb is 1. You can find the number by opening up the official Hue application and looking at the lights tab. Each bulb has a unique number.

I’ve added a total of four bulbs, as well as a simple declaration of the groups that we’ll expand on later. Here’s my complete home.items at this point:

Group Bedroom
Group Office
Group Kai
Group Living_Room
Group Cinema
Group Secret
Group Lights
/* Lights */
Color Bedroom_Hue "Bedroom Hue" <hue> (Bedroom,Lights) {hue="1"}
Color Office_Hue "Office Hue" <hue> (Office, Lights) {hue="2"}
Color Secret_Hue "Secret Hue" <hue> (Secret, Lights) {hue="3"}
Color Kai_Hue "Kai's Hue" <hue> (Kai, Lights) {hue="4"}

The /* Lights */ text is just a comment, it has no function other than to help us scan the file later when it gets bigger. Now we have the devices added, but opening up http://raspberrypi.local:8080/?sitemap=home results in a blank interface – of course, because we haven’t actually created interface elements in the sitemap yet. Let’s start really simple for now. Open up home.sitemap.

The code used to describe the interface is different to items, but for now we’ll create a new “frame” and add a couple of group controls along with some icons.

sitemap home label="My Home"
 Frame {
  Group item=Lights label="All lighting" icon="hue"
  Group item=Bedroom label="Bedroom" icon="bedroom"
  Group item=Office label="Office" icon="desk"

Groups are a useful tool for quick testing, but in reality you’ll want more control over over how the items are display. For now, this will suffice. Save and reload your home sitemap in the browser. You should see this (or, whatever groups you’ve added).

openhab first sitemap

Click on All lighting to see every Hue light, since we’ve defined them all as belonging to that overarching lights group.

openhab lights group Hue demo

Notice that the Office Hue item is displayed with a different icon – that’s because my office light is already on, and OpenHAB knows this when it spoke to the Hue bridge and was smart enough to adjust the icon the “on” version of the file. Unfortunately, it doesn’t reflect the color, but if you have mobile app installed, that will reflect the current color.

If you’re seeing more items than you thought you’d defined or receiving errors about multiple definitions, know that although you can only load one sitemap at a time onto the page all sitemaps will pull items in from all .item files, so if you’ve left the demo items file there, you may have some additional items show up in your groups as well. I’d suggest at this point backing up the demo items content and moving it out of the folder to avoid duplication errors.

Remote Access, and IFTTT with My.OpenHAB

Right now, you need be on the same local network to access your OpenHAB system, but what if you want to control your devices and check on sensors when out of range of your Wi-Fi? For that we’ll need to set up remote access – and we’ll do it the easy way, with the My.OpenHAB web service [Broken URL Removed], which bypasses the need to mess around with port forwarding and router configurations. As a bonus, the My.OpenHAB service also has an IFTTT channel, giving you infinite possibilities for remote control and automation.

First: install the binding. Quick tip: if you don’t know the exact name of a particular install package, try searching for it with apt-cache.

apt-cache search

sudo apt-get install openhab-addon-io-myopenhab
sudo chown -hR openhab:openhab /usr/share/openhab


Before you can register on the My.OpenHAB site, you’ll need to create a secret key, and find your UUID, which uniquely identifies your installation. Check under the OpenHAB Home share -> webapps -> static and you should find a UUID file containing your unique identifier. It’s at this point that I discovered my Pi was using an older version of Java which doesn’t correctly create the secret key. Type

java -version

to check. If it doesn’t say 1.7 or higher, you have the wrong version. Oddly, the latest version of Raspbian does come with Oracle Java 8 installed, but not set as default.

sudo update-alternatives --config java

update java version

Choose the option that indicates jdk-8-oracle, then restart OpenHAB. Bonus: Oracle Java 8 is faster than the default OpenJDK!

Now you should also find a secret file in the webapps/static folder. Open both the secret and uuid, and be ready to copy paste.

uuid and secret

Now go create a My.OpenHAB account, using those details, then come back – you’ll also need to confirm your email before anything works. There’s a couple more steps to this one. First, we need to set the default persistence engine to myopenhab (persistence is something for a later guide, but regardless, we need to set up something basic in order to “export” our data to the online service and make it visible to IFTTT). To do this, open up openhab.cfg, and find the variable that says persistence:default= and change it to persistence:default=myopenhab. Save.

Lastly, create a new file in the configurations/persistence folder called myopenhab.persist, and paste in the following rule.

Strategies {
	default = everyChange
Items {
	* : strategy = everyChange

You don’t need to understand this for now, but know that it says “save every item state when it changes”.

my openhab items

To connect with IFTTT, head over to the OpenHAB channel – you’ll need to authenticate and give it access to your MyOpenHAB account. Also note that until your items have changed at least once, they won’t be visible in the items list on IFTTT, so if it’s not visible, toggle something on and off, then reload. Congratulations, you now have complete IFTTT access to everything in your OpenHAB system!

openhab ifttt channel

Bluetooth Presence Sensor using REST

A short while ago I showed you how to make an automatic office door lock using Bluetooth Make An Auto-Locking Office Door with Smartphone Proximity Sensor We'll be setting up a Raspberry Pi with a Bluetooth adapter to be on the lookout for when your smartphone is out of range, and snap a relay into action to lock the door. Read More scanning to detect presence of the user – I wanted to bring something like that into OpenHAB.

On any platform other than Raspberry Pi, this would be simple thanks to a ready-made Bluetooth binding; unfortunately, it doesn’t work on Pi due to a crucial Java file that would need to be recompiled for the ARM architecture, added to the binding, and then rebuild the binding. Suffice to say, I tried that, and it was hideously complicated and didn’t work. There is however a much easier solution that also serves as a good introduction to the sheer extensibility of OpenHAB: we’ll simply adapt our previous Python script to have it report directly to the OpenHAB RESTful interface.

Aside: a RESTful interface means you can interact with a system using it’s built in web server, simply by calling URLs and passing in or fetching data. You can visit this URL to see a simple example of this on your own server: http://raspberrypi.local:8080/rest/items – which outputs a coded list of all your defined items. This in incredibly powerful, as it exposes the full potential of OpenHAB and allows you to write custom interfaces; or in used reverse, to report the status of sensors without having a specific binding. We’ll use this capability to report the presence of a specific Bluetooth device without resorting to the Bluetooth binding.

Start by adding a new Switch item to your home.items file. I’ve called mine “JamesInOffice”, and I’ve made it a switch rather than a simple on/off contact so that I can manually control my presence in case my phone dies.

Switch JamesInOffice "James in Office" (Office)

Notice that I’ve not defined an icon, or associated a specific binding. It’s just a generic switch.

Next, insert a compatible USB Bluetooth dongle, and install some basic tools for interacting with it.

sudo apt-get install bluez python-bluez python-pip
sudo pip install requests
hcitool dev

The last command should show your Bluetooth adapter. If nothing is listed, try another adapter, yours isn’t compatible with Linux. The next step is to find the Bluetooth hardware address of your device.


Ensure your phone is open on the Bluetooth settings page (which puts it into pairing/public mode), and obviously that Bluetooth is activated. You should find a hexadecimal hardware address listed.

bluetooth identified

From your Pi user home directory, create a new Python script and paste in this code.
There’s a few things you’ll need to edit, starting with your particular device address:

result = bluetooth.lookup_name('78:7F:70:38:51:1B', timeout=5)

As well as the this line, which is in two places (yes, this could probably be structured better). Change JamesInOffice to the codename of the switch you defined.

r = requests.put("http://localhost:8080/rest/items/JamesInOffice/state",data=payload)

The final step is to tell this script to launch at boot time.

sudo nano /etc/rc.local

Scroll down to the bottom and just before the exit 0, add the following lines:

python /home/pi/ &

The & sign means “do this in the background”. Go ahead and run the script if you haven’t already, and open up your OpenHAB interface. If you’ve added it to a group, click through to that group. It takes about 10 seconds to update, but you’ll see the default lightbulb icon come on or off depending on whether your phone is detected or not. Check the log file if nothing happens, it could be that you’ve used the wrong Item name.

OpenHAB Mobile App

Though you can of course use the web interface from a mobile device, OpenHAB has native apps for both iOS and Android – and they look a lot nicer than the default browser interface. On the settings screen, enter the local URL as the internal IP you’ve been using until now, including the port number. For remote URL, enter, and you username (email) and password that you entered when you signed up. If you haven’t signed up for MyOpenHAB yet, just leave the authentication and remote URL blank, but you’ll only be accessing your system from your local Wi-Fi.


Moving Forward and Getting Help

The amount of customization and neat features you can add to your OpenHAB controller is really kind of epic. As well as the vast list of supported devices with bindings, you can use the RESTful interface, HTTP extensions, and IFTTT to read from or control literally any kind of IoT device, and then some (try some of our creative lighting ideas 7 Creative Uses for Colored LED Home Automation Lighting Turning on your lights automatically is certainly cool, but it doesn't take advantage of the full spectrum of colors available with RGB lighting. For that, we need to get creative. Read More ). Yes, it’s an absolute pain to install, but not a single commercial system can come close to the power of a customized OpenHAB system.

That said, the ride wasn’t at all easy for me, which is precisely why I wrote this guide, to ease the process for you. And if you find the OpenHAB system overwhelming, there are other options when it comes to Raspberry home automation—like using Raspberry Pi to automate your garage door How to Automate Your Garage Door With IFTTT and Raspberry Pi In this tutorial, we'll show you how to automate your garage door using nothing more than a Raspberry Pi and IFTTT. Read More for example.

Stay tuned to MakeUseOf for an advanced guide that covers Z-Wave and other cool tricks you can set up.

If you need help with a specific part of this guide, please ask away in the comments. If you want help with another binding or some advanced topics we haven’t covered yet, the official OpenHAB forums are a welcoming place.

Related topics: Home Automation, Longform Guide, Smart Hubs.

Affiliate Disclosure: By buying the products we recommend, you help keep the site alive. Read more.

Whatsapp Pinterest

Leave a Reply

Your email address will not be published. Required fields are marked *

  1. Mitchell Lombard
    November 5, 2016 at 1:41 am

    Someone has put together an img file which automates the whole setup process for raspberry pi, just download, flash to SD, boot and wait.

    You can find it at

    • James Bruce
      November 8, 2016 at 11:59 am

      Oooh, that does look interesting. It's for OpenHAB 2 however, which last time I checked is still very much in unsupported and alpha stages - but very cool way to test it out. Thanks for the link!

      • ThomDietrich
        December 7, 2016 at 11:06 am

        Hey, I'm the author of openHABian and happy to see the link here. Actually openHAB 2.0 has reached a pretty stable state and will soon reach it's final release. Many users including me are happy with openHAB 2 in everyday use for quite some time now. I would say it's safe to upgrade, I would even say Still staying with openHAB 1.8 is not worth it as all current improvements are going into openHAB 2.0 and you are seriously missing out. You just need to do your homework before switching and it would be recommendable to check for bigger changes when upgrading the package to the newest revision. One big setback was the limited documentation till now, recently many things were added and has reached a good level of detail (one big Change is currently awaiting approval).

        The Migration Tutorial for who is interested:

  2. Teddy Martin
    October 29, 2016 at 8:44 pm

    I have successfully installed Openhab and I am up to the point where I can access the shared drive on my laptop. I was able to access the shared folders, but I have not been able to access the page on my web browser when I type "http://raspberrypi.local:8080/". It says "This site can't be reached. raspberrypi.local refused to connect. Any ideas? Thanks!

    • James Bruce
      October 30, 2016 at 7:59 am

      Hmm - try with the IP address instead of raspberrypi.local. Try curling from the SSH session, which will tell you if the web server is even running. And check the openhab log file - if it's blank, the service isn't starting; if it's not blank, it should give some helpful debug output.

      • Teddy Martin
        October 31, 2016 at 9:42 pm


        So I tried the IP address as well as curling from the SSH session, and it says "connection refused." I was reading somewhere else online that I needed to start openhab from the command line using "./", so am I just completely missing something where I am supposed to start openhab? Also no openhab.log file has been created in /var/log/openhab. I have followed and double-checked all steps up until this point without errors.


        • James Bruce
          November 1, 2016 at 5:07 pm

          What happens if you type "service openhab start"? (also try "status" and "restart" instead of start).

        • Teddy Martin
          November 1, 2016 at 8:14 pm


          I receive an error "Failed to start/restart openhab.service: Access denied" when running the service openhab start/restart command. It also says openhab.service is disabled. Sorry for all the comments.


        • Mike
          August 30, 2018 at 1:56 am

          Yes, you have to start the service.
          I missed that somewhere also.
          Here it is 2018 and I am working through 1.8.3 as an educational experience. Once I get through then I'll understand and appreciate all that openHAB 2 has to offer.

          I am fairly intrigued and interested with having a private service and MQTT broker. It's the only way we can protect ourselves from the likes of product manufacturers who wish to gouge with fees for controlling an expensive product that is made cheaply.

          One of two things will get you going;
          1) sudo -i
          The previous command will put you into root mode.
          Now you will have permission to run the: service openhab start
          2) sudo service openhab start
          This second command can be run as if you are root WHEN you are not root.

  3. Fabio
    August 30, 2016 at 10:02 pm

    Hello James,

    Thanks for your nice article, really good stuff.

    I was struggling with the Hue pairing process, always had the error "2016-08-30 20:32:19.730 [DEBUG] [.h.internal.hardware.HueBridge] - Received pairing response: [{"error":{"type":6,"address":"/username","description":"parameter, usern$", so, finally it looks like the hue:secret value do matter, you have to create the secret (aka user) in advance at the bridge, go to from step #3 and it works like a charm.



  4. Julian
    August 21, 2016 at 9:42 pm

    First of all thank you very much for your article, it helped me a lot. But still I don't succeed at getting openhab running. Everything works just perfect until I want to check if the demo works. All I get is the same error 500 as without the demo. Can you tell me what I can do in order to fix this problem ? Thank you for doing this I appreciate it very much!

  5. Dario
    August 5, 2016 at 1:30 pm

    Hey and thank you for the great job!
    I am struggling having OpenHAB running.
    I tried first on a Synology NAS without success.
    Now I am trying with a PI (rev. B, not a 2... I have only Z-Wave devices and I am aware of the problems - at least that's what I was reading - but I would like to see it running at least, and I am waiting for a new PI to be delivered in the meanwhile).

    I got both some problems with
    - localisation, as already mentioned by someone else
    - with logs (tile says "file not found" and in fact if I ssh I can't see any file)
    - with having access to openhab/Config and openhab/Home

    I saw the modifications made (Wiki) and tried to correct.
    Can you eventually give it a check and edit the article itself, to avoid further problems?

    An other thing: I can't access the website via raspberry.local:8080/ in any way, like I couldn't with the installation in the NAS. No answer at all. So I can't in fact say if OpenHAB is running or not. How can I debug the situation? I am really willing to learn, but I have no experience in command line and Linux stuff, I am learning everything now... ;-)

    Thanks for helping!

    PS: by the way, I can ssh as pi@myraspberryIPthatIhadtofindmyself :-D but not with pi@raspberry.local - is there an alias somewhere to set? I opened that port for the PI's IP in the Router firewall, everything should be ok. I had other system (Domoticz, HomeSee etc) up and running without major issues both on the PI and on my NAS...

  6. Brian
    July 14, 2016 at 2:45 am

    Awesome Guide. I am new to the PI and OpenHab, and this is very helpful.

    I am scrolling through comments to find a solution to my problem, but can't find one.

    I am able to browse to \OpenHAB Home as a network drive, using openhab:openhab. I am not able to browse to or copy files to \OpenHAB Config. I get an Access Denied message.

    • James Bruce
      July 14, 2016 at 8:12 am

      They may have changed the config directory - if you SSH in and try browsing directly to the directory specified in the SAMBA config, does the folder actually exist?

  7. Anonymous
    July 11, 2016 at 10:54 am

    I am having problems finding this file as it is not where you said it is
    open up the OpenHAB Config shared folder, and edit the logback.xml. On line 40, change the following line to read DEBUG instead of INFO. I do not have this file. Is there a way I can check this using the Raspberry pi directories? As I had to access file like the configuration files through /usr/share/openhab/configurations by CDing into the folder. Also you have not explain the SSHing into the pi at the beginning.

    Other than that great write up so far.

    • James Bruce
      July 11, 2016 at 11:02 am

      Open a terminal, type: "ssh pi@raspberrypi.local". The password is "raspberry".

      According to the wiki, logback config location varies by install:

      apt-get installation

      /etc/openhab/logback.xml and /etc/openhab/logback_debug.xml

      manual installation

      /opt/openhab/configurations/logback.xml and /opt/openhab/configurations/logback_debug.xml

  8. Fraser
    July 11, 2016 at 9:12 am

    Brilliant article, thank you so much. This has enabled me to finally get a stable version of openhab up and running and it's great!!

  9. Srivishnu Piratla
    June 26, 2016 at 7:06 pm

    Hello, nice tutorial but while running tail -f /var/log/openhab/openhab.log , i get the error

    tail: cannot open ‘/var/log/openhab/openhab.log’ for reading: No such file or directory
    tail: no files remaining

    • James Bruce
      June 27, 2016 at 7:09 am

      Have you confirmed OpenHAB is even running, by visiting the demo sitemap?

      • Anonymous
        June 30, 2016 at 8:41 am

        I'm having same issue . Demo is running

    • James Bruce
      July 11, 2016 at 11:03 am

      Looks like they changed log locations - from the Wiki:

      apt-get installation

      The runtime log: /var/log/openhab/openhab.log Further log files are placed also into: /var/log/openhab/

      manual installation

      The runtime log: /opt/openhab/logs/openhab.log

      Further log files are placed also into: /opt/openhab/logs/

  10. Andrew
    June 21, 2016 at 4:20 pm

    Hello! Thank you for the guide! I am a little rusty on my linux skills, and I'm having some trouble copying the files from my PC to my Raspberry Pi using Samba. I have the server set up, and I can see the shares from my PC, but when I attempt to copy the Demo files over, I get an error saying "There is not enough space on OpenHAB-Config. You need an additional 20.0KB to copy these files". I'm sure the answer is something trivial that I've forgotten, so forgive me for my ignorance, but any help would be much appreciated!

    • James Bruce
      June 21, 2016 at 4:56 pm

      Have you expanded the disk space on your RPi? I've not seen that error before, but it would imply you've run out of room...

      • Andrew
        June 21, 2016 at 7:01 pm

        I have expanded the disk space. I have also noticed that I can't copy anything, even a 1KB text file, through the server without that error, so I'm thinking it's not simply that I've run out of space. I totally wiped and reinstalled Raspbian as well, and the error persisted, along with a strange third share just called "openhab", which mysteriously appeared at some point before I started over. The "not enough space" error and that third share are still here, despite me totally formatting the SD card and reinstalling everything, so I'm a little baffled.

  11. ERik
    June 20, 2016 at 1:20 pm

    Thanks for a well written tutorial.
    I Wonder if the LIFX can be used instead of Philip hue. Can't see that There is a binding for this or??

    • James Bruce
      June 20, 2016 at 1:52 pm

      Apparently not, or at least not easily. There does appear to be an OpenHAB 2.0 binding though:

      • ERik
        June 21, 2016 at 7:26 am

        Could the reason be because of the high price on the LIFX`?
        just starting to learn about OpenHab ..

        • James Bruce
          June 21, 2016 at 7:29 am

          I think they're roughly the same price as Hue bulbs, so I doubt it. Probably just a case of popularity - more people buy Hue, so the chances of having a developer with a Hue is higher.

          I'd love to checkout OpenHAB 2.0 myself, but last time I checked it didn't support Z-Wave yet.

  12. Alex B.
    June 9, 2016 at 9:37 pm

    To start openhab follow the instructions on

    Start openHAB - manually
    Init based on sysVinit (e.g. Debian 7 / Ubuntu 14.x and earlier)
    sudo /etc/init.d/openhab start
    sudo /etc/init.d/openhab status

    Init based on systemd (e.g. Debian 8 / Ubuntu 15.x and higher)
    sudo systemctl start openhab

    Start openHAB - at system startup
    Init based on sysVinit (e.g. Debian 7 / Ubuntu 14.x and earlier)
    sudo update-rc.d openhab defaults

    or using Init based on systemd (e.g. Debian 8 / Ubuntu 15.x and higher)
    sudo systemctl daemon-reload
    sudo systemctl enable openhab

  13. Henrik
    June 8, 2016 at 6:41 pm

    What used to be:
    sudo update-rc.d openhab defaults

    Should now be:
    sudo systemctl daemon-reload
    sudo systemctl enable openhab

    Based on these instructions:

  14. CIprian
    June 5, 2016 at 10:49 am


    Nice tutorial!

    I am having a problem with the first part! I have installed the demo but i cannot start the web page. Do i have to start any other services?


    • Samir Sogay
      June 9, 2016 at 12:04 am

      These instructions from elsewhere worked for me

      To run openHab at startup:

      sudo systemctl daemon-reload
      sudo systemctl enable openhab
      sudo nano /etc/rc.local


      /etc/init.d/openhab start
      before 'exit 0'

  15. Ramesh
    June 4, 2016 at 3:54 am

    Thank you James great tutorial..

    I have followed all the steps on my Raspberry Pi 3 until samba restart steps above.

    I am able to access the share drives but couldn't launch.
    Getting Connection refused. Please help.


    • Charles
      June 7, 2016 at 1:43 pm

      Hi, I'm mhaving the same problem here.

      I can see all the shared folders but cannot connect to

      Please Help!


      • Henrik
        June 8, 2016 at 10:34 am

        Got the same problem. Seems like the OpenHAB deamon never starts?

        • Henrik
          June 8, 2016 at 10:43 am

          Haven't tested it, but I think this might be the answer:

          Start openHAB - at system startup

          Init based on sysVinit (e.g. Debian 7 / Ubuntu 14.x and earlier)
          sudo update-rc.d openhab defaults

          or using Init based on systemd (e.g. Debian 8 / Ubuntu 15.x and higher)
          sudo systemctl daemon-reload
          sudo systemctl enable openhab

          from (

  16. Stefan
    June 1, 2016 at 7:53 pm

    Thank you James for this awesome tutorial. I got all the stuff going until the HUE section. The binding is installed correctly and the cfg file was changed with the ip address and the other entries.

    The log file shows the correct binding and then the countdown from 100 down to pair the device. But after I press the HUE bridge button, simply nothing happens. I can do a short tap, a long tap, three taps, doesn't matter. And so the countdown goes down to 0 and stops.

    I don't know if this is an issue of OH or of the HUE system. But I really hope for help.

    Here are some more informations:
    I am using an RPi3 with the latest Raspian OS installed with NOOBS (Java was pre-installed)
    I do have the "newer" HUE bridge (with Apple home kit support)
    I can ping the IP of the bridge from a raspberry shell
    I previously set up your tutorial on a VM with Debian in a MAC Fusion environment. Until the same point with the same result (at that time I thought that this might have been a problem of the VM)
    I can pair the HUE with my other home controller (Zipato Zipabox) without any problems.

    Do you have any suggestions?


  17. neo
    June 1, 2016 at 6:52 am

    Few questions on Security... In regards to openhap Mobile App, this could be hosted at some company or ^^ someone's garage for all I know... and is it really safe to have my entire home automation be accessed remotely through the internet using this app? Whoever works there would have access to all the smart items at other ppl's houses... Just wondering how secure are these ppl?

    • James Bruce
      June 1, 2016 at 6:59 am

      Convenience is a function of sacrificing security.

      There are two ways to access openhab remotely. Either you set up port forwarding on your router and use the built-in security (fiddly to setup), or you use their third party service, and have to inherently trust them.

  18. Johan Carlson
    May 15, 2016 at 9:10 pm

    Hi! First off all thanks for a great tutorial. I managed to set upp the demo mode and now started on my own sitemap but the "tail log" i s giving me an error that i dont understand.

    "2016-05-15 21:04:50.972 [WARN ] [.httpclient.HttpMethodDirector] - Unable to respond to any of these challenges: {oauth=OAuth oauth_problem="OST_OAUTH_PARAMETER_ABSENT_ERROR", realm=""}
    2016-05-15 21:04:51.002 [WARN ] [] - Method failed: HTTP/1.1 401 Unauthorized"

    Thanks for any help to resolve the problem.


    • James Bruce
      May 16, 2016 at 7:47 am

      Hi Johan. The error OAUTH_PARAMETER_ABSENT means you haven't provided an access key, which is a recent change on Yahoo's end. You can just delete the line from your items file to remove the error.

      If you need weather, try configuring another provider from the weather binding page:

      • Johan Carlson
        May 16, 2016 at 11:32 am

        Thank you that helped, but after I removed the line and restarted the Pi another problem took its place instead. Now i cant load the demo sitemap webpage and the log says:

        2016-05-16 11:03:21.214 [INFO ] [] - Stopped REST API

        Which might have something to do with it?


        • James Bruce
          May 16, 2016 at 12:00 pm

          That's a little more complex, and may point to another of issues. I'd suggest opening an issue on the Github tracker, as the creator will be better suited to help with that.

  19. Jon Morss
    May 8, 2016 at 6:05 am

    Very nice instructions. I did run into an issue with the Samba Server config where I kept getting printer errors as well as a "unable to connect to CUPS server locahost:631" after commenting the printer lines in the smb.conf .
    I found, after some searching, this are eliminated after adding the following lines under the Global section in the smb.conf file and the restarting samba.

    load printers = no
    show add printer wizard = no
    printing = bsd
    printcap name = /dev/null
    disable spoolss = yes

    Now I can view the raspberry Pi shares from a remote system.

    I am using a Raspberry Pi 3 running Raspbian Jessie 2016-03-18 and OpenHAB 1.8.2.



  20. Taylor
    April 23, 2016 at 7:51 pm

    Hi! Thanks for the awesome writeup first off. Very detailed and helpful. The problem I am currently having is that it seems my system cannot detect whether or not light are already on/off. If I turn my light on via the hue app, openhab doesn't realize this and just views it as off. I do have the refresh rate in the binding to 10000. Thoughts? Thanks!

    • James Bruce
      April 24, 2016 at 7:03 am

      Can you control the Hue lights through the OpenHAB app, or is that also broken? With a 10,000 refresh, it would take up to 10 seconds to reflect the current states in OpenHAB. Keep an eye on the log for relevant Hue entries.

      • Taylor
        April 24, 2016 at 11:16 am

        I can control the lights! They just don't reflect accurate states if changed via hue. It's hard to tell what exactly is going on in the log with the debug flag on. I see a lot of text that gets refreshed that I have no idea what it means!

        • James Bruce
          April 25, 2016 at 5:06 pm

          You definitely have the line in the config about refresh? By default, it won't poll for lamp status, so is it possible your line is commented out? Try changing it to a lower value, like 3000. Copy out some of your debug log to a Pastebin or Gist and put a link here for us to take a look.

        • Taylor
          April 25, 2016 at 7:20 pm

          Hi James,

          So in my openhab.cfg file I have

          hue:ip = numbers
          hue:secret= stuff here

          is the link with (I think) relevant debug information. But it's pretty verbose and I don't understand most of it to be honest. I would love any information you might have! Thanks

        • Taylor
          April 27, 2016 at 2:33 am

          Hey James,

          I actually re-installed raspbian on a new SD card and now the hue refresh is working correctly. No clue why. I'm seeing a "hue data refresh" which wasn't there before.

          Follow up question. Trying to remotely access my OpenHAB setup through the app. When I use my openhab PW and url, it gives me an error saying http: ok, but doesn't load. Any advice?

        • James Bruce
          April 28, 2016 at 7:27 am

          You really need to watch the debug log and paste those somewhere when it doesn't work. Finding the specific error and googling it tends to be the easiest way. If you can't find the right line, dump the recent bits into a pastebin and I'll take a look.

  21. Kevin
    April 14, 2016 at 7:40 pm

    I've gotten as far as the point where you connect to the smb://openhab@raspberrypi.local in finder I can connect to the pi, see the mounting drives both config and openhab. But when I try to double click on them it says I do not have permission to open.

    • James Bruce
      April 15, 2016 at 8:19 am

      Hi Kevin. First , make sure all your permissions are set right, so those folders are fully owned by openhab:openhab user, and the openhab user has been added to Samba. If that doesn't work, there's a similar problem posted two comments down, so try updating your Samba config with that one. Good luck!

  22. Alex
    April 10, 2016 at 3:54 pm

    Hey ! Thanks for the guide everything works smoothly. However, I was interested in getting my hue switch-on when bluetooth is detected.

    When I go to the web interface and turn the switch on the lights turns on, no problem.

    console output:
    Hueswitch received command ON
    Hueswitch state updated to ON

    However, when I run the script, User is detected but OpenHab simply outputs:
    Hueswitch state updated to ON

    March 31, 2016 at 11:50 pm

    Hi I had problems trying to access the Raspberry Pi share in Windows, to get around this I changed my Samba config a little. I changed the share name an now I can map to the location.

    comment= OpenHAB Home
    only guest=no
    create mask=0777
    directory mask=0777
    comment= OpenHAB Site Config
    only guest=no
    create mask=0777
    directory mask=0777

    • James Bruce
      April 1, 2016 at 7:39 am

      Thanks for the tip!

  24. Anonymous
    March 26, 2016 at 3:24 pm

    CHIP! Mine has been sitting on my desk the whole time I have been messing with this...right under my nose and didn't even think about it! Doh!!! Thank you sir!!
    (Thankfully it's a long weekend lol... Got lots to do now!)

  25. Marco
    March 26, 2016 at 8:15 am

    Hi there, thanks for your guide, i was literally crying in starting openhab on my raspberry. Now i get everything working. I see the shared folders on windows 10 in which i'm using the designer but i can't overwrite the files (only the working ones, like demo.sitemaps). I tried to stop the openhab service but didn't solved it. Any idea?

    • Marco
      March 26, 2016 at 9:48 am

      Sorry, i migrated openhab to pi user but the /etc/openhab/configurations was still on openhab:openhab user. I chmoded it to pi and now everythings working! ;)

      • Dario
        December 22, 2016 at 7:47 pm

        Please Marco, could you explain what you did?
        I am on W10 to, I can see the folders on my Rpi but I can't overwrtite the files too.. Moreover, when I open the folder from W10, I cannot pass username and password.

  26. Anonymous
    March 22, 2016 at 6:31 am

    I have a couple questions:
    I followed all of the code up until "So How Does OpenHAB Work?" When I open the demo sitemap, my browser says that the site cannot be reached. I have in the past been able to open the demo sitemap, but had to redo some stuff. Thru samba, I am able to access the files thru my network folders on my PC and add/remove files and the demo sitemap is under the configurations/sitemaps folder.

    Secondly, after I restart the Pi, how do I launch OpenHAB again (or does this tutorial enable it to auto-launch by default and I was not able to get it working in the first place to tell)? I cannot seem to find where the start file is located. Still a little new to Raspbian/Linux.

    It wouldn't be a great loss if I needed to wipe the Pi and start over (may end up doing that anyways), but still a hassle.


    • James Bruce
      March 22, 2016 at 7:54 am

      Look for the bit on debugging to figure out why your demo sitemap won't open. Assuming OpenHAB is running, it will have printed out some errors that should give a clue. Also, if you've been editing and moving files, you may have broken the permissions - search for permissions above and you should find the commands to reclaim permissions back to openhab user - that was the biggest issue when I was first starting out.

      It may just be that it isnt running: try

      sudo service openhab start

      OpenHAB is installed as a service, and to have it restart on startup, you'll need to add it to your /etc/rc.local files, like:

      sudo nano /etc/rc.local

      (add the following before the line that says “END”)

      sudo service openhab start &

      If this the first time you’re using that file, you need set the “execute bit” on the file with this:

      sudo chmod +x /etc/rc.local

      then it should start on restart.

      • Anonymous
        March 24, 2016 at 5:21 am

        Not sure what I did to get the Pi to connect to the sitemap, but it works now. As far as making OpenHAB run on startup, I ran

        sudo chmod +x /etc/rc.local


        sudo nano /etc/rc.local

        and then added

        sudo service openhab start &

        to the text below. Did I do this right? Does the rc.local file run on startup by default, or do I need to make that start up as well?

        #!/bin/sh -e
        # rc.local
        # This script is executed at the end of each multiuser runlevel.
        # Make sure that the script will "exit 0" on success or any other
        # value on error.
        # In order to enable or disable this script just change the execution
        # bits.
        # By default this script does nothing.

        # Print the IP address
        _IP=$(hostname -I) || true
        if [ "$_IP" ]; then
        printf "My IP address is %s\n" "$_IP"

        sudo service openhab start &

        exit 0


  27. Masejoer
    March 21, 2016 at 6:09 pm

    With the latest raspbian image, this process doesn't seem to work. There are major issues, and I'm not sure how to work through this last one.

    in syslog (nothing gets logged to /var/log/openhab):

    Mar 21 17:59:21 raspberrypi systemd[1]: Starting Starts and stops the openHAB Home Automation Bus...
    Mar 21 17:59:21 raspberrypi[2278]: setting permissions and owner openhab:openhab recursively for /var/lib/openhab
    Mar 21 17:59:21 raspberrypi[2278]: setting permissions and owner openhab:openhab recursively for /var/log/openhab
    Mar 21 17:59:21 raspberrypi[2278]: setting permissions and owner openhab:openhab recursively for /etc/openhab/configurations
    Mar 21 17:59:21 raspberrypi[2278]: setting permissions and owner openhab:openhab for /usr/share/openhab/webapps/static
    Mar 21 17:59:21 raspberrypi[2278]: setting permissions and owner openhab:openhab for /etc/openhab/jetty/etc/keystore
    Mar 21 17:59:21 raspberrypi[2278]: chown: cannot access ‘/etc/openhab/jetty/etc/keystore’: No such file or directory
    Mar 21 17:59:21 raspberrypi[2278]: chmod: cannot access ‘/etc/openhab/jetty/etc/keystore’: No such file or directory
    Mar 21 17:59:21 raspberrypi[2278]: setting permissions and owner openhab:openhab for /etc/openhab/configurations/users.cfg
    Mar 21 17:59:21 raspberrypi[2278]: chown: cannot access ‘/etc/openhab/configurations/users.cfg’: No such file or directory
    Mar 21 17:59:21 raspberrypi[2278]: chmod: cannot access ‘/etc/openhab/configurations/users.cfg’: No such file or directory
    Mar 21 17:59:21 raspberrypi systemd[1]: Started Starts and stops the openHAB Home Automation Bus.
    Mar 21 17:59:21 raspberrypi[2436]: Listening for transport dt_socket at address: 8001
    Mar 21 17:59:27 raspberrypi[2436]: 17:59:27.064 [Start Level Event Dispatcher] DEBUG org.eclipse.jetty.util.log - Logging to Logger[org.eclipse.jetty.util.log] via org.eclipse.jetty.util.log.Slf4jLog
    Mar 21 17:59:27 raspberrypi[2436]: 17:59:27.128 [Start Level Event Dispatcher] INFO o.e.j.o.b.i.s.DefaultJettyAtJettyHomeHelper - Configuring the default jetty server with file:/usr/share/openhab/etc/jetty.xml
    Mar 21 17:59:27 raspberrypi[2436]: 17:59:27.200 [Start Level Event Dispatcher] WARN o.e.j.o.b.i.s.JettyServerServiceTracker -
    Mar 21 17:59:27 raspberrypi[2436]: /usr/share/openhab/etc/jetty.xml (No such file or directory)

    ...and lots more - OpenHAB starts but its web interface will not load by DNS, IP, or changing the port and restarting OpenHAB. I have had no problem with OpenHAB on a Windows server, but want to get it moved over to a lower power device.

    • James Bruce
      March 21, 2016 at 6:27 pm

      If it possible you've installed the "light version" of Raspbian Jessie rather than the full version?

      Also, try reformatting and use the 1.7 branch, which is what this guide was written with. They invariably break everything with each new version (I assume you tried with 1.8).

      • Masejoer
        March 21, 2016 at 6:32 pm

        1.8.1, yeah. I used the full version, and decided to stick with the included Java v1.8, since I used that successfully on 1.8.1 under Windows.

        OpenHAB 1.8 fixed some issues I experienced with 1.7, so I don't want to downgrade. Since package installs seem to be the route everyone is going, I'd prefer to stick with that also , rather than manually install.

        I'm assuming we'll need to wait until the package itself is updated to install correctly on its own.

  28. Adi
    March 16, 2016 at 3:49 pm

    Awesome work
    I tried some tutorial. They were not comprehensive or usually I get stuck somewhere.
    But this was complete and very useful for a beginner like me.
    Keep up the great work :)

  29. LeoVe
    March 12, 2016 at 8:55 pm

    Great work, thanks !

  30. Harvey
    March 10, 2016 at 7:03 pm

    It looked very promising, but I did not get far.
    pi@RPI5 ~ $ wget -qO - '' |sudo apt-key add -
    pi@RPI5 ~ $ echo "deb stable main" | sudo tee /etc/apt/sources.list.d/openhab.list
    deb stable main
    pi@RPI5 ~ $ sudo chown -hR openhab:openhab /etc/openhab
    chown: invalid user: ‘openhab:openhab’
    pi@RPI5 ~ $ id openhab
    id: openhab: no such user

  31. James Bruce
    March 9, 2016 at 9:38 am

    Thanks for the tip, but the store shows it's currently in pre-order "Shipping June 2016", so not particularly useful for anyone trying to install OpenHAB now.

    • Jimmy`
      March 9, 2016 at 7:34 pm

      Yeah sorry, I bought via their kickstarter campaign. Thought they were made available already. Only a few months away... :-)

  32. Per Evers
    March 8, 2016 at 8:36 pm

    Hi. Great tutorial, however i have a problem.
    After downloading the Hue addon and editing the openhab.cfg file as you write im not seeing anything in my log telling me to pair my Hue bridge.
    i have followed your tutorial from step 1 multiple times, but same problem every time.
    Hope you can help me the write way.


    • James Bruce
      March 9, 2016 at 9:33 am

      Couple of possible things to look at:

      - Have you restarted the Pi? Once you restart, you need to log in again pretty quickly (within 100 seconds), to see the Hue bridge requesting authorization.
      - Have you confirmed file permissions on the Hue binding are correct (check for the CHOWN command listed)?
      - Do you see any output at all in the debug log from the Hue binding? If not, the binding isn't loading at all, so there's something wrong with your config. Paste your config somewhere and edit out any passwords so we can take a look and verify. Ensure you're using the actual config file, and not the demo/sample one.

      • Per Evers
        March 9, 2016 at 3:12 pm

        I have restarted the Pi many times, and the first thing i do is log in and tail the openhab.log file, and this is what i see:

        pi@raspberrypi:~ $ tail -f /var/log/openhab/openhab.log
        2016-03-08 21:06:14.767 [WARN ] [inding.hue.internal.HueBinding] - Hue binding skipped command because no Hue bridge is connected.
        2016-03-08 21:08:06.302 [ERROR] [.myopenhab.internal.MyOHClient] - Socket.IO error: not authorized
        2016-03-08 21:14:07.704 [INFO ] [c.internal.ModelRepositoryImpl] - Loading model 'myopenhab.persist'
        2016-03-08 21:14:57.944 [INFO ] [c.internal.ModelRepositoryImpl] - Refreshing model 'myopenhab.persist'
        2016-03-08 21:25:04.091 [WARN ] [inding.hue.internal.HueBinding] - Hue binding skipped command because no Hue bridge is connected.
        2016-03-08 21:25:04.286 [WARN ] [inding.hue.internal.HueBinding] - Hue binding skipped command because no Hue bridge is connected.
        2016-03-08 21:25:04.479 [WARN ] [inding.hue.internal.HueBinding] - Hue binding skipped command because no Hue bridge is connected.
        2016-03-08 21:25:04.700 [WARN ] [inding.hue.internal.HueBinding] - Hue binding skipped command because no Hue bridge is connected.
        2016-03-08 21:25:04.782 [WARN ] [inding.hue.internal.HueBinding] - Hue binding skipped command because no Hue bridge is connected.
        2016-03-08 21:25:35.131 [INFO ] [] - Stopped REST API

        I have tried these commands without success:

        sudo chown -hR openhab:openhab /etc/openhab
        sudo chown -hR openhab:openhab /usr/share/openhab


        sudo chown -hR openhab:openhab /usr/share/openhab

        if it is those you mean.

        As far as i can see from the openhab.log file it tries to load the Hue binding.

        What config do you want to take a closer look at? the openhab.cfg?

        Here is the Philips Hue part of that file:

        ############################### Philips Hue Binding ###################################
        # IP address of Hue Bridge (optional, default is auto-discovery)

        # Default secret key for the pairing of the Philips Hue Bridge.
        # It has to be between 10-40 (alphanumeric) characters
        # This may be changed by the user for security reasons.

        # Polling interval in msec to retrieve Philips bulb status.
        # Other apps can change Hue status or a physical switch can turn on / off lamp status.
        # If this happens the status of hue lamps within OpenHAB won't reflect the real status.
        # Currently (September 2014) there is no push technology available, so the only option is
        # to poll Philips bulbs to retrieve status and update items accordingly to reflect changes.
        # Polling is enabled if refresh is specified, by commenting out "hue:refresh=10000" statement.
        # Be aware that polling will consume resources, so a small refresh interval will increase cpu load.


      • Anonymous
        March 9, 2016 at 9:03 pm

        Hi again. Found out that the problem was something with the opanhab service not auto starting. Fixed the problem with this command:
        sudo service openhab start

        So now i have it running via my computer browser, and have tried following your guide to get myopenhab working so i can control it via my iphone. But even though i follow your guide i cant login via iphone app and i can't see any items on the items list.
        Any clue to what i have done wrong? maybe you need some more info?

        And just one more question. I'm from Denmark and we have some weird letters (ÆØÅ) do you know if its possible to use them with openhab?
        From my .sitemap file:
        Group item=Kitchen label="Køkken" icon="kitchen"
        It makes the letter Ø to a "?"


        • James Bruce
          March 10, 2016 at 10:20 am

          - Add that command to rc.local to get it to run on startup,

          - Danish? Thats difficult. Unicode breaks many things. Can you romanize the words instead? Like, just use "ae o a"?

          - MyOpenHAB: you need to ensure persistence is setup, AND have a value written to each item before it'll appear in the items list.

          - Check the log output for anything related to MyOpenHAB service, and what it shows when loading the mobile app. You know you need to select the right sitemap from app too?

        • Udo Hartmann
          March 15, 2016 at 12:02 pm

          Should be possible by setting the locales from Raspberry to 'da_DK.utf8' or something like that, maybe you have to create it with 'sudo dpkg-reconfigure locales' for using it.
          openhAB should respect the locales from Raspbian - at least it does here in Germany ;)

  33. Anonymous
    March 6, 2016 at 9:19 pm

    How do you restart openhab on the raspberry pi after it's been turned off?


    • James Bruce
      March 7, 2016 at 8:26 am

      It's supposed to start again on restart, but in my case it wasn't, so I added this line to /etc/rc.local file (before the line that says "END"):

      sudo service openhab start &

      If this the first time you're using that file, you need set the "execute bit" on the file with this:

      sudo chmod +x /etc/rc.local

  34. Marc
    March 6, 2016 at 1:49 pm

    Question about the upcoming openhab 2. I'm a complete newbie without programming experience but can navigate around a computer if given decent instructions. Concerned this may be over my head but don't want to try something like smartthings since I've read about reliability issues. So question is will openhab2 be easier for newbies to setup?

    • James Bruce
      March 6, 2016 at 1:56 pm

      Eventually, it aims to be, but right now the OpenHAB 2 team are focussed on migrating from 1 and some of the more basic stuff. I like the vision of OpenHAB 2, but I dont think it's going to be any better than 1 for quite a while yet.

      If you dont want to get your hands dirty, SmartThings is a good beginners choice, but it's not the only beginner friendly hub out there. Check the Controllers section on the r/homeautomation wiki for more consumer smart home hubs:

      • Marc
        March 6, 2016 at 5:09 pm

        Thanks for the link. I've researched most of those hubs except the castle. Haven't come across that one. Seems like it is really robust and the most capable out of the bunch. But the price tag....ouch. I didn't look at it in depth yet but it seems like I could get a similar set up with a ras pi and additional hardware. The price I'm guessing is for them taking all the hard work out of configuring the set up? Before getting into something that expensive I think I'll get a ras pi and a couple components to 'test the waters'. Not feeling good about it to be honest. Some of this is so foreign to me, but I'm willing to give it a shot. I'm just glad websites like this exist to help with the process.

  35. Marc
    March 5, 2016 at 6:31 pm

    Will these instructions work on the raspberry pi 3?

    • James Bruce
      March 6, 2016 at 8:05 am

      I dont see why not, but I'm not sure if the Bluetooth module is compatible with the presence detection script. The core OpenHAB stuff should work fine.

  36. Jamie N.
    March 1, 2016 at 3:33 am

    First I gotta say, thank you for writing such a thorough tutorial! I was overwhelmed when looking into OpenHab (still am actually, just not as much).

    Anyway, I got to the point where you said:
    "Now we have the devices added, but opening up results in a blank interface – of course, ..."

    When I visit the link though, I get an:

    HTTP ERROR 500
    Problem accessing / Reason:
    Sitemap 'default' could not be found
    Caused by:
    org.openhab.ui.webapp.render.RenderException: Sitemap 'default' could not be found

    message on the page. I don't know why it's talking about 'default', because I do have a 'home.sitemap' file in the 'sitemaps' folder as you described.

    • James Bruce
      March 6, 2016 at 8:06 am

      Possibly a permissions error. Did you set ownership of the all the relevant directories to openhab:openhab user?

      • Jamie N.
        March 6, 2016 at 4:50 pm

        Hi James, thank you for the reply.

        If you are referring to the section that said:

        Curiously, everything was installed as owned by “root”. We need to fix that with the following commands.

        sudo chown -hR openhab:openhab /etc/openhab
        sudo chown -hR openhab:openhab /usr/share/openhab

        yes, I ran those 2 commands. Was there something else I missed?

      • Jamie N.
        March 6, 2016 at 5:01 pm

        Oh, and I did run the following 2 commands as you described in the 'Adding Philips Hue' section:

        sudo apt-get install openhab-addon-binding-hue
        sudo chown -hR openhab:openhab /usr/share/openhab

      • Jamie N.
        March 6, 2016 at 6:24 pm

        So sorry, the problem was a typo in the sitemap file - I had spelled 'lable' instead of 'label'. The web page looks right now, with the 3 elements in it. I'm sorry to keep bothering you.

        • James Bruce
          March 6, 2016 at 8:58 pm

          Hehe, no problem - glad you solved it!

  37. Mads
    February 23, 2016 at 4:32 pm

    Can't get My.OpenHAB to work :(
    Have tried looking around the web but can find, for me, useful help...

    anyone who may know a solution, i just followed the guide (without have hue lamps so)

    • James Bruce
      February 23, 2016 at 6:22 pm

      1. Have you tried checking the debug log for errors relating to the MyOpenHAB service? Post those on the OpenHAB support forum, and they should help pinpoint the exact issue.

      2. If there's nothing at all relating to MyOpenHAB in the log, the binding hasn't been loaded properly - could be a permission issue. Find the bit in the guide above about CHOWN on the relevant directories.

      • Mads
        February 23, 2016 at 8:12 pm

        It works now :D
        I don't know why, but some restarts and setting the time right must have help.

        I corrected the time some time ago, but it did not work... the log did not show.
        Now my.openhab works and the time shows right :D

  38. Agata
    February 23, 2016 at 12:44 am

    I've been looking into setting up a system like this for motion sensing using a PIR. A lot of other stuff I've been running into mentions the use of z-wave controllers such as Razberry. From what I can tell, you do not use a controller here, am I right? If the RPi can be used as a controller why do people use things such as the Razberry? Does it just come with more possibilities for bindings?

    • James Bruce
      February 23, 2016 at 8:15 am

      Hi Agata. You'll want to read part 2: //

      You do need an interface to the Z-Wave network; I use an Aoetec Gen 5 USB dongle. Razberry is another option, but I opted for USB in case I shift away from OpenHAB/RPi at some point. Razberry limits you to only ever using RPi, but a USB dongle can be used by PC or anything else.

  39. dbabits
    February 15, 2016 at 7:42 am

    Thank you for the great tutorial. I was actually amazed that everything worked as described, just by copy-pasting!
    One issue in the logs: "There is no queryable persistence service registered with the name 'myopenhab'"

    And probably as a result, I don't see anything interesting in IFTTT (connected to my.openhab)

    pi@raspberrypi:/usr/share/openhab/configurations $ grep persistence openhab.cfg
    # The name of the default persistence service to use

    pi@raspberrypi:/usr/share/openhab/configurations $ cat persistence/myopenhab.persist
    Strategies {
    default = everyChange
    Items {
    * : strategy = everyChange

  40. bunkombe
    February 8, 2016 at 8:22 pm

    Does anyone know where I can find someone to help me setup openHAB. They can probably do it remotely as I can help with the physical installation and texting. I'm somewhat tech savvy but just don't have time to devote to this project due to work.

    I need help with

    install OpenHAB on either a virtual machine or directly on OS X on a Mac Mini.

    deciding on and purchasing various pieces of equipment that is known to be rock-solid with OpenHAB.

    I need all of the devices configured in OpenHAB; at first this will just be the AV systems (TVs, subwoofers and soundbars, video switcher, and various boxes [Roku, AppleTV, Nexus
    Player, Xbox 360/One, Playstation 3/4]).

    Thanks for any advice, it would really be a great help!

  41. Matt
    January 27, 2016 at 9:58 pm

    Hi James,

    Sorry yet another question, I have openhab up and running really nicely after followiong really helpful guide. Now connected to music, lights, switches and some basic rules, just waiting for aurdino parts to arrive from China now :-)

    One question though, I find that if the raspberry pi is rebooted I have to manually start openhab. There are various bit of info about auto starting at start up, I'm just not sure which I need to follow and as I have everything running perfectly I'm a bit nervous of screwing something up if I follow the wrong guides. Most guides suggest adding a startup script such as here however I notice this file already has aload of code in it, so I'm not sure what I should do??

    • Svein
      February 1, 2016 at 7:39 am

      Hi Matt,

      I had the same issue as you where I had to manually start openhab after rebooting.

      This command helped me, as it seems like latest Jessie release are using init based on systemd:

      sudo systemctl daemon-reload
      sudo systemctl enable openhab

      Please see the installation wiki and installation guide part 8 for more details:

  42. Betawax
    January 27, 2016 at 7:52 am


    Thx for the heads up. One comment though: "Start with the latest Raspbian SD image." should be "Start with the latest Raspbian SD full image. The lite does not contain Jave VM"

    • James Bruce
      January 27, 2016 at 9:56 am

      Thanks Betawax. I don't think there was even a lite image at the time, I'll change that now.

  43. V Tank
    January 26, 2016 at 9:07 pm

    Can I use this guide to set up everything and then have Siri control stuff? For example, "Siri, turn the living room lights off."

    • James Bruce
      January 26, 2016 at 9:26 pm

      The short answer is: no. Apple has HomeKit locked down tight, and OpenHAB isn't connected to it (yet), and never will be officially.

      The long answer is: stay tuned. I literally just made a Wifi light today that responds to Siri commands, and is ALSO linked into OpenHAB. There'll be a tutorial published in a few weeks. You'll need to run a create a separate config for each device you want controlled by Siri, and add it individually to your iPhone (that's just how HomeKit works I'm afraid, it isn't designed to work with other things), but it will work. There's also a very early "Home Bridge" extension for OpenHAB which aims to connect the two, but it's not quite there yet. I'll investigate that next and if it's ready to go, I'll write a setup guide for that too.

  44. Anonymous
    January 22, 2016 at 4:17 am

    Thanks for the very interesting article. I have the basic question: what editor you use to edit files on MAC?

  45. Ben
    January 22, 2016 at 1:29 am

    Thanks a lot for these tutorials; they've been really helpful.

    I just stuck on one part with the Bluetooth presence detection. When I reboot, I get an error saying:

    Traceback (most recent call last):
    File "/home/pi/", line 27, in
    r = request.put("", data=payload)
    NameError: name 'request' is not defined

    Any idea what I'm doing wrong?

    Also, I've seen other people do similar things with the exec binding instead of REST. Any thoughts on how two compare? When would you use one over the other?

    • James Bruce
      January 22, 2016 at 8:42 am

      Hi Ben. You need to install the requests library. Try "sudo pip install requests".

      You might also need to install pip though, which is a part of python dev: "sudo apt-get install python-dev python-rpi.gpio".

      • Ben
        January 27, 2016 at 4:24 pm

        Thanks. I have the Bluetooth detection working well with my iPhone 5, but I'm having problems with my wife's iPhone 6S; OpenHAB only seems to detect the 6S when I have the phone actively searching for Bluetooth devices.

        If there's not a simple solution, I'm considering using an iBeacon instead. Any experience/ recommendations on these? It looks like there are a lot of different options and price points.

        • James Bruce
          January 27, 2016 at 6:35 pm

          That's very curiousI don't think the Bluetooth was changed from iPhone 6, which is working for me. I've got a couple of beacons I can play with, I haven't tried using them before but will give it a go and let you know.

  46. Matt
    January 19, 2016 at 10:01 am

    Hi James, sorry for all the questions, just wondering which the technology you would recommend in the UK for light and power control, based on using openhab as my controller?

    There are so many options and ideally I would like it to be as unobtrusive as possible. Which is simple and plays best with openhab? Thanks again matt

    • James Bruce
      January 19, 2016 at 10:13 am

      I haven't found the best solution for power yet, but I did buy some Belkin WeMo switches to test last week, and can confirm they are absolute trash - spent an hour trying to get them to connect to my home Wifi, tried two different routers, right next to them etc - nothing worked. I have a single Zwave power switch which is working reliably now, but it took a while for it to settle down and the range isn't great (old house with thick stone walls). I plan to have a hunt around for some other options, but right now ZWave is looking most likely.

      For coloured/effect lighting, my Philips Hue bulbs work reliably, so I havent tried any others. Unfortunately the rest of my house is mostly MR16/GU10 downlighters, and there aren't any compatible smart bulbs for those sockets, so it would mean doing them at the switch level, which is a whole other level of complexity and cost that I'm not sure I can justify. My next project is a DIY Philips Hue / Siri controlled light strip, using ESP8266 - if your DIY skills are up to it, that might be a cheaper and more reliable option than Hue.

  47. Storm
    January 19, 2016 at 1:35 am

    Great tutorial! I do have one issue that I would appreciate some help with. I followed all your steps for my.openhab and myopenhab is online, but I keep seeing in the log "[WARN ] [.o.c.p.e.PersistenceExtensions] - Thers is no queryable persitence service registered with the name 'myopenhab'".
    Is this an ok warning to be seeing all the time?

    • James Bruce
      January 19, 2016 at 10:14 am

      Very odd. If you're seeing all your data in the my.openhab dashboard, I wouldn't worry.

  48. Bruce Lunde
    January 15, 2016 at 4:16 am

    Great Guide! I wonder if you can talk to how the part works where the icon changes on the sitemap when something occurs? I created a motion sensor, and have the rule working to parse out the Contact change to 1 for tripped, but I do not understand how you cause the icon to change on the site map?

  49. Aaron
    January 4, 2016 at 11:17 pm

    I first off want to say thank you so much for a great tutorial. This is great.

    However I am struggling mounting all of the folders on my mac from the pi. Oddly enough when I connect to the server raspberrypi.local I can mount the folders openhab and OpenHAB Home but when I try to connect to OpenHAB Config I get an error message saying
    "There was a problem connecting to the server "raspberrypi.local"."

    Any ideas why that would happen?


    • James Bruce
      January 5, 2016 at 8:24 am

      Sounds like a Samba config typo, perhaps? Double check that you've got the two shares listed correctly. Paste your entries here if you like so we can check.

      • Aaron
        January 7, 2016 at 8:50 pm

        I literally copied your samba config into terminal when I was making edits and have double checked it. Everything looks fine. For some reason after I connect to the server when I am selecting a volume to mount I am also given the option to mount a volume called "openhab" which has persistence and workspace folders. Any idea when where it is finding the directory for that volume to mount?
        Here is my config file for the Share Definitions sections

        #======================= Share Definitions =======================

        comment = Home Directories
        browseable = no

        [OpenHAB Home]
        comment= OpenHAB Home
        only guest=no
        create mask=0777
        directory mask=0777
        [OpenHAB Config]
        comment= OpenHAB Site Config
        only guest=no
        create mask=0777
        directory mask=0777

        # By default, the home directories are exported read-only. Change the
        # next parameter to 'no' if you want to be able to write to them.
        read only = yes

        # File creation mask is set to 0700 for security reasons. If you want to
        # create files with group=rw permissions, set next parameter to 0775.
        create mask = 0700

        # Directory creation mask is set to 0700 for security reasons. If you want to
        # create dirs. with group=rw permissions, set next parameter to 0775.
        directory mask = 0700

        # By default, \\server\username shares can be connected to by anyone
        # with access to the samba server.
        # The following parameter makes sure that only "username" can connect
        # to \\server\username
        # This might need tweaking when using external authentication schemes
        valid users = %S

        # Un-comment the following and create the netlogon directory for Domain Logons
        # (you need to configure Samba to act as a domain controller too.)
        ; comment = Network Logon Service
        ; path = /home/samba/netlogon
        ; guest ok = yes
        ; read only = yes

        # Un-comment the following and create the profiles directory to store
        # users profiles (see the "logon path" option above)
        # (you need to configure Samba to act as a domain controller too.)
        # The path below should be writable by all users so that their
        # profile directory may be created the first time they log on
        ; comment = Users profiles
        ; path = /home/samba/profiles
        ; guest ok = no
        ; browseable = no
        ; create mask = 0600
        ; directory mask = 0700

        • James
          January 7, 2016 at 8:54 pm

          Oh, I have an generic "openhab" share too - I think that's just the default user share. I'm afraid I have no idea why it would suddenly not work for the config folder. Do you get the same error if you connect to the IP address directly, rather than using raspberrypi.local?

        • Aaron
          January 7, 2016 at 9:02 pm

          Yep same error with the IP address. I am able to mount openhab and OpenHAB Home but not config.

        • Aaron
          January 7, 2016 at 9:41 pm

          Well this is weird but I kinda got it to work. For some reason it doesn't want to mount the last volume in my samba config file so by comping a duplicate home folder to the bottom my config folder suddenly started working.

          #======================= Share Definitions =======================

          comment = Home Directories
          browseable = no

          [OpenHAB Home]
          comment= OpenHAB Home
          only guest=no
          create mask=0777
          directory mask=0777

          [OpenHAB config]
          comment= OpenHAB config
          only guest=no
          create mask=0777
          directory mask=0777

          [OpenHAB Home2]
          comment= OpenHAB Home2
          only guest=no
          create mask=0777
          directory mask=0777

  50. Big Baaad Bob
    January 3, 2016 at 9:50 pm

    Thanks for the tutorial. I appreciate the best-practices use of apt and service.

    Here are some missing things and comments: (add sudo as needed)

    If you start with Raspbian Jesse Lite you'll need to install a JRE. Recommend "apt-get install oracle-java8-jdk".

    With the instructions above the openhab service doesn't start on Jesse. Recommend "service openhab enable" and "service openhab restart".

    With the latest version of openhab I'm not sure the chowns are necessary because the openhab service runs "" each time it starts. I didn't test this from scratch though.

    It might make sense to move the copy of the openhab_defauts.cfg to openhab.cfg earlier in the tutorial to remove an unnecessary error message.

    Lastly (opinions vary) it might eliminate some complication if the Samba part was a separate optional step. Editing the config files via SSH is pretty straightforward given that you already have SSH running.


    • James Bruce
      January 5, 2016 at 8:27 am

      Thanks for the tips Bob. Would recommend this running on Raspian Lite? As in, any performance gains that might be beneficial?

      I do think the shares are essential for a beginner though - editing files through SSH is not fun and not every binding can be installed through apt-get (at least, not the latest versions if you need those to fix something).

      • Big Baaad Bob
        January 11, 2016 at 3:35 am

        The Lite distro is specifically intended to be and designed for headless operation. As to performance increases, I don't know, but less "stuff" seems to be good for a headless HAB instance. Regarding Samba, as I said "opinions vary"... ;-)

      • Big Baaad Bob
        January 11, 2016 at 4:17 am

        Incidentally, the chowns in your instructions are definitely not required with the current distro of openHAB. It chowns the necessary files during startup each time.

        Also, disregard my suggestion about "service openhab enable" and "service openhab restart". The service starts up just fine IF you install the JRE before you install openHAB.

  51. Russell
    January 2, 2016 at 1:56 am

    Might be obvious to some, but I was (rather ignorantly) stuck on this for a while.

    When you're adding the HUE light, you need to uncomment the section included in the default config file. Remove the # to uncomment as the bridge IP is commented out by default.

    I was stuck on that longer than I'd like to admit...

    It might be worth mentioning that in the article, just for folks like me.

    • James Bruce
      January 2, 2016 at 8:32 am

      Good point, though I was assuming readers would be following on from part 1, where I think we covered that. I'll add a note anyhow, thanks.

    • James Bruce
      January 2, 2016 at 8:33 am

      Wait, this IS part 1. Sorry, brain fried.

  52. Age
    December 31, 2015 at 12:27 am

    I wonder if someone can help with an error when running the command for the secure key and repository step.
    When I run:
    wget -qO - '' |sudo apt-key add -echo "deb stable main" | sudo tee /etc/apt/sources.list.d/openhab.list
    I get the error: gpg: conflicting commands
    Can anyone suggest how to fix this.

  53. David L.
    December 16, 2015 at 2:16 am

    If anyone is having problems restarting samba (I kept getting"Failed to restart samba.service"), try the following.

    sudo update-rc.d smbd enable
    sudo update-rc.d nmbd enable

    Then, use this to restart:

    sudo service smbd restart

    Took me the better part of an hour to get this working. Hopefully this prevents others from facing a similar ordeal.

    Great tutorial by the way! Excited to get this up and running.

    • James Bruce
      December 16, 2015 at 10:36 am

      Thanks David, I'll update the guide with those instructions for new readers. Much appreciated.

  54. Stephen
    December 4, 2015 at 9:44 am

    Hi, thanks for a superb tutorial. This gives me great confidence to attempt this, though I have no experience with the Pi or Linux. My mission, in this case, is to provide home automation to a remote home that has no Internet connection.
    I am trying to find a solution using a dedicated Android phone instead, connected to the Pi through a local network through the Android's USB port. The Pi would function like a Linux PC using the Android as a tether.
    The aim would be to use my Android phone to connect to the remote Android and drive the OpenHAB system using a PPTP VPN connection.
    Does this sound reasonable? Does anyone have experience with this? Thanks in advance.

  55. Ren Eric
    December 2, 2015 at 5:38 pm

    Great tutorial! Which case is that on the above pictured Raspberry Pi 2?

  56. Rajesh
    November 30, 2015 at 2:58 am

    Hi James,

    Thanks for the brilliant tutorial. Yesterday was my first day into openhab and your tutorial was all I needed to refer to. Thanks for the great work.


  57. Mark
    November 21, 2015 at 6:18 pm

    Hi Jamen
    Thanks for this guide ;.-) I'm new to coding so it's probably just me But i have tried for the second time now on the raspberry pi i followed the guide, got no errors everything looks fine the sanba is running and i put the demo on it... but when i tried assets the from the browser i get "ERR_CONNECTION_REFUSED" what am i doing wrong..

    • James Bruce
      November 21, 2015 at 7:54 pm

      1. Ensure all the files are owned by the correct user. This tripped me up for ages.

      sudo chown -hR openhab:openhab /etc/openhab
      sudo chown -hR openhab:openhab /usr/share/openhab

      2. Check the debug log of OpenHAB to confirm it's actually up and running. This shoudl also reveal any errors, so maybe paste what you find into a pastebin and give us the link if you can't decipher what it says.

      tail -f /var/log/openhab/openhab.log

      3. Check you're accessing the correct sitemap - so the url should end with sitemap=demo and not sitemap=default or sitemap=home

      • Bradley Herbst
        December 9, 2015 at 4:58 am

        Thank you much, I was having trouble figuring out how he was able to see the display when Openhab was running as a service.

        tail -f /var/log/openhab/openhab.log

      • Joe Q.
        December 23, 2015 at 1:30 am

        Hi -- I'm in a similar boat to the commenter above. Went through the process, no problem accessing the SMB shares on my Windows network, but I get the "ERR_CONNECTION_REFUSED" error and the log indicates that OpenHAB isn't actually running.

        How do I start it? (And how do I make sure it starts at boot?)


        • Joe Q.
          December 23, 2015 at 4:05 am

          Okay, I think I may have partially answered my own question.

          I started the OpenHAB service with the following:
          sudo /etc/init.d/openhab start

          That stopped the connection refused error but still gave me a "sitemap can't be found error".

          I then downloaded the demo files from the OpenHAB site again and completely overwrote the existing files in the SMB shares (by deleting them) with those demo files. It seems that the "merge folders" wasn't enough.

        • James Bruce
          December 23, 2015 at 7:27 am

          Glad to hear you got it sorted Joe - that's the hardest part over with.

  58. Dan Arnold
    November 21, 2015 at 4:25 pm

    I've not got as far as most! When I go to access the folders in OpenHAB Config/configurations I get an error message saying I don't have permissions to access this - I'm completely new to Linux so would appreciate any noob-level guidance!

    • James Bruce
      November 21, 2015 at 7:51 pm

      Can you confirm that you can see the config directory shared folder on the network? Or are you have issues when just double clicking to access your Raspberry Pi? Are you having the same problem with the other directory?

      1. Did you set a password for the "openhab" user? Use the password "openhab" just because it's easy to remember.

      2. Type these two commands to ensure it's the openhab user that owns the config directory etc:

      sudo chown -hR openhab:openhab /etc/openhab
      sudo chown -hR openhab:openhab /usr/share/openhab

      3. Ensure you're actually using openhab and openhab as username and password when trying to connect to the shared folder.

      • Dan Arnold
        November 21, 2015 at 11:33 pm

        I started over in the end and everything's working fine - not sure what I did wrong but we're all good now! Thanks for the great guide.

  59. Vaidas
    November 19, 2015 at 7:48 am


    first of all thanks for a very detailed tutorial. Got the system up and running without any problems. Although I'm very new to unix..
    I have one problem that I couldn't find in comments.. I started adding a binding dscalarm. Configured openhabcfg with the IP address and restarted the complete system. And after that I lost the raspberypi drives in my network.. tried googling samba problems. As "sudo service samba status" gave "failed to start samba.service: unit samba.service is masked" different forum answers suggested that I need smbd and not samba.. "sudo service smbd status" shows that it's active and running. any suggestions what went wrong?

    • James Bruce
      November 19, 2015 at 9:38 am

      This may be a silly question, but did you try to mount them again? Drives would disappear when you restart, but if the service is running then it should be working, in theory. Can you confirm the Pi still has full network access and can be pinged? Do you see the machine in your networked machines list?

      • Vaidas
        November 19, 2015 at 10:14 am

        Hi thanks for the suggestions. There are no dumb questions with a beginner :)
        The service was running, I could access Rasberry through terminal and openhab interface.
        The problem was elsewhere. I restored openhab.cfg to original state and when this didn't helped I restarted my windows PC and the network drives restored.. I often put my laptop to sleep so maybe this is where something went wrong..
        Maybe this will be helpful to someone else..

  60. CWempe
    November 15, 2015 at 8:22 pm

    Thank you for this great guide.
    It is easy to follow and does contain all important things you need to know. :)

    But I am wondering if this is the best way to deal with user permissions.

    In the samba.conf you define all new files to become 777.
    This means, that every user on the system can read and write all files the user copies via samba.
    Keep in mind the openhab.cfg most certainly will contain passwords in plaintext.
    I am no expert in linux file permissiions, but I would suggest something like 660.
    This way you can put other users in the openhab group and only the openhab user and other users of this group can read/write this files.
    Does this make sens? :)

    • James Bruce
      November 19, 2015 at 9:39 am

      It makes perfect sense, and a good tip. Personally, I don't care since it's on local (private) network only, but useful to know.

  61. Anonymous
    November 8, 2015 at 1:13 pm

    Hi James,
    thank you for the great Tutorial,
    could you explain, how to...

    Using the network shares, copy configurations to the OpenHAB Config share and overwrite the existing folder. Copy addons to the other OpenHAB Home share, again, overwriting the existing folders.

    • James Bruce
      November 8, 2015 at 2:24 pm

      Not sure what you mean - did you set up the network shares as explained in the guide?

  62. Anonymous
    October 21, 2015 at 8:04 pm

    I've got it all running and paired my z stick 5th gen with my 2 zwave devices. However I'm now working on the binding for the items on the z stick. Away for a few days but will crack on with it when I'm back. Can't wait to get my two zwave bits up and running :)

  63. Anonymous
    October 21, 2015 at 12:46 pm

    Thanks for the guide.

    It said:

    "Start with the latest Raspbian SD image."
    Please shortly confirm, that it was tested with:

    Raspbian Wheezy
    Based on Debian Wheezy
    Version: May 2015
    Release date: 2015-05-05

    I assume, that:

    Raspbian Jessie
    Based on Debian Jessie
    Version: September 2015
    Release date: 2015-09-24

    will occur in trouble.

    In additon, I am testing a lot with RPi2 and openHAB and it is really tricky.

    I was thinking of a special "openHAB1 RPi2 image", which would reduce:
    - problems with user permissions (wheezy)
    - minimizing the rasbian image (no x11 etc. -> console use)
    - already installed smb and afp support, to access the openhab installation by win/osx
    - already installed habmin for support
    Does anyone know similiar projects or are interested in it?
    regards, Tim

    • James Bruce
      October 21, 2015 at 12:48 pm

      pre-Jessie, yes, but I wouldn't suppose the latest offers any trouble.

      I wonder if I could image my SD and distribute that?

      • Anonymous
        October 21, 2015 at 1:44 pm

        Hi James,
        I am testing with several bindings and yes it is very tricky I was not able to get rrd4j up and running. This might be an user permission problem. (I dont know). But i got it runing with mysql. I was testing jessie, but I got problems with mysql.. strange.. Therfore, I would like to reduce the risks, with an predefined image for a RPi2.

  64. Anonymous
    October 20, 2015 at 6:16 pm

    Hey again, i'm up to...

    After restarting Samba (sudo service samba restart)

    but I received the error:

    Failed to restart samba.service: Unit samba.service is masked.

    Googling got me to here....

    but i've no idea what this means?

    • James Bruce
      October 20, 2015 at 6:21 pm

      Very odd. Try the instructions here to see what Samba service is listing as, and try using smbd instead of samba

      • Anonymous
        October 20, 2015 at 6:59 pm

        oh thanks for the reply-I did manage to get past this. Now hunting for to make it start every time the thing reboots

    • Anonymous
      October 20, 2015 at 6:58 pm

      well i got past there (it didnt seem to stop the rest of the guide working), but I ended up restarting the pi and now I cant find to restart openhab.

      I was about to see if I could add my first binding so I am making some progress.

      I am now hunting around for where might be and how to run it. or even auto-run it (if i ever find it!)

      • James Bruce
        October 20, 2015 at 7:19 pm

        you dont need, it should be installed as a service if you've followed this guide. turn on the debug log tail and see what you've got.

        • Anonymous
          October 20, 2015 at 7:53 pm

          ah ok, i shall do that, I was curious why I couldnt find it.

  65. Anonymous
    October 19, 2015 at 5:27 am

    Thanks for the guide btw, will use

  66. Anonymous
    October 9, 2015 at 10:50 pm

    What are you using for z-wave control? I am trying to decide between a z-stick and a razberry daughter board. Does anybody have any thoughts on these paired with a raspberry pi 2?

    • James Bruce
      October 10, 2015 at 8:10 am

      I bought a Z-Stick, purely because I dont want to be tied to a Raspberry Pi forever - if things dont work out with OpenHAB, I might like to try Castle OS from an old PC. I have some problems with range to a Everspring metered socket, but other than that it seems reliable (and I dont think the board would do any better with the sockets).

      I think theyre about the same price anyway, and I'm sure I read some other bad stuff about the z-wave daughterboard, though I cant recall what.

    • Anonymous
      October 19, 2015 at 5:26 am

      Hi Ben, I just got the Z-Stick 5th Gen off of Amazon for £32 with the Pi2. Going to give that a shot with openhab for the same reason James Bruce said.

      Ive got an on-off plug to try and a z wave plus RGB bulb.

      Will let you know my progress :)

      • Anonymous
        October 21, 2015 at 7:59 pm

        I have ordered another Pi2 and a z-stick as well. I am experimenting with my original pi for the time being. I would like to start on the new Pi with OpenHAB2 and the z-stick. For now, I will just see if I can get the Bluetooth portion working. I really like this idea as my phone is always on me and location sensing with the iphone eats so much battery.

  67. Anonymous
    October 9, 2015 at 9:44 pm

    This is just an excellent tutorial. Thank you very much for the clear instructions. I will be slowly moving devices off of my Wink hub and over to OpenHAB. I am anxiously awaiting the z-wave tutorial portion of your project. Thanks again.

  68. Anonymous
    September 23, 2015 at 1:58 am

    This has been great for me. Thank you for post.
    Have not made it all the way through. Still getting error trying to bring up demo site. Says it can not be found.

    Wanted to let you know you do have an error in your text above. The url to access the demo site missing the pi in the url.

    thanks again

    • James Bruce
      September 23, 2015 at 7:41 am

      Thanks, will fix that now.

      1. Turn on debugging. It'll show you in the logs whether the demo sitemap has been loaded correctly or what errors have been found.

      2. Make sure the files are actually there, obviously. You need all of the components (rules, sitemap, items, persistence) to make the demo work.

      3. Ensure you've done the CHOWN step as the file permissions being wrong will mean it can't find the sitemap file

      • Anonymous
        September 25, 2015 at 2:17 am

        Figured it out. When I replaced the configuration directory as you stated. I needed to merge the folder not replace. When you replace it deletes user.cfg file and maybe some others...
        Working good now. Look forward to completing the rest of the above..

  69. Anonymous
    September 18, 2015 at 3:32 am

    I am trying to follow your tutorial, seems like the most complete tutorial I've found.......but......

    the first wget

    usage: apt-key [--keyring file] [command] [arguements]

    • Anonymous
      September 18, 2015 at 3:34 am

      sorry, get this

      gpg: no valid OpenPGP data found.

    • James Bruce
      September 23, 2015 at 7:42 am

      Hmm, sorry Branden, the line works for me as is the same as official documentation, so I'm not sure what the problem might be. Have you copy pasted the exact command in?

  70. Anonymous
    September 8, 2015 at 11:38 am

    Thanks for such a great post, I can't wait to get in to it properly, but I'm getting a little stuck just before getting the demo up and running. Having copied all the demo files in to the correct place I'm getting errors when I try to load the demo website [Broken URL Removed]

    Do you have any idea what I did wrong? I don't know if this matters, but I'm running this on a first gen RP atm.


    • James Bruce
      September 8, 2015 at 1:12 pm

      Assuming the files are in the correct place, it sounds like they've been written in with the wrong permissions. Make sure to chown the whole config directory to openhab:openhab user.

      • Anonymous
        September 8, 2015 at 3:05 pm

        Ah ha - yes, I had to chown and also ran 'sudo chmod -R 755 .' to get permissions the same as the existing folders. Importantly I then had to restart openhab (I did a power cycle) for it to pickup the changes.

        Thanks :)

  71. Anonymous
    September 7, 2015 at 8:24 pm

    Thanks for your awesome tutorial!

    Got the first part, the demo setup up and running. Like to give those Philips hue lights a try.

    I want to build sensor units (temp, humidity, co2, smoke, pir, light, ... ) to install in the rooms and display the readings in OpenHUB. Later to be used for automatic and manual control of heating, ventilation, air conditioning, ...
    I want to use MQTT for communication. Do you have tips on how to get MQTT up and running in OpenHAB?

    • James Bruce
      September 8, 2015 at 1:13 pm

      Good question. I'm looking into the best way of doing this now, and will certainly be including it in an upcoming article or guide if I can get it all working.