[SOLVED] JSONPATH-transformation failed - MQTT binding

Hi!

So I am using MQTT to get the states/actions of things into openHAB. This works really well so far, but sometimes I get this warning message in the logs:

[t.generic.ChannelStateTransformation] - Executing the JSONPATH-transformation failed: Invalid path ‘$.action’ in ‘{“linkquality”:76,“battery”:16}’

I am pretty sure that the “thing” is not always publishing the state of the “action” anytime it sends a message. This seems logical as I did not press any button (in this case an Ikea Tradfri remote), but it just informs about basic information. Which is nice.

But since I have created a specific channel for the “action”, the JSON transformer assumes there must be an “action”, too. Which there isn’t any:

    Thing topic zigbee_tradfri_remote_03 "Ikea Tradfri Remote (003, Kueche)" @ "ZigBee" {
        Channels:
            Type string : action [ stateTopic="zigbee2mqtt/0xd0cf5efefee24600", transformationPattern="JSONPATH:$.action", trigger="false", retained=true]
            Type number : battery [ stateTopic="zigbee2mqtt/0xd0cf5effee24600", transformationPattern="JSONPATH:$.battery", trigger="false", retained=true]
    }

Is there a way to let the transformer know the “action” might be “optional”? Like creating a swagger definition of what to expect?

Thank you.

2 Likes