michielpost / Q42.HueApi

C# helper library to talk to the Philips Hue bridge
MIT License
411 stars 114 forks source link

System.ArgumentException : Requested value 'Free' was not found #270

Closed AleRoe closed 2 years ago

AleRoe commented 2 years ago

Hello!

When fetching groups using GetGroupsAsync(), I see a System.ArgumentException in Newtonsoft.Json.dll with "Requested value 'Free' was not found". I assume this is due to a missing enum value for one of the Group properties (maybe "GroupType"?).

My code still works, but it might be worth while updating the Group-class to be in sync with the JSON response from the server.

Kind regards Alexander

michielpost commented 2 years ago

Can you check the json (with a proxy tool, for exmple Fiddler) and see which property holds the value of Free?

I see no reference of a value Free in the documentation: https://developers.meethue.com/develop/hue-api/groupds-api/#general-group-recourse

It might be the GroupType, but it can also be the RoomClass property.

AleRoe commented 2 years ago

Hi Michiel, yes, I also looked at the docs and could not find a reference. Looks like it's not up to date.

Here's the response to GetGroupsAsync() as traced by Fiddler:

{"1":{"name":"Wohnzimmer","lights":["3","1"],"sensors":[],"type":"Room","state":{"all_on":false,"any_on":false},"recycle":false,"class":"Living room","action":{"on":false,"bri":254,"hue":8402,"sat":140,"effect":"none","xy":[0.4575,0.4099],"ct":366,"alert":"select","colormode":"xy"}},"2":{"name":"Küche","lights":["2"],"sensors":[],"type":"Room","state":{"all_on":false,"any_on":false},"recycle":false,"class":"Kitchen","action":{"on":false,"bri":113,"hue":53968,"sat":80,"effect":"none","xy":[0.3720,0.3037],"ct":236,"alert":"select","colormode":"xy"}},"3":{"name":"TV area","lights":["1"],"sensors":[],"type":"Entertainment","state":{"all_on":false,"any_on":false},"recycle":false,"class":"TV","stream":{"proxymode":"auto","proxynode":"/bridge","active":false,"owner":null},"locations":{"1":[-0.05,0.84,0.00]},"action":{"on":false,"bri":254,"hue":8402,"sat":140,"effect":"none","xy":[0.4575,0.4099],"ct":366,"alert":"select","colormode":"xy"}},"4":{"name":"Musikbereich","lights":["3","1"],"sensors":[],"type":"Entertainment","state":{"all_on":false,"any_on":false},"recycle":false,"class":"Free","stream":{"proxymode":"auto","proxynode":"/bridge","active":false,"owner":null},"locations":{"3":[1.00,1.00,0.00],"1":[0.00,0.87,0.00]},"action":{"on":false,"bri":254,"hue":8402,"sat":140,"effect":"none","xy":[0.4575,0.4099],"ct":366,"alert":"select","colormode":"xy"}},"5":{"name":"Fernseher","lights":["1"],"sensors":[],"type":"Zone","state":{"all_on":false,"any_on":false},"recycle":false,"class":"TV","action":{"on":false,"bri":254,"hue":8402,"sat":140,"effect":"none","xy":[0.4575,0.4099],"ct":366,"alert":"select","colormode":"xy"}}}

"Free" is a member if the RoomClass enum, which is currently missing.

Again, nothing serious as the deserialization still works with the property being set to null, but maybe it can fixed at some time to avoid unnecessary exceptions.

Thanks for considering!

Kind regards Alexander

michielpost commented 2 years ago

Thanks, I added it to the RoomClass enum. A new release is being pushed to NuGet.

AleRoe commented 2 years ago

Thanks, highly appreciated!