In The Air – Week 5

Other competitors in this challenge have already described how they installed openHAB. I did notice however that they used different methods to go the job done.

In this post, I describe the method that I’ve used to deploy the latest version of openHAB (v1.6.0) and how I created a basic configuration to receive MQTT messages.
By the end of the post, I have openHAB subscribing to a broker, receiving MQTT messages sent by the CC3200 containing some statistics on the FuelTank’s battery.

Preparation

First, I updated my system and ensured the “unzip” tool was installed, as I’ll be requiring it to install openHAB.

I also configured the proper timezone.

Java

To install Java on the BBB, I followed the steps defined by nikil511 in the following post: [Air ex Machina] #04 Beaglebone for dummies – JAVA,OpenHab

I did add “sudo” here and there, as I was running the commands as user “debian” and not “root”.

Easy enough, and Java was installed!

openHAB

I installed openHAB a bit more manually than the other competitors here, but it works just as well.

First thing I did, was to download the openHAB runtime and addons for version 1.6.0 directly on the Beaglebone Black.

Next, I prepared the location I would deploy the application to.

Then, I deployed the addons (bindings, actions, persistence, …), but I did it in a subfolder called “unused”.
That way, openHAB will not load all the addons, but I can easily deploy/activate them by moving the files from the “unused” folder back to the “addons” folder.

openHAB requires a configuration file to be able to work properly, so I created one, based on the default.

I also created some placeholders for my items, sitemap and rules.

Finally, I made the startup script executable, edited the HTTP port in it to use port “9090” instead of the default “8080”.

openHAB was installed successfully!

MQTT

Last week, I already explained how I got the CC3200 to publish data to a broker. The next step, was to have openHAB subscribe to that same data and visualise it.

Using MQTT with openHAB is made easy by means of a ready-to-use MQTT binding.

The first step, is to prepare the MQTT binding addon and define the broker to be used.
To activate the addon, I moved it from the “unused” folder created earlier, to the “addons” folder so that openHAB would be able to use it.

Because I also intend to use persistence, I deployed the required addon for that as well.
I’ve used MySQL persistence before and thought I’d use RRD4J this time around.

Next, I specified the broker information in the general openHAB configuration file “openhab.cfg”.
There is a MQTT binding section in the file, which I edited as follows:

For the parameters you intend to use, it is important to uncomment them and to replace “<broker>” by an alias you can refer to in the items configuration. In this case, I used “eclipseIot” as an alias for testing.
Then, I started defining my items in the “intheair.items” file.

After the items, I defined the sitemap in the “intheair.sitemap” file. Pretty simple so far: three clickable items, leading to a chart visualising the history of that specific item.

Finally, I set up the persistence by creating a configuration file for it.
The file should be located in “/opt/openhab/configurations/persistence” and have the name of the persistence service to be used with “.persist” extension. In my case “rrd4j.persist”.

This is what I put inside the configuration file:

After all the modifications, I restarted openHAB for everything to take effect.

To close this week’s post, I have some screenshots of openHAB with some Fuel Tank BoosterPack data received from the CC3200 via MQTT:

Screen Shot 2014-11-26 at 10.40.21 Screen Shot 2014-11-26 at 10.39.27 Screen Shot 2014-11-26 at 10.39.48 Screen Shot 2014-11-26 at 12.38.11

In my next post, I’ll be describing in detail how I got the Fuel Tank to work with the CC3200 in order to retrieve battery information, along with longer duration measurements.

Leave a Reply

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