Advanced Circadian Lighting

Hi All,

This is an automation blueprint to adjust light brightness, temperature, and color hue, based on presence, current time and sun position. Its main features are outlined in the blueprint description, but I will be happy to provide additional information and further details if anyone is interested.


Nice piece of code! Have you tried GitHub - basnijholt/adaptive-lighting: Adaptive Lighting custom component for Home Assistant before creating it?

1 Like

Thanks, Krzysztof!

Yes, I did get a lot of ideas and inspiration from the code you mentionned, as well as from other blueprints that have been made available - maybe I should add a reference list, to give the appropriate credits.

There are several differences from the adaptive lighting project:

  • First, I thought I could manage to achieve a similar effect with a blueprint, which I find cleaner and easier to implement and maintain.

  • Secondly, I only recently noticed that Adaptive Lighting allows you to manually define sunset and sunrise times. I do find sun-based circadian rythms a bit annoying, as our own biological clock is shifted compared to the sun’s position (we go to sleep and wake up long after sunset and sunrise, respectively).

  • Thirdly, my main focus was to define the color hue of my RGB lights: it is now set to gradually change from red (at “midnight”), to yellow, then green, cyan, blue, magenta and finally back to red. Color temperature and brightness came in later.

  • Most importantly, I wanted to combine the circadian lighting with brightness-adjustment based on sun elevation: now, I have two brightness coefficients, one for the circadian cycle and one for sun elevation, and they are being multiplied with each other to define the actual brightness. The idea is that, using the same algorithm, I can get my red night lights to gradually dim up and change color when waking up in the morning, and then gradually fade out when the sun rises. Similarly, I can have the lights gradually dim on during sunset, and also gradually dim off as bedtime approaches.

  • Since I added elevation-based dimming on, it was quite easy to also implement automatic presence-based turning-on & off.

  • Finally, it is nice that I can now have such effects for a large number of lights, with just a few automations (e.g. I set my toddler’s lights with different sleeping times, and I also set different automations for lights that should turn on automatically, and lights that I want to get circadian-type properties only when I manually turn them on myself).

Again, though, the adaptive lighting project is really really good, and I do hope that it will sometime become an official component.


do you have a graph that shows a typical behavior of the function of your blueprint?

1 Like

No, but I am planning to produce one, so please stay tuned.

Note that I am not a professional coder, I am only doing this in my (rather limited) free time, and I am still testing the code, fixing bugs and making improvements, so I apologise in advance for any delay.


I keep getting an unknown error trying to import this.

How properly setup this automatation? When i choose light nothing happens

Triggered by the time pattern at 24 мая 2022 г., 14:36:00

Choose: Default action executed

Finished at 24 мая 2022 г., 14:36:00 (runtime: 0.08 seconds)
alias: Advanced Circadian Lighting
description: ''
  path: dimkaram/advanced_circadian_lighting.yaml
    circadian_function: None
      entity_id: light.podsvetka_zal_gruppa
    circadian_type: Time
    elevation_switch_on: false
    elevation_switch_off: false
    presence_switch_on: false
    presence_switch_off: false
    presence_entity: device_tracker.7c_03_ab_2e_52_8b
    sleep_mode: None
    circadian_hue_default: 110
    circadian_saturation_default: 95

Apologies, but I don’t think I can help you without any additional information on this.

Could you please explain what you are trying to do? At the moment, the blueprint is not configured to do anything, as no circadian function is selected and all switches are set to false.

First, thank for you blueprint!
I need brightness and white color temperature adjustment all day, and after sundown i need get red color and adjustment its brightness. I did not understant how work Circadian default hue and saturation options.

And other question: when i setup automatation and turn light on, it seems work properly. When i change light color, i guess light must resume to proper color temp and brightness after minute, but did not happen until i toggle light.

First, you need to define what you mean as “day”. You can do this based on fixed times (e.g. if you wake up and go to bed at given times), or based on the sun position (i.e. day is from sunrise to sunset).

Then, if you want adjustment during the day, you should pick one of the “day only” options. You can try both functions, although I think that the half-sine looks a bit better (when I get some free time, I will prepare some graphs to show how it works).

Unfortunately, the blueprint can’t automatically switch from white temperature in the day to rgb colour in the night. This would make it even more complicated than it already is. Still, if you have a light that does both white temperature and rgb colour, whenever you switch colour mode manually, the automation will continue to adjust it. When the light is in white temperature mode, the automation will adjust its brightness and temperature, and when it is in colour mode, it will adjust its brightness and colour hue. For lights that have brightness mode only, it will only adjust the brightness. And for simple switch lights, it will only turn them on or off.

Finally, it is expected for the automation to stop adjusting the light when you change it manually. This is done on purpose. For example, it would adjust my living room lights based on my routine, but when I have friends at home, I would simply increase the brightness and it would stay there.

I hope this helps, but please do let me know if you need any further clarifications.

P.S. Just as a disclaimer, I am not a programmer and I am doing this as a hobby, so I am sure that this code can be rewritten in a simpler and more efficient way. In fact, I wrote most of it on a text editor on my mobile phone, during these endless nights when my baby boy was asleep in my arms :slight_smile:


Thank you for detailed information!

Perhaps an stupid question, but… in the scenario that using zigbee switches and lights, and being lights bond to switches… this (and perhaps other) Circanian lights solution would not work, isn’t it?
It would not trigger?

This has nothing to do with Home Assistant, but I can definitely assure you that there is no such thing as a stupid question.

Anyway, I think it should still work, since the switch would trigger the turn on service and this would in turn trigger the circadian automation.

In an ideal world, I would tell you to try it out and let me know if you encounter any issues, but, unfortunately, I am so busy with other commitments, that I don’t think I will manage to provide adequate support, so I can’t promise anything. Sorry about that!

1 Like

Thanks @dimkaram for this blueprint I was looking for something similar. I gave it a shot last night and found my lights dimming and brightening on their own randomly. I selected my light entity, set the circadian cycle to Sun, circadian function as Day & night and left the sliders and switches at their default. I have attached a video (mind you during daylight) of what I’m talking about. I tried in my kitchen which has an MQTT light entity and in my living room using Hue bulbs.

Hi @dimkaram
Thanks very much for this Blueprint. It mostly gets around an issue I have with some of my lights. I have RGBW lights, which can be set by the light turn on service, but RGBW isn’t a supported colour mode. Supported colour modes are color_temp and hs, which would be fine, except for some reason the max_mireds is 370, and I want to get much higher. It seems that if the lights are turned on before the colour temp reaches 370, then they won’t go any warmer than 370. If turned on after the colour temp reaches 370, then I can go as high as I want.
I’m curious if you may understand why this is the case, and if there’s any modifications to the blueprint I can make to get around this.

Disregard my previous comment. I went back and reread the previous conversations in more depth, and found something I’d missed about color changing. My lights were initially turning on at a mired level, and I was expecting the colors to change, and that’s not the way this blueprint is designed. I’ve now adjusted these lights to turn on with a color pre-defined, and immediately upon doing so, the color adjusted to an appropriate circadian pattern.

Thanks much for this!

Thanks a lot for this automation, it’s great! However, I’m struggling to get it to work with color mode. I have philips hue lights that can be set to any color, but the automation only adjusts the temperature. You mentioned in one of the above posts that it will adjust color if the light is set to color mode, but I don’t understand how I can do that, since you also mentioned that the automation stops adjusting if a particular color is set manually. How do I get it to work?

Hi Dimikaran

At first thanks for creating this Blueprint, it is indeed easier to install if you don’t have hacs.
I am very new to HA and am a little confused on this Blueprint. I hope you can help me understand this one. I thought that after installing the Blueprint and adding the lamps, the automation would run in the background and as soon as a lamp was turned on, it would take the given light temperature depending on the day/night time. Like in your description:
Gets automatically activated when a light is turned on.
- Runs when the turn on service does not define light brightness or color.
But for some reason it don’t change the light temperature and I don’t have figure out why.
Do you have some Tips where I should look? Any help would be nice.