No description
- Rust 100%
| Filename | Latest commit message | Latest commit date |
|---|---|---|
| examples | ||
| src | ||
| .gitignore | ||
| Cargo.lock | ||
| Cargo.toml | ||
| LICENSE | ||
| README.md | ||
govee-rs
An async Rust client for the Govee OpenAPI.
Control Govee smart lights from Rust: turn them on or off, change colors, and set brightness — all over the official cloud API.
[dependencies]
govee-rs = "0.1"
tokio = { version = "1", features = ["full"] }
Usage
use govee_rs::GoveeApiBuilder;
#[tokio::main]
async fn main() -> Result<(), govee_rs::GoveeError> {
let mut api = GoveeApiBuilder::new()
.api_key(std::env::var("GOVEE_API_KEY").unwrap())
.build()
.await?;
let devices = api.get_devices().await?;
if let Some(d) = devices.first() {
api.turn_on(d).await?;
api.set_color(d, 255, 140, 0).await?; // warm orange
api.set_brightness(d, 75).await?;
}
Ok(())
}
Getting an API key
Open the Govee Home app → Profile → About Us → Apply for API key. You'll receive a key by email within a few minutes.
Running the example
GOVEE_API_KEY=your_key cargo run --example basic
Error handling
All fallible functions return Result<T, GoveeError>. The variants are:
| Variant | When |
|---|---|
MissingApiKey |
.build() called without .api_key() |
EmptyApiKey |
API key was blank/whitespace |
Http |
Network-level failure (timeout, TLS, etc.) |
ApiError { status, body } |
Govee returned a non-2xx status |
Json |
Response body failed to parse |
License
MIT