JSONPATH-transformation failed - MQTT binding

Platform information:
    Hardware: Rpi4B
    OS: Openhabian (Linux openhabian4B 4.19.75-v7l+ #1270 SMP Tue Sep 24 18:51:41 BST 2019 armv7l GNU/Linux)
    Java Runtime Environment:
    openjdk version "1.8.0_222"
    OpenJDK Runtime Environment (Zulu8.40.0.178-CA-linux_aarch32hf) (build 1.8.0_222-b178)
    OpenJDK Client VM (Zulu8.40.0.178-CA-linux_aarch32hf) (build 25.222-b178, mixed mode, Evaluation)
    openHAB version: 2.5.6 (Build)
    

Issue of the topic:

Hi,

I don’t know why I can’t get the value

Original MQTT Msg:

zigbee/send {"cmd":"report","id":2000000755,"did":"lumi.158d00012653fb","time":1629707070473,"rssi":-49,"zseq":54,"params":[{"res_name":"3.1.85","value":1}],"dev_src":"0"}

Things:

Type string : PIR3          "Motion Sensor" [ stateTopic="zigbee/send", transformationPattern="REGEX:(.*158d00012653fb.*)∩JSONPATH:$.params.res_name" ]

And I got error from Console

16:24:30.878 [WARN ] [tt.generic.ChannelStateTransformation] - Executing the JSONPATH-transformation failed: Invalid path '$.params.res_name' in '{"cmd":"report","id":2000000755,"did":"lumi.158d00012653fb","time":1629707070473,"rssi":-49,"zseq":54,"params":[{"res_name":"3.1.85","value":1}],"dev_src":"0"}'

I get no error if I only use $.params or $.rssi
does error come from _?
what can I do?

Does

JSONPATH:$.params.[0].res_name

work?

Yes,Thank you, it works, Just I don’t know why

This is the relevant section of JSON:

"params":[{"res_name":"3.1.85","value":1}]

The value of params is an array, denoted by enclosing the value in square brackets.

In this case the array only has a single member

{"res_name":"3.1.85","value":1}

which is at position zero in the array. (Array positions are numbered from 0 to infinity).

res_name is within the position zero array member, within the params value. Hence

$.params.[0].res_name
3 Likes

thank you for your kindly explanation :grinning: