Circadian Lighting [Custom Component]

OK…this is great! I’m ready with my initial follow-up questions. Separately in Node Red I built more of a sunise / sunset fade for my RGBCTT bulbs from dim red to brighter red to orange before it cuts over to the white LEDs. I tried running that at the same time as this CL script and they seem to interfere with one another… not necessarily surprising. My dim red will briefly flash to the white LEDs before resuming it’s slow brightening and then another flash of white… not really a soothing sunrise. lol Is there an easy way to “engage/disengage” the CL script at a certain time? That way I could have it take over after my sunrise and then “give up control” to the bedtime “sunset.”

Question #2 - is there a way to “bias” the CL more towards blue in the early morning? As I understand it, blue light helps you wake up faster. Before I got this script working I had my “sunrise” transition to Cool White; would be nice if I could do the same in CL… otherwise I’m sure I can make it work if there’s a ready answer to Q1.

Thanks!!

#1 yes
The Switches can be turned off from node red HA integration

On the entities page in HA search for the circadian Switches

Is this normal? I’m just starting to play around with this, and my brightness stays at 100% for all three of my switches… Shouldn’t it vary with the movement of the sun? I know this is a small dataset, but there is no variation.

Here is my config:

circadian_lighting:
  min_colortemp: 2100
  max_colortemp: 4000

switch:
  - platform: circadian_lighting
    name: color_temp
    lights_ct:
      - light.living_room_ceiling_light_1
      - light.living_room_ceiling_light_2
      - light.living_room_ceiling_light_3
    min_brightness: 5
    max_brightness: 100
    disable_entity: input_boolean.circadian_lighting
    disable_state: 'off'

As long as the sun is above horizon brightness stays at 100%

@bernhard Thanks. Ok, it’s starting to make sense to me now
image

I wonder if I lower my elevation so the the horizon is higher in the sky if I can adjust it so that the brightness doesn’t peak until later.

After updating to v2.0.0b I see this error, and the lights don’t change in color:

Log Details (ERROR)
Logger: homeassistant
Source: custom_components/circadian_lighting/switch.py:381
First occurred: 8:24:57 PM (9 occurrences)
Last logged: 8:24:57 PM

Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/config/custom_components/circadian_lighting/switch.py", line 381, in _light_state_changed
    if to_state.state == "on" and from_state.state != "on":
AttributeError: 'NoneType' object has no attribute 'state'

What are you using to get “brightness” and “circadian_CT” in your graphs? I can’t figure it out.

Don’t know if i’m stupid or not, but what mode are you supposed to use when?

Been playing around with lights_ct, lights_rgb and lights_xy on an WLED (https://github.com/Aircoookie/WLED) RGBW strip.

Regardless of method I get similar, but not exactly the same, color. In some of the modes the “white value” does not change by this addon, but in others it does.

What mode am I supposed to run to get the most accurate color and how do I know?

I’ve been using light_xy for my RGBW WLED strip. Seems to work well.

This should be fixed in 2.0.1b.

That’s a history graph card - there are a couple ways to get the attributes as states for the graph; you could use template sensors, or use custom lovelace cards that allow for using templates directly in lovelace, etc.

Basically lights_ct is best because color temperature is the proper measurement for the intended outcome and what you are ultimately trying to achieve. Also, for lights with designated white diode (RGBW), sending ct usually results in the R, G, B diodes to be off and only the W diode to be used which it typically more visually pleasing. lights_rgb and lights_xy use some formulas to estimate color equivalent to color temperature so they aren’t as accurate, but they are included so that color lights without color temp options can still be used. lights_brightness is there for dimming-only lights, or if you only want the brightness to be set.

@claytonjn

Thanks for this awsome component. I’ve been using it for a couple of weeks and I’m really loving it.

I have a question, and am looking for some advice. I’ve created a simple Node-RED flow to turn a LIFX globe on at a certain time, at brightness: 1, and then transition it to maximum brightness over a preiod of half an hour. The problem is, whenever the flow triggers, the light turns on, then shortly after it suspends its brightness transition and is stuck at a low brightness; until manually adjusted.

I just did a test where I turned off the Circadian Lighting component and the flow worked as intended. Is there a way around this, so Circadian Lighting can continue to be turned on over the half hour while the transition occurs? Below are my config entry and Node-Red flow if that helps.

Once again, thanks for all the effort you have put into this component; it’s really nice!

Node-RED Flow

Switch.yaml

- platform: circadian_lighting
  lights_ct:
    - light.drums
    - light.grey_lamp
    - light.brass_lamp
    - light.tall_lamp
  disable_brightness_adjust: true
  name: Circadian Lighting

Awesome! Thanks for the very detailed explanation.

I did find that I liked lights_xy more, but will continue to test. And yes, when I included other lights it became obvious why some modes were needed.

As far as I know there are no lights than can simultaneously hand two different transition requests - so there’s no way that CL can adjust color temperature while the brightness transition continues to occur. Your only option would be to take the same approach as CL and rather than sending a single 30 minute transition you send a number of short intermediary transitions (e.g. send new brightness every second)

1 Like

Good to know, I’ll have a play around and see what I can come up with.

Thanks for the help!

Thanks for this info Clayton. I’ll try changing mine to use lights_ct and see if it fixes my issue of pink downlights during the day (when the LED strip is showing white).

I can confirm, fixed in v2.0.1b, thanks!

Is there a way to bias this CL plugin “earlier” somehow? The bulb CT is quite warm when I wake up in the morning and I’d love for it to be cooler since blue light is excellent for helping you wake. Similarly, it’s almost my bedtime and the CT is still 370; I’d love for it to be 500 by now. See what I mean about shifting the whole cycle earlier?
Edit - I’m looking in _init_.py and thinking it’s probably something to do with sunrise_offset but I’m not sure how or where to edit that to perhaps make the script think everything is happening (two hours?) earlier than it is… I’d hate to just put a “+2” on the end of a line somewhere and break the whole thing.

Thanks for your thoughts!

sunrise_offset and all other configuration options are outlined here.

Recently, I have spent a lot of time in rewriting the fantastic cirdadian_ligthing component. About 600 lines are rewritten! (see all changes here) :tada:

In summary, I have added the functionalities:

  • add only_once option to switch, which makes the light change to the correct value only when turning it on (or disabled_state, sleeping_state switch). This is useful when you want to manually change the settings of the lights sometimes and make it stay.
  • add the ability to make sleep_state and disable_state lists of options. For example when using an input_select where something should be disabled on multiple states. This is a non-breaking change because it also accepts just a single string.
  • simplified the dependencies (making it easier to install)
  • the integration is now fully async, which means that when adjusting the lights, all lights get the service call simultaneously!

I encourage everyone to try out the latest beta 2.0.1b (on HACS too). Please open an issue if you have any problems.

7 Likes

I’m using template sensors:

sensor:
  - platform: template
    sensors:
        circadian_lighting_ct_brightness:
        entity_id: sensor.circadian_values
        value_template: >-
          {{ state_attr("switch.circadian_lighting_living_room_main","brightness") }}
        unit_of_measurement: '%'
      circadian_lighting_ct_kelvin:
        entity_id: sensor.circadian_values
        value_template: >-
          {{ state_attr("sensor.circadian_values","colortemp") | round }}
        unit_of_measurement: 'K'