2021-06-12
First light on zigbee environment sensors
The package with the zigbee environment sensors I ordered arrived this morning and I had to get the first test done right away. Joining the network/resetting the sensor is easy with a long press of the button and it showed up:Zigbee2MQTT:info 2021-06-12 11:53:17: Device '0x00158d0006fafb00' joined Zigbee2MQTT:info 2021-06-12 11:53:17: Starting interview of '0x00158d0006fafb00' gbee2MQTT:info 2021-06-12 11:53:52: Successfully interviewed '0x00158d0006fafb00', device has successfully been paired Zigbee2MQTT:info 2021-06-12 11:53:52: Device '0x00158d0006fafb00' is supported, identified as: Xiaomi Aqara temperature, humidity and pressure sensor (WSDCGQ11LM) Zigbee2MQTT:info 2021-06-12 11:53:52: Configuring '0x00158d0006fafb00' Zigbee2MQTT:info 2021-06-12 11:53:52: Successfully configured '0x00158d0006fafb00'And now it gives me data!Zigbee2MQTT:info 2021-06-12 12:15:53: MQTT publish: topic 'zigbee2mqtt/0x00158d0006fafb00', payload '{"battery":100,"humidity":45.77,"linkquality":153,"pressure":1033,"temperature":24.9,"voltage":3055}' Zigbee2MQTT:info 2021-06-12 12:15:53: MQTT publish: topic 'zigbee2mqtt/0x00158d0006fafb00', payload '{"battery":100,"humidity":45.85,"linkquality":156,"pressure":1033,"temperature":24.9,"voltage":3055}' Zigbee2MQTT:info 2021-06-12 12:15:53: MQTT publish: topic 'zigbee2mqtt/0x00158d0006fafb00', payload '{"battery":100,"humidity":45.85,"linkquality":156,"pressure":1033,"temperature":24.9,"voltage":3055}'Also visible via mqtt:koos@testrouter:~$ mosquitto_sub -t zigbee2mqtt/0x00158d0006fafb00 -v zigbee2mqtt/0x00158d0006fafb00 {"battery":100,"humidity":45.77,"linkquality":153,"pressure":1033,"temperature":24.9,"voltage":3055} zigbee2mqtt/0x00158d0006fafb00 {"battery":100,"humidity":45.85,"linkquality":156,"pressure":1033,"temperature":24.9,"voltage":3055} zigbee2mqtt/0x00158d0006fafb00 {"battery":100,"humidity":45.85,"linkquality":156,"pressure":1033,"temperature":24.9,"voltage":3055}As you can see the published data are json objects. I can't subscribe to subject zigbee2mqtt/0x00158d0006fafb00/temperature so before I can import this into influxdb it will need work to get the right translation from the subject zigbee2mqtt/0x00158d0006fafb00 plus the data in the json object to influxdb values that I can use. I will also probably use 'user-friendly' names for temperature locations. And it looks like measurement values are sent 3 times for every measurement so a bit of filtering of only new values is needed. I also note updates are irregular (I've seen intervals of 3 to 30 minutes) so the communication is probably limited to 'something new to report'. Lots of ways to save energy, but the software that gathers and presents this data has to be able to deal with this! A translation from subject zigbee2mqtt/0x00158d0006fafb00 and message {"battery":100,"humidity":45.77,"linkquality":153,"pressure":1033,"temperature":24.9,"voltage":3055} to a call to use influxdb environment to insert a record into table environment with tags location=livingroom and values battery=100,humidity=45.77,linkquality=153,pressure=1033,temperature=24.9,voltage=3055. This will need a translation table from 0x00158d0006fafb00 to a home location like livingroom. Update 2021-06-13: In the long run I've been doing tests with putting the sensor in different places. It has spent the night in the fridge because I wondered what that does for the zigbee communication (works fine) and once we had a measurement from inside the fridge we wondered about the temperature, it seemed somewhat warm for a fridge! So we also adjusted the fridge. A measurement from the fridge:Zigbee2MQTT:info 2021-06-13 10:51:08: MQTT publish: topic 'zigbee2mqtt/0x00158d0006fafb00', payload '{"battery":100,"humidity":68.87,"linkquality":57,"pressure":1042,"temperature":8.18,"voltage":3125}'Suspending the system running zigbee2mqtt makes it confused (I guess the usb stick going into powerdown / coming back is a bit of an issue) so I had to restart zigbee2mqtt after the suspend/resume. After that zigbee2mqtt restores communication fine. It feels quite robust, it can deal with the mqtt server going away and coming back.