Is anyone using the Open Energy Monitor (emonPi)

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:


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


> # 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

Thanks @kevin,

Yeah I had been referring to the Emonhub tab. I’m getting a log line like this:

> 2015-12-6 21:58:04 MQTT INFO Received mqtt message: emonhub/rx/5/values 588,0,588,247.54,0,0,0,0,0,0,36968

Which is all exactly as I’d expect.

My openhab.cfg sets the listening thus:

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

And my items are as follows:

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

Which, even if I’ve cocked up the number of REGEX skips, should still return me a value.

I’m wondering whether anything is getting sent between the two Raspberry Pi’s. If I use mosquitto in a shell on the openHAB Pi, and subscribe to what I understand should be the topic title:

> mosquitto_sub -d -t emonhub

I tried ‘emonPi’ and ‘emoncms’ too. As well as ‘emonhub/rx/5/’. But as I understand it it should be ‘emonhub’

I don’t see any messages from the emonPi at all.

Lets see if we can get anything to work.
Copy and paste this below as an item in default.items
Number GridPower { mqtt="<[mymosquitto:emonhub/rx/5/values:state:REGEX((.?),.)]" }
Copy and paste this below into the default.sitemap at the top on the next line after the { at the end of the Frame label
Text item=GridPower label=“Current Grid Power [%.0f W]” icon=“socket”

Reboot it and when its up let me know what you see in the web interface

You have 2 raspberry Pi’s? If you do you’ll need to open up the mosquitto ports in UFW as by default they are closed.
I’m running EMONCMS and Openhab on the same Raspberry Pi2

mosquitto_sub -d -t emonhub also gives me nothing on my working Pi so that command must be missing something. When I was debugging I opened the port and used a windows machine to look at the messages

Hi @kevin,

Well, I changed the items file to include just that one line. And I’ve got UFW open for the relevant ports on the emonPi:

> pi@emonpi ~ $ sudo ufw status
> Status: active

> To                         Action      From
> --                         ------      ----
> 80/tcp                     ALLOW       Anywhere
> 443/tcp                    ALLOW       Anywhere
> 22/tcp                     ALLOW       Anywhere
> 1883/tcp                   ALLOW       Anywhere
> 8883/tcp                   ALLOW       Anywhere
> 8080/tcp                   ALLOW       Anywhere
> 8081/tcp                   ALLOW       Anywhere
> 8084/tcp                   ALLOW       Anywhere

UFW is disabled on the OH Pi. But still nothing showing up in the UI.

Bit stumped!

Hi, I’m jumping back on this thread as I have just taken delivery of the final piece of my emonPi puzzle (a new rPi 2) and put everything together. The emonPi case does come with mounting brackets (you can see the top of one of them in the photo).

I’m going to spend some time setting up MQTT to see if I can catch up with you. Will report back if I make any headway beyond what is already mentioned!


You’ve jumped ahead of me with the hardware mounting there, I’m going to be mounting mine tomorrow, got some extra brackets I need today.

EDIT: Here’s mine…

I run MQTT.fx for troubleshooting from a windows machine, subscribing to “#” should get you all the messages on your network once you tell it to connect to the broker on your Pi, putting a checkbox in “Show only latest” should show whats around. Download from this page

On my Pi that’s running the EMONPI image,
entering “mosquitto_sub -t emonhub/rx/9/values” shows the values as they are sent, (you will need to substitute 5 instead of 9)
entering “mosquitto_sub -t #” shows everything albeit with no reference to which topic is being received
NOTE ITS BACKSLASH #, for some unhelpful reason the forum removes the backslash
assuming this gives you something, you can then use a tool on another machine to see whether the messages can be received with one of the mqtt client tools

Yeah I’m getting the emonhub MQTT messages on my iMac. So it’s something on the openhab Pi that’s blocking.

Not that it’s much consolation but I think I’m in the same boat as you. I’m not getting anything on my openhab rPi but when I try a local Windows client things look rosier.
Hopefully it’s something simple!

Out of interest, am I barking up the wrong tree by considering looking into using what appears to be a purpose-built openenergymonitor addon for openhab [here]

I think that addon doesn’t work with the low write version of EMONCMS.

So you have an EMONPI that sends the MQTT, and you can see the messages on your imac when you point it at the EMONPI’s ip address? If that’s the case the EMONPI is working as expected.
You are running OPENHAB on a seperate Pi?
Is the seperate Pi pointing at the MQTT broker on the EMONPI or at itself?

Yeah, I’m getting myself very confused now…

I can see the emonPi’s MQTT publishes fine on the iMac usif MQTTfx. So the firewall is open on port 1883, and the emonPi is doing what I want it to.

I have installed Mosquitto myself on the openhab Pi. I struggled to get the mosquitto.conf installed, so I downloaded an example and copied and pasted it. As I understand it, it’s not needed as everything defaults to usable options without it, but I wanted to be able to see what the options were.

> # =================================================================
> # Default listener
> # =================================================================

> # IP address/hostname to bind the default listener to. If not
> # given, the default listener will not be bound to a specific
> # address and so will be accessible to all network interfaces.
> # bind_address ip-address/host name
> #bind_address

> # Port to use for the default listener.
> #port 1883

> # The maximum number of client connections to allow. This is
> # a per listener setting.
> # Default is -1, which means unlimited connections.
> # Note that other process limits mean that unlimited connections
> # are not really possible. Typically the default maximum number of
> # connections possible is around 1024.
> #max_connections -1

So in theory the Mosquitto client on the openhab Pi is sitting there listening on all interfaces to port 1883. So it should be hearing the MQTT stream coming from the emonPi. Am I right?

So if I point MQTTfx at the openhab Pi, and subscribe to ‘#’ I am seeing no messages. Do I need to tell the Mosquitto client on the openhab Pi to listen for messages from a particular IP address?

try changing the MQTT part of openhab.cfg to
from what I understand MQTT isn’t a broadcast protocol so you’d either need to tell the instance of mosquitto on the openhab pi all about the one on the emonpi, and what to subscribe to or much easier just use the one on the emonpi

Yeah I’ve been trying that. The IP in openhab.cfg is currently set to the emonPi, port 1883.

So Mosquitto on the openhab Pi is just a kind of handler for the MQTT binding to allow it access to port 1883 effectively?

Confused now!

I think mosquitto on the openhab Pi isn’t needed but I’m no expert.
I’d suggest working your way through

Yeah I’d been looking at that too. All looks like I’d expect, it’s the settings you gave me a few posts above!

I wanted to

on both Pi’s try ‘mosquitto_sub -h ip address of emonpi -t #’
to see if you see any messages
NOTE ITS BACKSLASH #, for some unhelpful reason the forum removes the backslash

and you’ll need to allow port 1883 incoming on the openhab Pi as out of the box it will be closed, although that may not be necessary thinking about it as your openhab pi will be going to get the MQTT messages rather than having them sent to it.

You didn’t install anything else in openHAB? Just the mqtt binding JAR?