Howto suppress JSON transformation errors in logging


In my network I have a large number of zigbee devices from MI /AQARA etc. These send a nice JSON formatted message when they are triggered. This message contains an “ACTION” field which I filter out for my items.

BUT, sometimes these devices send an “hello I’m still alive” message, which missses the “ACTION” part. This leads to a very large and long error message (at least 30 lines) in my logging. Unneeded I would say. It is sort of a crash log.

Can it be disabled?

Or is there a trick to prevent JSON errors when the incomming string does not contain the field the transformation was looking for?

2019-07-25 19:35:48.991 [ERROR] [ui.internal.items.ItemUIRegistryImpl] - transformation throws exception [transformation=org.eclipse.smartho                             me.transform.jsonpath.internal.JSonPathTransformationService@b72523, value=-]
org.eclipse.smarthome.core.transform.TransformationException: Invalid path '$.action' in '-'

Greetings Matthijs

I’m also dealing with this issues having different starting fields. Did you manage to resolve this?

I’m having the same issue, I think the only way is to create a rule that parses the JSON values and updates the items accordingly (if the value is present). I don’t know of any other solution … :thinking:

Yep, I followed that route. Made an “item” which is not shown on the basic ui but is linked to a mqtt channel. This item receives the complete json string.

String  AqaraDeurcontact1_raw   "Test1 contact raw [%s]"                <frontdoor>   {channel="mqtt:topic:0d154420:5467797200"}
String  AqaraDeurcontact1_1     "Test1 contact [%s]"                    <frontdoor>   (gAqara)
String  AqaraDeurcontact1_2     "Test1 contact battery  [%s%%]"         <frontdoor>   (gAqara)

Then made a rule which triggers on the “AqaraDeurcontact1_raw” received update. Check if certain keys are in the JSON and then filter out the relevant info from the JSON and update the visible items on the UI. Meanwhile also triggering “actions”.

rule AqaraDeurcontact1_raw
    Item AqaraDeurcontact1_raw received update
    val String json    = AqaraDeurcontact1_raw.state.toString
    if (json.toString.contains("contact")) 
        logInfo("Garagedeur", "Garagedeurcontact update: " + json) 

        val String contact    = transform("JSONPATH", "$.contact",   json) 
        val String battery    = transform("JSONPATH", "$.battery",   json)

        if (contact == "true")
        } else 


That works correctly, even when the JSON contains different keys sometimes (in fact is missing some keys sometimes).

Ofcourse it would have been nice if the JSON parser would shut up if a key is not present and not fill the log with the “crash report”. Until then, this seems a nice solution.

Hope this helps.

Pre-scan JSON using REGEX transform, then chain to JSONPATH transform

Please explain how to do this. The link provided is too generic for me to work with.

Using paperui, I made a THING and then a CHANNEL. In the CHANNEL configuration it is possible to define an “Incoming value transformations”.

I did have an JSON transform there, but if the channel is NULL (after startup) or when the JSON does not match, that gives the huge error log blabla.

So that is where this discussion started.

Is that the place to put the combined REGEX + JSON transformation? Or should I put it in the xxx.items files? (which seems to do the same as putting it in the channel configuration).

Please advice,

Greetings Matthijs

Yes. See the binding doc section on transformations, that describes chaining using a magic character ∩

You would use REGEX to search for your “ACTION” field, then if present the result passes to JSONPATH.
Apparently, if not present the chain fizzles out without error.

You mean xxx.things file? That’s up to you. The end result is the same. Choose consistently to avoid madness.

You can’t put any channel configuration in xxx.items files.

In case you are are running zigbee2mqtt you should set it to attribute transmission. It’s a new experimental config parameter. No more ugly JSONPATH and no more exceptions.

Great. 2 options to test & play with. Happy.

Will let you know the results. Thanks