Circadian Lighting [Custom Component]

I had a similar issue … because my timezone settings were messed up in docker. Did you check yours are correct, in whatever way you run HA ?

The first warning is generated by Home Assistant for any custom component, it doesn’t indicate a problem. The second warning should be resolved in CL 1.0.4.

1 Like

I just started playing around with this but haven’t perfected the settings just yet. How do I control / fine adjust brightness other than set a min and max brightness value on a switch? I have a deconz night scene where the lights a dim and warm yellow. Tonight I flipped on one of the CL switches to see the difference it would be from my scene to what CL would do. And colorwise it’s what I set it up for. But all bulbs turned 100% brightness. Even though it was late at night. I have that group set to min 20 and max 100, because of course I want the bulbs to be able to be bright at the middle of the day.

What am I doing wrong?

One of my switches

  - platform: circadian_lighting
name: Living room
lights_rgb:
  - light.sang_tak
  - light.fonsterbrade
  - light.taklampa
  - light.matbord
  - light.tv
lights_ct:
  - light.skrivbordslampa
min_brightness: 20
max_brightness: 100

What value did sensor.circadian_values show at that time? Also, anything in the logs? Debugging instructions.

Hm. I only got “sensor.circadian_values” and the switches. Strange. What have I been missing/doing wrong?

Edit:
But the info only mentions one sensor…hm, so I guess maybe you just ment sensor.circadian_values?

I’ll have a look tonight again, thanks.

Edit 2:

So this is what I get, and its now 22:07 where I live. Still same behavior.

Yes, I did mean sensor.circadian_values, sorry!

Based on the graph, the lights should dim between approximately 0:00 and 5:00 (the section of the graph below 0). Is sunset at your location ~22:00 and sunrise ~5:00?

I’m stupid - I removed the sunset offset and now it’s working as intended. Sorry for all confusion. Now I just have to fine adjust all things, I would love to have different settings for different days and weekends.

Thanks for your help.

Edit:

I realized that I would like to be able to not only set brightness max min on a switch/group but also color max min. I realize that some might say that this would work counter to the actual purpose of the Circadian lighting with synced color temp. But when having mixed bulbs (brands, color, white spectrum) and also different usage for different bulbs I would like this feature to be optional.

Also using it for now - But only the values - Got 2 Instances running (one “proper” server and a pi) witch makes stuff harder. so i gone for an automation with the Circadian values.

automation:
- alias: 'circadian test'
  trigger:
    - platform: state
      entity_id: light.sz_lightstrip_plus
      to: 'on'
    - platform: time_pattern
      minutes: 15
  condition:
    - condition: state
      entity_id: light.sz_lightstrip_plus
      state: 'on'
  action:
    - delay: '00:00:02'
    - service: light.turn_on 
      entity_id: light.sz_lightstrip_plus
      data_template: 
        transition: 5
        xy_color: [ "{{states.sensor.circadian_values.attributes.xy_color[0]|float}}", "{{states.sensor.circadian_values.attributes.xy_color[1]|float}}" ]

Zigbee2MQTT doesn’t like the custom component very much.
with 12 lights It is hitting the Mosquittto server on the pi to hard.

Right, so the component installed fine, and doesn’t error all over my logs.
sensor.circadian_values shows a lovely number and graph.
I replaced the list with bulbs that support a variety of brightness/colour commands.

Then I left my lights on, watched the sensor.circadian_values change, and… nothing happened to my bulbs. For an entire evening. Is there another step I’m missing here?

1 circadian_lighting:
2   max_colortemp: 5000
3   min_colortemp: 2857
4   interval: 600
5   transition: 3
6 
7 switch:
8   - platform: circadian_lighting
9     name: "Circadian"
10     lights_ct:
11       - light.master_bedroom_reading_light
12       - light.master_bedroom_ceiling_light
13       - light.bathroom1
14       - light.bathroom2
15       - light.living_room_reading_light
16       - light.living_room_light
17       - light.office1
18     min_brightness: 1
19     max_brightness: 100
20     sleep_entity: input_boolean.b_circadian_sleepmode
21     sleep_state: "on"
22     sleep_colortemp: 5500
23     sleep_brightness: 18
24     disable_entity: sensor.wohnzimmer_tado_mode
25     disable_state: AWAY

Hmm, config looks good - I assume your sensor.wohnzimmer_tado_mode was not in AWAY state…was the switch switch.circadian_lighting_circadian turned on?

I added the switch.circadian_lighting_circadian to my lovelace, and get the error: Failed to call service switch/turn_on. 'NoneType' object has no attribute 'state'

1 Like

Okay, that must not be the correct entity_id then. If you go to the dev-state page (<> icon at the bottom of the left menu) do you see the Circadian Lighting switch in the list of entities? You should be able to enter switch.circadian_lighting in the filter entities box to narrow down the list.

it’s switch.circadian_lighting_circadian… strange.

Here’s the device state (I renamed back to ‘wohnzimmer’ just in case it was a hardcoded thing somewhere, same error)

So it was off before? Is it working now?

It’s still giving the same error, but it APPEARS to be on. Perhaps this is a cosmetic thing. I’ll adjust some values and see if I can get it to trigger.

You can follow the instructions here to turn on debug logging - that should help figure out exactly what’s going on.

OKAY something fixed it. Probably be trimming off most of the extra config options like the sleep bit.

Thanks for the help!

I just pushed an update to __init__.py to the dev branch, here. It’s a complete re-write of how the values are calculated. It’s much simpler math, should remove any potential for values to be set below/above the min/max, and should remove the possibility for any “jarring” changes.

I’ve been running this code for 24+ hours now on my system and it’s working as expected, but I want to give it a few more days before I push the update out. Anyone willing to test would be appreciated - especially if you configured a sunrise or sunset offset or time, or if you’ve experienced values falling outside of the configured min/max or any other “weirdness”.

If you do test let me know in a couple days how it’s been working for you! Thanks!

1 Like

You should probably post a reminder here in a couple days because I’ll probably forget to reply with feedback :laughing::man_facepalming: