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>
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…
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!