Which channel? "Executing the JSONPATH-transformation failed: An error occurred while transforming JSON expression."

Hi everyone,

I’m running openHAB 3.4.4.

I have configured a couple of transforms in the past and now looking at the log I am getting these lines:

2024-05-21 12:47:30.664 [WARN ] [t.generic.ChannelStateTransformation] - Executing the JSONPATH-transformation failed: An error occurred while transforming JSON expression.
2024-05-21 12:47:30.665 [WARN ] [t.generic.ChannelStateTransformation] - Executing the JSONPATH-transformation failed: An error occurred while transforming JSON expression.
2024-05-21 12:47:30.665 [WARN ] [t.generic.ChannelStateTransformation] - Executing the JSONPATH-transformation failed: An error occurred while transforming JSON expression.
2024-05-21 12:47:30.665 [WARN ] [t.generic.ChannelStateTransformation] - Executing the JSONPATH-transformation failed: An error occurred while transforming JSON expression.

But I have no idea what the problem is. How can I enable a debug log option in Karaf (or similar) where I can see which channel this is on? Or what value is the problem happening on?

Any help is much appreciated.

A couple of transformations I have in some things:

      transformationPattern: JSONPATH:$.eto∩JS:|(+input).toFixed(3)*100
      transformationPattern: JSONPATH:$.dws∩JS:|(+input).toFixed(2)*10/3600
      transformationPattern: JSONPATH:$.tmp
      transformationPattern: JSONPATH:$.nrg[11]
      transformationPattern: JSONPATH:$.[0]
      transformationPattern: JSONPATH:$.[1]
      transformationPattern: JSONPATH:$.[11]

This is not an answer, but I think in the latter versions this has been remedied by including the channel details in the error message.

Edit: nope it seems not!

Based on the timing of the warnings I would conclude the following…

It’s coming from a single MQTT Thing. MQTT because I think that’s the only place where generic would be in the package name. Single because you have four warnings within a millisecond which implies all four are coming from a single JSON message being processed by four different Channels with four different JSONPATHs.

If that’s not enough to narrow it down, I recommend putting the MQTT binding into DEBUG level logging and see which message received happens almost immediately before the warnings. That should help you narrow down to the specific Thing and tell you what’s up with the JSON to make it not work with those JSONPATHs.

You can change the logging level of the MQTT binding under Settings → Add-on Settnigs → MQTT Binding (you might need to click “show all”).

Hopefully this will help

1 Like

The additional logging is merged. But the reporter is on 3.4.4.
Unless you can create a JAR that is 3.4.4 compatible, i guess @ralfonat needs to update to 4.2 snapshot to check.

@ralfonat

Here’s a jar for you to try

org.openhab.binding.mqtt.generic-3.4.6-SNAPSHOT.jar.txt (101.4 KB)

Please remove the .txt extension - it’s there just so I can upload the file. Place this file in your addons folder, and disable the other addon that has the same name.

To do this, go to karaf console, and type

list -s | grep mqtt.generic

You’ll see a list of bundles, note the bundle id number.
stop the original bundle and make sure the snapshot bundle is started.

stop <bundle_id>

Hopefully that works.

Sorry for a non-information post, but I just want to express my sincere thanks for these quick, extremely helpful replies @jimtng @rlkoshak @lsiepel . I am really blown away. THANKS!

I will try and replace the addons and test it out and post the results.

2 Likes

just documenting this in-between step as I had some trouble with it. Just putting the .jar file in addons did not autoload it for me as a bundle.

So I did this:

openhab> bundle:list -s | grep generic
256 x Active x  81 x 3.4.4                  x org.openhab.binding.mqtt.generic

put the snapshot .jar into /tmp

openhab> bundle:update 256 file:///tmp/org.openhab.binding.mqtt.generic-3.4.6-SNAPSHOT.jar
openhab> bundle:list -s | grep generic
256 x Active x  81 x 3.4.6.202405212346     x org.openhab.binding.mqtt.generic

Works!

So now I am waiting for the next WARN…

1 Like

OK now I am a bit puzzled:

#@OpenHAB:/var/log/openhab# tail -f -n50 *.log | egrep "WARN|ERR"
2024-05-27 09:07:40.618 [WARN ] [t.generic.ChannelStateTransformation] - Executing the JSONPATH-transformation failed: An error occurred while transforming JSON expression.
2024-05-27 09:07:40.618 [WARN ] [t.generic.ChannelStateTransformation] - Executing the JSONPATH-transformation failed: An error occurred while transforming JSON expression.
2024-05-27 09:07:40.618 [WARN ] [t.generic.ChannelStateTransformation] - Executing the JSONPATH-transformation failed: An error occurred while transforming JSON expression.
2024-05-27 09:07:40.618 [WARN ] [t.generic.ChannelStateTransformation] - Executing the JSONPATH-transformation failed: An error occurred while transforming JSON expression.
#@OpenHAB:/var/log/openhab# ssh -p 8101 openhab@localhost

                           _   _     _     ____
   ___   ___   ___   ___  | | | |   / \   | __ )
  / _ \ / _ \ / _ \ / _ \ | |_| |  / _ \  |  _ \
 | (_) | (_) |  __/| | | ||  _  | / ___ \ | |_) )
  \___/|  __/ \___/|_| |_||_| |_|/_/   \_\|____/
       |_|       3.4.4 - Release Build

Use '<tab>' for a list of available commands
and '[cmd] --help' for help on a specific command.
To exit, use '<ctrl-d>' or 'logout'.

openhab> bundle:list -s | grep generic
256 x Active x  81 x 3.4.6.202405212346     x org.openhab.binding.mqtt.generic

It might have gone onto the next line. try

tail -f -n50 *.log | egrep -A 2 "WARN|ERR"

Failing that, try this jar in case I messed up and forgot to change the line before building the jar. I’ve rebuilt it again.

org.openhab.binding.mqtt.generic-3.4.6-SNAPSHOT.jar.txt (101.4 KB)

As before, just rename it and remove the .txt extension

root@OpenHAB:/var/log/openhab# tail -f -n50 *.log | egrep -C2 "WARN|ERR"
2024-05-28 09:03:53.816 [INFO ] [ding.snmp.internal.SnmpTargetHandler] - failed to renew target address, waiting for next refresh cycle
2024-05-28 09:08:53.820 [INFO ] [ding.snmp.internal.SnmpTargetHandler] - failed to renew target address, waiting for next refresh cycle
2024-05-28 09:09:04.524 [WARN ] [t.generic.ChannelStateTransformation] - Executing the JSONPATH-transformation failed: An error occurred while transforming JSON expression.
2024-05-28 09:09:04.525 [WARN ] [t.generic.ChannelStateTransformation] - Executing the JSONPATH-transformation failed: An error occurred while transforming JSON expression.
2024-05-28 09:09:04.525 [WARN ] [t.generic.ChannelStateTransformation] - Executing the JSONPATH-transformation failed: An error occurred while transforming JSON expression.
2024-05-28 09:09:04.525 [WARN ] [t.generic.ChannelStateTransformation] - Executing the JSONPATH-transformation failed: An error occurred while transforming JSON expression.
2024-05-28 09:13:53.823 [INFO ] [ding.snmp.internal.SnmpTargetHandler] - failed to renew target address, waiting for next refresh cycle
2024-05-28 09:18:53.826 [INFO ] [ding.snmp.internal.SnmpTargetHandler] - failed to renew target address, waiting for next refresh cycle

I’m trying the new jar now…
will report back

sorry but I seem to be doing something wrong…

2024-05-28 12:33:01.462 [WARN ] [t.generic.ChannelStateTransformation] - Executing the JSONPATH-transformation failed: An error occurred while transforming JSON expression.
2024-05-28 12:33:01.462 [WARN ] [t.generic.ChannelStateTransformation] - Executing the JSONPATH-transformation failed: An error occurred while transforming JSON expression.
2024-05-28 12:33:01.462 [WARN ] [t.generic.ChannelStateTransformation] - Executing the JSONPATH-transformation failed: An error occurred while transforming JSON expression.
2024-05-28 12:33:01.462 [WARN ] [t.generic.ChannelStateTransformation] - Executing the JSONPATH-transformation failed: An error occurred while transforming JSON expression.
openhab> bundle:list -s | grep generic
256 x Active x  81 x 3.4.6.202405271835     x org.openhab.binding.mqtt.generic

I thought this was “hot-plug” or do I have to reload something?

I thought this indicated the reload was successful:

2024-05-28 13:25:06.028 [INFO ] [ab.event.ThingStatusInfoChangedEvent] - Thing 'mqtt:topic:93aeba343f' changed from UNINITIALIZED (HANDLER_MISSING_ERROR) to INITIALIZING
2024-05-28 13:25:06.071 [INFO ] [ab.event.ThingStatusInfoChangedEvent] - Thing 'mqtt:topic:93aeba343f' changed from INITIALIZING to ONLINE

Restart org.openhab.binding.mqtt or failing that, restart openhab then make sure it hasn’t reverted to the original binding.

Sorry for no updates but after replacing and restarting openhab I am not getting any errors anymore ¯_(ツ)_/¯