michielpost / Q42.HueApi

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

Client.CreateSensorAsync(Sensor); returns null? #82

Closed niels9001 closed 7 years ago

niels9001 commented 7 years ago

I'm trying to create a sensor to create a Hue Tap toggle button (http://www.developers.meethue.com/how-create-hue-tap-toggle-button).

The following code returns null instead of an ID:

Sensor Sensor = new Sensor(); Sensor.Name = "TapsensorToggle"; Sensor.Type = "CLIPGenericFlag"; Sensor.ModelId = "toggle01"; Sensor.ManufacturerName = "Manufacturer"; Sensor.SwVersion = "0.1"; Sensor.UniqueId = "0123456A";

        string ID = await Client.CreateSensorAsync(Sensor);
michielpost commented 7 years ago

Are you on version 3.2.3? I've made some changes to the Sensor models this weekend to correct the casing in the Json. That should probably fix this issue.

If that doesn't fix it, please check the raw Json to and from the Bridge (with Fiddler)

niels9001 commented 7 years ago

This is the JSON that is being sent out:

{"ManufacturerName":"Huetro","ModelId":"toggle01","Name":"TapToggle.18","SwVersion":"0.1","Type":"CLIPGenericFlag","UniqueId":"0123456A"}

The result:

[ { "error": { "type": 6, "address": "/sensors/ManufacturerName", "description": "parameter, ManufacturerName, not available" } }, { "error": { "type": 6, "address": "/sensors/ModelId", "description": "parameter, ModelId, not available" } }, { "error": { "type": 6, "address": "/sensors/Name", "description": "parameter, Name, not available" } }, { "error": { "type": 6, "address": "/sensors/SwVersion", "description": "parameter, SwVersion, not available" } }, { "error": { "type": 6, "address": "/sensors/Type", "description": "parameter, Type, not available" } }, { "error": { "type": 6, "address": "/sensors/UniqueId", "description": "parameter, UniqueId, not available" } } ]

I think the error is in the capitals in the strings.. E.g. "ManufacturerName" instead of "manufacturername".

michielpost commented 7 years ago

Yes, you should update to that latest version (3.2.3). Is already fixed.

niels9001 commented 7 years ago

Ah, sorry for the confusion. Thanks!