michielpost / Q42.HueApi

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

UpdateScheduleAsync(Schedule S) not working #83

Closed niels9001 closed 7 years ago

niels9001 commented 7 years ago

UpdateScheduleAsync(Schedule S) also wants to update the 'Id' and 'Created' parameters.

Raw JSON: { "Id":"1", "name":"sdfsdf", "description":"Floor aan", "command":{ "address":"/api/ID/lights/1/state", "method":"PUT", "body":{ "bri":255, "on":true, "transitiontime":0 } }, "localtime":"W20/T10:45:00", "created":"2016-11-04T09:45:50", "status":"disabled" }

Results in: [ { "error": { "type": 6, "address": "/schedules/1/Id", "description": "parameter, Id, not available" } }, { "error": { "type": 6, "address": "/schedules/1/created", "description": "parameter, created, not available" } } ]

Leaving out Id and created solves the issue!

michielpost commented 7 years ago

Thanks for the bug report, should be fixed now in version 3.2.4 that's on NuGet.

niels9001 commented 7 years ago

Thanks that helped! However, it now (for some reason..) sets my Schedule ID to null as well.. Any ideas?

` ToggleSwitch selectedSwitch = sender as ToggleSwitch; Schedule selectedSchedule = selectedSwitch.DataContext as Schedule;

        if (selectedSchedule.Status == "enabled")
        {
            selectedSchedule.Status = "disabled";
        }
        else
        {
            selectedSchedule.Status = "enabled";
        }

        // AT THE SECOND TIME, THE SELECTEDSCHEDULE.ID IS NULL.
        await Client.UpdateScheduleAsync(selectedSchedule .Id, selectedSchedule );`
michielpost commented 7 years ago

Ok, should be fixed in version 3.2.5 up on NuGet now.

niels9001 commented 7 years ago

Last update solved this! Thanks!