MQTT thing setup with json HELP!

@Taffy - in your original post the data shown doens’t include any data for “Voltage” or “Battery”, so if it isn’t in the data being sent by your sensor, you are not going to be able to parse it out of the air. This was mentioned already by @hafniumzincin his first post.

You also still have all of your transformations incorrect. @hafniumzinc showed them correct per your posted data in two different posts. I’d suggest using those.

it sends battery Percentage and voltage on a seperate line. this is why i didnt include it.
i have also tried the transformations @hafniumzinc showed me and they unfortunatly didnt work so i was just trying a few combinations.

heres is my setup after altering fully from what @hafniumzinc said

tasmota output

19:43:18.809 MQT: tele/Zigbee_Bridge/SENSOR = {"ZbReceived":{"0xB85C":{"Device":"0xB85C","Name":"Kids_Bedroom_Sensor","Temperature":21.09,"Humidity":61.57,"Endpoint":1,"LinkQuality":100}}}
19:43:24.512 MQT: tele/Zigbee_Bridge/SENSOR = {"ZbReceived":{"0xB85C":{"Device":"0xB85C","Name":"Kids_Bedroom_Sensor","BatteryVoltage":3.2,"BatteryPercentage":100,"Endpoint":1,"LinkQuality":105}}}

items

Number Kids_Bedroom_Temperature  "Temperature [%.1f °C]"  <temperature>   { channel="mqtt:topic:Kids_Bedroom_Sensor:temperature" }
Number Kids_Bedroom_Humidity     "Humidity [%.1f %%]"     <humidity>      { channel="mqtt:topic:Kids_Bedroom_Sensor:humidity" }
Number Kids_Bedroom_LinkQuality  "Link Quality [%d]"      <network>       { channel="mqtt:topic:Kids_Bedroom_Sensor:linkquality" }
Number Kids_Bedroom_Voltage      "Voltage [%d mV]"        <energy>        { channel="mqtt:topic:Kids_Bedroom_Sensor:voltage" }
Number Kids_Bedroom_Battery      "Battery [%.1f %%]"      <battery>       { channel="mqtt:topic:Kids_Bedroom_Sensor:battery" }

things

Thing mqtt:topic:Kids_Bedroom_Sensor "Kids Sensor" (mqtt:broker:MQTTBroker) {
    Channels:
        Type number : temperature        [ stateTopic="tele/Zigbee_Bridge/SENSOR",  transformationPattern="JSONPATH:$.ZbReceived.0xB85C.Temperature" ]
        Type number : humidity           [ stateTopic="tele/Zigbee_Bridge/SENSOR",  transformationPattern="JSONPATH:$.ZbReceived.0xB85C.Humidity" ]
        Type number : voltage            [ stateTopic="tele/Zigbee_Bridge/SENSOR",  transformationPattern="JSONPATH:$.ZbReceived.0xB85C.BatteryVoltage" ]
        Type number : battery            [ stateTopic="tele/Zigbee_Bridge/SENSOR",  transformationPattern="JSONPATH:$.ZbReceived.0xB85C.BatteryPercentage" ]
        Type number : linkquality        [ stateTopic="tele/Zigbee_Bridge/SENSOR",  transformationPattern="JSONPATH:$.ZbReceived.0xB85C.LinkQuality" ]
        
}

sitemap

Text item=Kids_Bedroom_Temperature label="Bedroom Temperature [%.1f °C] " icon="temperature"
               Text item=Kids_Bedroom_Humidity label="Humidity [%.1f %%]" icon="humidity"

still no activity in openhab. using MQTTOOL to make sure messages are being sent and received, which they are so the problem must lie in my configs.

You may be hitting the known bug where Things files aren’t correctly parsed by openHAB, especially as you’re still on OH2.4. Easiest thing to do is restart openHAB.

Thank you for that, it is now showing all relevant data.
im only on 2.4 still because when i tried to update to latest stable version all the mqtt items wouldnt work as id not brought them all upto date, which im currently in the process of doing.

Glad to hear you now have this working. One thing further:

This seems very strange to me. You are sending different data to the same mqtt topic? I think what is going to happen here is this:

1.You receive the first data on “tele/Zibbee_Bridge/SENSR” as

{"ZbReceived":{"0xB85C":{"Device":"0xB85C","Name":"Kids_Bedroom_Sensor","Temperature":21.09,"Humidity":61.57,"Endpoint":1,"LinkQuality":100}}}

You will populate temp, humidity, and link quality, but have errors trying to transform voltage and battery since they don’t exist in your data

2 You recevie the second data on “tele/Zigbee_Bridge/SENSOR” as

{"ZbReceived":{"0xB85C":{"Device":"0xB85C","Name":"Kids_Bedroom_Sensor","BatteryVoltage":3.2,"BatteryPercentage":100,"Endpoint":1,"LinkQuality":105}}}

You will populate voltage, battery and link quality, but receive errors trying to transform temp and humidity since those don’t exist in your data.

I would suggest creating two separate topics for these two data sets.

Or you could use the REGEX Transformation Service to filter the incoming JSON, to that only the relevant strings get sent to the JSONPATH Transformation.

For one of the transformations, this would look like:

transformationPattern="REGEX:(.*Temperature.*)∩JSONPATH:$.ZbReceived.0xB85C.Temperature"
2 Likes

Didn’t know that was a thing… Thanks for sharing!

so if i was to use this Regex for say Humidity would i just change the two parts that say Temperature to Humidity?

Yes - change them to the exact spelling of what you want to extract from your JSON file.

1 Like

Found myself a new issue now!
I have added additional sensors to the zigbee bridge. All sensors are outputting mqqt data from the bridge. I was reading the tasmota zigbee documentation and it stated by using the command SetOption89 1 each sensor could have its own mqtt topic which is great but now nothing is reporting like it should on the openhab side. nothing even pops up on the log when there is incoming mqqt data.

So here is the tasmota outputs

17:46:27.058 MQT: tele/Zigbee_Bridge/CD15/SENSOR = {"ZbReceived":{"0xCD15":{"Device":"0xCD15","Name":"Living_Room_Sensor","Humidity":60.82,"Endpoint":1,"LinkQuality":58}}}
17:44:52.771 MQT: tele/Zigbee_Bridge/B85C/SENSOR = {"ZbReceived":{"0xB85C":{"Device":"0xB85C","Name":"Kids_Bedroom_Sensor","Temperature":18.41,"Endpoint":1,"LinkQuality":86}}}

things

Thing mqtt:topic:Living_Room_Sensor "Living Room Sensor" (mqtt:broker:MQTTBroker) {
    Channels:
        Type number : temperature        [ stateTopic=" tele/Zigbee_Bridge/CD15/SENSOR",  transformationPattern="REGEX:(.*Temperature.*)∩JSONPATH:$.ZbReceived.0xCD15.Temperature" ]
        Type number : humidity           [ stateTopic=" tele/Zigbee_Bridge/CD15/SENSOR",  transformationPattern="REGEX:(.*Temperature.*)∩JSONPATH:$.ZbReceived.0xCD15.Humidity" ]
        Type number : voltage            [ stateTopic=" tele/Zigbee_Bridge/CD15/SENSOR",  transformationPattern="REGEX:(.*BatteryVoltage.*)∩JSONPATH:$.ZbReceived.0xCD15.BatteryVoltage" ]
        Type number : battery            [ stateTopic=" tele/Zigbee_Bridge/CD15/SENSOR",  transformationPattern="REGEX:(.*BatteryPercentage.*)∩JSONPATH:$.ZbReceived.0xCD15.BatteryPercentage" ]
        Type number : linkquality        [ stateTopic=" tele/Zigbee_Bridge/CD15/SENSOR",  transformationPattern="REGEX:(.*LinkQuality.*)∩JSONPATH:$.ZbReceived.0xCD15.LinkQuality" ]
        
}
Thing mqtt:topic:Kids_Bedroom_Sensor "Kids Sensor" (mqtt:broker:MQTTBroker) {
    Channels:
        Type number : temperature        [ stateTopic="tele/Zigbee_Bridge/B85C/SENSOR",  transformationPattern="REGEX:(.*Temperature.*)∩JSONPATH:$.ZbReceived.0xB85C.Temperature" ]
        Type number : humidity           [ stateTopic="tele/Zigbee_Bridge/B85C/SENSOR",  transformationPattern="REGEX:(.*Humidity.*)∩JSONPATH:$.ZbReceived.0xB85C.Humidity" ]
        Type number : voltage            [ stateTopic="tele/Zigbee_Bridge/B85C/SENSOR",  transformationPattern="REGEX:(.*BatteryVoltage.*)∩JSONPATH:$.ZbReceived.0xB85C.BatteryVoltage" ]
        Type number : battery            [ stateTopic="tele/Zigbee_Bridge/B85C/SENSOR",  transformationPattern="REGEX:(.*BatteryPercentage.*)∩JSONPATH:$.ZbReceived.0xB85C.BatteryPercentage" ]
        Type number : linkquality        [ stateTopic="tele/Zigbee_Bridge/B85C/SENSOR",  transformationPattern="REGEX:(.*LinkQuality.*)∩JSONPATH:$.ZbReceived.0xB85C.LinkQuality" ]
        
}

items

Number Kids_Bedroom_Temperature  "Temperature [%.1f °C]"  <temperature>   { channel="mqtt:topic:Kids_Bedroom_Sensor:temperature" }
Number Kids_Bedroom_Humidity     "Humidity [%.1f %%]"     <humidity>      { channel="mqtt:topic:Kids_Bedroom_Sensor:humidity" }
Number Kids_Bedroom_LinkQuality  "Kids Bedroom Link Quality [%d]"      <network> (gALLLinkQuality)      { channel="mqtt:topic:Kids_Bedroom_Sensor:linkquality" }
Number Kids_Bedroom_Voltage      "Kids Bedroom Voltage [%d mV]"        <energy>  (gALLBatteryVoltage)      { channel="mqtt:topic:Kids_Bedroom_Sensor:voltage" }
Number Kids_Bedroom_Battery      "Kids Bedroom Battery [%.1f %%]"      <battery> (gALLBatteryPercentage)     { channel="mqtt:topic:Kids_Bedroom_Sensor:battery" }
Number Living_Room_Temperature  "Temperature [%.1f °C]"  <temperature>   { channel="mqtt:topic:Living_Room_Sensor:temperature" }
Number Living_Room_Humidity     "Humidity [%.1f %%]"     <humidity>      { channel="mqtt:topic:Living_Room_Sensor:humidity" }
Number Living_Room_LinkQuality  "Living Room Link Quality [%d]"      <network> (gALLLinkQuality)      { channel="mqtt:topic:Living_Room_Sensor:linkquality" }
Number Living_Room_Voltage      "Living Room Voltage [%d mV]"        <energy>  (gALLBatteryVoltage)      { channel="mqtt:topic:Living_Room_Sensor:voltage" }
Number Living_Room_Battery      "Living Room Battery [%.1f %%]"      <battery> (gALLBatteryPercentage)     { channel="mqtt:topic:Living_Room_Sensor:battery" }

All sensors output data for all things stated just at different times as stated in an earlier post so i used a regex transformation as explained by @hafniumzinc

I had this working perfectly with just one sensor but since adding the second and using seperate mqqt topics i dont seem to get anything?

Note that your JSON string doesn’t contain both temperature and humidity. Is that what you expect?

Yes, The Sensors seem to communicate with the bridge regarding temp, humidity and all other data at different times. I presume this happens when a change occurs not at specific intervals.

Your are regexing Temperature but want Humidity…

Did a restart help?

Hi Taffy
You should use also SetOption83 1,
then your Tasmota output should be without “ZbReceived”

17:46:27.058 MQT: tele/Zigbee_Bridge/CD15/SENSOR = {"0xCD15":{"Device":"0xCD15","Name":"Living_Room_Sensor","Humidity":60.82,"Endpoint":1,"LinkQuality":58}}}

and your JSONPATH is calling directly your device.

"REGEX:(.*Temperature.*)∩JSONPATH:$.0xCD15.Temperature"

Rolli

No I have a different regard for all the different data to correspond to the correct thing ie temp and humidity. Unfortunately a restart did not help. Only one sensor is showing up in openhab logs now but says there’s a warning this happens with all the data incoming from the Zigbee bridge


2021-01-03 17:52:17.416 [WARN ] [eneric.internal.generic.ChannelState] - Incoming payload '{"ZbReceived":{"0xB85C":{"Device":"0xB85C","Name":"Kids_Bedroom_Sensor","Humidity":61.76,"Endpoint":1,"LinkQuality":89}}}' not supported by type 'NumberValue'

Setoption83 does not get rid of the zbrecieved it just uses the friendly name ie kids_sensor Instead of 0x…

Try to remove the humidity tag from your channel definition.

Type number :         [ stateTopic=" tele/Zigbee_Bridge/CD15/SENSOR",  transformationPattern="REGEX:(.*Temperature.*)∩JSONPATH:$.ZbReceived.0xCD15.Humidity" ]

This is my Tasmota output with SetOption83 1, 89 1 and friendly Name

19:38:05 MQT: tele/Hue1/SENSOR = {"Hue1":{"Device":"0xC110","Name":"Hue1","Temperature":18.95,"Endpoint":2,"LinkQuality":45}}

i have just reset both options and this is the output.


19:50:29.620 CMD: SetOption83 1
19:50:29.625 MQT: stat/Zigbee_Bridge/RESULT = {"SetOption83":"ON"}
19:50:37.679 CMD: SetOption89 1
19:50:37.684 MQT: stat/Zigbee_Bridge/RESULT = {"SetOption89":"ON"}
19:50:38.510 MQT: tele/Zigbee_Bridge/STATE = {"Time":"2021-01-03T19:50:38","Uptime":"0T01:45:15","UptimeSec":6315,"Vcc":3.504,"Heap":28,"SleepMode":"Dynamic","Sleep":50,"LoadAvg":20,"MqttCount":2,"Wifi":{"AP":1,"SSId":"ASUSHughes","BSSId":"E0:63:DA:15:4E:DF","Channel":13,"RSSI":100,"Signal":-32,"LinkCount":1,"Downtime":"0T00:00:03"}}
19:51:45.067 MQT: tele/Zigbee_Bridge/CD15/SENSOR = {"ZbReceived":{"Living_Room_Sensor":{"Device":"0xCD15","Name":"Living_Room_Sensor","Humidity":46.21,"Endpoint":1,"LinkQuality":52}}}

i had the same Warning when i set up my Sonoff Zigbee Bridge wit Tasmota, now i try to recreate it and unfortunately i can not find how i solved it. :man_facepalming: :