ZigBee Tasmota JSONPATH issues

Hello all,
I’ve been working with Sonoff ZigBee Bridge running Tasmota 12.4.0. My current version of openHAB is 3.3.0 Release Build. I am able to get the data I need from the connected sensors. However, I get “Executing the JSONPATH-transformation failed: Invalid path” in the log. See below. For the SNZB-02:Temp/Hum sensor, when the bridge reports the “Humidity” a [Warn] message is generated in the log for “Temperature”. The reverse is true when “Temperature” is reported. I’ve tried several things, but I cannot seem to solve my problem. Any help would be very much appreciated.

Thank you,

Bob

Connected Sensors:
SNZB-02:Temp/Hum
SNZB-03: Motion
SNZB-04: Door Sensor
SNZB-01 Button

Console output Sonoff ZbBridge
16:31:42.703 MQT: tele/ZbBridge/Temp_Bob_BedRM/SENSOR = {“ZbReceived”:{“Temp_Bob_BedRM”:{“Device”:“0xC6AB”,“Name”:“Temp_Bob_BedRM”,“Humidity”:30.03,“Endpoint”:1,“LinkQuality”:120}}}

tail -f /var/log/openhab/openhab.log /var/log/openhab/events.log
2023-03-13 17:31:43.041 [WARN ] [t.generic.ChannelStateTransformation] - Executing the JSONPATH-transformation failed: Invalid path '$.ZbReceived.Temp_Bob_BedRM.Temperature ’ in ‘{“ZbReceived”:{“Temp_Bob_BedRM”:{“Device”:“0xC6AB”,“Name”:“Temp_Bob_BedRM”,“Humidity”:30.03,“Endpoint”:1,“LinkQuality”:120}}}’

2023-03-13 17:31:43.117 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item ‘Bobs_Bedroom_Humidity’ changed from 31.1 to 30.03

Code:
UID: mqtt:topic:OH3:Temp_Bob_BedRM
label: Zb Temp-Humd Sensor Temp1
thingTypeUID: mqtt:topic
configuration: {}
bridgeUID: mqtt:broker:OH3
location: Bob Bedroom
channels:

  • id: Bob_BedRm_Temp
    channelTypeUID: mqtt:number
    label: Bob Bed Room Temperature
    description: “”
    configuration:
    stateTopic: tele/ZbBridge/Temp_Bob_BedRM/SENSOR
    transformationPattern: "JSONPATH:$.ZbReceived.Temp_Bob_BedRM.Temperature "

  • id: Bob_Bedroom_Humidity
    channelTypeUID: mqtt:number
    label: Bob Bedroom Humidity
    description: “”
    configuration:
    stateTopic: tele/ZbBridge/Temp_Bob_BedRM/SENSOR
    transformationPattern: JSONPATH:$.ZbReceived.Temp_Bob_BedRM.Humidity

Thank you, @hafniumzinc, I think I get the concept, but I fail on the syntax/application. For my code above:
stateTopic: tele/ZbBridge/Temp_Bob_BedRM/SENSOR
transformationPattern: JSONPATH:$.ZbReceived.Temp_Bob_BedRM.Humidity

Do I add the REGEX before the transformationPattern like this:
transformationPattern: **REGEX (.Humidity.)**JSONPATH:$.ZbReceived.Temp_Bob_BedRM.Humidity

Thank you.

Bob

What does the JSON data coming in look like?

If it is something like this:
{"ZbReceived":{"0x2B14":{"Device":"0x2B14","Contact":1,"Endpoint":1,"LinkQuality":42}}}

The JSONPATH would be like this:
JSONPATH$.ZbReceived.0x2B14.Contact
Above is from: Json from Tasmota for window sensor - how to

I have lots of door/window sensors SNZB-04 but I am using zigbee2mqtt.
I am using mosquitto as the mqtt.

My json looks like this:
{“battery”:100,“battery_low”:false,“contact”:true,“last_seen”:“2023-03-15T19:47:28+11:00”,“linkquality”:93,“tamper”:false,“voltage”:3100}

My mqtt topic is: zigbee2mqtt/door-back

My JSONPATH is JSONPATH:$.contact for the open close.

UID: mqtt:topic:mqttbroker:0bc8c6461a
label: Zigbee door back sensor
thingTypeUID: mqtt:topic
configuration:
  payloadNotAvailable: offline
  availabilityTopic: zigbee2mqtt/door-back/availability
  payloadAvailable: online
bridgeUID: mqtt:broker:mqttbroker
location: Kitchen small deck
channels:
  - id: zigbeedoorback
    channelTypeUID: mqtt:contact
    label: Zigbee door back
    description: ""
    configuration:
      stateTopic: zigbee2mqtt/door-back
      transformationPattern: JSONPATH:$.contact
      off: "true"
      on: "false"
  - id: zigbeedoorbackbattery
    channelTypeUID: mqtt:number
    label: Zigbee door back battery
    description: ""
    configuration:
      stateTopic: zigbee2mqtt/door-back
      transformationPattern: JSONPATH:$.battery
      unit: "%"

I am using OH3.
I didn’t need any REGEX to get it to work.
Hope this may help. I did have a sonoff zigbee bridge and it did take a bit if trial and error to get the syntax to work.
I think it pretty much came down to you put a dot for any { in your data payload and then the item you want the value.
EG {“ZbReceived”:{“0x2B14”:{“Device”:“0x2B14”,“Contact”:1,“Endpoint”:1,“LinkQuality”:42}}}

            JSONPATH$.ZbReceived.0x2B14.Contact
                     ^          ^      ^
                  1st {      2nd {     3rd {

Hello @ubeaut.
I have some SNZB-04 and they work fine with no errors in the log. The issue I am having is with the SNZB-02:Temp/Hum. These have both temperature and humidity. However, only report one at a time.

Console output Sonoff ZbBridge sending Humidity
16:31:42.703 MQT: tele/ZbBridge/Temp_Bob_BedRM/SENSOR = {“ZbReceived”:{“Temp_Bob_BedRM”:{“Device”:“0xC6AB”,“Name”:“Temp_Bob_BedRM”,“Humidity”:30.03,“Endpoint”:1,“LinkQuality”:120}}}

tail -f /var/log/openhab/openhab.log /var/log/openhab/events.log
Error in log for temperature:
2023-03-13 17:31:43.041 [WARN ] [t.generic.ChannelStateTransformation] - Executing the JSONPATH-transformation failed: Invalid path '$.ZbReceived.Temp_Bob_BedRM.Temperature ’ in ‘{“ZbReceived”:{“Temp_Bob_BedRM”:{“Device”:“0xC6AB”,“Name”:“Temp_Bob_BedRM”,“Humidity”:30.03,“Endpoint”:1,“LinkQuality”:120}}}’

The event in Log confirming the change in Humidity
2023-03-13 17:31:43.117 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item ‘Bobs_Bedroom_Humidity’ changed from 31.1 to 30.03

The reverse is true. When ZigBee Bridge sends the Temperature, an error for Humidity shows up in the log along with an event for Temperature. You can see my JSONPATH in the code of my original post.

My goal is to eliminate the error “Executing the JSONPATH-transformation failed: Invalid path” in both cases.

Cheers,

B

This isn’t an error, only a warning - you can safely ignore it.

The thread linked in the second post provides instructions and syntax examples if you do want to get rid of the warning.

Ok. I had the same issue with a light and I used this
REGEX:(.White.)∩JSONPATH:$.White

Also I have this in one of my colured bulbs which will more than likely be what you want.

REGEX:(.HSBColor.)∩JSONPATH:$.HSBColor

Thanks for your support, @ubeaut . This is not working for me. I am missing something and will need to dig deeper. The warning only happens with the ZigBee devices with multiple parameters reporting separately. I will need to experiment with Tasmota’s SetOptions commands. I update the thread with what I come up with.

Cheers,

I’m also using the SNZB-02.
If you set

Setoption83 1
Setoption112 1
Setoption100 1

then the tasmota output looks like this

18:33:58.773 MQT: tele/Zigbee/Gefrierschrank3/SENSOR = {"Gefrierschrank3":{"Device":"0x05DC","Name":"Gefrierschrank3","Humidity":67.31,"Endpoint":1,"LinkQuality":39}}

and TransformationPattern like this

REGEX:(.*\"Humidity\".*)∩JSONPATH:$.Gefrierschrank3.Humidity

In your case, if you get rid of the “ZbReceived” with

Setoption100 1

16:31:42.703 MQT: tele/ZbBridge/Temp_Bob_BedRM/SENSOR = {"Temp_Bob_BedRM":{"Device":"0xC6AB","Name":"Temp_Bob_BedRM","Humidity":30.03,"Endpoint":1,"LinkQuality":120}}}

REGEX:(.*\"Humidity\".*)∩JSONPATH:$.Temp_Bob_BedRM.Humidity
2 Likes

Thank you @Rolli . Your syntax worked. My events log is “Warning” free.

Cheers,

Bob

1 Like