Skip to content

Instantly share code, notes, and snippets.

@vmenajr
Last active June 30, 2025 13:44
Show Gist options
  • Select an option

  • Save vmenajr/2d41f5536f6ad556fe34c7ededbcad56 to your computer and use it in GitHub Desktop.

Select an option

Save vmenajr/2d41f5536f6ad556fe34c7ededbcad56 to your computer and use it in GitHub Desktop.
Govee H5100 adv snoop
REEN = "\033[92m"
RED = "\033[91m"
RESET = "\033[0m"
def clear_bit(value: int, bit_position: int) -> int:
return value & ~(1 << bit_position)
# The H5100 should have the data in section 0x1 with length 6
devices=dict()
def decode_govee_advertisement(device, advertisement_data):
if device.name and "GVH5100" in device.name:
data = advertisement_data.manufacturer_data
raw = data[0x1]
base = int.from_bytes(raw[2:5], byteorder="big")
base = clear_bit(base, 23)
temp = celsius_to_fahrenheit(base / 10000.0)
if temp < 0:
temp = temp * -1.0
hum = ( base % 1000 ) / 10.0
batt = raw[5]
devices[device.address]=(device.name,raw.hex(),temp,hum,batt)
#print(f"{device.name}:{device.address} {devices[device.address][1:]}")
point = Point("govee_hygrometer") \
.tag("device", device.address) \
.field("temperature", temp) \
.field("humidity", hum) \
.field("battery", batt)
#write_api.write(bucket=INFLUX_BUCKET, record=point)
async def main():
while True:
async with BleakScanner(detection_callback=decode_govee_advertisement) as scanner:
await asyncio.sleep(60) # Scan for x seconds
for k,v in devices.items():
name, raw, temp, hum, batt = v
print(f"{name}:{k} [{raw}] Temp:{GREEN if temp < 79.0 else RED}{temp}°F {RESET}Hum:{GREEN if hum < 60.0 else RED}{hum}% {RESET}Batt:{GREEN
if __name__ == "__main__":
asyncio.run(main())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment