Circadian lighting

Hi guys!

I’ve always wanted lighting that changed colour and brightness based on my circadian rhythm, and with HASS and AppDaemon, now I can!

For this purpose I wrote an app that takes timepoints, brightness and color-temperature (see lines 37-54) and uses those into a current “circadian brightness” and “circadian colour temperature”.

It then stores them in a global variable called c_brightness and c_color.

Since I occasionally work night shifts, I can offset my circadian rhythm from baseline. The script takes an input_select called circadian_hour and an input_select circadian_minute and uses those to offset the generated values.

While it isn’t too pretty, it’s perfect for my uses!

Dependencies:

  1. rgbxy: pip3 instal rgbxy, https://pypi.python.org/pypi/rgbxy/0.4

Current bugs:
· Doesn’t cross midnight properly

Source code: https://github.com/ryqiem/homeassistant/blob/master/apps/c_gen_v2.py

A separate script sets my lights to fade to the given value every 4 minutes, but that script is heavily dependent on the names of the lights. It’s on the github project, “circadian_setter”.

If you find this useful, or you have comments for improvements, please leave a comment! :blush:

3 Likes

i first had to look up circadian rhythm before i could know if i could use this :wink:
and then i got just questionmarks :wink:

i guess you first need to find your circadian rhythm before you can work with this.
then i ask myself: what is the right brigthness and colortemp for what time?

so i guess i can see what you are doing, but i want to know more about why and based on what?

1 Like

Your circadian rhythm is basically just a biological alarm clock telling your body when to go to sleep, and when to wake up :slight_smile:

If you know when you feel tired, you’ve “found” your circadian rhythm :wink:

The primary stimulus setting the clock (called a zeitgeber) is light, specifically blue light. The idea is to gradually remove blue light from your environment as you approach the time you want to fall asleep, to prepare your mind and body for sleep.

Why? To fall asleep easier, to feel refreshed when you wake up.

Based on what? A pretty good introduction to chronobiology here: http://lesswrong.com/lw/meu/solving_sleep_just_a_toedipping/.

And more info here: https://justgetflux.com/research.html

Is this similar to https://home-assistant.io/components/switch.flux/. The flux component works pretty well, however if this is better I might check it out.

ah, i see.
i have to change all my lighting first then, because now im not having any blue lights a lot of hours before i go to sleep :wink:

thx for the info.

This generates the values for use in your AppD apps, it doesn’t set any lights on its own :slight_smile: