I’m still on a steep learning curve with OpenHAB using openhabian 1.4, but I’m stuck on trying to read a couple of MQTT values into an items file. I am using RTL_433 to read power consumption from a Current Cost meter and I can see the values in JSON format:
What I want is just the power0 value, so I am using this in the items file:
Number PowerMeter “Power [%d W]” (g1) {mqtt="<[openHAB2:RTL_433/JSON:state:JSONPATH($.power0)]"}
I have installed the JSON path transform and there are no errors in the logs, but I do not see the value in my sitemap.
Can someone please point out whatever glaring mistake I have made?
Thanks!
Your JSONPATH is ok it seems.
I presume openHAB2 is the name of your broker and RTL_433/JSON is your MQTT topic?
are you sure those are correct?
Are you able to read any of the other values in the JSON stream?
As it is easy to overlook something, let me just put my JSONPATH here, that I use for a similar shaped JSON:
Number Temperature_coop "Temperatuur [%.2f °C]" (coop) {mqtt="<[mosquitto:home/coop:state:JSONPATH($.Temperature)]"}
I think that is indeed exactly how you do it, so maybe the fault is not in yr JSONPATH
Do you have any MQTT monitor like MQTT spy? can you see the JSON actually being sent on that topic?
Hi Kees, I just found it through a process of elimination. My mqtt.cfg is:
mqtt:broker.url=tcp://localhost:1883
mqtt:brokerclientId=OpenHAB2
I thought I should be using the brokerclientID in the item but it’s the broker.url, so:
Number PowerMeter “Power [%d W]” (g1) {mqtt="<[broker:RTL_433/JSON:state:JSONPATH($.power0)]"}