JSON Transformation Help

OH 5.0.2 on RPi5 configured entirely using MainUI

I’m trying to integrate a new water meter device, the Droplet.

I’ve got MQTT working but the device sends all data in a single Topic as serialized JSON like this

{“server”:“Connected”,“signal”:“Strong Signal”,“volume”:-39.31,“flow”:0.00}

I’ve created a Generic MQTT thing and it’s capturing the whole string. I’m assuming I could create channels by extracting the data I’m interested in using a JSON transformation for each channel.

I’m mainly interested in “volume” and “flow”.

I’ve read the docs but I’m struggling to create the expression I need.

Any guidance would be much appreciated.

Hi @brianlay

There is an issue with your JSON in that the quotes are not standard JSON quotes. Now that may be just a copy and paste issue (copying to from a spreadsheet can do this).If they are wrong in the source the openOpenHAB parser may fail no matter what path, there may be an entry in the openhab.log file .

I have adjusted that here and it is formatted readability:

{
“server”: “Connected”,
“signal”: “Strong Signal”,
“volume”: -39.31,
“flow”: 0
}

That issue aside, expression you refer to is called a JSON Path and I typically use this site for the more difficult ones but it will show you the path when you select the item in the right hand window.

For example flow is

x.flow or for the inclusion in openHAB $.flow

Brett

Maybe it is obvious, but let me simply add that the complete expression that must be written in the channel definition is

      transformationPattern:
        - JSONPATH:$.flow

and that the “JSONPATH transform” addon must be added in openhab

You need to install the addon

thanks all for the suggestions!

It’s working perfectly now

Now the next step is to collect and persist the data to make something useful.