Hi Folks,
i have a small issue using Xiaomi Sensors with Sonoff ZbBridge and receiving the sensor date via MQTT in OpenHAB 3.
The Thing and Channel configuration is working fine i can receive the data.
Im Using JSONPATH to receive the needed value from the json string.
transformationPattern: JSONPATH:$.ZbReceived.Tp_GstKlo.Contact
But…
…one of the behavior of Tasmota is that it is sending payloads for different “events” on the same MQTT topic!
The result is, that there are not always the expected values in the payload.
Here is an example:
Expected payload with the needed “Contact” value:
{ "ZbReceived": { "Fr_GsKlo": { "Device": "0xA8D1", "Name": "Fr_GsKlo", "Contact": 1, "Endpoint": 1, "LinkQuality": 92 } } }
and then there are sometimes payloads like this:
{ "ZbReceived": { "Fr_GsKlo": { "Device": "0xA8D1", "Name": "Fr_GsKlo", "BatteryVoltage": 3, "BatteryPercentage": 98, "Endpoint": 1, "LinkQuality": 63 } } }
As you can see there is no “Contact” value.
The result is that i get a lot of warnings like this:
Executing the JSONPATH-transformation failed: Invalid path '$.ZbReceived.Fr_GsKlo.Contact' in '{"ZbReceived":{"Fr_GsKlo": "Device":"0xA8D1","Name":"Fr_GsKlo","BatteryVoltage":3,"BatteryPercentage":98,"Endpoint":1,"LinkQuality":63}}}'
Now my question is:
is it somehow possible to “pre-check” the payload and discard the payload in case the needed value is not there?
I would really like to get rid of these warnings.
Cheers
Niko