I'm trying to write a basic script which uses the remote API to turn on my lights, then transition them to a certain color. The code for doing so using a custom SDK looks something like this:
group.SetState(hue.State{On: true, Bri: 0, Hue: 4000, TransitionTime: 0})
time.Sleep(1 * time.Second)
group.SetState(hue.State{TransitionTime: 300, Bri: 254, Hue: 11500, Sat: 0})
Where each of the SetState
calls makes a call to the Group command API. Seems simple enough but I'm having a couple of issues:
setState
call.Any thoughts on what I am doing wrong?
EDIT: It looks like the API isn't even respecting the first statement's brightness setting. If I make the call to set it to 0, nothing happens.
It turns out the issues I described were due to json:"___,omitempty"
being on the brightness, transition, and saturation settings. This means that when they have a value of 0 they are left out when marshalling to json in Go. facepalm.
Converting the values to int pointers fixed the issue for me.