How to read and display Zigbee temperature and humidity sensor values?

mosquitto_sub -h localhost -t β€˜#’ -v gives the following output

tuya/gateway/dps/state {β€œ1”:11}
tuya/gateway/dps/1/state 11
tuya/gateway/dps/state {β€œ1”:11}
tuya/gateway/dps/1/state 11
tuya/gateway/dps/state {β€œ2”:804}
tuya/gateway/dps/2/state 804
tuya/gateway/dps/state {β€œ2”:804}
tuya/gateway/dps/2/state 804
tuya/gateway/dps/state {β€œ1”:204}
tuya/gateway/dps/1/state 204
tuya/gateway/dps/state {β€œ1”:204}
tuya/gateway/dps/1/state 204
tuya/gateway/dps/state {β€œ2”:326}
tuya/gateway/dps/2/state 326
tuya/gateway/dps/state {β€œ2”:326}
tuya/gateway/dps/2/state 326

This neither looks like humidity nor temperature data. Has anyone else configured these Tuya Zigbee temperature and humidity sensors to be read and displayed on OpenHAB 3?

Just some wild guesses:

Syntax error in devices.conf?

Restart tuya-mqtt after modifying devices.conf.

Are you sure that tuya-mqtt does support tuya-Zigbee devices (it isn’t obvious to me)?

Please note that tuya-mqtt is in β€˜maintainance [sic] mode’.

Read on if getting rid of the Tuya-Zigbee gateway is an option:

Your devices might be supported by the Zigbee Binding or by Zigbee2MQTT (cf. TuYa ZTH01 control via MQTT | Zigbee2MQTT) - of course, one cannot be sure. You would have to buy a Zigbee coordinator to find out (my recommendation: https://itead.cc/product/zigbee-3-0-usb-dongle/ - supported by the Zigbee Binding and by Zigbee2MQTT (experimental, but rock solid in my Zigbee2MQTT setup - YMMV)).

1 Like

OP here, some progress.

I added the gateway ip adress and version to devices.conf and that seems to have made the trick, like so:

name: 'Gateway',
id: 'xxxxxxxxxxxxxxxxxxxxxxx',
key: 'yyyyyyyyyyyyyyyy',
ip: '192.168.zzz.qww',
version: '3.3',

Now
mosquitto_sub -v -h localhost -t β€˜#’
results in the following output:

tuya/gateway/status online
tuya/gateway/dps/state {β€œ1”:200}
tuya/gateway/dps/1/state 200
tuya/gateway/dps/state {β€œ2”:292}
tuya/gateway/dps/2/state 292
tuya/gateway/dps/state {β€œ1”:192}
tuya/gateway/dps/1/state 192
tuya/gateway/dps/state {β€œ2”:278}
tuya/gateway/dps/2/state 278
tuya/gateway/dps/state {β€œ1”:195}
tuya/gateway/dps/1/state 195
tuya/gateway/dps/state {β€œ2”:282}
tuya/gateway/dps/2/state 282
tuya/gateway/dps/state {β€œ1”:208}
tuya/gateway/dps/1/state 208
tuya/gateway/dps/state {β€œ2”:265}
tuya/gateway/dps/2/state 265
tuya/gateway/dps/state {β€œ1”:205}
tuya/gateway/dps/1/state 205
tuya/gateway/dps/state {β€œ2”:261}
tuya/gateway/dps/2/state 261
tuya/gateway/dps/state {β€œ1”:-4}
tuya/gateway/dps/1/state -4
tuya/gateway/dps/state {β€œ2”:803}
tuya/gateway/dps/2/state 803
tuya/gateway/dps/state {β€œ1”:134}
tuya/gateway/dps/1/state 134
tuya/gateway/dps/state {β€œ2”:269}
tuya/gateway/dps/2/state 269
tuya/gateway/dps/state {β€œ1”:200}
tuya/gateway/dps/1/state 200
tuya/gateway/dps/state {β€œ2”:291}
tuya/gateway/dps/2/state 291
tuya/gateway/dps/state {β€œ1”:192}
tuya/gateway/dps/1/state 192
tuya/gateway/dps/state {β€œ2”:277}
tuya/gateway/dps/2/state 277

Comparing the values to the values in the Android app I found out that the numbers correspond to the values measured by the sensors.

For example:

tuya/gateway/dps/state {β€œ1”:-4}
tuya/gateway/dps/1/state -4
tuya/gateway/dps/state {β€œ2”:803}
tuya/gateway/dps/2/state 803

Corresponds to the outdoor sensor that currently measures -0,4C and 80,3% humidity. There are 4 lines per sensor in the output and values need to be divided by 10. Apparently all my zigbee sensors are now recognized. The sensor IDs are missing, still.

Next question is how to get the sensors identified AND how to draw them into a nice graph in OpenHAB?

It seems like the Tuya Zigbee gateway just forwards the topic values from the subunits without labeling the values at all.
Is there a way to use for example devices.conf to create recognizable labels to the topic values, to identify which sensor is being reported?

So instead of:
tuya/gateway/dps/state {β€œ1”:200}
tuya/gateway/dps/1/state 200
tuya/gateway/dps/state {β€œ2”:271}
tuya/gateway/dps/2/state 271
tuya/gateway/dps/state {β€œ1”:-3}
tuya/gateway/dps/1/state -3
tuya/gateway/dps/state {β€œ2”:814}
tuya/gateway/dps/2/state 814

It would report

tuya/gateway/dps/state {β€œ1”:200}
tuya/gateway/dps/1/state 200 Garage Temperature
tuya/gateway/dps/state {β€œ2”:271}
tuya/gateway/dps/2/state 271 Garage Humidity
tuya/gateway/dps/state {β€œ1”:-3}
tuya/gateway/dps/1/state -3 Outdoor Temperature
tuya/gateway/dps/state {β€œ2”:814}
tuya/gateway/dps/2/state 814 Outdoor Humidity