[−][src]Struct huemanity::Bridge
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: String
client: Client
base_url: String
light_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.
pub fn link() -> Self
[src]
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]
&self,
endpoint: &str,
req_type: RequestType,
params: Option<&Value>
) -> Result<Response, Box<dyn Error>>
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
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]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToString for T where
T: Display + ?Sized,
[src]
T: Display + ?Sized,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
U: TryFrom<T>,