Help needed with JSONpath and MQTT

Hi, I have OH 3.2 and struggeling the whole evening with MQTT and jsonpath. I am a newbee with jsonpath, hope that you can help me.

Situation: I have a device that puts via MQTT the following string to OH:

{"temp":0,"hum":0,"ppmw":0,"AirQuality (%)":2,"AirQbased on":0,"CO2level (ppm)":1,"Indoorhumidity (%)":0,"Outdoorhumidity (%)":0,"Exhausttemp (°C)":0,"SupplyTemp (°C)":0,"IndoorTemp (°C)":0,"OutdoorTemp (°C)":0,"SpeedCap":0,"BypassPos (%)":1,"FanInfo":"unknown","ExhFanSpeed (%)":0,"InFanSpeed (%)":0,"RemainingTime (min)":200

What I would like to do is to store every value in a sperate thing. So I have configured a MQTT broker and a Generic MQTT thing. I am able to store data from “temp” in a channel/item. Tags with a space, i can’t store them in a item. For example “InFanSpeed (%” is not possible to store in in a thing/item.

I have the following questions:

  1. How do I store tags with spaces (for expample ‘InFanSpeed (%)’ in a thing/item?
  2. How can i configure the Generic MQTT thing on the most efficient way? Do i need to configure tag by tag manualy? Or can i configure the Generic MQTT thing that it creates automaticaly the things based on the JSON string.

Many thanks for your help!

I think $.['CO2level (ppm)'] should work, note the single quote marks.
Not so sure about when including %, try it and see.

Yes!! that works! Thanks!

If there are any suggestion how to implement the whole json string in OH, please let me know. I will start by making things/items by manually

Yes.
openHAB MQTT binding supports self-identifying devices using Homie or HomeAssistant conventions. But not analysing and guessing about arbitrary JSON.

I have also the option to configure HomeAssistant MQTT in my device. I get the first part of below string. It creates one channel, the other channels are missing… :frowning: What do i wrong?

{"dev":{"identifiers":"nrg-itho-89e4","manufacturer":"Arjen Hiemstra","model":"ITHO Wifi Add-on","name":"ITHO-WIFI(nrg-itho-89e4)","sw_version":"HW: vNON-CVE 1, FW: 2.3-beta2"},"avty_t":"itho/lwt","uniq_id":"nrg-itho-89e4_fan","name":"nrg-itho-89e4_fan","stat_t":"itho/lwt","stat_val_tpl":"{% if value == 'online' %}ON{% else %}OFF{% endif %}","json_attr_t":"itho/ithostatus","cmd_t":"itho/cmd/not_used/but_needed_for_HA","pct_cmd_t":"itho/cmd","pct_cmd_tpl":"{{ value * 2.54 }}","pct_stat_t":"itho/state","pct_val_tpl":"{{ ((value | int) / 2.54) | round}}"}

What i Get is this:


transformationPattern: JSONPATH:$.['InFanSpeed (%)']

This will work.

First create a couple of channels then you can add them in the code tab once you see the structure.

1 Like

yes, worked really well! thx