JSON Transformation problem with TASMONA MQTT bin

Dear All,

I have not been abble to solve the following message I get in Openhab 2.4 logs when using my Sonoff Touch T2 device with TASMONA firmware:
2019-01-25 21:45:56.065 [WARN ] [l.generic.ChannelStateTransformation] - Executing the JSONPATH-transformation failed: Invalid path ‘$.POWER’ in ‘{“POWER1”:“ON”}’
2019-01-25 21:45:56.069 [WARN ] [eneric.internal.generic.ChannelState] - Command ‘{“POWER1”:“ON”}’ not supported by type ‘OnOffValue’: No enum constant org.eclipse.smarthome.core.library.types.OnOffType.{“POWER1”:“ON”}

The device does what it is expected (turn on or off the light) but it is as if Openhab expected a POWER path in the JSON whereas MQTT returns POWER1 (or POWER2) because the sonoff touch T2 has 2 switches on it.

Did someone encountered the same problem?

Thank you for your help.

My things file looks like:
Thing mqtt:topic:LS_FF_Salon1_thg “Sonoff Light Switch Piano” (mqtt:broker:mosquitto) @ “MQTT” {
Type switch : PowerSwitch “Lumière Piano” [ stateTopic=“stat/sonoff/POWER1”, commandTopic=“cmnd/sonoff/POWER1”, ON=“1”, OFF=“0” ]
Type switch : PowerSwitchRes “Lumière Piano status” [ stateTopic=“stat/sonoff/RESULT”, transformationPattern=“JSONPATH:$.POWER1”,ON=“1”,OFF=“0” ]
Type string : Version “Version 02” [ stateTopic=“tele/sonoff/light/INFO1”, transformationPattern=“JSONPATH:$.Version”]
Type string : fallback “fallback topic” [ stateTopic=“tele/sonoff/light/INFO1”, transformationPattern=“JSONPATH:$.FallbackTopic”]
Type string : hostname "hostname " [ stateTopic=“tele/sonoff/light/INFO2”, transformationPattern=“JSONPATH:$.Hostname”]
Type string : IP "IP " [ stateTopic=“tele/sonoff/light/INFO2”, transformationPattern=“JSONPATH:$.IPAddress”]
Type string : time “Time” [ stateTopic=“tele/sonoff/light/STATE”, transformationPattern=“JSONPATH:$.Time” ]
Type string : uptime “Uptime” [ stateTopic=“tele/sonoff/light/STATE”, transformationPattern=“JSONPATH:$.Uptime” ]
Type number : vcc “VCC” [ stateTopic=“tele/sonoff/light/STATE”, transformationPattern=“JSONPATH:$.Vcc” ]
Type string : wifi-ap “Wifi AP” [ stateTopic=“tele/sonoff/light/STATE”, transformationPattern=“JSONPATH:$.Wifi.AP” ]
Type string : wifi-ssid “Wifi SSID” [ stateTopic=“tele/sonoff/light/STATE”, transformationPattern=“JSONPATH:$.Wifi.SSId” ]
Type string : wifi-channel “Wifi Channel” [ stateTopic=“tele/sonoff/light/STATE”, transformationPattern=“JSONPATH:$.Wifi.Channel” ]
Type string : wifi-rssi “Wifi RSSI” [ stateTopic=“tele/sonoff/light/STATE”, transformationPattern=“JSONPATH:$.Wifi.RSSI” ]
Type string : SensorTime “Sensor Time” [ stateTopic=“tele/sonoff/light/SENSOR”, transformationPattern=“JSONPATH:$.Time” ]
Type string : POW-startTime “POW Start Time” [ stateTopic=“tele/sonoff/light/SENSOR”, transformationPattern=“JSONPATH:$.ENERGY.TotalStartTime” ]
Type string : POW-Total “POW Total” [ stateTopic=“tele/sonoff/light/SENSOR”, transformationPattern=“JSONPATH:$.ENERGY.Total” ]
Type string : POW-Voltage “POW Voltage” [ stateTopic=“tele/sonoff/light/SENSOR”, transformationPattern=“JSONPATH:$.ENERGY.Voltage” ]
Type string : devicestate “Device State” [ stateTopic=“tele/sonoff/light/LWT” ]
} // end of thing

My items file is:
Switch LS_FF_Salon1 “Piano” (FF_Salon) [ “Lighting” ] { channel=“mqtt:topic:LS_FF_Salon1_thg:PowerSwitch” }

The path should be:


Hi Vincent,

I agree but in which piece of code should I change it?
In my things files I already put Power1 so I guess the error comes from somewhere else.

Kind regards


You’ll have to use a javascript transformation and check if the json key exists or not in the transformation
Or you can use the tele/ topics from the tasmota

Hi Olivier - I have the same problem did you find a solution? I don’t understand the answer given by Vincent.

Hi Julian,

No, I still have the error but since the light turns on and off I have not investigated any further.


I encountered the same problem with a “switch stripe” with 4 sockets.
Problem is, if you use
tateTopic=“stat/switch4/RESULT” with transformationPattern=“JSONPATH:$.POWERx” (where x=[1-4])
for each line, you will get 3 errors an 1 hit, because the pattern is found only once, but transformation is done 4 times.
I do not know how to solve this, by now.

Using tele/… fixes the errors, but the telemetry topic is not send when pushing a button, it is send only in a time interval.

for example (using tele topic):

    Type switch : switch4_1     "Steckdosenleiste AOFO S1"      [ stateTopic="tele/switch4/STATE", transformationPattern="JSONPATH:$.POWER2", commandTopic="cmnd/switch4/POWER2" ]
    Type switch : switch4_2     "Steckdosenleiste AOFO S2"      [ stateTopic="tele/switch4/STATE", transformationPattern="JSONPATH:$.POWER3", commandTopic="cmnd/switch4/POWER3" ]
    Type switch : switch4_3     "Steckdosenleiste AOFO S3"      [ stateTopic="tele/switch4/STATE", transformationPattern="JSONPATH:$.POWER4", commandTopic="cmnd/switch4/POWER4" ]
    Type switch : switch4_4     "Steckdosenleiste AOFO S4"      [ stateTopic="tele/switch4/STATE", transformationPattern="JSONPATH:$.POWER5", commandTopic="cmnd/switch4/POWER5" ]

This can be fixed by using a javascript transformation and checking if the key POWERx exists

An alternative approach for users of MQTT binding 2.5M1 onwards.
Chained transformation - REGEX to select on POWER1,POWER2 etc. ans then JSONPATH as usual

I know it’s been a while but I thought I’ll share the solution on this thread for anyone that stumbles on it in the future. Assuming you’re using a switch with more than on gang e.g Sonoff Touch T2 or even any other devices flashed with Tasmota, for your Thing Channel for the MQTT State Topic rather than subscribing to the stat/[devices name]/RESULT topic, subscribe to the stat/[devices name]/POWER topic instead, now since the POWER topic sends pain text, get rid of the JSON transformation in the Incoming Value Transformations section and your done, no more errors.

Keep in mind that for devices with more than one Gang, you should subscribe to the corresponding POWER topic e.g stat/[devices name]/POWER1 for 1st Gang, stat/[devices name]/POWER2 for 2nd Gang and so on.