I am trying to implement presence detection by using OwnTrack.
Everything is working so far, with the exception of some warnings like:
2023-07-26 15:26:22.271 [WARN ] [t.generic.ChannelStateTransformation] - Executing the JSONPATH-transformation failed: Invalid path '$.SSID' in '{"_type":"location","acc":11,"alt":198,"batt":67,"bs":1,"cog":17,"conn":"m","lat":48.228935,"lon":17.042565,"m":2,"tid":"SL","tst":169037794
The reason is that the JSON payload is not constant and misses values when they do not make sense.
In my example, I am monitoring the two values for
“connection” with possible values “w” for WiFi" and “m” for mobile
and “SSID” which may contain the SSID of the WiFi or is not existing at all when “connection” is “m”
here is the things file content:
Thing mqtt:topic:vevedock:owntracks_sasha "OwnTracks Sasha" (mqtt:broker:4739c61702) @ "iPhones" {
Channels:
Type string : connection "Connection" [ stateTopic="owntracks/openhab/sasha", transformationPattern="JSONPATH:$.conn" ]
Type string : ssid "SSID" [ stateTopic="owntracks/openhab/sasha", transformationPattern="JSONPATH:$.SSID" ]
}
Thing mqtt:topic:vevedock:owntracks_iveta "OwnTracks Iveta" (mqtt:broker:4739c61702) @ "iPhones" {
Channels:
Type string : connection "Connection" [ stateTopic="owntracks/openhab/iveta", transformationPattern="JSONPATH:$.conn" ]
Type string : ssid "SSID" [ stateTopic="owntracks/openhab/iveta", transformationPattern="JSONPATH:$.SSID" ]
}
Is there any way to have a conditional transformation pattern in order to eliminate warnings and assign an empty value as a result?
There are definitely other solutions like getting the whole topic into a rule and parsing it there, which I would not like to do.