Sonoff Tasmota + MQTT Binding 2.5.1 + JsonPath Transformation - problem

Hi everyone
I faced a probelm wih using JSONPath Transformation while transforming jsons
I have
RPi 3B+ with installed OH2.5.1
Mosquitto
Bindings: MQTT Bindings, HSONPath Transformation

.thing file configuration (based on Sonoff Tasmota with MQTT Binding 2.4 (using config files); Tasmota - OH and few other…

Bridge mqtt:broker:myMQTTBroker [ host="192.168.1.130", secure=false, clientID="myMQTTClientOH25" ]
{
    Thing topic Test2 "Sonoff Basic Test2" {
    Channels:
        Type string : reachable     "Reachable"             [ stateTopic="tele/sonoff2/LWT" ]
        Type switch : PowerSwitch   "Power"                 [ stateTopic="stat/sonoff2/POWER", commandTopic="cmnd/sonoff2/POWER"]
        Type number : rssi          "WiFi Signal Strength"  [ stateTopic="tele/sonoff2/STATE", transformationPattern="JSONPATH:$.Wifi.RSSI"]
        Type string : my_SSId       "SSId"                  [ stateTopic="tele/sonoff2/STATE", transformationPattern="JSONPATH:$.Wifi.SSId"]

.items file

Switch Switch2 "Switch_2"  {channel="mqtt:topic:myMQTTBroker:Test2:PowerSwitch"}Number rssi "WiFi   " {channel="mqtt:topic:myMQTTBroker:Test2:rssi"}
String reachable "Connected " { channel="mqtt:topic:myMQTTBroker:Test2:reachable"}
String my_SSId "my_SSId " { channel="mqtt:topic:myMQTTBroker:Test2:my_SSId"}

In return I get

2020-02-19 23:05:51.773 [WARN ] [rest.core.item.EnrichedItemDTOMapper] - Failed transforming the state '100' on item 'rssi' with pattern 'JSONPATH($.Wifi.RSSI):%s': Invalid path '$.Wifi.RSSI' in '100'

Or somotimes in return i get nothing - no any error, no any warning, and no value :frowning:

I spent a plenty hours trying to figure out this issue, trying different configuration eg,

.things
Type number : rssi          "WiFi Signal Strength"  [ stateTopic="tele/sonoff2/STATE"]

.items
Number rssi "WiFi  [JSONPATH($.Wifi.RSSI):%s]" {channel="mqtt:topic:myMQTTBroker:Test2:rssi"}

bindings reinstallation, cleaning cache, reinstalling mosquitto
But still no positiv results

I will be greatful for any ideas. Thx in advance

Why not make a temporary String type Item and channel to capture the whole JSON message so you can examine it.

I checked
channel:

Type string : my_status          "My_status"  [ stateTopic="tele/sonoff2/STATE"]

.items

String my_status "My BSSId [JSONPATH($.Wifi.BSSId):%s" { channel="mqtt:topic:myMQTTBroker:Test2:my_status"}

and a result in a log

2020-02-20 19:45:50.271 [ERROR] [ui.internal.items.ItemUIRegistryImpl] - transformation throws exception [transformation=org.openhab.transform.jsonpath.internal.JSonPathTransformationService@1f4da0d, value=- [- ]

org.eclipse.smarthome.core.transform.TransformationException: Invalid path '$.Wifi.BSSId' in '- [- '

	at org.openhab.transform.jsonpath.internal.JSonPathTransformationService.transform(JSonPathTransformationService.java:73) ~[?:?]

	at org.eclipse.smarthome.ui.internal.items.ItemUIRegistryImpl.transform(ItemUIRegistryImpl.java:537) [bundleFile:?]

	at org.eclipse.smarthome.ui.internal.items.ItemUIRegistryImpl.getLabel(ItemUIRegistryImpl.java:449) [bundleFile:?]

	at org.openhab.ui.basic.internal.render.AbstractWidgetRenderer.preprocessSnippet(AbstractWidgetRenderer.java:123) [bundleFile:?]

	at org.openhab.ui.basic.internal.render.TextRenderer.renderWidget(TextRenderer.java:61) [bundleFile:?]

	at org.openhab.ui.basic.internal.render.PageRenderer.renderWidget(PageRenderer.java:194) [bundleFile:?]

	at org.openhab.ui.basic.internal.render.PageRenderer.processChildren(PageRenderer.java:160) [bundleFile:?]

	at org.openhab.ui.basic.internal.render.PageRenderer.processPage(PageRenderer.java:124) [bundleFile:?]

	at org.openhab.ui.basic.internal.servlet.WebAppServlet.service(WebAppServlet.java:189) [bundleFile:?]

	at javax.servlet.http.HttpServlet.service(HttpServlet.java:790) [bundleFile:3.1.0]

	at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:852) [bundleFile:9.4.20.v20190813]

	at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:544) [bundleFile:9.4.20.v20190813]

	at org.ops4j.pax.web.service.jetty.internal.HttpServiceServletHandler.doHandle(HttpServiceServletHandler.java:71) [bundleFile:?]

	at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:143) [bundleFile:9.4.20.v20190813]

	at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:536) [bundleFile:9.4.20.v20190813]

	at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:127) [bundleFile:9.4.20.v20190813]

	at org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:235) [bundleFile:9.4.20.v20190813]

	at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:1581) [bundleFile:9.4.20.v20190813]

	at org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:233) [bundleFile:9.4.20.v20190813]

	at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1307) [bundleFile:9.4.20.v20190813]

	at org.ops4j.pax.web.service.jetty.internal.HttpServiceContext.doHandle(HttpServiceContext.java:293) [bundleFile:?]

	at org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:188) [bundleFile:9.4.20.v20190813]

	at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:482) [bundleFile:9.4.20.v20190813]

	at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:1549) [bundleFile:9.4.20.v20190813]

	at org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:186) [bundleFile:9.4.20.v20190813]

	at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1204) [bundleFile:9.4.20.v20190813]

	at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141) [bundleFile:9.4.20.v20190813]

	at org.ops4j.pax.web.service.jetty.internal.JettyServerHandlerCollection.handle(JettyServerHandlerCollection.java:80) [bundleFile:?]

	at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:127) [bundleFile:9.4.20.v20190813]

	at org.eclipse.jetty.server.Server.handle(Server.java:494) [bundleFile:9.4.20.v20190813]

	at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:374) [bundleFile:9.4.20.v20190813]

	at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:268) [bundleFile:9.4.20.v20190813]

	at org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:311) [bundleFile:9.4.20.v20190813]

	at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:103) [bundleFile:9.4.20.v20190813]

	at org.eclipse.jetty.io.ChannelEndPoint$2.run(ChannelEndPoint.java:117) [bundleFile:9.4.20.v20190813]

	at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.runTask(EatWhatYouKill.java:336) [bundleFile:9.4.20.v20190813]

	at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.doProduce(EatWhatYouKill.java:313) [bundleFile:9.4.20.v20190813]

	at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.tryProduce(EatWhatYouKill.java:171) [bundleFile:9.4.20.v20190813]

	at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.run(EatWhatYouKill.java:129) [bundleFile:9.4.20.v20190813]

	at org.eclipse.jetty.util.thread.ReservedThreadExecutor$ReservedThread.run(ReservedThreadExecutor.java:367) [bundleFile:9.4.20.v20190813]

	at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:782) [bundleFile:9.4.20.v20190813]

	at org.eclipse.jetty.util.thread.QueuedThreadPool$Runner.run(QueuedThreadPool.java:918) [bundleFile:9.4.20.v20190813]

	at java.lang.Thread.run(Thread.java:748) [?:1.8.0_222]


2020-02-20 19:48:30.715 [WARN ] [ab.binding.mqtt.generic.ChannelState] - MQTT message received for topic tele/sonoff2/STATE, but MessageSubscriber object hasn't been started!

2020-02-20 19:48:30.724 [WARN ] [ab.binding.mqtt.generic.ChannelState] - Incoming payload '{"Time":"2020-02-20T19:48:30","Uptime":"0T00:20:47","UptimeSec":1247,"Heap":26,"SleepMode":"Dynamic","Sleep":50,"LoadAvg":19,"MqttCount":1,"POWER":"ON","Wifi":{"AP":1,"SSId":"T","BSSId":"14:CC:20:AC:8F:2A","Channel":10,"RSSI":100,"Signal":-32,"LinkCount":1,"Downtime":"0T00:00:06"}}' not supported by type 'NumberValue'

So, it seems like a problem with JSONPath :frowning:

I found a missing bracket in an item definition. So it works now.

String my_status "My BSSId [JSONPATH($.Wifi.BSSId):%s]  " { channel="mqtt:topic:myMQTTBroker:Test2:my_status"}

@rossko57 Thx for advice.

A question - JSONPath shouldn’t be used in channels definition or did I some mistake?