Circadian rythm for lights

I cobbled together a small plugin exposing a service to set light colors according to the circadian rhythm, inspired by a similar thing for SmartThings.

Not only did I never touch python before, I’m also still finding my way around HA, so it kinda sucks :wink: But it should work.

If people are actually interested in this, they can either create a proper repo out of it (and please tell me about it) or message me and I’ll spin it out and accept PRs and issues.

1 Like

Wow,was looking for something like this…thanks a lot, is there a way to add a GUI component to this as well?

I have no clue :wink: What would you want there? Currently, I just use a boolean switch to enable or disable the automation I set up to call it every minute.

Yes…thats what i wanted…a switch to turn off the automation.Could you share how you setup the boolean switch?

It’s pretty simple :wink:

    name: Activate Circadian Lights
    initial: 'off'
    icon: mdi:spotlight

Nice…thanks a lot :grin:

Make sure to tell me if it works, today is my first day of actually running it so there might well be bugs :wink:

Sure…waiting for nightfall :relaxed:

So I tried it and color temp seems to work,but hue bulb brightness does not…it stays at full brightness,any idea?

It’s actually not working correctly at all :frowning:
Working with datetime in python is no fun at all, I’m not sure I will fix this, sorry.

No worries, i wish i could help, but looking at the code i have no idea what math the code is doing :persevere:

Were you able to get this working?

I don’t understand the math either, I might revisit it at some point but not currently :confused:

I found a better way here - so HA can simply call this script. Will try it tonite.

This program is supposed to work only while is day (it ‘simulates’ the sun…). At night the output is constant, for color and for brightness (at night your circadian cycle tells you to sleep!). So if, in automation, you activate it only at night, you will not see it work…

I am working in a component that for the day it works like this, and at night makes a smooth transition to red colors (don’t mess up your circadian cycle with blues at night!).

Soon, I need a few days for testing, I will put a link here.

1 Like

As promised, here it is

By the way, see for a complement.

@vswraith Thanks for the link. I converted that script into a Home-Assistant component. You can drop this file in your custom_components and have HA set your lights like flux. I’ll polish it up and submit a PR soon.

Thanks, looks good. But is there a way to stop the process? When i manually turn off a light, the component again started it :slight_smile:

You could create an automation that calls the service flux/update whenever you want to update, similar to the OP’s method. You could then disable/enable the automation.

I also changed the component so it will only modify the light if it’s already on. See PR 2097