I need a little help with a new device. I want to use Zigbee devices and I don´t want to stick something like a USB device directly to my server.
I stumbled over the projekt Zigbee2Tasmota. This project can use the sonoff zigbee bridge to act as a zigbee coordinator and turn the values into mqtt messages.
So I bought a sonoff zigbee bridge and a sonoff zigbee tem/hum sensor.
Then I flashed the bridge with the proper tasmota image and it´s working fine, the sensor sends it´s values to the bridge.
But now I´m at a hurdle I cannot step over.
The Zigbee2Tasmota will send all value in strings like this:
The sensor device adress is 0xB426 and I want to extract the temp and the hum values.
My problem is, that all sensors will use the same mqtt topic “tele/tasmota_zigbee/SENSOR” and the separation has to use the device adress.
By using the PaperUI I made a thing for the Zigbee2Tasmota bridge. And in these thing I tried to make channels for each value I need. I think the separation has to work with JSONPATH but I don´t know how.
Here´s the log entry:
12:32:34.946 [WARN ] [tt.generic.ChannelStateTransformation] - Transformation service “JSONPATH for pattern $.0xB426.Humidity” not found!
12:32:34.948 [WARN ] [hab.binding.mqtt.generic.ChannelState] - Incoming payload ‘{“ZbReceived”:{“0xB426”:{“Device”:“0xB426”,“Name”:“TempHumWohnzimmer”,“Temperature”:23.54,“Humidity”:58.17,“Endpoint”:1,“LinkQuality”:97}}}’ not supported by type ‘NumberValue’
I will thankful for some hints.
Tank you
Platform information:
Hardware: Intel Pentium (don´t know the exact version)
First you probably need to install the jsonpath transformation service. in paperui AddOns, Transformation
Second you somehow need to combine a regex with your jsonpath transformation.
Like: Only if json string contains value “0xB426” then use jsonpath to store temp. And another one for hum value. I tried the exact same thing in the past and it didn’t work on my side. No clue why. At least the doc says it’s possible
The chaining does work, but only after restarting the entire OH installation. I had the same issue and found some post on the forum stating that it only worked after a restart of OH. Unlike other changes, reloading the file or tweaking the PaperUI didn’t work. No idea why.
I’m not certain Stefan’s idea will work because if the JSONPATH doesn’t match anything it returns the whole JSON String. You want to return nothing if the device ID isn’t present. To achieve that use the REGEX filter first chained to the JSONPATH.
I could be wrong on that point though. I’ve never tried to chain two JSONPATHs together like this.
and the right JSONPATH is: JSONPATH:$.ZbReceived.0xB426.Humidity
As explanation: The mqtt path ends with the word sensor, in the jsonpath every step of {} has to be mentioned. In my case the first step was “ZbReceived”, the second “0xB426” and the last brackets are the values - Humidity or Temperture …
Note that, if you add more sensors, and they publish on the same topic, your log will start to show warnings for what you’ve just configured because it will read the published message, but not find the right sensor ID. Your can ignore this, but if it bothers you then you will need to implement a chained transformation with REGEX first, then JSONPATH, as mentioned by @rlkoshak in his post above.