Control Govee LED Lights from Python
This library provides control over Govee-manufactured lights. @wez built this for use with Home Assistant. You can find the corresponding hacs-govee-lan repo here.
It has an emphasis on making use of their LAN API but also makes use of their HTTP API in order to retrieve the user-assigned names of the devices, and to control the devices that don't yet support the LAN API.
Getting Started
from govee_led_wez import GoveeController, GoveeDevice
controller = GoveeController()
def device_changed(device: GoveeDevice):
print(f"{device.device_id} state -> {device.state}")
controller.set_device_change_callback(device_changed)
if YOUR_API_KEY:
controller.set_http_api_key(YOUR_API_KEY)
controller.start_http_poller()
controller.start_lan_poller()
if YOU_WANT_BLE:
# Optional, if you want bluetooth device control.
# This will disconnect from devices after they are idle
# for a while. If you omit this, devices will be disconnected
# in case of error. You probably want this.
controller.start_ble_idler()
# This will look for new devices in the background,
# by default every 10 minutes
controller.start_ble_poller()
# Alternatively: This will look for devices right now,
# but note that it needs # to perform discovery and can
# take several seconds
# await controller.query_ble_devices()
# Devices will now be discovered asynchronously
Notes
Devices are discovered asynchronously. While the full set of devices
associated with your account can be returned via the HTTP API, the
initial request for them is made asynchronously by the background
http poller task. If you need the list immediately, you can call
controller.query_http_devices() to obtain that list.
The HTTP API has some tight rate limits. This library prefers to avoid
read-after-write operations to verify the state in order to reserve the calls
for issuing commands to your devices. This means that, for devices that don't
support the LAN API, the assumed state may be a bit wonky until the device
is controlled. You can call controller.update_device_state() to
explicitly retrieve the state.
BLE is preferred over HTTP. When we know a device is accessible via BLE, then we will attempt to control it via BLE before trying to use HTTP. LAN is always attempted first, as it has the lowest latency.
BLE is currently only usable in conjunction with HTTP and/or LAN discovery. There isn't a BLE-only usage at the moment.
Contributing
A Makefile provides shortcuts for doing stuff:
make setup- do one-time setup for developingmake check- performs type checking and lintingmake test- runs testsmake fmt- runs code formatting, potentially appeasingmake checkmake build- builds distributable bits
GitHub Actions will run the check, test and build actions on PRs.
Metadata
Release files for govee-led-wez 0.0.15
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| govee_led_wez-0.0.15.tar.gz | 16.6 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| govee_led_wez-0.0.15-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 31.7 kB
Release files / govee_led_wez-0.0.15.tar.gz
| Download URL | govee_led_wez-0.0.15.tar.gz |
|---|---|
| Size | 16.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
937a4449d76ed7e243887ea671eb3f34e583bd58fa38c85fb164bf48b5bdc6a6
|
|
BLAKE2b-256 checksum How to use checksums |
8bfff03b6a96287b5327adfbbac540613aba9d89b5261843b54ada796803042c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.3
|
Release files / govee_led_wez-0.0.15-py3-none-any.whl
| Download URL | govee_led_wez-0.0.15-py3-none-any.whl |
|---|---|
| Size | 15.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
3d5e962989be6c144c84a5fce10f2805bf2f4f6d2e1d469c68548091501edc21
|
|
BLAKE2b-256 checksum How to use checksums |
76ca6784de05f8a33f89d3853ca6d4f3f2c355d03fb9eb23822dab30497f124a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.3
|
Security for govee-led-wez 0.0.15
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.