• Stars
    star
    402
  • Rank 106,842 (Top 3 %)
  • Language
    C#
  • License
    MIT License
  • Created almost 12 years ago
  • Updated 10 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

C# helper library to talk to the Philips Hue bridge

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 library targets .net462, .net 6 and .net 7! Download directly from NuGet:

Features:

  • Support for Hue Entertainment API
  • Support for the Hue Remote API
  • Multiple Color Converters
  • NEW: Support for Clip V2 API

Make sure to install the new packages:

How to use?

Some basic usage examples

Use the LocalHueApi:

var localHueApi = new LocalHueApi("BRIDGE_IP", "KEY");

Register your application

//Make sure the user has pressed the button on the bridge before calling RegisterAsync
//It will throw an LinkButtonNotPressedException if the user did not press the button
var regResult = await LocalHueClient.RegisterAsync("BRIDGE_IP", "mypersonalappname", "mydevicename");

//Save the app key for later use and use it to initialize LocalHueApi
var appKey = regResult.Username;

Change the lights:

var lights = await localHueApi.GetLightsAsync();
var id = all.Data.Last().Id; //Pick a light

var req = new UpdateLight()
	.TurnOn()
	.SetColor(new ColorConverters.RGBColor("FF0000"));
	
var result = await localHueApi.UpdateLightAsync(id, req);

API Reference

Use the API reference provided by Hue to discover the capabilities of the API. https://developers.meethue.com/develop/hue-api-v2/api-reference/

EventStream

Listen to the new EventStream to get notified by the Hue Bridge when new events occur.

localHueApi.OnEventStreamMessage += EventStreamMessage;
localHueApi.StartEventStream();

void EventStreamMessage(List<EventStreamResponse> events)
{
  Console.WriteLine($"{events.Count} new events");

  foreach(var hueEvent in events)
  {
    foreach(var data in hueEvent.Data)
    {
      Console.WriteLine($"Data: {data.Metadata?.Name} / {data.IdV1}");
    }
  }
}

//localHueApi.StopEventStream();

Sample usage can be found in the included Console Sample App: HueApi.ConsoleSample

Clip V2 API

Philips Hue has developed a new Clip V2 API. This library has support for the new Clip V2 APIs. Philips Hue is still developing these APIs and new functionality is added regularly. Please create an issue or PR if you need something that is not supported yet.

Support for Hue Entertainment.

Check out the HueApi.Entertainment documentation
Read about the Philips Entertainment API

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. There's a sample app and documentation can be found here: https://github.com/michielpost/Q42.HueApi/blob/master/RemoteApi.md

For remote usage with the new CLIP v2 API, use the new RemoteHueApi("KEY", "token")

Color Conversion

The Philips Hue lights work with Brightness, Saturation, Hue and X, Y properties. More info can be found in the Philips Hue Developer documentation: http://www.developers.meethue.com/documentation/core-concepts#color_gets_more_complicated It's not trivial to convert the light colors to a color system developers like to work with, like RGB or HEX. HueApi has 2 different color converters out of the box. They are in a seperate package and it's easy to create your own color converter.

The HueApi.ColorConverters NuGet package contains:

  • Original: The original converter based on a large XY array.
  • HSB: Converts based on Hue, Brightness and Saturation.

How to use a color converter? Add one of the following usings:
using HueApi.ColorConverters.Original
using HueApi.ColorConverters.HSB

This will add extension methods to Light, State and LightCommand. So you can set the color using new RGBColor() and convert the State back to RGBColor

Pull Requests with improvements to the color conversion are always welcome!

How To install?

Download the source from GitHub or get the compiled assembly from NuGet

Credits

This library is made possible by contributions from:

License

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 and publish

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

Windows Phone

WinForms

Xbox One

Android

Command Line Tools - Windows, Linux (x64 & ARM) and Windows 10 IOT (ARM)

Other

More Repositories

1

HueLightDJ

Hue Light DJ using Hue Entertainment API
C#
68
star
2

MetaMask.Blazor

Use MetaMask with Blazor WebAssembly
C#
40
star
3

SkyDocs

Sia Skynet Google Docs alternative
C#
23
star
4

SiaSkynet

Sia Skynet client
C#
11
star
5

Dfinity.Blazor

Blazor library to work with Dfinity Internet Computer
JavaScript
11
star
6

PublishSettings2AppVeyor

Batch create AppVeyor environments based on .PublishSettings files
C#
8
star
7

DynamicDataCMS

Open source Q42 CMS
C#
8
star
8

AppVeyorDeployConsole

Create deploy groups to deploy to multiple environments at once
C#
7
star
9

NanoRPC

Nano RPC Client library in C#
C#
6
star
10

AElfBlazor

aelf Blazor SDK
C#
5
star
11

aoWebWallet

Arweave ao Web Wallet
C#
5
star
12

DumpAzurePublishProfiles

Mass download PublishSettings for Azure Websites
C#
4
star
13

Hathor.Faucet

Hathor Community Faucet
CSS
3
star
14

WindowsPhone.Treintijden

[Archive] Windows Phone 7.1 app
C#
3
star
15

NEOGravatar

NEO Gravatar Smart Contract
C#
3
star
16

Hathor.Client

Client for Hathor Wallet API
C#
3
star
17

Chainlink-RealWorldEvents

Chainlink Spring Hackathon 2021
JavaScript
3
star
18

TheGraph.Client

C# client to interact with The Graph network
C#
3
star
19

AElfFaucet

Application to interact with the Aelf Testnet Faucet
HTML
3
star
20

jitswap-thorchain

JITswap on THORChain
HTML
2
star
21

onlineafspraken.nl

C# SDK for onlineafspraken.nl
C#
2
star
22

WindowsPhone.Woordenboek

[Archive] Windows Phone app
C#
2
star
23

Win8.Woordenboek

[Archive] Windows 8 app
C#
2
star
24

Win8.Trein

[Archive] Windows 8 app
C#
2
star
25

Hue.Blazor

Blazor WebAssembly application for Philips Hue
HTML
2
star
26

NEOChecksumChecker

NEO Smart Contract to store and check checksums
C#
2
star
27

NuGetPackager

C#
2
star
28

WindowsPhone.GroupChat

[Archive] Windows Phone app
C#
2
star
29

AElfFund

Community Funded Aelf Projects
C#
2
star
30

AzureWebsitesSuperSwapper

Swap multilple website slots from a single command
C#
2
star
31

TreintijdenApi

Treintijden API voor de NS API - Nederlandse Spoorwegen
C#
2
star
32

Win8.ServerStatus

[Archive] Windows 8 app
C#
2
star
33

WindowsPhone.5inARow

[Archive] Windows Phone 5 in a row game
C#
2
star
34

SilverlightMultiFileUploader

Silverlight Multi File Uploader
C#
2
star
35

Treintijden-Dashboard

C#
2
star
36

Win8.Rijmwoordenboek

[Archive] Windows 8 app
C#
2
star
37

PolkadotRPC

C#
1
star
38

WindowsPhone.FileMeldingen

[Archive] Windows Phone app
C#
1
star
39

Win10IoTLeds

C#
1
star
40

NEOAdvertising

NEO Advertising marketplace. Sell and buy ads for GAS
C#
1
star
41

WindowsPhone.ServerMonitor

[Archive] Windows Phone app
C#
1
star
42

WindowsPhone.RijksmuseumLockscreen

[Archive] Windows Phone lockscreen app
C#
1
star
43

TheShareItNetwork

The Share It Network
Solidity
1
star
44

WindowsPhone.ChainReactionGame

[Archive] Windows Phone game
C#
1
star
45

WindowsPhone.Rijksmuseum

[Archive] Windows Phone app
C#
1
star