Govee BLE Thermometer/Hygrometer sensor

I am not sure either but that last message is the one you want. Parsing out the information it is similar to the H5075 reading above:

Characters [40:42] + [38:40] = 07 88 = 19.28 C
Characters [44:46] + [42:44] = 11 8C = 44.92% humidity

Well, somehow got it working ā€“ some combination of manually resetting the hci interfaces and enabling active scanning. Active scanning does seem to be required. Thanks for the help!

One thing I found though is that the temp handling doesnā€™t like temps below approximately -2.52C.

2020-03-31 01:07:13 DEBUG ... NEW DATA: {'rssi': -56, 'mac': 'E0121D61xxxx', 'temperature': -2.52, 'humidity': 31.92, 'battery': 100.0, 'packet': 'FF030C78'}
2020-03-31 01:07:13 DEBUG ... NEW DATA: {'rssi': -54, 'mac': 'E0121D61xxxx', 'temperature': 652.79, 'humidity': 31.94, 'battery': 100.0, 'packet': 'FEFF0C7A'}
2020-03-31 01:07:13 ERROR ... Temperature spike: 652.79 (E0121D61xxxx)

With a matching raw message:

2020-03-31 01:20:44 DEBUG ... NEW DATA: {'rssi': -55, 'mac': 'E0121D61xxxx', 'temperature': 642.28, 'humidity': 39.62, 'battery': 100.0, 'packet': 'FAE40F7A'}
2020-03-31 01:20:44 ERROR ... Temperature spike: 642.28 (E0121D61xxxx)
2020-03-31 01:20:44 ERROR ... 043E1702010400xxxx611D12E00B0AFF88EC00E4FA7A0F6402C9

After a short time it always errors out:

2020-03-31 01:08:14 DEBUG ... NEW DATA: {'rssi': -56, 'mac': 'E0121D61xxxx', 'temperature': 652.66, 'humidity': 32.01, 'battery': 100.0, 'packet': 'FEF20C81'}
2020-03-31 01:08:14 ERROR ... Temperature spike: 652.66 (E0121D61xxxx)
2020-03-31 01:08:14 ERROR (MainThread) [homeassistant.core] Error doing job: Future exception was never retrieved
Traceback (most recent call last):
  File "/usr/local/lib/python3.7/concurrent/futures/thread.py", line 57, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/data/custom_components/goveetemp_bt_hci/sensor.py", line 521, in update_ble
    discover_ble_devices(config)
  File "/data/custom_components/goveetemp_bt_hci/sensor.py", line 449, in discover_ble_devices
    if m_temp:
UnboundLocalError: local variable 'm_temp' referenced before assignment

Glad you got it working. Iā€™ll add a check if there are excessive temperature spikes.

And just to clarify, the actual temperature in this case is negative (itā€™s in a freezer). Once the temperature dropped below approximately -2.52C (the last correct reading with the component), is when the 600+ values started appearing.

Right now the temp is -20.83C but the component canā€™t read it correctly and eventually crashes.

Hello,

I just purchased an H5074 and was trying to connect it to Hassio on a RPi 3. Iā€™m able to install the custom integration via HACS, restarted, added the config to sensors.yaml, restarted, but my sensor never shows up. I confirmed that The RPi can see the BLE device by using bluetoothctl scan on and used the MAC address that it displayed. Iā€™m not sure what else I can do to get it connected. Any ideas?

edit: corrected mistyping of bluetooth to bluetoothctl

Other than adding hcitool_active: True I cannot think of anything else to suggest.

I tried that and it still didnā€™t show up. I think that this component may not work on Hassio. Hassio doesnā€™t seem to run hcitool or hcidump. Instead it has bluetoothctl. Iā€™m trying to manually install pybluez in the Hassio container, but itā€™s not working for me either.

Thatā€™s odd. I cannot see where hcitool and hcidump would have been removed from HASS. pybluez does not have these programs, they are part of the bluez package installed through the OS. As Home Assistant is made up of different docker images, I am not entirely sure you have SSHed into the correct one.

If it turns out hcitool and hcidump were removed from HASS, I have plans to rewrite the component using native python sockets but just havenā€™t had the time.

@Thrilleratplay, was wondering if you had any insights as to a fix low temperature handling on the 5074? Iā€™m not clear on how its supposed to be derived or whatā€™s going wrong below ~-2.52C. I could provide more raw data from more low temp readings if itā€™d be helpful.

No, I havenā€™t had time to investigate. Sorry.

EDIT: @Martso taking a quick look, I am almost certain I over simplified the twos compliment conversion. Let me try updating that locally and Iā€™ll throw my H5074 in the freezer to see if that corrects the issue.

@Martso The temperature is reporting correctly from within my freezer. I pushed V0.4 with this fix. Sorry it took so long.

Is there any chance of adding the water sensor support for this?

They connect to a govee wifi gateway first, and then the gateway can talk to multiple water leak sensors at once.

Not sure if thereā€™s a way to pull from the wifi gateways directly. Iā€™d love to have these sensors in my setup, otherwise I may swap them out in the future to something else to get automations out of them.

Thanks!

I purchased the Govee flood detector but havenā€™t had time to set it up or reverse engineer the protocol. When I do, it will be a different component. The H5074 and H5075 Thermometer/Hygrometers are Bluetooth.

Thank you for the response! I figured they must operate differently.
Looking forward to the flood sensors - if you need someone to assist with any testing let me know, I have two different WiFi gateways and 6 total water/flood sensors :slight_smile:

Thanks @Thrilleratplay! No worries at all, appreciate it whenever you find the time. :slight_smile:

Strangely, the first time I restarted with the updated version, it didnā€™t detect broadcasts the H5074 on the first pass. After I reset the hci interface it did, and I saw the debug messages/packets in the logs, with the correct approx -20C temperature reading. However in Home Assistant, it showed ~62F. Watching it for a bit, I noticed that each update it was alternating between having the same temp value as my two H5075ā€™s, but just for temperature. All other values matched the H5074ā€™s debug messages. After restarting Home Assistant, the 5704 entity displayed its own value correctly. Not sure if that was an issue with Home Assistant or not, just an fyi in case it comes up again later. Looks good now.

As an aside, have you noticed much battery impact from running with hcitool active?

@Martso After updating Home Assistant, I have occasionally needed to restart it once again because something did not load correctly the first time. Not sure if it is the same as the issue you saw but will keep an eye out for it.

What do you mean by battery impact? On the Govee thermometers? None. Unlike the Govee app, this only reads the broadcast sent by the devices which they emit every second. This is why the historical data and firmware version is not available in this component as that would require actually connecting to the devices. Active and passive are the two types of Bluetooth scan modes but I cannot find a basic explanation describing the difference. It either relates to how often it scans or the power used.

Just wanted to document my (in)experience here trying to get the Govee sensor (H5074) hooked up:

My Raspberry Pi 3b was a non-starter for anything BLE. I had no success even getting HASSā€™ built-in device trackers working (bluetooth_tracker and bluetooth_le_tracker). To my understanding, this was a combination of a hass/core introduced in late 2019 (issue #30147) and the fact I had a USB device that was possibly blocking the BT chip from attaching to /dev/ttyAMA0. The device in question was HUSBZB-1 (Zwave and Zigbee adapter) which was a non-negotiable device so my interest tapered off while I waited for resolution to that issue.*

Anyway, I bought an pi4 which sidestepped that whole issue, but I was having a similar challenge as @Martso with their H5074. The sensor script was logging that it found the mac address and put it in an OrderedDict but never went past that point. Luckily, setting the hcitool_active flag to true fixed it for me! Seems to be spot-on accurate so far and it hasnā€™t quit on me yet (Iā€™ll edit this if it does). IMO it might be worth adding a note about the H5074 to the README somewhere.

@Thrilleratplay thanks for putting this sensor component together!

*By the way, a recent update may have resolved the bug in core. My pi3 has found a new life so I canā€™t personally verify.

Will this work on ESPHOME BLE tracker?

I do not know. I have not used ESPHOME before.

1 Like

Because BT is limited in range, how would you deploy this for two-story house? I saw the Govee website and they really look nice. But I have two-story house and plus my garage. I donā€™t think Iā€™ll be able to use just one BT receiver. Any idea?