I’m configuring JSONPATH transformation for the first time and seems to be missing something basic. Please advise.
This is the item: String Sonoff1info "Sonoff #1 startup info [%s]" { mqtt="<[broker:tele/sonoff1/RESULT:state:JSONPATH($.Info1.Version)]" }
And this is the raw JSON received from the broker: {"Info1":{"AppName":"Sonoff 8266 Module", "Version":"3.2.13", "FallbackTopic":"DVES_XXXXXX", "GroupTopic":"sonoffs"}}
My goal is to extract:
a) single value like "3.2.13"
b) name with value like “Version”:"3.2.13"
c) the whole string like it was before the firmware author switched to JSON
At the moment I’m getting: [WARN ] [pse.smarthome.core.items.GenericItem] - failed notifying listener '[org.eclipse.smarthome.core.persistence.internal.PersistenceManagerImpl@ee100e1, Sonoff1info, null]' about state update of item java.lang.NullPointerException: {}
No error and no update of the item. Added per example from the docs: String Sonoff1info "Sonoff #1 startup info [%s]" { mqtt="<[broker:tele/sonoff1/RESULT:state:JSONPATH($.Info1.Version):REGEX(.*\"Info1\".*)]" }
Yes, this works, but I was not able to harden the filter by checking for leading {
Constructions like \{*\"Info1\".* or .*\{\"Info1\".*are not working, but I can live with this.
Currently I can grab the individual values as well as the whole string by using JSONPATH($.Info1)
{AppName=Sonoff 8266 Module, Version=3.2.13, FallbackTopic=DVES_XXXXXXX, GroupTopic=sonoffs}
How can I get rid of {} ?