JSONPATH conversion of MQTT topic

  • Platform information:
    • Hardware: Supermicro Server
    • OS: Debian 10 VM on Proxmox
    • Java Runtime Environment: openjdk 1.8.0_272
    • openHAB version: 2.5.10

I’m trying to set up my first MQTT item where the payload is formatted in JSON and can’t extract the value of it. VSCode always says “NULL” and PaperUI NaN. Since reading the string itself works, probably the JSONPATH transformation isn’t working. JSONPATH transformation is installed.

irrelevant to the problem itself, I’m trying to read the watertemperature of my watercooled PC. aquasuite, my watercooling controller software, can write its sensordata to MQTT since a couple of updates back.

Here is my configuration:

Bridge mqtt:broker:mosquitto "Mosquitto" [ host="localhost", secure=false, username="mqtt", password="supersecret" ] {
Thing topic Computer "Computer" {
        Type number : Computer_PC1_watertemperature "watertemperature [%.1f °C]" [stateTopic="computer/pc1/waterT",transformationPattern="JSONPATH:$.Data[0].Value"]
        Type string : Computer_PC1_watertemperature_str "watertemperature [%s °C]" [stateTopic="computer/pc1/waterT"]


Number  Computer_PC1_watertemperature "watertemperature [%.1f °C]"    <temperature>   (gTemperature,Arbeitszimmer)    {channel="mqtt:topic:mosquitto:Computer:Computer_PC1_watertemperature"}
String  Computer_PC1_watertemperature_str "watertemperature [%s °C]"    <temperature>   (gTemperature,Arbeitszimmer)    {channel="mqtt:topic:mosquitto:Computer:Computer_PC1_watertemperature_str"}

MQTT-payload of computer/pc1/waterT

{"Id":"7a2aee3e-c4a2-4bb4-bc64-ffffffff","Topic":"computer/pc1/waterT","Title":"Wassertemperatur","Message":"","Data":[{"Name":"Wassertemperatur CPU in","Unit":"°C","Value":27.19}]}

as mentioned above, reading the string works, converting it to a number does not. Is my JSONPATH correct?

best regards

  • Issue of the topic: please be detailed explaining your issue
  • Please post configurations (if applicable):
    • Items configuration related to the issue
    • Sitemap configuration related to the issue
    • Rules code related to the issue
    • Services configuration related to the issue
  • If logs where generated please post these here using code fences:

Can’t see anything immediately obvious. It’s perhaps the known issue with openHAB not properly loading Things files after they’ve been edited. Restarting openHAB should fix that, or corrupt your things file, save it, then uncorrupt and save it again.

What do your openHAB log files say when an MQTT message is sent?

And welcome!

EDIT: Another option might be to try slightly different syntax:



1 Like

Thanks for the warm welcome :slight_smile:

Since openhab usually applied changes without restart I did not consider this. Restarting openhab2.service fixed it! Thank you very much :smiley:

PS: Log was empty.