Strange Exception while transforming JSON from MQTT message

Tags: #<Tag:0x00007f1830897b60> #<Tag:0x00007f1830897638> #<Tag:0x00007f18308970e8>

(Frank Kintrup) #1


I’ve encountered a strange Exception while trying to receive the current power from a Sonoff POW via MQTT.
MQTT itself is running perfectly as are all other transformations via JSONPATH.

This is the exception:

2018-02-12 23:07:18.814 [ERROR] [.mqtt.internal.MqttMessageSubscriber] - Error processing MQTT message.
org.openhab.core.transform.TransformationException: An error occurred while transforming JSON expression.
	at org.openhab.core.transform.TransformationHelper$TransformationServiceDelegate.transform( [208:org.openhab.core.compat1x:2.2.0]
	at org.openhab.binding.mqtt.internal.MqttMessageSubscriber.processMessage( [226:org.openhab.binding.mqtt:1.11.0]
	at []
	at org.eclipse.paho.client.mqttv3.internal.CommsCallback.deliverMessage( []
	at org.eclipse.paho.client.mqttv3.internal.CommsCallback.handleMessage( []
	at []
	at [?:?]

This is my items definition (broken in two lines for readability):

Number sonoff_washer_power "Power: [%.1f W]" (group_sonoff)
   { mqtt="<[mosquitto:sonoff_washer/tele/ENERGY:state:JSONPATH($.ENERGY.Power)]" }

and this is the JSON payload of the MQTT message “sonoff_washer/tele/ENERGY”:


A very similar JSONPATH transformation works absolutely fine:

Number sonoff_washer_power2  "Power: [%.1f W]" (group_sonoff)
    { mqtt="<[mosquitto:sonoff_washer/stat/STATUS8:state:JSONPATH($.StatusSNS.ENERGY.Power)]" }

JSON payload:


I don’t know how often I checked the syntax of my items definition and found nothing wrong. I copied from the working example multiple times, carefully replacing the relevant parts. But to no avail, the exception is very stable :roll_eyes:

This one works, but it’s obviously not what I want :wink::

String sonoff_washer_power3 "%s" (group_sonoff)
   { mqtt="<[mosquitto:sonoff_washer/tele/ENERGY:state:default]" }

Has anyone an idea what’s wrong?

(Frank Kintrup) #2

I’m somewhat baffled :face_with_raised_eyebrow:
I did not change a thing since yesterday, no reboot of openHAB or the MQTT broker or the Sonoff, nothing, and now the exception is gone and I receive the correct value.

Posting in this forum alone seems to have healing powers :smiley: