Starting off with OpenHAB

To start off, I would like to get OpenHAB running on my Linux based laptop. The assumption is that Java will be available on the end system that will eventually host the OpenHAB server.

Cloning OpenHAB

Clone the latest version of OpenHAB source from GitHub. This is fairly simple.

git clone https://github.com/openhab/openhab.git

Installing Build System

OpenHAB is built and managed using Maven build system. It performs automatic resolution of all the dependencies present in your workspace. If you don’t have Maven yet, get it first.

sudo apt-get update

sudo apt-get install maven

mvn -V
Apache Maven 3.0.4
Maven home: /usr/share/maven
Java version: 1.7.0_55, vendor: Oracle Corporation
Java home: /usr/lib/jvm/java-7-openjdk-amd64/jre
Default locale: en_US, platform encoding: UTF-8
OS name: “linux”, version: “3.2.0-67-generic”, arch: “amd64”, family: “unix”

Building OpenHAB

Please note that Maven requires that Java home to be setup properly. I use OpenJDK 7 on a 64 bit, and hence my JAVA_HOME is setup as,

JAVA_HOME = /usr/lib/jvm/java-7-openjdk-amd64/

If JAVA_HOME is incorrectly set, Maven will not be able to build anything.

Go to the newly cloned OpenHAB repository and perform a clean build,

cd openhab

mvn clean install

Please remember that Maven will take a lot of time for the first build since it downloads all the libraries. This will happen if you perform a clean everytime. To avoid this and to enforce Maven to use the locally cached libraries and dependencies, use the -o option

mvn install -o

If the build is successful, you will have the OpenHAB distribution zipped under ./distribution/target/. You should be expecting to see these packages,

cd distribution/target/

ls -l

distribution-1.6.0-SNAPSHOT-addons.zip
distribution-1.6.0-SNAPSHOT-demo.zip
distribution-1.6.0-SNAPSHOT-designer-linux64bit.zip
distribution-1.6.0-SNAPSHOT-designer-linux.zip
distribution-1.6.0-SNAPSHOT-designer-macosx64.zip
distribution-1.6.0-SNAPSHOT-designer-win.zip
distribution-1.6.0-SNAPSHOT-greent.zip
distribution-1.6.0-SNAPSHOT-runtime.zip
openhab-runtime-1.6.0-SNAPSHOT.deb

Of interest are the following distributions,

distribution-1.6.0-SNAPSHOT-runtime.zip : Contains the core OpenHAB modules

distribution-1.6.0-SNAPSHOT-addons.zip: Contains support for bundles that provide support for various types of devices.

distribution-1.6.0-SNAPSHOT-demo.zip: Provides demo configurations and sitemaps.

Starting OpenHAB

For a quick check, copy the above 3 distributions into a separate location and follow the below 4 steps,

1. Unzip the runtime distribution first.

unzip distribution-1.6.0-SNAPSHOT-runtime.zip

2. Unzip the demo distribution and say yes to any overwrite prompt.

unzip distribution-1.6.0-SNAPSHOT-demo.zip

3. Move the addons distribution into the addons directory and unzip it there. Say yes to any overwrite prompt.

mv distribution-1.6.0-SNAPSHOT-addons.zip addons/

cd addons/

unzip distribution-1.6.0-SNAPSHOT-addons.zip

4. Go back to the parent directory and then to configuration directory. Make a copy of OpenHAB default configuration as a running configuration. This is good enough to run in the demo mode.

cd ../

cd configurations/

cp openhab_default.cfg openhab.cfg

Now OpenHAB is ready to run in demo mode. Go back to the parent folder and you will find couple of start shell scripts. Run the start.sh and wait for a few seconds. Now go to the demo URL [ http://localhost:8080/openhab.app?sitemap=demo ] offered by OpenHAB server on your localhost, and have the first look at the GUI in the demo mode. You will be able to play around and change the state of some devices.

OpenHAB Demo Home
OpenHAB Demo Home
OpenHAB Demo - First Floor View
OpenHAB Demo – First Floor View
OpenHAB Demo - Bath View
OpenHAB Demo – Bath View

Now I cannot wait to toggle an LED with this web interface on my RaspberryPI.

Advertisements

2 thoughts on “Starting off with OpenHAB

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s