[][src]Struct huemanity::Bridge

pub struct Bridge {
    pub ip: String,
    pub key: String,
    pub client: Client,
    pub base_url: String,
    pub light_ids: Vec<u8>,
    pub n_lights: u8,
}

Fields

ip: String

The bridge struct represents a HUE bridge. The constructor for this struct link, tries to detect the light id's and is able to send new state to either a single light or all of the ones detected.

Currently to register a new bridge, you need to know 2 things:

  • the internal IP of the bridge (in future i'll implement ssdp)
  • the key assigned to you by the api/newdeveloper POST request see the documentation for the HUE API in order to see this. I will implement the authentication handshake request flow in the near future and in the CLI I will cache the key somewhere
key: Stringclient: Clientbase_url: Stringlight_ids: Vec<u8>n_lights: u8

Methods

impl Bridge[src]

pub fn register() -> Result<(String, String), Box<dyn Error>>[src]

Register the Bridge and save credentials to .env file Can be used as a standalone function to get a key registered if you know the IP of your Bridge, but generally is a helper for the link method.

Struct constructor that sets up the required interactions and also gets us the light id's as well as how many there are

If you have HUE_IP and HUE_KEY in your environment this will just proceed as normal linking to the bridge. If you don't have these variables in the environment, it will try to guide you throught a registration process. In that case you will need to know the IP of your Bridge.

pub fn send(
    &self,
    endpoint: &str,
    req_type: RequestType,
    params: Option<&Value>
) -> Result<Response, Box<dyn Error>>
[src]

Sends the a request with set parameters to the HUE API endpoint

pub fn state(&self, light: u8, state: &Value) -> Result<(), Box<dyn Error>>[src]

Given a light and a required state, send this state to the light.

pub fn state_all(&self, state: &Value) -> Result<(), Box<dyn Error>>[src]

Given a state send it to all lights found on bridge

pub fn collect_ids(&mut self) -> Result<(), Box<dyn Error>>[src]

Collect all found light ids

pub fn light_info(&self)[src]

Currently this function only prints out the light_ids, but there is scope in future for this to print out more. I will have to refactor the collect_ids into collect info and serialize all the data about the ligths (perhaps except state which will change).

Trait Implementations

impl Debug for Bridge[src]

impl Display for Bridge[src]

Auto Trait Implementations

impl !RefUnwindSafe for Bridge

impl Send for Bridge

impl Sync for Bridge

impl Unpin for Bridge

impl !UnwindSafe for Bridge

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToString for T where
    T: Display + ?Sized
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 

type Err = <U as TryFrom<T>>::Err