dattosma
(Datto Sma)
December 13, 2023, 1:25pm
1
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
rlkoshak
(Rich Koshak)
December 13, 2023, 3:21pm
2
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
dattosma
(Datto Sma)
December 13, 2023, 7:47pm
3
Thank you.
This will create multiple MQTT subscriptions correct ?
rlkoshak
(Rich Koshak)
December 13, 2023, 8:49pm
4
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
pt3
(pt3)
December 23, 2023, 2:14pm
5
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.
dattosma
(Datto Sma)
December 29, 2023, 9:51am
6
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
pt3
(pt3)
January 2, 2024, 10:35am
7
When connect to mosquitto server (mqtt explorer) I see this:
dattosma
(Datto Sma)
January 2, 2024, 5:24pm
8
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 …
pt3
(pt3)
January 2, 2024, 7:39pm
9
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.
dattosma
(Datto Sma)
January 3, 2024, 8:57am
10
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
pt3
(pt3)
January 3, 2024, 1:39pm
11
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?
dattosma
(Datto Sma)
January 3, 2024, 4:02pm
12
Zigbee2Tasmota (Z2T) documentation can be found here: Zigbee - Tasmota
You can set a friendly name to the device with zbname . For example:
zbname 0x2916,SNZB-02
To add the device / friendly name to the mqtt topic:
SetOption83 1
SetOption89 1
SetOption112 1
pt3
(pt3)
January 4, 2024, 12:49pm
13
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