I am using the Theengs Gateway to query BLE data from my different sensors and sending to OpenHAB through MQTT. I use OH 3.4 installed with openhabian on a raspberry pi v3.
For some of my sensors (Ie.g. a MiFlora plant monitor) the Theengs Gateway sends MQTT messages with different contents: sometimes there’s only temperature, some other there’s also luminosity and so on.
This behaviour floods my openhab log of messages similar to the following
2022-12-28 15:06:02.782 [WARN ] [t.generic.ChannelStateTransformation] - Executing the JSONPATH-transformation failed: Invalid path '$.lux' in '{"name":"Flower care","id":"C4:7C:8D:65:F5:E6","rssi":-86,"brand":"Xiaomi/VegTrug","model":"MiFlora","model_id":"HHCCJCY01HHCC","moi":0}
where, in this case, the JSONPATH transform complains that in the incoming message there is no lux field.
The configuration of the mqtt thing (I am doing through the UI) is as follows
Thank you for your quick answer.
It is unfortunate that there is no way to deal with this problem.
Wouldn’t it be possible to broadcast one message per json field?
Instead of sending
So basically the problem is that the value sometimes gets transmitted, but sometimes it is missing in the JSON, correct?
I have faced a similar issue with some Tuya zigbee buttons that only from time to time provide the battery SOC in the messages causing zigbee2mqtt to send a message without the value.
You may try to use a REGEX and an intersection to ensure your value is present.
Something like:
REGEX:(.*lux.*)∩JSONPATH:$.lux
This way I do not get the warnings in the log as the REGEX prevents the processing of the JSONPATH expression if there is no match.
Feel free to use a more precise pattern, but this was the simplest way to get it working in that situation.
Not for now, we have very little use of simplePublishing and we are not planning to integrate it into Theengs gateway.
We need to find another way to avoid these warnings.