[−][src]Crate huelib
Rust bindings for the Philips Hue API.
About
This library sends HTTP requests to the bridge using the ureq crate. The responses/requests are deserialized/serialized using the serde, serde_json and serde_repr crates.
Example
Register a user and set the brightness and saturation of a light.
use huelib::{bridge, light}; use std::net::{IpAddr, Ipv4Addr}; let bridge_ip = IpAddr::V4(Ipv4Addr::new(192, 168, 1, 2)); let username = match bridge::register_user(bridge_ip, "huelib-rs example", false) { Ok(v) => v.name, Err(e) => { println!("Failed to register user: {}", e); return; } }; let bridge = huelib::Bridge::new(bridge_ip, &username); let state_modifier = light::StateModifier::new() .brightness(huelib::ModifierType::Increment, 40) .saturation(huelib::ModifierType::Override, 200); match bridge.set_light_state("1", &state_modifier) { Ok(v) => { for response in v { println!("{}", response); } }, Err(e) => { println!("Failed to set the state of the light: {}", e); return; } };
Re-exports
pub use bridge::Bridge; |
pub use capabilities::Capabilities; |
pub use config::Config; |
pub use error::Error; |
pub use group::Group; |
pub use light::Light; |
pub use response::Response; |
pub use scene::Scene; |
Modules
bridge | Module for managing bridges. |
capabilities | Bindings to the Capabilities API. |
config | Bindings to the Configuration API. |
error | Errors that can occur while interacting with the Philips Hue API. |
group | Bindings to the Groups API. |
light | Bindings to the Lights API. |
response | Responses returned from the Philips Hue API. |
scene | Bindings to the Scenes API. |
Enums
Alert | Alert effect of a light. |
ColorMode | Color mode of a light. |
CoordinateModifierType | Type of a modifier for coordinates. |
Effect | Dynamic effect of a light. |
ModifierType | Type of a modifier. |