OpenHAB and Open Energy Monitor – Part 2

In the last post I outlined the broad strategy I am taking in the design of my Home Automation and Power Management System (HAPMaS) which has led me to try to integrate Open Energy Monitor and openHAB.

I want to keep the two systems apart as much as possible as that will make maintenance easier but I want to be able to show data on one system that is held in the other. If I can do that then I can take actions based on data from either/both systems.

So initially I wanted to have a item in openHAB that displayed the values from emonCMS… specifically current house power and current solar power. It has taken me all day today to achieve it as the documentation on both of these systems is very sketchy or difficult to find but I have achieved it and it works well.

It isn’t documented at all but reading various posts on the OEM forum it became clear that there is an API to access data held in emonCMS via HTTP and json. After a lot of hunting around and an hour or two of trial and error I eventually managed to access the house power and solar power from a browser window. The url I used was:

http://emoncms.org/feed/value.json?apikey=<my API key>&id=<my feed id>

such as:

http://emoncms.org/feed/value.json?apikey=aat8y5rr34vhutr5677&id=28765

This returned a single value that was the power in watts. The value was in double quotes , such as: “564”.

“apikey” is the read APIKey from the home page on your emonCMS. “id” is the feed id as on the feeds page of your emonCMS.

This was the first stage because now I know I can get the values out of emonCMS using HTTP and json.

So how was I going to get these values into openHAB? As a total newbie with openHAB (installed first time today!) I didn’t really understand how it hung together or its design concepts and so I set about trying to educate myself. That wasn’t at all easy as the information is buried in Github and the openHAB wiki. It took several hours but I discovered about Bindings and that there was a HTTP Binding module to get data through HTTP. That was the way but I had no idea how to use a binding. The documentation was sparse to say the least.

Eventually I found how to use the HTTP Binding but again, there are no real details in the docs but after several attempts and me rediscovering Regular Expressions (aaagh!) I got it to work and here is the proof…

emonCMS MySolar page showing house power and solar generation
emonCMS MySolar page showing house power and solar generation
openHAB showing same data retrieved from emonCMS via the HTTP Binding and the emonCMS API
openHAB showing same data retrieved from emonCMS via the HTTP Binding and the emonCMS API

So there we are… emonCMS data displayed in openHAB. It took me the best part of an entire day of constant researching, reading forums, changing the set up and trial and error to eventually get it going. Now I know I am not the brightest programming button in the box but if it takes me that much time to do this pretty simple task then I would imaging that this is way, way beyond the average bod wanting to install a Home Automation system. It isn’t that it is a difficult task. It is basically a simple task made horrendously difficult because of a severe lack of adequate documentation.

Having said that, it is Open Source, it is free, and it is created and supported by the community so it isn’t all that surprising. If you don’t have to sell it and there is no obligation to support it then why produce end user documentation? There isn’t really a percieved need. Let’s face it… most of the users are techies so the documentation is hugely technically biased and a lot of assumption is made to the technical knowledge of the user. A good example is that to use the HTTP Binding I had to use regular expressions. They are a great way to process strings but they are very, very esoteric and non-techies general don’t use them or even know what they are.

In summary then… both OEM and openHAB work and they work pretty well… once they are set up but expect to spend a lot of time hunting around trying to find out how to do even the most simplest of tasks. It is very hard work and hugely frustrating!

7 thoughts on “OpenHAB and Open Energy Monitor – Part 2”

  1. Just a point that is interesting… I say the documentation is sketchy. If you look at the graphic at the top of this post it shows an icon on the left of a thermometer. there is no documentation on what icons are available and so I just chose a thermometer to show something.

    I know I go on about documentation but if we want these systems to be viable for non-techies… and that is the vast majority of people… then we must have step-by-step instructions assuming that the reader knows almost NOTHING!

    The trouble is that producing that kind of documentation is a time-consuming task.

    I can understand why there is very sketchy info and I am not complaining about it (sorry if it comes over that way) but it is important if we want these systems to get a wider audience.

  2. Nice blog, I’m also new to openHAB. Just installed 5min ago! Would you be able to share how you got HTTP bindings to work or point me in the right direction. Also have you tired MQTT binding? Would be a more efficient way to get data real-time from an OpenEnergyMonitor emonPi / emonBase.

    1. Hi Glyn. I shall reply by email if that is OK and for everyone else I shall do a blog post to cover it. Thanks for reading. I have tried MQTT binding and I have that working too and MQTT is my preferred way to share data between the various parts of a Home Automation system.

  3. Snax, I too am looking forward to further detail on getting the http binding going for this. Love the blog… keep up the good work. Just wanted to throw in another vote to get a post on this! Thanks!

    1. Thanks Evan, I moved house a few weeks ago and I am still settling in so I have had almost no time to spend on it but I will! The new windows are going in this week and with those I am having keyless, z-wave locks on the external doors to the house. I guess that in a week or two I might find time to continue. Thanks for reading 🙂

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.