Is anyone using the Open Energy Monitor (emonPi)

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!

Nice!

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]
(https://github.com/openhab/openhab/wiki/Open-Energy-Monitor-Binding)?

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
mqtt:mymosquitto.url=tcp://ip_address_of_the_emonpi:1883
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?

Aha!

I’ve got something! I changed the format of the item from ‘Number’ to ‘String’ and now I get this error:

> 2015-12-08 22:25:03.899 [WARN ] [o.u.i.items.ItemUIRegistryImpl] - Exception while formatting value '529,0,529,249.5,0,0,0,0,0,0,8545' of item GridPower with format '%.0f W': java.util.IllegalFormatConversionException: f != java.lang.String

So the MQTT is getting through. It must be something wrong in the item (REGEX?) that’s not pulling a number out correctly…

Have you tried a simple copy and paste of EXACTLY what I put several posts back?
good to see the messages are arriving