Git Product home page Git Product logo

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

q42.hueapi's People

Contributors

andriks2 avatar angusmcintyre avatar ccicchitelli avatar d8ahazard avatar dependabot[bot] avatar digitalnut avatar dmarjoram avatar ermau avatar indigo744 avatar isaacrlevin avatar jakubmartinik avatar johanmolenaars avatar koenvanderlinden avatar leo60228 avatar madmonkey87 avatar matthidinger avatar mephistofeles avatar mgpreston avatar michielpost avatar mstfldmr avatar niels9001 avatar patrickmeiring avatar pcf0 avatar sleezly avatar slouakde avatar spudwebb avatar stevenjdh avatar teilmeier avatar tg2k avatar willem4ever 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  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  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  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  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  avatar  avatar  avatar  avatar  avatar

q42.hueapi's Issues

Misleading method description

Hello,

i found a few errors in the descriptions:

-group.Action = Action property only filled when getting a single group
-group.Lights = Lights property only filled when getting a single group
etc.

They are misleading, i get the data with the client.GetLightsAsync() method, but jus wasted 2 hours of work cause of it...

UpdateSceneAsync(string ID, Scene Scene) returns error

When calling above function an error is returned. Looking at the JSON with Fiddler:

The above JSON:

{"Id":"F0b-WGcJnehh0Xw","name":"Test","lights":["3","4","6","9"],"owner":"2df02300395f826f244b97502a92ba5f","appdata":{"version":1,"data":""},"picture":"","recycle":true,"locked":false,"version":2,"lastupdated":"2015-12-29T23:29:47","transitiontime":0}

Result:

[{"error":{"type":6,"address":"/scenes/F0b-WGcJnehh0Xw/Id","description":"parameter, Id, not available"}},{"error":{"type":8,"address":"/scenes/F0b-WGcJnehh0Xw/owner","description":"parameter, owner, is not modifiable"}},{"error":{"type":8,"address":"/scenes/F0b-WGcJnehh0Xw/recycle","description":"parameter, recycle, is not modifiable"}},{"error":{"type":8,"address":"/scenes/F0b-WGcJnehh0Xw/locked","description":"parameter, locked, is not modifiable"}},{"error":{"type":6,"address":"/scenes/F0b-WGcJnehh0Xw/version","description":"parameter, version, not available"}},{"error":{"type":6,"address":"/scenes/F0b-WGcJnehh0Xw/lastupdated","description":"parameter, lastupdated, not available"}}]

Turns out Id, Owner, Recycle, Locked, Version, LastUpdated should be ignored.

Could not load type 'System.Security.Authentication.SslProtocols'

Hi,

I've just started a project with getting the HueApi directly form NuGet and with just hitting run, I'm getting the following exception after about 15 seconds:
System.TypeLoadException: Could not load type 'System.Security.Authentication.SslProtocols' from assembly 'System.Net.Primitives, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.

It looks like all the required packages have also been downloaded. Any clue?

[edit]
Seems that the library works on a Windows 7 machine, but not on my Windows 8.1 machine. Any ideas? Is there a reason the choice has been made for System.Net.Http?

Cheers

Please Sign Nuget Distribution

Hello, first off thank you for the continued great work! We'd appreciate if you could sign the Nuget distribution so that it makes keeping up to date with the updates much simpler. Currently, we have to download the source code and do our own builds with signing enabled.

Distributing signed code via Nuget is the best practice. We're aware it could possible cause issues with some projects - but again the best practice is for those projects to download the source code, rather than the other way around.

Thanks again for the great work!!!

SendCommandRawAsync's 'create a group' logic breaks existing group configuration.

SendCommandRawAsync tries to be efficient when using a List of lights, by creating a temporary group and calling it with SendGroupCommandAsync.

However, if the Bridge contains existing groups, this 'temp group creation' logic will delete/reconfigure the existing group. I believe this is because bulbs cannot be shared by groups, so if an existing group's lights are sent to SendCommandAsync, SendCommandRawAsync will break that group/rename it.

Since an existing method exists to change group lights (SendGroupCommandAsync), I think this 'else' condition in SendCommandRawAsync should simply be removed. The efficiency of creating a temporary group is offset by the inefficiency of a) having to wait 2 seconds for the bulbs to sync, and b) breaking existing bridge group configuration.

Deserialization of schedules is a problem

If you have a schedule which will only occur on certain days the localtime and time string value will be formatted as stated in: http://www.developers.meethue.com/documentation/datatypes-and-time-patterns#16_time_patterns

This will not serialize to a DateTime or DateTime? value.
Capturing all possible datetime patterns into a DateTime will not be possible.

So maybe best to create a more complex object that also states what kind of timepattern is used. Like n occurrences on saturday...?

Change Light Name

Hi

It's not an issue, more a feature request.

I'm looking for a way to change the name of a light. Is this basically possible?

Thanks & have a nice day
Michael

JsonSerializationException calling GetLightsAsync()

This is my first experience with Q42.HueApi, so apologies if I missed something. I'm running under Visual Studio 2013 Professional, with .NET 4.5.1. I just installed my Hue lights, ran the bridge's update (from the phone app), and then I got the NuGet package and then tried locating the bridge, registering, initializing, and then I tried to get the lights by calling GetLightsAsync() and received this exception:

System.AggregateException: One or more errors occurred. ---> Newtonsoft.Json.JsonSerializationException: Cannot deserialize the current JSON array (e.g. [1,2,3]) into type 'Q42.HueApi.BridgeState' because the type requires a JSON object (e.g. {"name":"value"}) to deserialize correctly.
To fix this error either change the JSON to a JSON object (e.g. {"name":"value"}) or change the deserialized type to an array or a type that implements a collection interface (e.g. ICollection, IList) like List that can be deserialized from a JSON array. JsonArrayAttribute can also be added to the type to force it to deserialize from a JSON array.
Path '', line 1, position 1.
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.EnsureArrayContract(JsonReader reader, Type objectType, JsonContract contract)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateList(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, Object existingValue, String id)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateValueInternal(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.Deserialize(JsonReader reader, Type objectType, Boolean checkAdditionalContent)
at Newtonsoft.Json.JsonSerializer.DeserializeInternal(JsonReader reader, Type objectType)
at Newtonsoft.Json.JsonSerializer.Deserialize(JsonReader reader, Type objectType)
at Newtonsoft.Json.JsonConvert.DeserializeObject(String value, Type type, JsonSerializerSettings settings)
at Newtonsoft.Json.JsonConvert.DeserializeObject[T](String value, JsonSerializerSettings settings)
at Newtonsoft.Json.JsonConvert.DeserializeObject[T](String value)
at Q42.HueApi.HueClient.d__19.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.ConfiguredTaskAwaitable`1.ConfiguredTaskAwaiter.GetResult()
at Q42.HueApi.HueClient.d__54.MoveNext()
--- End of inner exception stack trace ---
at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions)
at System.Threading.Tasks.Task.Wait(Int32 millisecondsTimeout, CancellationToken cancellationToken)
at System.Threading.Tasks.Task.Wait()
(at my code)

I was just trying to figure out how to address the lights, by fetching them all first.

Id is null for groups

Very similiar to the bug that was fixed in package 2.0.3: the Id is set to null once it gets saved to cache. This was solved for Scene and Light but still occurs for Group.

private StorageHelper<IReadOnlyCollection> GroupsHelper = new StorageHelper<IReadOnlyCollection>(Windows.Storage.ApplicationData.Current.LocalCacheFolder);

IReadOnlyCollection Groups = await hueClient.GetGroupsAsync();
await GroupsHelper .SaveAsync(Groups , "Groups ");

Get from cache:
IReadOnlyCollection CachedGroups = await GroupsHelper.LoadAsync("Groups ");

After this, most properties are still there, but Id is set to null.

group ToHex() and ToRGB()

There is an extension method on the Group.Action status, ToHex() and ToRgb().

I think it is for give back the average color from lights in the group, but currently it return with black (r=0,g=0,b=0, and "000000").

RuleAction's RuleBody can contain more than just a single scene

The RuleAction's body is currently returned via the RuleBody class, which only has a single Scene string property. Although the Hue docs show this simple example, the rule action body can contain values other than just a scene. For example, when targeting a light or group, it can contain the values for the light state. Below is a working example taken from my hub where a rule turns on two separate groups of lights in response to a Hue Tap button press:

{
"1": {
"name": "Tap1-TurnLampsAndOverheadsOn",
"owner": "",
"created": "2014-10-22T04:09:19",
"lasttriggered": "2014-10-23T02:55:29",
"timestriggered": 26,
"status": "enabled",
"conditions": [
{
"address": "/sensors/2/state/buttonevent",
"operator": "eq",
"value": "34"
}
],
"actions": [
{
"address": "/groups/1/action",
"method": "PUT",
"body": {
"on": true,
"hue": 15331,
"bri": 240,
"sat": 121
}
},
{
"address": "/groups/3/action",
"method": "PUT",
"body": {
"on": true,
"hue": 15331,
"bri": 240,
"sat": 121
}
}
]
}
}

Please fix the RuleBody class to enable it to expose the full capabilities of the Hue's rules. At minimum, it could expose a simple dictionary. It'd be more elegant to have fully parsed collections of properties, such as light State.

Thanks!

AccessViolationException since last week

I have been getting this exception just since last week in a long-running lighting program:

mscorlib.dll!System.Threading._IOCompletionCallback.PerformIOCompletionCallback(uint errorCode, uint numBytes, System.Threading.NativeOverlapped* pOVERLAP) Unknown
[Native to Managed Transition]
kernel32.dll!@BaseThreadInitThunk@12�() Unknown
ntdll.dll!___RtlUserThreadStart@8�() Unknown
ntdll.dll!__RtlUserThreadStart@8�() Unknown

A first chance exception of type 'System.AccessViolationException' occurred in mscorlib.dll
Additional information: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.

There is no native or unsafe code on my end, it's all pure managed code. Also, my code didn't change for several days prior to the issues; it ran for that time almost constantly on and didn't have this issue. I had been running a few-month-old build of HueApi, and just upgraded it this weekend. It still crashes, usually 3-5 times a day now.

Here's my suspicion: I believe the problem started right after installing the latest Windows Updates. So I wonder if either this update is the entire issue, or if this update triggered a latent bug in the HueApi code. I didn't know if the HueApi code is pure safe, managed or not, but if it's all safe, managed code, then it does seem to point entirely at Microsoft.

I'm curious whether anyone else is having this issue.

Latest package breakes Scenes

Just a heads up - after installing the latest NuGet package scenes are no longer cast correctly. Stuff like id is null.

RemoteHueClient.Authorize() gives back HTML

User needs to log into the Hue account and authorize the app to control the lights remotely.

This call does not give back JSON, but gives back HTML from the login page.
Q42.HueApi.RemoteHueClient cl = new RemoteHueClient(null); string asd = await cl.Authorize("ID", "asdasd", "MyPC", "APPID", "ThisPC", "code");

My guess is that the following should work:
`string URL = string.Format("https://api.meethue.com/oauth2/auth?clientid=ID&response_type=code&state=asdasd&appid=APPID&deviceid=MyPC&devicename=ThisPC");

System.Uri startURI = new System.Uri(URL);
System.Uri endURI= new System.Uri(OtherURL);

var webAuthenticationResult = await WebAuthenticationBroker.AuthenticateAsync(WebAuthenticationOptions.None, startURI, endURI);'
image

Bridge discovery

The Hue bridge supports SSDP, there should be an API to search for it.

client.RegisterAsync, no timer/"button not pressed"

Hello,

This could be due to my own ignorance but I'm struggling to use client.RegisterAsync.

I keep getting "Button not pressed", the light doesn't blink on the bridge, but it makes sense that the command is being sent out, doesn't get a response, and returns "Button not pressed".

Am I missing something simple, like a correct wait statement or something?

    class Program
    {
        static void Main(string[] args)
        {
            Task tasker = thisDoesntWork();

            //thisWorks();

            Console.ReadLine();   
        }

        static async Task thisDoesntWork()
        {

            ILocalHueClient client = new LocalHueClient("192.168.1.3");
            string appKey = await client.RegisterAsync("mypersonalappname", "mydevicename");

            //Crash occures before this line, but I get "Button not pressed" in the debugger, so I think it's executing. 

            Console.WriteLine(appKey);

        }

        public static void thisWorks()
        {

            ILocalHueClient client = new LocalHueClient("192.168.1.3");

            client.Initialize("139f12ce32a30c473368dbe25f6586b");

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

            client.SendCommandAsync(command);

        }
    }

I'm able to use client.Initialize with a appKey I generated from the hue debug api, and I'm able to send basic light commands with your library, so I don't think this is a connection issue.

Any help is greatly appreciated.

Setting transitiontime on a scene

Having a problem setting transition time on a scene with API 1.11

LightCommand transition = new LightCommand() { TransitionTime = TimeSpan.FromSeconds(2) };
hueClient.ModifySceneAsync("bcbfb5af0-on-0", "0", transition);

Gives error result:

Q42.HueApi.Models.Groups.ErrorResult
Type: 3
Address: /scenes/bcbfb5af0-on-0/lights/bcbfb5af0-on-0
Description: resource, /scenes/bcbfb5af0-on-0/lights/bcbfb5af0-on-0, not available

Thanks

Color converter problem

I think i found a bug in the LightCommandExtension.
Currently, i'm using like this:

  LightCommand lightCommand = new LightCommand();
                lightCommand.Brightness = (byte)Brightness;
                lightCommand.On = true;

                lightCommand.SetColor(new Q42.HueApi.ColorConverters.RGBColor(r, g, b), "LCT001");

                Color myColor = Color.FromArgb(255, (byte)r, (byte)g, (byte)b);

                string hexBefore = myColor.A.ToString("X2") + myColor.R.ToString("X2") + myColor.G.ToString("X2") + myColor.B.ToString("X2");

                var rgbColorFromLight = Q42.HueApi.ColorConverters.OriginalWithModel.LightCommandExtensions.XYToRGB(
                 lightCommand.ColorCoordinates.First(),
                 lightCommand.ColorCoordinates.Last(),
                 "LCT001");

                Save(rgbColorFromLight.ToHex());

I'm givin an input rgb value (0,0,48), set it to a lightCommand, convert it with the extension and save the converted value.

The problem i found:
if i save the (0,0,48) rgb value as a converted hex(#4600FF) and try to iput this again, then its become a different value= (70,0,255) as (#4D00FF)

Not working from Visual Studio 2015

I tried to add this to a windows forms project in visual studio 2015 using nuget and it would not install correctly.

I was able to install it using a project created in VS2013. Once I opened the Solution in VS2015 it worked fine.

Make gamut calculation public

I use the library with Osram Lightify bulbs. They have a different color range and therefore would be necessary to provide the gamut points for red, green and blue from user code.

Slow

Hello

First of all , congrats with this api!

I want to control the Philips Hue from a C# application.
I got it up and running, but the lights are responding versy slow. With the Philips app it works fine.

So here's my code:

    HueClient client = new HueClient("192.168.0.100");

    private void Form1_Load(object sender, EventArgs e)
    {

       client.RegisterAsync("test user", "mypersonalappkey");

        client.Initialize("mypersonalappkey");


    }

    private void button1_Click(object sender, EventArgs e)
    {
        var command = new LightCommand();
        command.On = true;

        command.TransitionTime = new TimeSpan(0,0,0,0,1);
        command.TurnOn().SetColor("FF00AA");
        //command.TurnOff();



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




    }

If I execute the command, it takes sometimes up to 5 seconds for the lights to respond....

So what am I missing?

Thank you for the help!

Chris Briers

Exception by use SSDPBridgeLocator

IBridgeLocator locator = new SSDPBridgeLocator();
var ips = await locator.LocateBridgesAsync(TimeSpan.FromSeconds(4));

No support of utf-8??
""utf-8"" ist kein unterstützter Codierungsname.\r\nParametername: name"


System.InvalidOperationException was caught
_HResult=-2146233079
_message=The character set provided in ContentType is invalid. Cannot read content as string using an invalid character set.
HResult=-2146233079
IsTransient=false
Message=The character set provided in ContentType is invalid. Cannot read content as string using an invalid character set.
Source=mscorlib
StackTrace:
bei System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
bei System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
bei System.Runtime.CompilerServices.TaskAwaiter1.GetResult() bei Q42.HueApi.NET.SSDPBridgeLocator.<IsHue>d__12.MoveNext() --- Ende der Stapelüberwachung vom vorhergehenden Ort, an dem die Ausnahme ausgelöst wurde --- bei System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) bei System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) bei System.Runtime.CompilerServices.TaskAwaiter1.GetResult()
bei Q42.HueApi.NET.SSDPBridgeLocator.d__9.MoveNext()
--- Ende der Stapelüberwachung vom vorhergehenden Ort, an dem die Ausnahme ausgelöst wurde ---
bei System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
bei System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
bei System.Runtime.CompilerServices.TaskAwaiter1.GetResult() bei Q42.HueApi.NET.SSDPBridgeLocator.<LocateBridgesAsync>d__4.MoveNext() --- Ende der Stapelüberwachung vom vorhergehenden Ort, an dem die Ausnahme ausgelöst wurde --- bei System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) bei System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) bei System.Runtime.CompilerServices.TaskAwaiter1.GetResult()
bei Hue_Server.Hue.Bridge.d__0.MoveNext() in f:\Projects\2014\OSC-Projects\HUE-Server\Hue-Server\Hue-Server\Hue\Bridge.cs:Zeile 48.
InnerException: System.ArgumentException
_HResult=-2147024809
_message=""utf-8"" ist kein unterstützter Codierungsname.
HResult=-2147024809
IsTransient=false
Message=""utf-8"" ist kein unterstützter Codierungsname.
Parametername: name
Source=mscorlib
ParamName=name
StackTrace:
bei System.Globalization.EncodingTable.internalGetCodePageFromName(String name)
bei System.Globalization.EncodingTable.GetCodePageFromName(String name)
bei System.Text.Encoding.GetEncoding(String name)
bei System.Net.Http.HttpContent.<>c__DisplayClass1.b__0(Task task)
InnerException:

With the last update (= merge), colors are no longer correct for every ModelID

Since the last merge (removing some of the color conversion code) not all colors are correct anymore. The code was based on the official Obj-C code that Philips uses (http://www.developers.meethue.com/documentation/color-conversions-rgb-xy) in its official iOS and Android apps.

With the last commit, colors seem fine for the normal bulbs, but colors are off for the LightStrip. Red is now yellow etc. - before this was all correct.

Can this be undone? Or can the possibility be added to add a custom converter if you do not wish to support this into this API (optional)?

Niels

(enhancement request): more versatile schedule command parsing?

Hi,

the "waking up" scenario which can be found here: http://labs.meethue.com/ relies on other "sensors" and has a schedule item which is not a SceneCommand nor a LightCommand. It actually looks like this:

{
    "1": {
        "name": "waking-uphuelabs-abc",
        "description": "HueLabs schedule-huelabs-abc",
        "command": {
            "address": "/api/<id>/sensors/9/state",
            "body": {
                "status": 1
            },
            "method": "PUT"
        },
        "localtime": "W003/T09:15:00",
        "time": "W003/T08:15:00",
        "created": "2016-01-02T22:12:38",
        "status": "enabled"
    }
}

i did not look further into it yet, but the rules of the cited example also use actions which are not Scene or LightCommands, so the same issue might pop-up there.

Are there any plans to support these types of commands or would that lead this project to far?

kind regards
stefan

Light color to RGB

Would it be possible to add an ability to get the current color of a light in RGB since there is an ability to set the color using RGB?

Schedule API

Now that the SDK docs are released and there's finally a picture of what the schedule API looks like, we should add it.

System.Net.HttpRequestexception with RegisterAsync

hey ,...

sorry for this,...

i have a test application in c# in VS 2013

        HueClient client = new HueClient("192.168.0.6");
        var appKey = await client.RegisterAsync("homidomhue", "homidomserveur");

i have use this nuget command "" Install-Package Q42.HueApi "" so use the 1.10.0.42 version
i have updated the firmware of the bridge

but i have an ""System.Net.HttpRequestexception ""error when i try to register my app in the hue bridge

Exception:Levée : "Le serveur a commis une violation de protocole. Section=ResponseHeader Detail=CR doit être suivi par LF" (System.Net.WebException)
Une System.Net.WebException a été levée : "Le serveur a commis une violation de protocole. Section=ResponseHeader Detail=CR doit être suivi par LF"

what i have done wrong,....??

thx for in advance for your help,...

wrong RGB

If I change the brightness of a light I get the same color from ToRgb(). I have noticed that the color coordinates do not change, only the brightness property changes so I guess that method does not take account of this member.

Get groups function without lights

If i want all groups with lights list, the list of lights are empty.

Maybe you have forgotten to save the list of lights in the Class "HueClient-Groups" in the function "GetGroupsAsync".

Whitelist Enumeration

Just added whitelist enumeration to my local copy by extending the models (a little challenge for me having no c# experience at all) will setup a git environment so it can be merged back :-)

Cannot convert null value to Q42.HueApi.Effect. Path '[2].action.effect

Although these are not official Hue-compatible lights, GE Lights might trigger the following error:

Cannot convert null value to Q42.HueApi.Effect. Path '[2].action.effect', line 1, position 627 at Newtonsoft.Json.Converters.StringEnumConverter.ReadJson(Json.JsonReader reader, Type objectType, Object existingValue, Json.JsonSerializer serializer)

Bridge JSON related to the lights:

{"lights":{"1":{"state": {"on":true,"bri":40,"hue":50681,"sat":235,"effect":"none","xy":[0.2742,0.1158],"ct":153,"alert":"none","colormode":"xy","reachable":true}, "type": "Extended color light", "name": "Light1", "modelid": "LCT002", "manufacturername": "Philips","uniqueid":"00:17:88:01:00:d5:10:cc-0b", "swversion": "66013452"},"2":{"state": {"on":true,"bri":41,"hue":41826,"sat":216,"effect":"none","xy":[0.2494,0.1901],"ct":153,"alert":"none","colormode":"xy","reachable":true}, "type": "Extended color light", "name": "Light2", "modelid": "LCT002", "manufacturername": "Philips","uniqueid":"00:17:88:01:00:ea:92:38-0b", "swversion": "66013452"},"3":{"state": {"on":false,"bri":1,"hue":34495,"sat":232,"effect":"none","xy":[0.3151,0.3251],"ct":155,"alert":"lselect","colormode":"hs","reachable":true}, "type": "Extended color light", "name": "Light3", "modelid": "LCT002", "manufacturername": "Philips","uniqueid":"00:17:88:01:00:d1:76:75-0b", "swversion": "66013452"},"4":{"state": {"on":false,"bri":1,"alert":"lselect","reachable":true}, "type": "Dimmable light", "name": "Front porch", "modelid": "ZLL Light", "manufacturername": "GE_Appliances","uniqueid":"7c:e5:24:00:00:0b:97:c4-01", "swversion": "1197632"},"5":{"state": {"on":false,"bri":1,"alert":"none","reachable":true}, "type": "Dimmable light", "name": "GELight1", "modelid": "ZLL Light", "manufacturername": "GE_Appliances","uniqueid":"7c:e5:24:00:00:10:dd:43-01", "swversion": "1197632"},"6":{"state": {"on":false,"bri":1,"alert":"none","reachable":true}, "type": "Dimmable light", "name": "GELight2", "modelid": "ZLL Light", "manufacturername": "GE_Appliances","uniqueid":"7c:e5:24:00:00:0c:06:b6-01", "swversion": "1197632"},"7":{"state": {"on":false,"bri":26,"alert":"none","reachable":true}, "type": "Dimmable light", "name": "GELight3", "modelid": "ZLL Light", "manufacturername": "GE_Appliances","uniqueid":"7c:e5:24:00:00:12:5e:7d-01", "swversion": "1197632"},"8":{"state": {"on":false,"bri":1,"alert":"lselect","reachable":true}, "type": "Dimmable light", "name": "GELight4", "modelid": "ZLL Light", "manufacturername": "GE_Appliances","uniqueid":"7c:e5:24:00:00:13:2a:ec-01", "swversion": "1197632"},"9":{"state": {"on":false,"bri":22,"alert":"none","reachable":true}, "type": "Dimmable light", "name": "GELight5", "modelid": "ZLL Light", "manufacturername": "GE_Appliances","uniqueid":"7c:e5:24:00:00:03:29:08-01", "swversion": "1197632"}}

Looks like there are issues with deserializing when the effect does not exist on a light!

When CreateSceneAsync setting 'recycle' is required

Didn't had this issue earlier, but my code stopped working (maybe due to firmware update).

{"lights":["3","2","5"],"recycle":true,"name":"My Scene" } /api/username/scenes // works
{"lights":["3","2","5"],"name":"My Scene" } to /api/username/scenes // does not work

With the 1.11 POST request recycle needs to be set. The API description mentions that the bool will be set automatically if not but looks like it doesn't.

Would be nice if the Q42.HueApi would set this to true or false if it is not being set. What do you guys think?

"Could not load type 'Q42.HueApi.LocalHueClient'" when running with mono

My application is a console application and everything works correctly when running on windows(10), however when I attempt to run the same build with mono I get the following error:
Unhandled Exception: System.TypeInitializationException: The type initializer for 'com.LuminousVector.Karuta.Karuta' threw an exception. ---> System.TypeLoadException: Could not load type 'Q42.HueApi.LocalHueClient' from assembly 'Q42.HueApi, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'. at com.LuminousVector.Karuta.Karuta.RegisterCommands () <0x40df24c0 + 0x00213> in <filename unknown>:0 at com.LuminousVector.Karuta.Karuta..cctor () <0x40dcd5f0 + 0x002ef> in <filename unknown>:0 --- End of inner exception stack trace --- at com.LuminousVector.Karuta.Program.Main () <0x40dccd50 + 0x00033> in <filename unknown>:0 [ERROR] FATAL UNHANDLED EXCEPTION: System.TypeInitializationException: The type initializer for 'com.LuminousVector.Karuta.Karuta' threw an exception. ---> System.TypeLoadException: Could not load type 'Q42.HueApi.LocalHueClient' from assembly 'Q42.HueApi, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'. at com.LuminousVector.Karuta.Karuta.RegisterCommands () <0x40df24c0 + 0x00213> in <filename unknown>:0 at com.LuminousVector.Karuta.Karuta..cctor () <0x40dcd5f0 + 0x002ef> in <filename unknown>:0 --- End of inner exception stack trace --- at com.LuminousVector.Karuta.Program.Main () <0x40dccd50 + 0x00033> in <filename unknown>:0

The package was installed via NuGet and I've tried reinstalling, rebuilding as release/debug and nothing makes a difference, it doesn't load on mono. First I should ask if this project normally works correctly with mono and if so, is there a solution to this?

My project is .Net 4.6.1, Console Application, Any CPU

You can find my project here if there's anything you want to double check, and the class specifically that uses this project.

GetLightsAsync return nothing

hey ,...

it seems i have some trouble ,...oops
on a c# project on VS 2013 running under win 10 pro
i have registered my app on the hue bridge
(note kis desactivated to be sure)

i use
"" await client.GetLightsAsync();""

and this return nothing

here is fiddler print screen
fiddler printscreen

sorry for this post,...

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.