And while I don’t at all want to take away from @cloak’s commendable efforts there, it seems that that post offers these color-conversion functions, and of them, it doesn’t appear that there are currently functions for converting from those color systems to Kelvin (other than colour_mireds_to_kelvin)?:
And while I don’t want to appear ungrateful for your helpful efforts in finding that, it so happens that my script is written in Jinja and it looks like the linked conversion relies upon Python’s Image.convert() function. And I don’t personally have the Python knowledge to be able to port that Python function to Jinja.
And while again I don’t want to appear ungrateful as I very much appreciate your engagement and comments here, I also can’t help thinking that even if I were able to find a formula for converting from RGB to Kelvin, I might still seem to have a gap in terms of converting from XY to Kelvin?
I can understand where you’re coming from. And I agree that the map there is intriguing. All the same, I’m not quite sure how to make use of that map so as to convert in the opposite direction, from RGB to Kelvin? For instance, if a light were set to, say, rgb(255, 231, 211), how might I convert that to a Kelvin value?
I’ve tried googling for a formula to convert from XY to Kelvin, and I haven’t come up with anything. If you can find something, I would welcome it.
Hi! I just found this script, and it almost exactly fits my needs - it’s brilliant! My one request would also be for colour support, so here’s my idea: Why not simply have a fade-from and fade-to value, both of which can be inputted as kelvin (or whatever is easiest for you to implement) and fade between them, instead of trying to fade from the current colour?
At the same time, I might imagine that there could also be occasions where the user might not have any way of knowing what a lamp’s current Kelvin value might be? (And I wouldn’t want to leave those folks hight and dry either.)
And so at a minimum, if I were to implement the feature that you had suggested, I think that I’d also want to implement the feature where the user only had to enter the final Kelvin value?
I definitely want to implement color fading of some sort, and I very much appreciate your thoughts and feedback on this!
This is something FANTASTIC !!! I would like to say GIANT THANK YOU for your time, work, effort and incredible result ! The script is great just as it is, but im glad that some updates are already planned. Fingers crossed, and my compliments once again !
Maybe a dumb question, but i would like to kindly ask you about “End brightness level”. I try to explain the topic :
The slider allows easily change the desired end brightness level in percentage from 0% to 100%. I have some lights which i wish to DIM to value of “1” in scale “0-255”. I can switch the option “The lamp’s internal brightness scale” but the “End brightness level” remains in percents. I know it sounds strange, but the reason is, that some of our LED strips (especially in children’s room) remains on during night, just to avoid full darkness. In percent scale is 1% end brightness brighter as “value 1”. I know it is maybe construction fault of cheap bulbs and LED strip controllers, but it is clearly visible and maybe im not alone who has crap equipment like this. I can also after dimming period set another automation like “Light: Turn On” and set the brightness value to “1”, but it would be really awesome to have the option to set the End Brightness Level in “value range” also inside of your fantastic script.
Hi, @ronnieSVK—thanks so much for your kind words!
And for whatever it’s worth, while I totally understand your use case—and I also have an idea in the next paragraph that may be able to help with that!—I’m also slightly hesitant to add a secondary brightness slider for 0–255 if only because the script already has tons of options, and I just feel that with each additional field that I were to add, the script might become a bit more daunting to newcomers?
All the same, I also have an idea that I think may be able to resolve your use case: I believe that you can achieve what you describe if you were to add an input-number helper within your Home Assistant instance? And if by chance you might be new to that sort of thing, here’re the steps for that if it may be of interest—
Within your Home Assistant instance, go to Settings → Devices & services.
Then click on the “Helpers” tab (across the top).
From there, click on “Create Helper” (at the bottom right)
Then select “Number”.
And then on the next screen, you might enter values such as these:
Name: “Extra-low brightness”
Icon: [anything that you’d like]
Minimum value: 1
Maximum value: 5
Display mode: slider
Step size: 1
Unit of measurement: “brightness”
(And all together, that might look something like this:)
After you’ve created it, you should then see an entry for “Extra-low brightness” (or whichever name you’ve given it) within the list of items on the “Helpers” tab.
Lastly, I’d recommend clicking on that “Extra-low brightness” entry and then setting its slider’s value to “1” (if it isn’t already set to that value).
From here, if you then open to the automation where you’re calling Ashley’s Light Fader, you can then make use of that entity by entering its name within the ”Use an entity instead for the end-brightness value?” field and then setting the “The end-brightness entity’s brightness scale” field to “0 to 255”:
And with that in place, I think that that should hopefully do what you need. And if you might have any questions along the way, feel free to reply here, and I’ll be happy to chime in!
Thank you for the really helpful script! I was just wondering how I could use this script to always fade my light if I change the brightness. So that if I change the brightness a fade should always be applied. I thought that using a number helper as an entity for the end-brightness value should do the job. It does work if I directly control the number helper. But I am controlling my lights through my Google Assistant and my Google Home App where the number helper does not appear and thus cannot be used. Is it somehow possible to make this work?
For better or for worse, what you describe—having this fader script be automatically applied for all light transitions—isn’t really possible. And that’s in part because when you change your lights through Google Assistant or the Google Home app, that controls the lights directly, which bypasses most of the triggers that Home Assistant can hook into.
Hello Ashley,
This script is great thank you for your great effort. I could make it work with my Govee led strip light transition for turning on more smoothly. But i want it turn off exactly how it turned off. Is it even possible with this script ?
Hey Ashley. I’ve got an existing basic script based on Jeffrey Stone’s (Slackerlabs) Lights With Level script that works pretty well, but I’ve added your script too and will put it through its paces later .
I’m also now stalk… I mean following you on X or Twitter or whatever it’s called these days
I’m rooting for ya!
Appreciate the update!
Your script is such an effortless addition to my family’s daily use of HA
I’m baffled that this feature isn’t baked into HA itself!
Stay fantastic!
This is fantastic! I’m wondering if it’s possible to allow an area to be input in lieu of entity id. I know you can use groups, and maybe that’s actually the way to go… What I’m hoping to do is use this script with the assist feature, and say “sunset {{ area name }}” to trigger a script called “sunset” (which then calls your script,) on lights in whatever area is mentioned.