Is anyone using the Open Energy Monitor (emonPi)

Yeah, I always copy and paste, been burned by that before!

So yeah MQTT seems to be functioning, it’s just the handling in openHAB that seems to be going awry.

In your openhab config (sitemap, I think), change the bit where you have defined the value to display as “%.0f” to “%s” and you should be away. Wish I was in the same boat, but I’m lagging behind trying to get openhab to do anything useful!
I reached the same conclusion as you in that everything was ok with MQTT and it is openhab messing things up somehow.

Tried that, no joy I’m afraid. I’d added in an extra item to see if I could get the pulse count out of it too:

Number GridPower { mqtt=“<[openhabMQTT:emonhub/rx/5/values:state:REGEX((.?),.)]” }
Number HWCPower { mqtt=“<[openhabMQTT:emonhub/rx/5/values:state:REGEX(.?,.?,.?,.?,.?,.?,.?,.?,.?,.?,.?,(.?),.)]” }

That now at least shows a ‘-’ instead of nothing!

And now my mySQL connection has gone mental and started throwing up errors every 2 seconds!

Not wishing to go off on a tangent but I have been getting the following error:

2015-12-08 22:56:26.574 [ERROR] [o.u.i.items.ItemUIRegistryImpl] - Cannot retrieve item GridPower for widget org.openhab.mel.sitemap.Text

Not sure why though. Nothing I have tried so far (and I have tried a fair bit!) has gotten rid of it.

Edit: I also note that my Harmony remote control stuff has stopped displaying too, and that config seems to be heavily based on MQTT as well. Hmm… roll on openhab2.

It took ages to get regex to work on this as it was a finicky little sod and didn’t seem to follow the usual implementations.
It looks like the forum has missed out half of the syntax so I’ll spell it out
The syntax after the word REGEX should read open bracket open bracket dot star question close bracket comma dot star close bracket close square bracket speech mark space close curly bracket

In your site map it needs to be

Text item=GridPower label= speech mark Current Grid Power open square bracket percent dot zero lower case f space W close square bracket speech mark spec icon=speech mark socket speech mark
Assuming you called the item “GridPower”

What are the item and sitemaps file entries like? Do the names match?

Sounds like “GridPower” in items is either invalid or doesn’t exist exactly as its spelt in the sitemap

Ha ha, I love it. Spellling out code. But guess what, you’re right, I now have a (regularly) changing, accurate, correct, formatted, brilliant, power on my classic UI!!!

Jesus, that was like giving birth!

So to clarify on the REGEX protocol, if I wanted to get the last digit out of this lot:

emonhub/rx/5/values 399,0,399,248.7,0,0,0,0,0,0,8911

I thought it would be something like:

Number pulseCount { mqtt="<[openhabMQTT:emonhub/rx/5/values:state:REGEX(.*,.*,.*,.*,.*,.*,.*,.*,.*,.*,.*(.*?),.*)]" }

But that doesn’t seem to work. How do I skip numbers before the one I want? Maybe you should format your posts using the </> button above the editor, maybe then it won’t do any weird reformatting. Maybe there’s some kind of protection against scrpt injection that’s removing some characters or combinations of characters for security.

Thanks though @kevin!

MQTT is pretty cool actually isn’t it.

The names definitely match - I must have checked that a dozen times at least but thanks for the tip! One thought I did have is that the Harmony and MQTT addons don’t play nicely together so I’m trying a few things out on that front.
It looks like my regex was wrong too (a few missing asterisks) so hopefully that’ll help if and when I get that far…

I just changed my ‘HWCPower’ to ‘pulseCount’ in the items, and I immediately got the same error:

2015-12-08 23:19:59.277 [ERROR] [o.u.i.items.ItemUIRegistryImpl] - Cannot retrieve item HWCPower for widget org.openhab.model.sitemap.Text

Of course I’d not updated it in the sitemap yet, but once I did the error went away. Have you copy-and-pasted it?

The code seems to be adding a “dot star question comma” to each of the values you DON’T want, then putting an “open bracket dot star question close bracket” around the one you do want with a “comma dot star” on the end.
In your example you don’t have enough question marks

Ha, this is the gift that keeps on giving. Your response makes complete sense, so I tried that, but now these two items both read out the same number!

Number GridPower { mqtt="<[openhabMQTT:emonhub/rx/5/values:state:REGEX((.*?),.*)]" }
Number pulseCount { mqtt="<[openhabMQTT:emonhub/rx/5/values:state:REGEX(.*?.*?.*?.*?.*?.*?.*?.*?.*?.*?.*?(.*?),.*)]" }

408 at the moment!

Is the pulse count the last one in the string? Maybe if it is you can drop the last set of dot star questions. I don’t use that output as they have a somewhat unique way of wiring smart meters up around here!

Yes, I am pretty sure it’s the same.

Here is the section from my sitemap:

    Frame label="Energy Monitor" {
            Text item=GridPower label="Current Grid Power [%.0f W]" icon="socket"
    }

And here is my item (note: I made the asterisks appear below by including a leading backslash to ‘escape’ them):

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

Woop!

This works!

Number GridPower { mqtt="<[openhabMQTT:emonhub/rx/5/values:state:REGEX((.*?),.*)]" }
Number pulseCount { mqtt="<[openhabMQTT:emonhub/rx/5/values:state:REGEX(.*?,.*?,.*?,.*?,.*?,.*?,.*?,.*?,.*?,.*?,(.*?))]" }

You’re right, lose the last ,.* and make sure there’s a , before the open brackets of the bit you want.

That looks correct, did you copy the mqtt binding to the addons folder? Can you see the messages with mosquitto_sub?

Asterisks definately disappear if you don’t click on the “</>” button for the pasted code:

Plain:

Number GridPower { mqtt=“<[openhabMQTT:emonhub/rx/5/values:state:REGEX((.?),.)]” }
Number pulseCount { mqtt=“<[openhabMQTT:emonhub/rx/5/values:state:REGEX(.?,.?,.?,.?,.?,.?,.?,.?,.?,.?,(.*?))]” }

Just "

Number GridPower { mqtt=“<[openhabMQTT:emonhub/rx/5/values:state:REGEX((.?),.)]” }
Number pulseCount { mqtt=“<[openhabMQTT:emonhub/rx/5/values:state:REGEX(.?,.?,.?,.?,.?,.?,.?,.?,.?,.?,(.*?))]” }

With </>

Number GridPower { mqtt="<[openhabMQTT:emonhub/rx/5/values:state:REGEX((.*?),.*)]" }
Number pulseCount { mqtt="<[openhabMQTT:emonhub/rx/5/values:state:REGEX(.*?,.*?,.*?,.*?,.*?,.*?,.*?,.*?,.*?,.*?,(.*?))]" }

Both " and </>

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

Fantastic, glad we got there in the end!
The loss of crucial characters in the forum posts between left and right box was a good curveball!

I’ll look at that next time I’m sat at my desktop, for now the garden beckons

For me it’s bed that’s beckoning. Are you still in daylight?