Openhab Setup

Home Automation seems to be a hot topic at the moment. There are so many products coming on to the market that offer a way to manage them via an app over the Internet. This is great but leaves you with multiple apps to manage multiple devices from multiple vendors. This is not a great way to achieve a cohesive home automation solution. I am new to the game and have done only a little research but I have found the Openhab project and want to see what we can do with it. This page is going to detail the setup and use of the Openhab software including the integrations that I make. Here’s a list of some of the things I want to try out.

  • Integration with Amazon Echo
  • Use of smart switches
  • Integration with Plex Media Server
  • Use of scenes to set up different environments
  • Integration with Android
  • Garage door automation
  • Alarms and locks integration

That’s for starters. I want to figure out ways to do all these things but also keep the cost under control. I don’t want to do all the work and spend the farm. The installation of the software is not something we need to detail here as it’s already available on the Openhab site and my trials and tribulations are in the earlier post here  It is important to note that what I am posting here is my understanding and your mileage may vary.

Sitemap

The sitemap is a key concept of Openhab it is nicely explained in an article called Explanation of Sitemaps this will give the basics as to what they are for. The syntax of a site map is not complex but it is detailed and must be correct. There doesn’t seem to be an easy way to create one but it begs for an app to make them. My default.sitemap looks like this:

default.sitemap

sitemap default lable=”Main Menu” {
Frame label=”Date” {
Text item=Date
}
Frame label=”Lights” {
Text label=”Group 1″ icon=”1stfloor” {
Switch item=LivingRoom label=”Living Room” icon=”Light” mappings= [ “1”=”ON”, “0”=”OFF” ]
}
}

Items

Items are critical to be able to do anything. The only item I have at the moment is a swtich. I am using an unsupported switch so my switch is bound to the exec binding and running a script that talks to the physical switch. My items list looks like this:

default.items

Switch Living_Room “Living Room Light” { exec=”>[ON:/etc/openhab2/scripts/tp-link.sh 192.168.1.X 9999 on] >[OFF:/etc/openhab2/scripts/tp-link.sh 192.168.1.X 9999 off]” }

Both the ON and the OFF setting call the same script with the on and off parameters. The script is a brilliant piece of work by George Georgovassilis You can find it on his page. Replace the X in the IP address with whatever your IP address is.

 

My sitemap has one switch on it and I can turn my living room light on and off with it. That’s great, now I am working on integrating the Echo but that is another unsupported piece of technology so there are some steps to go through to integrate it.

It appears that every time there is an update it will replace the configuration files with templates, this is problematic as I have to tell Karaf where the java installation lives in the setenv file. This file is found in:

/usr/share/openhab2/runtime/karaf/bin

The variable to modify is JAVA_HOME and it should be where there bin directory is so don’t include the bin itself.

export JAVA_HOME=/usr/java/jvm

The layout for openHAB2 when installed from the package is:

Configuration files are found in

/etc/openhab2/

User data is found in

/var/lib/openhab2/

Installation files are found in

/usr/share/openhab2/

logs are found in

/etc/openhab2/

I have been working on my installation and now have the following integrated:

  • Two remote sockets
  • Two cameras
  • Presence
  • Roku
  • Sun & Moon locations
  • Amazon Echo
  • my.openhab

I am working on garage door integration next using a “garadget” device to operate my garage door opener.

The two remote sockets are used to operate my living room light and bedroom light. Those lights are simple lamps that plug in the socket. I opted to use two different sockets one is the TP-LINK HS100 and the other is an Orvibo S20. They use different but similar things to switch them simply on and off. One area that you can get into “trouble” is if the light is changed by an external source i.e. their app or the Alexa directly.

The two cameras are Wansview and the integration allows me to tell them to record a short excerpt. I have installed zoneminder so I will use the interface to that to detect motion as well.

Presence relies on checking the network to see when phones have joined the wireless network. It works well, as soon as someone comes home with their phone the presence is detected. Based on presence we can then decide if we want to turn a light on or run the camera etc.

The Roku allows us to tell Alexa to turn on Netflix or some other channel. It’s actually more efficient than going through the menu.

The sun & moon locations allow us to tell if it’s day or night so we can decide if we should turn on lights. Of course there are many other things you might want to do based on the sun position but you can also use time as a trigger.

The Amazon echo integration allows us to do all of the above through voice commands to Alexa. She turns the light off in the living room every night. – It gets turned on automatically based on the sunset. However, the TP-LINK HS100 has it’s own integration into Alexa so it can turn the light on off without openHAB. The Orvibo does not so when Alexa turns that light on, it’s through openHAB.

I have moved the installation from my laptop to a server so that the computer is always available. I have set up my.openhab so the entire sitemap is available from anywhere in the world.

I have set up backups so I can just rsync all the necessary files to a separate disk that is mirrored.

So far, there have been many headaches getting everything to work but it’s starting to come together.

 

 

Loading