Crates.io | yeelib_rs |
lib.rs | yeelib_rs |
version | 0.1.1 |
source | src |
created_at | 2021-01-21 13:39:30.121654 |
updated_at | 2021-03-11 00:27:18.464923 |
description | Easily find and interface with Yeelight IoT smart lights |
homepage | https://github.com/teppah/yeelib |
repository | https://github.com/teppah/yeelib |
max_upload_size | |
id | 344883 |
size | 66,250 |
A Rust library for easy interfacing with Yeelight products, including LAN light discovery with multicast and SSDP, with intended implementation of all major parts of the Yeelight Third-party Control Protocol.
Unless otherwise specified, methods to adjust the light's parameters have the method name and behavior exactly as specified in the above spec.
use std::time::Duration;
use std::thread::sleep;
use yeelib_rs::{YeeClient, Light, YeeError};
use yeelib_rs::fields::{PowerStatus, Transition};
fn main() -> Result<(), YeeError> {
let client = YeeClient::new()?;
let mut lights: Vec<Light> = client.find_lights(Duration::from_secs(1));
for light in lights.iter_mut() {
light.set_power(PowerStatus::On, Transition::sudden())?;
sleep(Duration::from_secs(1));
light.set_bright(50, Transition::sudden())?;
sleep(Duration::from_secs(1));
light.set_ct_abx(3500,
Transition::smooth(Duration::from_millis(400))
.unwrap())?;
sleep(Duration::from_secs(2));
light.toggle()?;
}
}
See main.rs for some more examples.
set_ct_abx
set_rgb
set_hsv
set_bright
set_power
toggle
adjust_bright
adjust_ct
Licensed under either of
at your option.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.