Awhile back I needed to have a semi-reliable temp sensor that I wanted to use to calibrate some of my DIY sensors which, because they are in various forms of cases and such with poor ventilation often read the temp too high and humidity too low.
Anyway, I bought a Govee H5072 mainly because it was $12, battery powered, and I saw online that there was a Python script I could use to get the readings. I finally had time to actually integrate this sensor with openHAB. This is how I did it.
I was initially inspired by https://github.com/Thrilleratplay/GoveeWatcher which, while deprecated, showed how to get it to work. Unfortunately it requires Python 3 so I couldn’t implement this with Jython rules. So, my goto solution when I can’t integrate something directly with OH is my good old sensorReporter.
- MQTT set up and configured
It took a little bit to upgrade sensorReporter to run on Python3 (they moved a couple of imports) and get a goveeSensor extension working. See
goveeSensor.py in the above repo to see the code and how it works.
Read the README.md file for installation instructions and details about how sensorReporter works. At a tl;dr level:
- clone the repo to /opt/sensorReporter
- pip3 install paho-mqtt and bleson
- create and fill out sensorReporter.ini using default.ini as a guide
- install the services scripts (see the config folder)
- start sensorReporter and watch the logs for errors
If there are no errors, you should start to see it publishing sensor readings almost immediately.
An example config:
[Sensor0] class = goveeSensor.goveeSensor Destination = govee Connection = MQTT Poll = -1 [Logging] File = /tmp/sensorReporter.log MaxSize = 67108864 NumFiles = 10 Syslog = NO Level = INFO [Connection0] Class = mqttConn.mqttConnection Name = MQTT Client = govee User = USER Password = PASSWORD Host = broker-host Port = 1883 Keepalive = 60 Topic = govee/getUpdate LWT-Topic = govee/lwt LWT-Msg = OFF TLS = NO
The above will publish to the following topics:
govee/<name>/temp_C govee/<name>/temp_F govee/<name>/humi govee/<name>/battery govee/<name>/rssi
<name> is the unique name of the sensor. I’ve only one of these but it looks like is takes the format of “GVH5072_XXXX” where “XXXX” is the last four digits of the BT MAC address for the device. Therefore you will probably want to enable and label each sensor one at a time to map between a physical device and the name.
This assumes you already have MQTT 2.x installed and configured.
In PaperUI navigate to the Things menu and click the + icon and select MQTT and MQTT Generic Thing. Give it meaningful name (e.g. Frontroom Temp/Humi Sensor). Optionally set the LWT topic and payload for the thing.
Next create a Channel for each of the topics you care about.
|Value||Channel Type||State Topic||Unit of Measurment||Item Type|
|Temp in C||Number||
|Temp in F||Number||
Finally link the Channels to Items and you are done!