get_all_lights/get_all_lights.rs
1//! Prints every light that is connect to a bridge.
2
3use huelib2::{bridge, Bridge};
4
5fn main() {
6 // Discover bridges in the local network and save the first IP address as `bridge_ip`.
7 let bridge_ip = bridge::discover_nupnp().unwrap().pop().unwrap();
8
9 // Register a new user.
10 let username = bridge::register_user(bridge_ip, "huelib-rs example").unwrap();
11
12 // Create a new bridge.
13 let bridge = Bridge::new(bridge_ip, username);
14
15 // Print out every light that is connected to the bridge.
16 let lights = bridge.get_all_lights().unwrap();
17 println!("{:?}", lights);
18}