peter-murray / node-hue-api

Node.js Library for interacting with the Philips Hue Bridge and Lights
Apache License 2.0
1.19k stars 145 forks source link

Transition times incorrect #109

Closed TomMettam closed 7 years ago

TomMettam commented 7 years ago

After a lot of swearing at my transitions apparently not working, I discovered that the transition durations are not working as documented.

Rather than being in milliseconds (i.e, 4000 = 4 seconds), to get a 4 second transition I had to specify 40.

peter-murray commented 7 years ago

What part of the API are you using? Are you passing in JSON, or a lightstate object, and to which function call.

TomMettam commented 7 years ago

(Sorry - github code formatting is awful in comments, it seems)

This gives a long transition of 20 seconds:

`var api = hueBase.HueApi(bridge.ipaddress, bridge.username);

    var lightState = hueBase.lightState;
    var xy = $scope.toXY($scope.colours[$scope.sequences[entity].col]);
    var state = lightState.create().on().xy(xy).transitionTime(200).brightness(20);

    api.setGroupLightState(group, state, function(err, lights) {
        if (err)
        {
            console.error(err);
        }
    });`
peter-murray commented 7 years ago

Thanks, I see that I messed up the documentation. There was already a function there transtion that was working on actual milliseconds, but the documentation for transitiontime and transtionTime was wrong.

I also added two more convenience functions of transitiontime_milliseconds and transitionTime_milliseconds as shortcuts to transition to operate in millisecond values.