Item OpenHab 3 MQTT

Hi :slight_smile:

i’m using OpenHab 3 on an PI.
I created an Thing file for my MQTT Devices and now i want to do the same for my Items.

I found that i had to use “Profiles” for my Item like

String <itemName> { channel="<channelUID>"[profile="transform:JSONPATH", function="<jsonPath>", sourceFormat="<valueFormat>"]}

so i did

{channel=“mqtt:topic:04448dbf25:Trockner:voltage”[profile=“transform:JSONPATH”, function="$.ENERGY.Voltage", sourceFormat="%s"]}

but its not working.

How does ist work?

Michael

Welcome!

You don’t have to use Profiles. You can do the transformation directly in your Thing. It looks like you’re using configuration files, so maybe check my lights.things example code part way through this post.

In either case, make sure you have installed the JSONPATH Transformation Service!

Hi, i installed the Transformation. When i configure the Item by Hand it workes.

Here is my Thing File

   Bridge mqtt:broker:04448dbf25 "MqttBroker" [ host="192.168.178.41", port=1883, secure=false /* username="", password="", clientID="openhab2"/*/ ]
{  
    Thing topic Trockner "Trockner over MQTT" @ "Geräte" {
    Channels:
        
        Type string : reachable     "Reachable"              [ stateTopic="tele/Trockner/LWT" ]
        Type switch : power         "Power"                  [ stateTopic="stat/Trockner/POWER", commandTopic="cmnd/Trockner/POWER" ]
        Type number : powerload     "Power load"             [ stateTopic="tele/Trockner/SENSOR", transformationPattern="JSONPATH:$.ENERGY.Power"]
        Type number : voltage       "Line voltage"           [ stateTopic="tele/Trockner/SENSOR", transformationPattern="JSONPATH:$.ENERGY.Voltage"]
        Type number : current       "Line current"           [ stateTopic="tele/Trockner/SENSOR", transformationPattern="JSONPATH:$.ENERGY.Current"]
        Type number : totaltoday    "Total energy today"     [ stateTopic="tele/Trockner/SENSOR", transformationPattern="JSONPATH:$.ENERGY.Today"]
        Type number : totalyest     "Total energy yesterday" [ stateTopic="tele/Trockner/SENSOR", transformationPattern="JSONPATH:$.ENERGY.Yesterday"]
        Type number : total         "Total energy total"     [ stateTopic="tele/Trockner/SENSOR", transformationPattern="JSONPATH:$.ENERGY.Total"]
        Type number : rssi          "WiFi Signal Strength"   [ stateTopic="tele/Trockner/STATE", transformationPattern="JSONPATH:$.Wifi.RSSI"]
    }
}

In OH2 i used the item files and i want to do the same in OH3

in OH2 it looks like this

Number   MiAqara_Bad_temp          "Temperatur Bad [%d °C]"         <temperature>               (BadTemp,gTemp)    	    { channel="mqtt:topic:0x00158d00044db0bc:temp" }

in OH3 it looks like this?

Number TrockneroverMQTT_Voltage              "Spannung"              {channel="mqtt:topic:04448dbf25:Trockner:voltage"[profile="transform:JSONPATH", function="$.ENERGY.Voltage", sourceFormat="%s"]}

Now I’m confused. You had a working OH2 configuration? Then that exact same configuration will work for OH3, no changes required.

(This isn’t true if you used the v1 MQTT Binding, but your code shows that you’re using V2 in OH2 so that’s fine).

i’m confused too.

when i use my old configuration from OH2 in OH3 the Thing will not show any values. Voltage or Power for example.

When i configured the thing by hand with the transormation value it works.

You might have to edit it to fit new broker names, etc.

Excellent.
Stop trying to transform it again by applying a profile to channel-Item link.