GithubHelp home page GithubHelp logo

gavwang / q42.hueapi Goto Github PK

View Code? Open in Web Editor NEW

This project forked from michielpost/q42.hueapi

0.0 2.0 0.0 2.14 MB

C# helper library to talk to the Philips Hue bridge

License: MIT License

C# 99.99% Batchfile 0.01%

q42.hueapi's Introduction

Q42.HueApi

Open source library for communication with the Philips Hue bridge. This library covers all the Philips hue API calls! You can set the state of your lights, update the Bridge configuration, create groups, schedules etc.

This Portable Library is compatible with: .Net45, Windows 8 and Windows Phone 8 (and Universal Apps) Download directly from NuGet Q42.HueApi on NuGet.

How to use?

Some basic usage examples

Bridge

Before you can communicate with the Philips Hue Bridge, you need to find the bridge and register your application:

IBridgeLocator locator = new HttpBridgeLocator();

//For Windows 8 and .NET45 projects you can use the SSDPBridgeLocator which actually scans your network. 
//See the included BridgeDiscoveryTests and the specific .NET and .WinRT projects
IEnumerable<string> bridgeIPs = await locator.LocateBridgesAsync(TimeSpan.FromSeconds(5));

Register your application

ILocalHueClient client = new LocalHueClient("ip");
var appKey = await client.RegisterAsync("mypersonalappname", "mydevicename");
//Save the app key for later use

If you already registered an appname, you can initialize the HueClient with the app's key:

client.Initialize("mypersonalappkey");

Control the lights

Main usage of this library is to be able to control your lights. We use a LightCommand for that. A LightCommand can be send to one or more / multiple lights. A LightCommand can hold a color, effect, on/off etc.

var command = new LightCommand();
command.On = true;

There are some helpers to set a color on a command:

//Turn the light on and set a Hex color for the command
command.TurnOn().SetColor("FF00AA")

LightCommands also support Effects and Alerts

//Blink once
command.Alert = Alerts.Once;

//Or start a colorloop
command.Effect = Effects.ColorLoop;

Once you have composed your command, send it to one or more lights

client.SendCommandAsync(command, new List<string> { "1" });

Or send it to all lights

client.SendCommandAsync(command);

Remote API

There is also a Philips Hue Remote API. It allows you to send commands to a bridge over the internet. You can request access here: http://www.developers.meethue.com/content/remote-api
Q42.HueApi is compatible with the remote API.
You need an Access Token and a Bridge Id. Please refer to the Philips Hue API documentation on how to obtain them. This library does not have support for it yet. Pull Requests are welcome!

IRemoteHueClient remoteHueClient =  new RemoteHueClient("access token");
remoteHueClient.Initialize("bridge id");

After the setup, you can send normal commands to the remote API:

remoteHueClient.SendCommandAsync(command, new List<string> { "1" });

How To install?

Download the source from GitHub or get the compiled assembly from NuGet Q42.HueApi on NuGet.

Credits

This library is made possible by contributions from:

Open Source Project Credits

  • Newtonsoft.Json is used for object serialization

License

Q42.HueApi is licensed under MIT. Refer to license.txt for more information.

Contributions

Contributions are welcome. Fork this repository and send a pull request if you have something useful to add.

Build status

Related Projects

Apps that use Q42.HueAPI

Are you using Q42.HueAPI? Get your app listed here! Edit this page and send a pull request.

Windows Phone

Windows

Windows Desktop

MONO

q42.hueapi's People

Contributors

michielpost avatar ermau avatar koenvanderlinden avatar johanmolenaars avatar willem4ever avatar lbodtke avatar tg2k avatar ccicchitelli avatar patrickmeiring avatar

Watchers

James Cloos avatar Gavin Wang avatar

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.