michielpost / Q42.HueApi

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

'Newtonsoft.Json.JsonSerializationException' for some Rules #81

Closed niels9001 closed 8 years ago

niels9001 commented 8 years ago

I have just installed the Hue Motion Sensor using the official app, and it seems it breaks the Q42.HueApi.

The following JSON causes an exception:

"29": { "name": "MotionSensor 13.day-on", "owner": "Ftg8b0E4NVk3vVpodvV-Nh-rg8q3XfB0sDUZv3Hy", "created": "2016-10-15T12:01:33", "lasttriggered": "2016-10-23T08:59:32", "timestriggered": 5, "status": "enabled", "recycle": true, "conditions": [ { "address": "/config/localtime", "operator": "in", "value": "T08:00:00/T23:00:00" }, { "address": "/sensors/13/state/presence", "operator": "eq", "value": "true" }, { "address": "/sensors/13/state/presence", "operator": "dx" }, { "address": "/sensors/15/state/status", "operator": "lt", "value": "1" }, { "address": "/sensors/14/state/dark", "operator": "eq", "value": "true" } ], "actions": [ { "address": "/groups/3/action", "method": "PUT", "body": { "scene": "kZvpr1yJTqvHyQA" } }, { "address": "/sensors/15/state", "method": "PUT", "body": { "status": 1 } } ] },

michielpost commented 8 years ago

Which API call retuns this json? Getting all rules?

niels9001 commented 8 years ago

Oh yes..

await Client.GetRulesAsync();

You should be able to re-create if you use the JSON mentioned above.

michielpost commented 8 years ago

Fixed with this commit: https://github.com/Q42/Q42.HueApi/commit/d131c2064c83e657039e235f43c4bdaa5ef5f1d1 Main problem was a missing operator (in). And also fixed parsing the sensor action in the json.

New release is on NuGet

niels9001 commented 8 years ago

Yep, that fixed it :)! Thanks for being so fast!