Hi all!
I’m stuck in my mind trying to automate my lights. To make it simple, I’ll focus on one light.
What I’d like to do is one light to cycle it’s brightness, colour temperature/colour based on the time of the day. For example, at 14:00 when I work from home, I would like the light to display a cool blue light at 255 brightness. Then, at 20:00, it should be a warm white on a 149 brightness, while at 22:00 it should be red (xy_color) with a brightness of 79, etc. I’ve made a list of the values I’d like per time of day.
At the moment, I’m using a 6 scenes to cycle trough this configuration. I call them using a script with a transition, and that works nice. I’m really happy with how the lights behave! I did it to help my circadian rhythm - I’m up north and in winter there is barely any sun, and in the summer it’s there all the time. I am aware of the circadian plugin, but I’m quite sure it’s not what I’m looking for.
The problem, however, is for example when I arrive home at 21:53. It will activate the latest scene; the one of 20:00, which is not fitting for that moment. The same for when my chromecast changes to ‘stop’ (disactivating the movie lights mode), and the lights turn on to their normal state, it’s usually way too bright.
Using the list from the picture, I would like to use the time to calculate the brightness, colour etc. For example, turning on the lights at 20:45 takes the times of 20:00 and 21:00 and calculates the according brightness: 123:
149+((114-149)*45/60)
oldBrightness+((newBrightness-oldBrightness)*currentMinute/60)
I tried to do this using a script, but it didn’t know how to get it to work properly, this is what I got at the moment;
ceiling_default_sate:
alias: Ceiling Default State
variables:
current_hour: now().hour
brightness: [8,8,8,8,8,8,43,79,114,149,184,220,255,255,255,255,255,255,220,184,149,114,79,43]
color_temperature: [500,500,500,500,500,500,500,500,500,500,500,414,153,153,153,153,153,153,414,500,500,500,500,500]
x_color: [0.689,0.689,0.689,0.689,0.689,0.689,0.689,0,0,0,0,0,0,0,0,0,0,0,0,0,0.539,0.581,0.675,0.689]
y_color: [0.309,0.309,0.309,0.309,0.309,0.309,0.309,0,0,0,0,0,0,0,0,0,0,0,0,0,0.392,0.387,0.392,0.309]
sequence:
- service: light.turn_on
data:
entity_id: light.ceiling
brightness: {{ brightness[current_hour] }}
rgb_color: 179,255,251
mode: single
icon: mdi:ceiling-light
I think that should give a good idea of what I’m trying to do.
My question is, do you have a tip for me where to start with this project? I’ve done a lot of googling and looking around on the forum, but can’t find the right terms. Do you know of a blueprint, tutorial, documentation or anything else that can get me started with this? I can get into programming it too if that’s easier. Thanks a lot!