Documentation

Yeelight API This library provides a Rust API for the Yeelight device. It is based on the official Yeelight API documentation.

Examples

use apyee::device::Device;
use apyee::method::Method;

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
// Create a new Device with the IP address of the device and the default port.
// creating the Device will also connect to it and start listening for responses.
let mut device = Device::new("192.168.100.5").await?;

// Send a command through a convenience method and toggle its power state.
device.toggle().await?;

// Set its RGB Color to red.
device.set_rgb(255, 0, 0).await?;

// Send any possible command to the device.
device.execute_method(Method::SetBright(50, None, None)).await?;

Ok(())
}