Right now my homeassistant is configured to change light temperature in the morning and in the evening with an automation that check if it’s almost sunset or sunrise and turn light on with the correct temperature settings, and than off. I turn the light on/off with a tradfri switch (the round one that change brightness levels) or via hue app.
I was thinking to make it a bit more “complicated” by detecting when light is turned on and than check what time is it and change light temperature according to that, is this possible or an event like this could only be started if I turn on the light via homeassistant (or some switch managed by homeassistant)?
That depends on your hardware. I could see this working but it wouldn’t be ‘seemless’. When you’d turn the device on, it would resume at the last setting momentarily, then switch to the desired light temperature.
EDIT: This is assuming that your switch turns on your light without home assistant. I.E. a normal switch.
I could see this working but it wouldn’t be ‘seemless’
Yes, that’s exactly what I was thinking, i turn on the light and after 10 seconds home assistant check what time is it and adjust the temperature, but how would I implement this? Do I need something in backgroud that check light status every n-seconds?
Na, if your switch is connected to home assistant, just build an automation that detects the switch ‘turn_on’ change. Make sure you only fire the automation when the switch is off.
- alias: adjust temperature of light
trigger:
- platform: state
entity_id: xxx.xxx
from: 'off'
to: 'on'
Yes! I had the solution literally under my eyes, and i was thinking something very complicated.Of course I have light state in homeassistant because lights are all connected to HA, thanks for pointing me in the right direction.
I’m gonna create a trigger that monitor the light entity from off to on and than a template that pass the ‘kelvin’ parameter to the ‘light.turn_on’ service, based from the sun position.
But what if I would like to use an offset before sunset / after sunrise? I don’t get how i should change the ‘states’… I need something like this (that I’m currently using to change light temps)
- alias: warm light in kitchen
trigger:
platform: sun
event: sunset
offset: "-00:59:00"
I also use Tradfri, at the moment I just have a “night mode” and a “day mode” automation where if the light is changed to ON it sets the colour and brightness correctly, but I plan on using the below instead:
you could have an extra encompassing if then else to max to 330 I guess, but I am not sure that would be the correct way for implementing circadian algorithm.
In fact the “length of day” factor detemines the width and depth of the graph. If you change values here, you can influence how high the values will climb right before sunset and after sunrise. Simply put the formula in to MS Excel or similar and built your own graph. This will allow you to modify the variables used in the “length of day” factor so that you managed to achieve a max of 330 mireds.