Coder Social home page Coder Social logo

huelib-rs's Introduction

huelib-rs's People

Contributors

algorab avatar deckarep avatar demerzel3 avatar dependabot[bot] avatar dvdsk avatar nn1ks avatar twistedfall avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

huelib-rs's Issues

Add simpler way to create `Action`

Currently the only way to create a Action is by setting all the attributes manually. For example:

use huelib::resource::{Action, ActionRequestType};

let mut map = std::collections::HashMap::new();
map.insert("on", true);
let action = Action {
    address: "/api/<username>/lights/<id>/state",
    request_type: ActionRequestType::Put,
    body: map,
};

This can be simplified with functions for modifying, creating and deleting which automatically generate the attributes.

For example, the modify function would need the username, an identifier, a resource type, and a modifier:

use huelib::resource::{light, Action, Modifier, ResourceType};

let action = Action::modify(
    "<username>",
    "<id>",
    ResourceType::Light,
    light::StateModifier::new().on(true),
);

Add support for accessing bridge metadata

Hue bridges have an endpoint at <bridge_ip>/description.xml that allows retrieving meta data about the bridge.

It would be nice if that meta data was accessible through this library. Especially the UDN/UUID field might be useful to check whether a bridge has changed its IP address.

Add support for changing a light color with RGB/HEX values

Instead of only being able to change the color of a light with color space coordinates it should also be possible to use RGB or HEX values.

This could be done by introducing a new Color enum with the variants SpaceCoordinates, Rgb, and Hex. The color_space_coordinates functions of Modifiers could then be replaced by a color function with the Color enum as parameter.

Add tests

Add tests for serializing Modifiers/Creators and generating colors.

Turn a scene on / off

Hi,

How can I turn a scene on / off ?

I tried

use huelib::resource::scene::LightStateModifier;
use huelib::{bridge, Bridge};

fn main() {
  let bridge_ip = bridge::discover().unwrap().pop().unwrap();

  let user = bridge::User {
    name: String::from("username"),
    clientkey: None,
  };

  let bridge = Bridge::new(bridge_ip, &user.name);

  let m: LightStateModifier = huelib::resource::Modifier::new();
  m.on(true);
  bridge.set_scene("scene_id", m);
}

But bridge::set_scene does not accept a LightStateModifier :

error[E0308]: mismatched types
  --> src/main.rs:16:32
   |
16 |   bridge.set_scene("scene_id", m);
   |                                ^ expected `&huelib::resource::scene::Modifier`, found struct `huelib::resource::scene::LightStateModifier`

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.