Chaining MAP to JSONPATH does not work

I am creating a sitemap where a Text item has to show the status of an alarm contact received via MQTT
Messages are like this

{"TYPE": "ZON", "A": "N", "STA": "R"}

The sitemap definition using only JSONPATH works well.
Then I have introduced a map file named “” placed under the usual /transform folder:


Then I configured the sitemap like this

sitemap alarmapp label="Alarm App Test" {
    Frame label="Zone" {
        Text item=zona_5 label="Zona 5 [JSONPATH($.STA)∩MAP(]"

With this mapping i get exceptions in the log file: looks like the chained mappings are not parsed well by the interpreter.

org.eclipse.smarthome.core.transform.TransformationException: An error occurred while transforming JSON expression.
        at org.openhab.transform.jsonpath.internal.JSonPathTransformationService.transform( ~[?:?]
        at org.eclipse.smarthome.ui.internal.items.ItemUIRegistryImpl.transform( [bundleFile:?]
        at org.eclipse.smarthome.ui.internal.items.ItemUIRegistryImpl.getLabel( [bundleFile:?]
        at [bundleFile:?]
        at [bundleFile:?]
        at [bundleFile:?]
        at [bundleFile:?]
        at org.eclipse.smarthome.core.items.GenericItem$ [bundleFile:?]
        at java.util.concurrent.ThreadPoolExecutor.runWorker( [?:1.8.0_144]
        at java.util.concurrent.ThreadPoolExecutor$ [?:1.8.0_144]
        at [?:1.8.0_144]
Caused by: com.jayway.jsonpath.InvalidPathException: Arguments to function: 'STA)∩MAP' are not closed properly.
        at com.jayway.jsonpath.internal.path.PathCompiler.parseFunctionParameters( ~[?:?]
        at com.jayway.jsonpath.internal.path.PathCompiler.readPropertyOrFunctionToken( ~[?:?]
        at com.jayway.jsonpath.internal.path.PathCompiler.readNextToken( ~[?:?]
        at com.jayway.jsonpath.internal.path.PathCompiler.readDotToken( ~[?:?]
        at com.jayway.jsonpath.internal.path.PathCompiler.readNextToken( ~[?:?]
        at com.jayway.jsonpath.internal.path.PathCompiler.readContextToken( ~[?:?]
        at com.jayway.jsonpath.internal.path.PathCompiler.compile( ~[?:?]
        at com.jayway.jsonpath.internal.path.PathCompiler.compile( ~[?:?]
        at com.jayway.jsonpath.JsonPath.<init>( ~[?:?]
        at com.jayway.jsonpath.JsonPath.compile( ~[?:?]
        at ~[?:?]
        at ~[?:?]
        at org.openhab.transform.jsonpath.internal.JSonPathTransformationService.transform( ~[?:?]
        ... 10 more

Any suggestion? Is it a bug or I use the wrong syntax?
Thanks for help

Item labels simply do not support chaining of transforms.

So far as I know, the only place in openHAB that does support chaining is the MQTT binding.

Is there some reason you are not parsing the JSON field out at the binding channel into an Item?

Hi rossko57
Thank you for your answer. This explains all.
Well, I actually tried to do as you write: I have set the definition (which I do not recall now) into the Generic MQTT Thing’s channel transformation field using the Paper UI, but I got exceptions as well.
I will give it another try and post here the result.

Hi rossko57
Well, yes, it is working now.
The string “JSONPATH:$.STA∩” in the channel’s transformation does the job.
Thank you!!

1 Like