lifxjs
lifxjs copied to clipboard
Documentation for fade_time
I spent a while working with the fade_time parameter today, trying to figure out its quirkiness (because it certainly is not milliseconds or seconds). At least on the two kickstarter bulbs I received a few weeks ago, the following formula seems to apply:
(fade_time parameter) = ((seconds)*225)^2
I have tested this, and it seems to work appropriately for all fade times large and small (less than a second up to several minutes). The 225 value is estimated based on testing, but the formula definitely seem to be quadratic.
See this graph for my test results: http://i.imgur.com/sbUEkGi.png
It may be worth including this formula in the docs, or even accepting "seconds" as the parameter in code, and converting it with this formula before sending it to the bulb. Additional testing is probably required to make sure this works on other shipments of the bulb as well.
Excellent sleuthing! I re-visited the Android application and you're right, the seconds description is wrong. They handle the value as if it's milliseconds but that could be one of many bugs.
Seems there may be even more to it than that. Usually, my bulbs seem to follow the formula above, but occasionally they seem to flip into some other mode where fade_time means something entirely different. No idea what's going on at this point. Hopefully an official api will clear some things up at some point.
Yeah - fade seems to work great on brightness and kelvin, but do something different when moving from color to color.
Had another chance to play with this today. I've been using this code with acceptable results: https://gist.github.com/sonicsnes/8648212
It seems that any fades involving kelvin (either going to kelvin, or if the bulb was using kelvin BEFORE you called lightsColour), fadeTime represents milliseconds -- otherwise, it is calculated with the formula above.
Don't ask me why. Sounds like a firmware bug.
Today I got the formula switch without even using Kelvins.
I found that calling setColor with a fadeTime of 0 resets it back to ((seconds)*225)^2