Is anyone using the Open Energy Monitor (emonPi)

Hi,

I’m looking into expanding my setup to cover the energy usage of my house. I’ve been reading a lot about the Open Energy Monitor and it sounds ideal for what I need and want to do. I know there is a binding available for openHAB, but I’ve been searching this community for any reference to it, and I’ve not really found anything.

Is that because it just works!? Or is that because not many people are using it with openHAB?

If you’ve got one, I’d love to know your experiences of the emonPi and integrating it with openHAB.

Thanks

Chris

I’m also interested in this. I already have Heatmiser Neo and Philips hue integrated in openhab but think that open energy monitor’s system looks nifty and would be a good addition.

Chris, in case you weren’t aware there is a 10% discount code on their twitter feed that is valid this Saturday.

I’m still trying to figure out which solution would work best for me - a pi-based unit or a separate base and TX.

I’m also unlucky enough to have an ancient gas meter so wouldn’t really be able to monitor gas usage.

Anyway, if I bite the bullet on Saturday I’ll keep you posted (although I might be forced to keep it to unwrap at Christmas!).

I am using EmonCMS and OpenHab but I have not been able to connect the two. As I understand it, there are a new module in emon system called emonhub that could be use to transfer data to openhab. Emonhub (running on the Pi) collects data from the TXnodes and publish it as mqtt messages on the network.
I am using openhab and mqtt to lot of other things and it works quit well. As I am not a Linux guy i cant figure how to set up the emonhub to do what i want. The first obstacal is to make emonhub connect to my normal mqtt broker instead of the defalult on the Pi. Then I need to configure it to read the messages from my TXnodes I guess…

I also use both EmonCMS and OpenHab. I used the standard sd image for EmonHub, and it exports data directly to to the hosted EmonCms rather than my own instance.

Ideally, I’d like to do two things - get emonhub running on the same RPI as Openhab, and import the data into openhab to add to me Grafana graphs. That said, I’ve just set up the emoncms to use their Solar energy app, which is very nice!

I also have a TinyTX [1], and 5 1-wire temp sensors connected, all exporting to emoncms for boiler flow & return and top, middle, bottom temp’s of the hot water tank.

I’d highly recommend Open Energy Monitor - I bought a kit - stand alone EmonTX and a RFM12b chip to plug into the Pi.

James

[1] http://nathan.chantrell.net/tinytx-wireless-sensor/

I am running both openHAB and EmonCMS on local servers. I have an Arduino Uno + Ethernet Shielf + EmonTx Shield running a modified version of their monitoring sketch which publishes the readings using MQTT over ethernet.

I then have openHAB configured to subscribe to those topics and thus have all my energy readings/data available for use in rules etc. I also have openHAB setup to store these readings in my InfluxDB timestore (via the persistence binding), I run Grafana on top of the InfluxDB to provide the pretty dashboards and graphs.

I then have a little script called mqttwarn which monitors the same MQTT feeds and forwards the values onto my EmonCMS instance (I wrote the EmonCMS plugin for mqttwarn for this very purpose).

So in short, the EmonTx (on the Arduino) measures my electricity feeds etc, and publishes to a set of MQTT topics. openHAB and mqttwarn then subscribe to those topics, with mqttwarn forwarding the values onto EmonCMS.

Ideally EmonCMS would subscribe directly but that functionality wasn’t available when I set all this up.

Massive +1 for the guys at OEM. Their hardware/firmware/software is great and the support is fantastic.

Hi all, thanks for the feedback, great to hear (some of) you have it working.

Blimey, it all looks a bit more complex than I was lead to believe by the wiki entry!

@jmoloney thanks for the discount tip! Might be doing that then…

So I was planning on getting the emonPi fully built and ready to go. The temptation to get it in bits and put it all together was there, but I can’t be bothered with the messing about.

As I understand it then, it’s an Arduino shield running on a RasPi 2B. Which has EmonHub running to send the data to EmonCms.

So you guys are either using some kind of MQTT or custom stuff to get the data across to openHAB.

I found this on the old google group:

OEM binding just listening UDP port, so you need to run rfm12pigw to be able to receive data from your nodes.
By command “rfm12pigw -h” you can get help of the gw application.
rfm12pigw usage:
-h Print help -d Serial port device (default: /dev/ttyS0) -a IP address (default: 127.0.0.1) -p UDP port (default: 9999) -i RFM12i initialization command (default: 8b 200g)
Where
ip address should be the ip address of the openhab server. If you run
your OH on same raspberry pi than gw, then localhost (127.0.0.1) is fine
(which is also the default address). By option i, you can give rfm12pi
configuration attributes. v
option is the verbose/debug flag for the application. So when v is
given, application will print debug information. You can give more than
one flag to get more debug (e.g. -vvv).
So by command:rfm12pigw -vv -d /dev/ttyAMA0 -a 127.0.0.1 -p 9997 -i “4b 200g”

gateway initialise rfm12pi to 433MHz and 200 group address, and sent all received packets to 127.0.0.1 UDP port 9997.
Be sure, that AMA0 device is not used e.g. by getty (see /etc/inittab).

Which kind of sounds quite straightforward, but I guess it’s not that easy?! It sounds like it needs to be run on the Pi hosting the OEM???

And I also found this bit in the emonhub.conf detailing ‘reporters’:

> # This reporter sends data to emonCMS
>         
>         [[emonCMS]]
>       
>             Type = EmonHubEmoncmsReporter
>       
>             [[[init_settings]]]
>       
>             [[[runtimesettings]]]
>       
>                 # url = http://localhost/emoncms #(defaults to emoncms.org)
>                 apikey = xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

Maybe you can add another reporter in there too? To send to the openHAB Pi? Anyone tried it? Dunno.

Bit worried now!

IMHO the best way is to use MQTT - setup a broker (pretty simple), and get as many things publishing sensor data to it directly - i.e. EmonPi/EmonTx anything else you can setup.

Then you have the data there and any number of 3rd party systems and services can then subscribe to the data feed and use as required.

Decouples openHAB from EmonCMS for example - they have no idea about each other - they just both subscribe to the same MQTT feed,

And mqttwarn is a very useful little script for monitoring MQTT topics and forwarding messages onto other services - e.g. EmonCMS (until it has native MQTT support), all sorts of other notification services like Pushover, NMA, Pushbullet, even XBMC clients!

1 Like

I use open energy monitor with 2 x EMONTX collecting the power readings and talking over 433MHz radio to the base Raspeberry Pi which is running the EMONPI image. All incoming data is published over MQTT by this version of open energy monitor out of the box, and you just need to set Openhab to read whichever bits you need. The standard EMONPI has only 2 inputs for power measurement and likely also publishes their readings over MQTT without modification.
It works very well giving little trouble until you try to update it from V8.5 to V9, later images may have this working, but after wasting a lot of time I gave up on V9 until a proven upgrade path for the Emonpi image arrives. I haven’t looked in a while so this may exist now.
Only the Emonpi image uses MQTT out of he box, other versions of open energy monitor may support MQTT but not out of the box

Ah OK. Sounds good.

So I just need to establish openHAB as the MQTT client and listen out for the stream coming from the emonpi then?

Yep - setup a broker (mosquitto is good) and get openHAB listening to that - then the world is your oyster :wink:

The Emonpi image includes mosquito installed and working. All that’s needed is to add the MQTT binding to Openhab and I think add settings in Openhab.cfg to tell Openhab where it is - my setup was default port and no security. (port not open to Internet on my setup)
Once this is done simply create the items.
Getting the regex syntax correct in items is a little fiddly but I can provide working examples from my setup if needed later

Sorry Kevin - missed your post - that sounds like a nice simple solution.

1 Like

Cheers everyone, I’ve learned a huge amount from the openHAB hive mind tonight. What makes me so enthusiastic and optimistic about this software, is that there’s such enthusiasm and optimism from the whole community about what openHAB is and can become.

I think I will be using that discount code on Saturday then. The WAF is helped by the fact that she’s away on business all next week, so I can get it installed without her ever seeing it…

I may well be tapping you for some coaching getting the items set up then @kevin! I’ve always recoiled a bit from regex when I’ve been doing PHP/javascript stuff in the past. I’ve only heard of MQTT since discovering openHAB, but I’m beginning to see how powerful it is, and why pattern matching could well be very important to sort the wheat from the chaff.

Welcome aboard!

To get you started I have the following in the MQTT section of Openhab.cfg
mqtt:mymosquitto.url=tcp://localhost:1883
mqtt:mymosquitto.retain=true
the rest of the stuff is left with the default # at the beginning of the line
In my items I have
Number GridPower { mqtt="<[mymosquitto:emonhub/rx/10/values:state:REGEX((.?),.)]" }
Number HWCPower { mqtt="<[mymosquitto:emonhub/rx/10/values:state:REGEX(.?,.?,(.?),.)]" }

The GridPower uses Regex to pull out the first value
The HWCPower uses Regex to pull out the third value

In your case you will need to change the number 10 to 5 for an emonpi and you will need to modify the Regex to pull the second value, as well as the first one. This should read
Number Solar { mqtt="<[mymosquitto:emonhub/rx/5/values:state:REGEX(.?,(.?),.*)]" }
Note the difference, by adding extra .?, (dot question comma) for each value you DON’T want you can move through the data string to pick out the one you do.

Hopefully this all helps - it took a while to work out with help from great people both online and offline

Also don’t forget to copy the MQTT binding to the addons folder

1 Like

Thanks Kevin. That looks fairly logical. I’ll let you know how I get on.

Daft question… Does the emonpi come with the mounting brackets included?

Don’t know as I don’t have one, I am just running the software image. The EMONTX’s I have did include mountings so its likely. If you have a smart meter with an LED that flashes its worthwhile getting the addon that sticks over the LED so it can be read by the EMONPI, as it will give you the same readings from the EMONPI that you are billed for.

Yeah I ordered the optical pulse counter as well. It got dispatched today, so I should be able to get it up and running at the weekend.

I’ve got my eye on one of these too:

http://www.utilitymeterswarehouse.com/index.php/en/shop/gass-meters/meter-accessories/pulse-blocks/pulse-block-for-sensus-u6-detail

I’ll planning to get an emonTX shield to stick on an old Arduino, and use this to count the pulses from the gas meter too.

1 Like

So it’s here, it’s installed and working well! Just got to make a little right angle bracket thing to mount it below a shelf near the meter…

I stuck those values in that you gave me @kevin, but it’s not showing up yet:

Items

> String GridPower { mqtt="<[mymosquitto:emonhub/rx/5/values:state:REGEX((.?),.)]" }
> Number PulseCount { mqtt="<[mymosquitto:emonhub/rx/5/values:state:REGEX(.?,.?,.?,.?,.?,.?,.?,.?,.?,.?,(.?),.)]" } 

openhab.cfg

> # URL to the MQTT broker, e.g. tcp://localhost:1883 or ssl://localhost:8883
> mqtt:mymosquitto.url=tcp://localhost:1883

> # Optional. True or false. Defines if the broker should retain the messages sent to
> # it. Defaults to false.
> mqtt:mymosquitto.retain=true

Everything else commented out.

I tried the IP address of the emonpi first in the MQTT address, assuming that it would need to look for a different device (as it is running on a different pi to openHAB). But I’ve just been trying it set to localhost to see if that works.

Use a web browser to login to EMONCMS on the pi and click on the Emonhub tab, open EMONCMS.log and look for lines like
MQTT INFO received MQTT message Emonhub/rx/5/values 11,11,32,44,55,0,0,0

That’s the string you want to get at. The number after “rx” is the node and this is what you need to put into your items. The comma seperated values will be the inputs you can see in the nodes tab in order. The regex statement should reflect which one you want to get too