Change light temperature over time

While I've built an impressive amount of flows for my smart home, now is the time I need some extra brains to help me :slight_smile:

What I want: Change the light temperature of my living room lights from the time they turn on until 23:00 the same day. Starting from 3500 kelving from the time they turn on ending on 2500 at 23:00.

The lights are turned on gradually from another flow (using a light sensor and a range node), so the ON time is fairly random. At the end of the day the lights are turned of manually.

My initial thoughts were to again use a range node to gradually change from 'ohgodmyeyes'-light to 'candlelight-esque'. The main rub there is the lack of comparison scale. For the brightness this is done by my light-sensors, but there appears to not be something like that for time.

In a perfect world I'd like something that translates "ontime lights" - "23:00" into a diminishing value for a range node, or something like that. If at all possible, I'd also like to stay away from overly complex function nodes. My JS is minimal at best, and I'd like to keep understanding my automations...

In short: (convert time range to number) -> (trigger on that number changing) -> (send number to a change node) -> (adjust light temp).

The last part (adjust light temp) is the only one I'm currently able to... And while my solution works, based on a series of inject triggers, it's just too janky.

So, I'd love to hear your thoughts!

Is that really what you want or would it be better to simplify and fix the change throughout the day. Keeping the on/off/brightness completely separate. I think that would be a simpler calculation for a start.

The next thing to do is to work out how many useful colour changes you can actually get out of your lights. Then you can create a formula that, given a time, returns a light temperature. How many changes you can actually get then defines how often it is worth calling that function.

Bear in mind that not all colours are perceived the same either and you may find that some brightness/temperature combinations acually don't work very well and you might need to skip over them.

All of this is likely very dependent on what lights you have and how much control they give you.

BTW, the other advantage of fixing the colour temperature in time is that you could then apply a date adjustment to allow for different times of the year and that would be an easy adjustment to add.

Can this node be helpful?

The only problem is, that it has node-red as a direct dependency, so a complete Node-RED will be installed in your workspace. (I opened an issue for that)

Closed due to forum spam.