Design pattern for Zigbee2Mqtt Thing

Hi,

I have created SonoffZigBee2MqttBridge which is generic mqtt think.

The Sonoff produce messages as follows:

/home/ZBBridgeP1/tele/SENSOR = {"ZbReceived":{"0xB5D2":{"Device":"0xB5D2","Temperature":20.48,"Humidity":71.74,"Pressure":1020,"PressureScale":-1,"PressureScaledValue":10205,"SeaPressure":1020,"BatteryPercentage":100,"Endpoint":1,"LinkQuality":36}}}
/home/ZBBridgeP1/tele/SENSOR = {"ZbReceived":{"0x1A5D":{"Device":"0x1A5D","Temperature":23.04,"Humidity":60.74,"Pressure":1019,"PressureScale":-1,"PressureScaledValue":10192,"SeaPressure":1019,"BatteryPercentage":92,"Endpoint":1,"LinkQuality":138}}}
/home/ZBBridgeP1/tele/SENSOR = {"ZbReceived":{"0x48B3":{"Device":"0x48B3","BatteryVoltage":3.03,"BatteryPercentage":100,"Contact":0,"Endpoint":1,"LinkQuality":109}}}

I have multiple devices contact and weather devices.

Example of my think’s chanel configuration:

  - id: ZigBee_CF0C_Contact
    channelTypeUID: mqtt:contact
    label: ZigBee_CF0C_Contact_KitchenWindowUp
    description: null
    configuration:
      stateTopic: /home/ZBBridgeP1/tele/SENSOR
      transformationPattern: JSONPATH:$.ZbReceived.0xCF0C.Contact
      off: "0"
      on: "1"
  - id: ZigBee_E1D3_Temperature_LivingRoom
    channelTypeUID: mqtt:number
    label: ZigBee_E1D3_Temperature_LivingRoom
    description: null
    configuration:
      stateTopic: /home/ZBBridgeP1/tele/SENSOR
      transformationPattern: JSONPATH:$.ZbReceived.0xE1D3.Temperature
      unit: °C

I have created channels for all devices with their code and it works principally. The problem is, that I regularry receive a lot of error messages:
2022-10-27 17:12:51.751 [WARN ] [t.generic.ChannelStateTransformation] - Executing the JSONPATH-transformation failed: Invalid path '$.ZbReceived.0x8CD9.Humidity' in '{"ZbReceived":{"0x2A2A":{"Device":"0x2A2A","FCC0/00F7":"03281B05212300082136010A2100000C20141020011220006520006620036720006820006920016A20016B2003","Endpoint":1,"LinkQuality":69}}}'

I do generally understand the problem, all messages for all devices are sent to the same subscription /home/ZBBridgeP1/tele/SENSOR, so json path JSONPATH:$.ZbReceived.0x8CD9 will be invalid for message with: '{"ZbReceived":{"0x2A2A":...

What is the best design pattern to parse e.g. temperature, humidity, pressure, contact sensors messages without errors?

  • openHAB version: 3.3.0