How to read data from MQTT message

Hello,
I’m beginner in this stuff;)
I’m getting this code from mosquitto_sub:

{"Bediening":"2006-0310","Modus":"2006-0343","Cvretourtemp":"47","Cvaanvoertemp":"50","Zone1gemetentemp":"NaN","Zone1ingesteldetemp":"NaN","Zone1watertemp":"50","Zone2gemetentemp":"0","Zone2ingesteldetemp":"0","Zone2watertemp":"0","Dhwgemetentemp":"47","Dhwingesteldetemp":"47","Buffertanktemp":"0","Buitentemp":"0","Waterdebiet":"25.18","pompsnelheid":"3700","driewegklep":"2006-0950","Ruimteverwarming":"2006-0960","Tankverwarming":"undefined","Ontdooien":"2006-0300","Zon":"","Zontemp":"0","Bivalent":"","Foutstatus":"-","Compressorfrequentie":"75","Bedrijfstijd":"2916","Startstops":"3797","Ruimteverwarmingcapaciteit":"3","Ruimteverwarmingbedrijfstijd":"115","Tankverwarmingbedrijfstijd":"0"}

How to read this data to items?? I’m using MQTT 2.4 binding.
I have made Thing with channel
String with mqtt state topic “/panasonic/out” .
I added item:
String pompa_dane { channel="mqtt:topic:2da5c4d0:state" }
What now??

Is there a specific value you want? Or multiple of them? The easiest way is to create a channel for each of the values you need, and apply an “incoming value transformation” in the channel config. Use the JsonPath transform.

1 Like

@pacive Can You give me any example how it should look like??


I have made like this and nothing happens

Have you installed the JsonPath transformation service? I think you have written it correctly, and the expression is valid.

Is the thing marked as online?

yes JsonPath is installed, Thing is marked as online…
mosquitto_sub is still getting data but openhab not.
Other mqtt things is working normally.

If you skip the transform, does the item get updated?

no. It should get all data??? maybe stateTopis is different??

What topic did you use with mosquitto_sub?

panasonic/out

Then remove the / at the beginning of the state topic. It’s valid to have a slash in the beginning of a mqtt topic, but not recommended.

1 Like

Yeah Man!!! That was it;)

Great! Does it work with the JsonPath as well now?

YESS!!! :smile:
Thank You so much!

One more little problem;)

Number:Temperature pompa_dane_temp_zewn "Rzeczywista [%.1f °C]" <temperature> { channel="mqtt:topic:2da5c4d0:state" }

What is wrong? It’s not working. Still shows NaN

it is changing channel but not item.

2019-04-19 12:20:28.676 [vent.ItemStateChangedEvent] - mqtt_topic_2da5c4d0_state changed from 25 to 24

That is an Item that’s linked to the channel, that’s been created automatically, I guess you have simple mode enabled?
Anyway, what type is the channel? If you want to use a Number item, then the channel must also be of type Number.