Multiple JSON patern possible for one item...Executing the JSONPATH-transformation failed: Invalid path

Hello!

I’m having a puzzle which I don’t know the answer…

I have my all my thermostats connected to OH through a Sonoff Zigbee Bridge. Everything is working fine, I am able to control hem and receive statuses that are being brodcasted and extract the info through JSON transformation, BUT…

Problem is that the thermostats are broadcasting different paterns, at different times (ie, sometime it will publish the SetPoin and the current temperature, sometimes just the temperature, sometimes the heating demand, etc. So, what is happenning is that my log gets filled with errors, because each time something is published, there are always some info that are not present, hence, OH is complaining with a warning that the transformation failed (because item was not found).

Is there a way to prevent that? System is working fine, but the log is a mess since I have 12 thermostats that are publishing frequently, it makes it very hard to read through the log

Thanks

Are you getting these errors from a transform in a rule? Or from a transform in a binding?

You need to provide some details.

Yes, you can.

But first, these aren’t errors, they appear as WARN log items. You can safely ignore them.

However, if - like me - you hate the clutter, you can use the REGEX Transformation Service chained before the JSONPATH Transformation to only send relevant strings to JSONPATH. Check this magic out:

2 Likes

Another way is to get tasmota to split out all your mqtt into the device. I think its setoption4 1

You can try and changing back is to 0 default.

Thanks for all your answers…

I have installed the regex binding and tried @hafniumzinc suggestion, but maybe I didn’t do it properly because it is sill doing the same.

Here is the definition of my thing:

Thing mqtt:topic:ThermoLavage "Thermostat Lavage" (mqtt:broker:MQTTBroker) @ "SDL"  {
Channels:
    Type number : Temperature           "Temperature"           [stateTopic="tele/THERMO_LAVAGE/SENSOR", transformationPattern ="REGEX:(.*Temperature.*)∩JSONPATH:$.THERMO_LAVAGE.Temperature" ]
    Type number : SetPoint              "SetPoint"              [stateTopic="tele/THERMO_LAVAGE/SENSOR", transformationPattern ="REGEX:(.*OccupiedHeatingSetpoint.*)∩JSONPATH:$.THERMO_LAVAGE.OccupiedHeatingSetpoint", 
                                                                 commandTopic="cmnd/ZBBRIDGE/THERMO_LAVAGE/ZbSend", formatBeforePublish="{\"Device\":\"THERMO_LAVAGE\",\"Write\":{\"OccupiedHeatingSetpoint\":%s}}"]
}

and here is the warning that I get (you were right @hafniumzinc… I knew it was a warning, but I like logs tidy and clean!)

2020-12-31 10:12:31.053 [WARN ] [t.generic.ChannelStateTransformation] - Executing the JSONPATH-transformation failed: Invalid path '$.THERMO_LAVAGE.Temperature' in '{"THERMO_LAVAGE":{"Device":"0xB341","Name":"THERMO_LAVAGE","LocalTemperature":21.37,"Endpoint":1,"LinkQuality":86}}'

you can see that in this particular message, thermostat didn’t publish the temperature nor the OccupiedHeatingSetpoint… hence the warning.

This section in your JSON string includes the word “Temperature”, so it will pass the REGEX and move on to the JSONPATH!

You could try:

REGEX:(.*\"Temperature\".*)
2 Likes

oh gosh… that was so obvious that I couldn’t see it! Also, I had to do the trick wher I voluntarly corrupt the file, save, fix it back and save, otherwise my file don’t get loaded.

Everything is fine now, thank y’all!