MQTT things definition transformationPatternOut with JSONPATH not working

He everyone. I am using OH2 Release Build 2.5.3
I am having trouble with transformationPatternOut and JSONPATH. I’m not able to make them work.

Maybe I’m doing a mistake in my .things definition:

Thing topic H801-RGBWW "H801 RGBWW Livingroom"
{
    Type switch : LivingH801_PowerSwitch        [ stateTopic="H801-RGBWW/GENERAL_STATUS", commandTopic="H801-RGBWW/GENERAL_STATUS", transformationPattern="JSONPATH:$.GENERAL_STATUS", transformationPatternOut="JSONPATH:$.GENERAL_STATUS" ]
}

I am receiving only 1 byte at destination (ie: 1: ON 0:OFF). Clearly not json format.
Any help you can provide? Maybe a working example?

Is thre any way to enable logging to see in raw what is the message send/publish by openhab?

Thanks!

JSONPATH selects one value from a whole set of JSON key-value pairs. There’s not much use for that in an outbound transformation. You’d have to command your Item with a set of JSON so that the JSONPATH could pick out one value to be sent to MQTT.

What is it you are trying to do?

Thanks for your response.

What I’m tring to achieve is a response like

{ GENERAL_STATUS : true }

or

{ GENERAL_STATUS : 1 }

For something that simple, with a switch ON OFF command as your source, I’d use a MAP look-up transformation in transformationPatternOut

That was a simple example.
I need to send multiple datatypes, no only switch, but color, string, etc…
I thought I could use JSONPATH to achieve this. I was mistaken i believe

If you need to send multiple different bits of info in one payload, it’s probably easiest to assemble that with a rule.
Once you’ve built your single string of JSON, you can either publish it directly from the rule using MQTT action, or command a suitable Item linked to channel.

If only need to send one Item’s worth of information in one payload, but it might be multi-part, like a Color state, you could use a javascript JS transform to build a JSON string and do any scaling or conversion of values