Zigbee gateway MQTT channels / items modeling

Hello,

Disclaimer - I’m an absolute OH newbie.

I have a Zigbee gateway running tasmota ZB-GW03.

The tasmota gateway is publishing all the device/sensor status under the same MQTT topic (variable json payload that always contains the device name).

I’m not really sure how to model that:

  • a single gateway channel and postprocess the Json payload into multiple items (script only? jsonpath?)
  • a channel for each devices (same question as above - script? jsonpath?)
  • a channel for each sensors (tested jsonpath and it seems to be working)

Thank you in advance.
Datto

The general approach is that one Thing represents one device. So even though it’s a little more work, I would model it that way.

This means one Thing per Zigbee device. Sure they will all be subscribing on the same topic but you can use transformation chaining with REGEX so that only those messages for that device are processed by that Thing. Then each Channel represents one sensor/actuator on that device and use a JSONPATH transform on the Channel to extract the value.

If you’ve a lot of the same type of devices, you can copy/paste/edit to create new copies. In 4.1 I think the PR got merged that added a “duplicate Thing” option. But if you are on an older version you can copy the YAML from the code tab and paste/edit it to quickly create copies of Things.

1 Like

Thank you.
This will create multiple MQTT subscriptions correct ?

Probably but not multiple connections to the broker. There’s only one connection.

And subscriptions are pretty light weight. You’d need thousands of them to see any sort of performance issues if that’s your concern.

1 Like

Hello all.
I’am new in zigbee devices. I also have tasmota ZB-GW03. My configuration:
OpenHab 4.0.3 (on Windows 10 OS)
Installed Mosquitto
MQTT broker thing created and online

Tasmota ZB-GW03 is paired with one Zigbee device and MQTT settings is (192.168.100.253 is OpenHAB and Mosquitto server):

What next? I create new generic MQTT thing for ZB-GW03 but is offline.
How connect paired Zigbee device to Openhab?

PS: sorry for bad english.

Do you see the MQTT messages from a MQTT client (for example http://mqtt-explorer.com/) ?

Otherwise my ZB-GW03 Thing is defined a follow (I just have Uptime channel):

UID: mqtt:topic:3ed6775118:c81fa52cf2
label: Zigbee Gateway (ZB-GW03)
thingTypeUID: mqtt:topic
configuration:
  payloadNotAvailable: Offline
  availabilityTopic: tele/ZBGW03/LWT
  payloadAvailable: Online
bridgeUID: mqtt:broker:3ed6775118
channels:
  - id: ZBGW03_uptime
    channelTypeUID: mqtt:string
    label: Uptime
    description: null
    configuration:
      stateTopic: tele/ZBGW03/STATE
      transformationPattern: JSONPATH:$.Uptime

When connect to mosquitto server (mqtt explorer) I see this:
image

Are you sure that tasmota was able to connect to the broker ?
You should see entries like that in the Tasmota console.

01:17:15.307 MQT: Attempting connection...
01:17:15.315 MQT: Connected

Maybe your broker accept only connections from localhost. Or firewall is blocking …

Yes, it was firewall.Now I see communication betwen to sensors behind gateway.
I need create this sensors in openhab. New things with channels? How read one sensor exactly?
I try this path: tele/ZB-GW03topic/SENSOR/hexcodeforsensor/Temperature but not working.

I doubt that tasmota can expose the temperature as a topic, it is probably part of the json payload.
Something like that

UID: mqtt:topic:3ed6775118:d2703d3679
label: Temp (TS0201-1)
thingTypeUID: mqtt:topic
configuration: {}
bridgeUID: mqtt:broker:3ed6775118
channels:
  - id: TS0201-1_temperature
    channelTypeUID: mqtt:number
    label: Temperature
    description: ""
    configuration:
      stateTopic: tele/ZBGW03/TS0201-1/SENSOR
      transformationPattern: REGEX:(.*Temperature.*)∩JSONPATH:$.ZbReceived.TS0201-1.Temperature
      unit: °C

OK, I undrestand.But where do I get the sensor topic from? In your examle TS0201-1.
I see in MQTT explorer this data:

It is 0x8BFF?

Zigbee2Tasmota (Z2T) documentation can be found here: Zigbee - Tasmota

  1. You can set a friendly name to the device with zbname. For example:
zbname 0x2916,SNZB-02
  1. To add the device / friendly name to the mqtt topic:
SetOption83 1
SetOption89 1
SetOption112 1

That’s my functional thing with channels:

UID: mqtt:topic:725eef2270:TH1
label: TH1
thingTypeUID: mqtt:topic
configuration: {}
bridgeUID: mqtt:broker:725eef2270
channels:
  - id: TH1Temperature
    channelTypeUID: mqtt:number
    label: TH1Temperature
    description: ""
    configuration:
      stateTopic: tele/tasmota_2D5ACC/TH1/SENSOR
      transformationPattern: JSONPATH:$.ZbReceived.TH1.Temperature
      unit: °C
  - id: TH1Humidity
    channelTypeUID: mqtt:number
    label: TH1Humidity
    description: ""
    configuration:
      stateTopic: tele/tasmota_2D5ACC/TH1/SENSOR
      transformationPattern: JSONPATH:$.ZbReceived.TH1.Humidity
      unit: "%"
  - id: TH1BatteryPercentage
    channelTypeUID: mqtt:number
    label: TH1BatteryPercentage
    description: ""
    configuration:
      stateTopic: tele/tasmota_2D5ACC/TH1/SENSOR
      transformationPattern: JSONPATH:$.ZbReceived.TH1.BatteryPercentage
  - id: TH1BatteryVoltage
    channelTypeUID: mqtt:number
    label: TH1BatteryVoltage
    description: ""
    configuration:
      transformationPattern: JSONPATH:$.ZbReceived.TH1.BatteryVoltage
      stateTopic: tele/tasmota_2D5ACC/TH1/SENSOR
      unit: V

For me is only JSONPATH working in transformationPattern. REGEX not working (RegEx transformation installed).

Thank you VERY much.

Only one question: battery level and voltage is NULL. But in tasmota console i see data for these parameters.

Correction: battery level and voltage parameter its now OK. Values appeared after some time.
Everything working. Thanks