philips-hue

Basic Transition Issues


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:

  1. Unless I dim the lights then turn them off first (or call the 'Cinema' formula from Hue Labs), when I call this code the lights come on at whatever brightness they were at before, seemingly ignoring the first setState call.
  2. The brightness and saturation of the transition are ignored. All it does is transition Hue, though this behavior varies depending on if I include the sleep timer or not.

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.


Solution

  • 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.