| 1 |
# Usage |
| 2 |
|
| 3 |
`govee-ble` is a stateless parser for Govee Bluetooth Low Energy |
| 4 |
advertisement payloads. It does **not** scan for devices or open |
| 5 |
connections — feed it raw advertisement data and it returns a |
| 6 |
[`SensorUpdate`](https://github.com/Bluetooth-Devices/sensor-state-data) |
| 7 |
describing what was decoded. |
| 8 |
|
| 9 |
## Scope |
| 10 |
|
| 11 |
This library has a deliberately narrow scope: **decode passive BLE |
| 12 |
advertisements from Govee sensor devices**. That boundary defines what |
| 13 |
belongs here and what does not. |
| 14 |
|
| 15 |
**In scope** |
| 16 |
|
| 17 |
- Parsing raw advertisement payloads (manufacturer data, service data, |
| 18 |
local name) into `SensorUpdate` readings. |
| 19 |
- Sensor and event devices: thermometers, hygrometers, BBQ/meat probes, |
| 20 |
motion/occupancy, door/window, vibration, presence, pressure pads, |
| 21 |
buttons, and CO₂/air-quality monitors. See |
| 22 |
[Supported devices](#supported-devices). |
| 23 |
- Stateless, pure per-packet decoding (beyond the small accumulator |
| 24 |
needed for multi-packet protocols such as the H5178 primary/remote |
| 25 |
pair). The parser never opens a connection. |
| 26 |
|
| 27 |
**Out of scope** |
| 28 |
|
| 29 |
- **Active GATT control** — connecting to a device, writing |
| 30 |
characteristics, polling, or sending commands. This library only |
| 31 |
reads advertisements; it does not import `bleak` or hold connections. |
| 32 |
- **Light / LED control** — Govee BLE lights that require a GATT |
| 33 |
connection to switch on/off, set brightness, or change colour belong |
| 34 |
in [`led-ble`](https://github.com/Bluetooth-Devices/led-ble), the |
| 35 |
org's active-control library for Telink-style LED devices. For |
| 36 |
example, the iHoment/Govee H6196 light controller raised in |
| 37 |
[issue #259](https://github.com/Bluetooth-Devices/govee-ble/issues/259) |
| 38 |
is out of scope here — it advertises a writable Telink service and |
| 39 |
needs an active connection, which is `led-ble`'s domain. |
| 40 |
- **Smoothing, de-glitching, or filtering readings** — these are |
| 41 |
stateful concerns that belong in the consumer (e.g. Home Assistant), |
| 42 |
not in a pure parser. |
| 43 |
|
| 44 |
The split is intentional: `govee-ble` stays a connection-free parser so it |
| 45 |
can be used anywhere advertisement bytes are available, while anything that |
| 46 |
needs to _talk back_ to a device lives in a connection-based package. |
| 47 |
|
| 48 |
## Quick start |
| 49 |
|
| 50 |
```python |
| 51 |
from bluetooth_sensor_state_data import BluetoothServiceInfo |
| 52 |
from govee_ble import GoveeBluetoothDeviceData |
| 53 |
|
| 54 |
service_info = BluetoothServiceInfo( |
| 55 |
name="GVH5075_2762", |
| 56 |
address="A4:C1:38:00:00:00", |
| 57 |
rssi=-63, |
| 58 |
manufacturer_data={ |
| 59 |
60552: b"\x00\x03A\xc2d\x00L\x00\x02\x15INTELLI_ROCKS_HWPu\xf2\xff\x0c" |
| 60 |
}, |
| 61 |
service_uuids=["0000ec88-0000-1000-8000-00805f9b34fb"], |
| 62 |
service_data={}, |
| 63 |
source="local", |
| 64 |
) |
| 65 |
|
| 66 |
device = GoveeBluetoothDeviceData() |
| 67 |
update = device.update(service_info) |
| 68 |
|
| 69 |
for description in update.entity_descriptions.values(): |
| 70 |
value = update.entity_values[description.device_key] |
| 71 |
print(description.device_key.key, value.native_value) |
| 72 |
``` |
| 73 |
|
| 74 |
`device.update()` accepts a `BluetoothServiceInfo` for every |
| 75 |
advertisement seen for a given MAC. Reuse the same |
| 76 |
`GoveeBluetoothDeviceData` instance per device — readings from |
| 77 |
multi-packet protocols (e.g. the H5178 primary/remote pair) are |
| 78 |
accumulated on the instance. |
| 79 |
|
| 80 |
## Inspecting a device |
| 81 |
|
| 82 |
After at least one successful `update()`, the instance exposes: |
| 83 |
|
| 84 |
| Attribute | Description | |
| 85 |
| --------------------- | --------------------------------------------------------------------------------------------------------- | |
| 86 |
| `device.device_type` | Govee model id, e.g. `"H5075"`. `None` until the first packet is decoded. | |
| 87 |
| `device.sensor_type` | A `SensorType` enum: `THERMOMETER`, `BUTTON`, `MOTION`, `WINDOW`, `VIBRATION`, `PRESENCE`, or `PRESSURE`. | |
| 88 |
| `device.button_count` | Number of buttons, for button-bearing models. | |
| 89 |
| `device.sleepy` | `True` for battery-powered sleep-and-wake devices that only advertise on events. | |
| 90 |
|
| 91 |
`get_model_info(model_id)` returns the same metadata without needing |
| 92 |
an instance: |
| 93 |
|
| 94 |
```python |
| 95 |
from govee_ble import get_model_info, SensorType |
| 96 |
|
| 97 |
info = get_model_info("H5121") |
| 98 |
assert info.sensor_type is SensorType.MOTION |
| 99 |
assert info.sleepy is True |
| 100 |
``` |
| 101 |
|
| 102 |
## Supported devices |
| 103 |
|
| 104 |
The parser decodes ~30 Govee BLE models across several categories: |
| 105 |
|
| 106 |
- **Thermometers / hygrometers** — H5051, H5052, H5055, H5071, H5072, |
| 107 |
H5074, H5075, H5100, H5101, H5102, H5103, H5104, H5105, H5106, |
| 108 |
H5108, H5174, H5177, H5179, GV5179 |
| 109 |
- **Multi-probe thermometers** — H5110, H5112 (dual probe) |
| 110 |
- **BBQ probes** — H5181, H5182, H5183, H5184, H5185, H5191, H5198 |
| 111 |
(up to four probes per device with high/low alarm temperatures) |
| 112 |
- **Thermometer + hygrometer with remote sensor** — H5178 (primary + |
| 113 |
remote) |
| 114 |
- **Temperature / humidity / CO₂** — H5140 |
| 115 |
- **Motion / occupancy** — H5121, H5127 |
| 116 |
- **Door / window** — H5123 |
| 117 |
- **Vibration** — H5124 |
| 118 |
- **Buttons** — H5122 (1 button), H5125 (6 buttons), H5126 (2 buttons) |
| 119 |
- **Pressure pad** — H5130 |
| 120 |
|
| 121 |
The encrypted H512x family (H5121–H5126, H5130) advertises a CRC-checked |
| 122 |
24-byte payload; the parser drops packets that fail the CRC check. |
| 123 |
|
| 124 |
## Integration with Home Assistant |
| 125 |
|
| 126 |
`govee-ble` is the parser library behind Home Assistant's |
| 127 |
[`govee_ble` integration](https://www.home-assistant.io/integrations/govee_ble/). |
| 128 |
In Home Assistant, advertisement bytes arrive via the Bluetooth |
| 129 |
integration; you generally do not need to call `govee-ble` directly. |
| 130 |
For external scripts and other consumers, the API shown above is the |
| 131 |
full surface. |