@kvikindi Many thanks for your kind words—that means a lot!
And while I’m not opposed to potentially adding a feature to have the script also fade color temperature, I’ve come across a bit of a couple of hiccups while trying to envision how I might approach such a feature. (And I’m open to any ideas or suggestions that you may have for getting around these problems:)
-
I’m not quite sure what might be a reasonable way for the script to handle a scenario in which someone were to request a color-temperature fade but the targeted lamp’s starting color wasn’t a traditional Kelvin color temperature. For instance, if a lamp’s starting color were green, then what should the script do? Should the script maybe just abort the fade in that case? Or should the script perhaps do the brightness portion of the fade but skip the color-temperature part of the fade?
-
A second issue is that whenever a light is off, it has no defined color_temp_kelvin
value. And so that would make it rather difficult to calculate the fade curve in a scenario where someone were to be fading a light from off up to ##% while also fading its color temperature at the same time. (If it may be of interest, you can see this for yourself by checking on a light’s properties in Developer Tools → States and then manually turning off that light.)
-
And lastly, what might perhaps be a larger issue is that while there’s a single brightness-measuring system for lights (namely, its brightness
attribute), there are several color-temperature systems that Home Assistant supports—Kelvin, xy, rgb, and mired—and Home Assistant doesn’t appear to have any means of converting between them.
So just for a quick experiment, I checked on the current properties for the Hue lamp that’s next to my desk:
In this case, the lamp is currently set to 2906
Kelvin.
And since the lamp’s rgb
value is listed as 255, 174, 103
, I would presume that that rgb
value would be equivalent to 2906
Kelvin? But if I manually set the lamp to rgb(255, 174, 103)
using the Developer Tools → Services tab, the lamp’s color_temp_kelvin
attribute disappears from its listing under the Developer Tools → States tab. (I guess because the lamp is technically now in rgb mode?) And on top of that, the lamp’s visual appearance with that new RGB doesn’t seem to match the original Kelvin value that it had before, which is seems weird.
The main hangup, though, is that it’s seemingly possible for someone to set a lamp to a particular RGB color or an XY color that happens to line up perfectly with an existing Kelvin color—but if someone were to do that, I don’t know how I’d be able to have the script fade that lamp to a target Kelvin color since the lamp’s color_temp_kelvin
attribute disappears as soon as its color is set using RGB or XY.
As well, one might reasonably assume that surely there would have to be some formulas available that one could use to convert an RGB color to a Kelvin value or to convert from an XY color to a Kelvin value—but I’ve done a bit of looking around, and I haven’t seen any.
In theory, I’m not opposed to adding this color-temperature-fading feature—but as it is at the moment, I don’t know how to get around these roadblocks.
That being said, if anyone might have any ideas for how I could resolve these hiccups, I’d be legitimately interested. (And if it turns out that there may be a way to get around these problems, I’d then be quite open to trying to add this feature.)