Hi @Morphy
Which type of light are you using? Does it support color_temp? In other words, can you change the color temperature from the home assistant UI?
On a side note, I recommend you to check out this post. I put all this code together in a app for appdaemon and I put it on HACS, so you can download the latest code in there and have many more feature than these scripts.