#light #hue #philips #bulb

bin+lib hueclient

Rust library for Philips Hue lights

24 releases

0.4.3 Apr 5, 2023
0.4.2 Jun 16, 2022
0.4.1 Feb 2, 2021
0.3.10 Oct 17, 2020
0.2.1 Mar 26, 2015

#349 in Hardware support

Download history 1/week @ 2024-02-19 47/week @ 2024-02-26 7/week @ 2024-03-04

55 downloads per month
Used in purple-hue

WTFPL license

37KB
840 lines

Rust library for Philips Hue

Build Status

Features

  • discover bridge by querying philips hue website or using UPnP
  • list lights with their state
  • simple actions on lights (on, off, bri/hue/sat, transition time)
  • simple CLI utils for docs and tests :)

lib.rs:

This library aims to enable communicating with Philips Hue lights via the correspnding Bridge.

Examples

A short overview of the most common use cases of this library.

Initial Setup

let bridge = hueclient::Bridge::discover_required()
    .register_user("mycomputer") // Press the bridge before running this
    .unwrap();
println!("the username was {}", bridge.username); // handy for later

Second run

const USERNAME: &str = "the username that was generated in the previous example";
let bridge = hueclient::Bridge::discover_required()
   .with_user(USERNAME);

Good night

let cmd = hueclient::CommandLight::default().off();
for light in &bridge.get_all_lights().unwrap() {
    bridge.set_light_state(light.id, &cmd).unwrap();
}

Dependencies

~12–28MB
~444K SLoC