michielpost / Q42.HueApi

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

Issue with updating rules #162

Closed niels9001 closed 5 years ago

niels9001 commented 5 years ago

Looks like values that are null are still part of the JSON that is send to the Bridge:

When I parse this JSON from the Bridge to a Rule:

{ "name": "Dimmer Switch 59 on0", "owner": "QRsiWA03DiRMiG4BGFPFDrP7aUPwkUk9ynwEdTeD", "created": "2018-12-22T15:44:09", "lasttriggered": "2018-12-23T04:45:44", "timestriggered": 2, "status": "enabled", "recycle": true, "conditions": [ { "address": "/sensors/59/state/buttonevent", "operator": "eq", "value": "1000" }, { "address": "/sensors/59/state/lastupdated", "operator": "dx" }, { "address": "/sensors/15/state/status", "operator": "lt", "value": "1" } ], "actions": [ { "address": "/groups/5/action", "method": "PUT", "body": { "scene": "kOi64QxZfb8fLgf" } }, { "address": "/sensors/15/state", "method": "PUT", "body": { "status": 1 } } ] }

updating an action, and then UpdateRule() with the above Rule Fiddler shows that this JSON is send to the Bridge:

{"conditions":[{"address":"/sensors/59/state/buttonevent","operator":"eq","value":"1000"},{"address":"/sensors/59/state/lastupdated","operator":"dx","value":null},{"address":"/sensors/15/state/status","operator":"eq","value":"1"}],"actions":[{"address":"/sensors/15/state","method":"PUT","body":{"buttonevent":null,"dark":null,"daylight":null,"flag":null,"humidity":null,"lastupdated":null,"lightlevel":null,"open":null,"presence":null,"status":2,"temperature":null}}],"name":"Dimmer Switch 59 on1"}

Resulting in error:

[{"error":{"type":7,"address":"/rules/25/value","description":"invalid value, null}, for parameter, value"}},{"error":{"type":7,"address":"/rules/25/body","description":"invalid value, too big, for parameter, body"}}]

michielpost commented 5 years ago

Ok thanks. Fixed and available in NuGet version 3.8.2