I have a Govee Smart Thermo-Hygrometer, model H5102. I found this article about reading from a Govee sensor via Bluetooth. I would like to use this device to monitor my homelab until I make my own ESP32 based version.
On the Pi, we're going to need Python:
$ python --version
Python 3.9.2
It's already installed, so now we need to install bleson,
$ sudo apt install python3-pip
(usual apt output skipped)
$ pip3 install bleson
> Successfully installed bleson-0.1.8
The bleson documentation recommends the following to allow Python to access Bluetooth without root permissions:
$ sudo setcap cap_net_raw,cap_net_admin+eip $(eval readlink -f `which python3`)
Important note: For me, it appeared that Python couldn't find bleson without it.
Now it's time to find the id of my sensor, it's not one of the ones already listed. According to the bleson README we can run
$ python3 -m bleson --observer
Looking through the output for my device I found:
Advertisement(flags=0x05, name='GVH5102_5D31', txpower=None, uuid16s=[UUID16(0xec88)], uuid128s=[], rssi=-67, mfg_data=b'\x01\x00\x01\x01\x03y\r3')
Using this gist I added a case for my device and by trial and error confirmed the correct data indices into mfg_data and removed the conversion to Farenheit as I prefer Celcius.
My final observe.py script is in a fork of tchen's gist. I may come back and play with MQTT support in the future. I was thinking of using it when I have Home Assistant running but there is already a Govee BLE integration so I may move on to other things.
< Back