Home automation

For the last 2 years I have been using Indigo Domotics and have been very satisfied with that. It’s a very easy way to start building home automation and getting something to work fast for testing an automation concept. However I want to move to some hardware with a smaller footprint instead of my mac mini. So I have decided to try out OpenHAB for Raspberry Pi

The internet of things are coming to a house near you, in a future not so far away any more…

Getting the hardware for OpenHAB

First up I have bought a RapberryPi 2 model b, a Raspberry Pi Universal Power Supply, NOOBS 8GB SD Card and a Wifi/bluetooth USB dongle. Most of it you can get at the raspberry swag shop .

Second up I needed a z-wave modul for my Raspberry Pi. I had a USB dongle for my mac mini – but since that was being used for what I had working already I have decided to try the Raspberry PI Board from z-wave.me.

You will also need a monitor and HDMI cable and maybe a converter to you monitor if it’s using VGA monitor – and of course a mouse and a keyboard.

Oh and while we are at it – if you don’t have Philips HUE – now is the time to get it 🙂



It is pretty straight forward, fist you need to download the operating system for your Raspberry Pi – you do that from raspberrypi.org.

Being on a mac I used mac tutorial for instaling the operating system on the Raspberry Pi SD card but if you use a windows or linux you can find the on the website as well.

Nice terminal commands to know:

Will take you to the basic setup of the RASPBIAN
$ sudo raspi-config

If you disable the RASPBIAN to boot into the visual userinterface X-server you can enable it by typing
$ startx


Making the RaZberry work on my RapberryPi

OK – I ended up starting over and reinstalling Raspian Jessie and using the tutorial from homeautomationforgeeks.com. This also guide you through installing HABmin that gives you a web interface for connecting and configuring z-wave devices.

This guide from homeautomationforgeeks.com tells you how to install OpenHab in a better way

The only thing missing in this tutorial is that you need to make a openhab.cfg file the configurations directory, by copying openhab_default.cfg

You do that from the terminal by typing:
sudo cp /opt/openhab/configurations/openhab_default.cfg /opt/openhab/configurations/openhab.cfg

This guide from homeautomationforgeeks.com tells you how to make z-wave work, now I didn’t want to start out by enabling my multi sensor but instead I started out by playing with my Fibaro smoke sensor – go and see later post.

The two above links from homeautomationforgeeks.com don’t have the enabling og SMB shares – however you can find those guides the makeuseof.com link I have posted earlier. Keep in mind that the installation of OpenHAB now is in the /opt directory and your share definition now must be:

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

You also need a user since the openhab user isn’t uses in the opt installation you need to decide if you want that.
You asign a SMB user  by typing:
sudo smbpasswd -a [username]

So far these sites have been helpfull:

OpenHAB Designer installation

I am having some problems with making rules work using HABmin, I can make them work but when I want to edit them OpenHAB stops working and I have to reboot. I still need HABmin to handle my z-wave devices though…

OpenHAB Designer is local programming and designing environment and this is why it is a good thing to have SMB enabled for your OpenHab. To make it work you need to either change permissions on the directories OpenHAB Designer needs to access or sign into the share as root after you have given the root user access to the Openhab share…  both solutions have their own security issues and you should change it back when you are in “production”.

Now is a good time to make a backup image of you OpenHAB installation!

Fibaro smoke sensor Configuration i OpenHab

I included my Fibaro Smoke sensor from HABmin by pressing the inclusion button on my smoke sensor – OpenHAB included it but didn’t get the vendor information right away – but after pressing the inclusion button 3 times again it turned up nicely.

In the Items directory I have added this configuration to my default.items file:

Group All
Group Security (All)
Group SmokeSensors "Kitchen" (Security)
Switch Smoke_Sensor_smoke "Smoke detected in kitchen [%s]" (SmokeSensors) { zwave="4:command=sensor_alarm,alarm_type=1" }
Switch Smoke_Sensor_tampered "Smoke sensor kitchen tampered [%s]" (SmokeSensors) { zwave="4:command=sensor_alarm,alarm_type=0" }
Number Smoke_Sensor_battery "Smoke sensor kitchen battery [%s %%]" (SmokeSensors) { zwave="4:command=BATTERY" }
Number Smoke_Sensor_temp "Kitchen temperature [%.1f C]" (SmokeSensors) { zwave="4:command=SENSOR_MULTILEVEL,sensor_type=1" }
DateTime Smoke_Sensor_updated "Last updated [%1$td/%1$tm/%1$tY %1$tH:%1$tM:%1$tS]" (SmokeSensors) { zwave="4:command=info,item=LAST_UPDATE" }

And this configuration to my default.sitemap  file

sitemap default label="Main Menu"
Frame label="Kitchen" {
Text item=Smoke_Sensor_smoke
Text item=Smoke_Sensor_tampered
Text item=Smoke_Sensor_battery
Text item=Smoke_Sensor_temp
Text item=Smoke_Sensor_updated

Finally I have added two rules to notify me on a push notification if the alarm is trickered:

import org.openhab.core.library.types.*
import org.openhab.core.persistence.*
import org.openhab.model.script.actions.*

rule “PushoverSmokeSensorInKitchenTampered”
Item Smoke_Sensor_tampered changed
if (Smoke_Sensor_tampered.state.toString()== “ON”) {
pushover(“Smoke Sensor Tampered”, “NameOnMyiPhoneOnPushoverWebsite”)

logInfo(“Smoke_Sensor_tampered changed: “,Smoke_Sensor_tampered.state.toString())


And …

import org.openhab.core.library.types.*
import org.openhab.core.persistence.*
import org.openhab.model.script.actions.*

rule “PushoverSmokeSensorInKitchenTriggered”
Item Smoke_Sensor_smoke changed
if (Smoke_Sensor_smoke.state.toString()== “ON”) {
pushover(“Smoke detected in kitchen”, 2)

logInfo(“Smoke_Sensor_smoke changed: “,Smoke_Sensor_smoke.state.toString())



OpenHAB becoming aware of me… so to speak

I need my home to know if anybody is at home. On my Indigo installation I used to check if our iPhones were visible on the wifi network buy the latency was to long and I would normally get to far inside the house before I was discovered as my and the alarm would be trickered instead. So for OpenHAB I am working on using bluetooth instead.

First of I got hold of a USB bluetooth for my pi – and installed the drivers needed  for it to work and modified the examples on this page: https://github.com/openhab/openhab/wiki/Samples-Tricks I didn’t use the bluetooth binding but used org.openhab.binding.exec to be able to execute command line from OPenHAB

In the OpenHAB Scripts directory I added the bt_check.sh to ping for my iPhones bluetooth MAC address


DEVICES=`l2ping F5:F2:7A:05:CB:7A -c 1`

if [[ $DEVICES = *received* ]]
curl –max-time 2 –connect-timeout 2 –header “Content-Type: text/plain” –request PUT –data “ON”
echo “Bluetooth pingscript has been executed. Device found” >> /opt/openhab/logs/openhab.log
curl –max-time 2 –connect-timeout 2 –header “Content-Type: text/plain” –request PUT –data “OFF”
echo “Bluetooth pingscript has been executed. Device not found >> /opt/openhab/logs/openhab.log

In the  Items directory I added the file BlutoothState.items
Switch TSiPhone

In my sitemap file I added this to the file:
Frame label="Bluetooth devices" {

Switch item=TSiPhone label=”TSiPhone” icon=””

And finally I added bluetoothPing.rules to the rules directory to trickier the bt_check.sh bluetooth ping script every 30 sek.

import org.openhab.core.library.types.*
import org.openhab.core.persistence.*
import org.openhab.model.script.actions.*

rule “BluetoothPingRules”
Time cron “0,30 * * * * ?”

var String command
command = “/opt/openhab/configurations/scripts/bt_check.sh”
executeCommandLine(command, 20000)


…now I need to make it a little more intelligent, first thing is probably to ping me less when it has seen me …

This link was helpfull: https://www.raspberrypi.org/learning/robo-butler/bluetooth-setup/
I used this to install command wassudo apt-get install –no-install-recommends bluetooth

Wake me up slowly

In the winter I love to sleep in a cold bedroom around 17° – but it doesn’t make it easier to get up in the morning. So what I have done is I have bought a STELLAZ Thermostat and taken one of my Philips HUE lights to generate a sunrise in my bedroom. So far I am using my Indigo Domotics to set the alarm for when I want to get up. Two hours before the alarm I start heating my bedroom to 21° and 20 minutes before the alarm i slowly turn up the light from a dark blue going to purple then orange and finally white until it is at 65%

So far I think this has been the home automation project that has meant most for my everyday life, and of course I reverse it in the evening to create a sunset.

Why your vacuum cleaning robot needs a brain

When I think about then the thing I hate most about vacuuming is not necessarily the time I need to spent on it – it’s more about the noise… – and then the time I need to spent on doing it because we have a cattery and way to many cats not to vacuum a lot !

So I got myself and old iRobot roomba 555 a couple of years ago, just before I started all this home automation. And of course with the cats I will never be able to not vacuum anymore ever, but it turned out that I still have to listen to all the noise when it was driving around. Then of course I can time to only fool around – because it does that – but somehow it not how it’s supposed to work with a robot. Just clean, when you are on your own and don’t bother me about it – that is more like it should be!

So I got myself a RooWifi board for my Roomba, and luckily somebody have made a plugin for Indigo Domotics server. Until recently my Roomba have only been fooling around when we are not at home as it is triggered only to clean when we are away using this nice location php script that can locate my iPhone.

Unfortunately my Roomba performed a lobotomy on itself not so long ago and somehow managed to break of and ruin the RooWifi board. So lets see maybe the new Roomba 900 from iRobot with wifi will replace it soon.

If you wan’t to avoid the lobotomy scenario look at this page http://homematic-forum.de/forum/viewtopic.php?f=18&t=17168