Circadian Lighting [Custom Component]

TY for your response, and your time spend to develop this fantastic component.
I’m trying too via Node red compare the value of sensor circadian. How he calcul his state ?

thats what I see there:

2020-06-08 14:47:25 DEBUG (SyncWorker_4) [custom_components.circadian_lighting.switch] light.led_strip_kinderzimmer change from <state light.led_strip_kinderzimmer=off; min_mireds=153, max_mireds=500, effect_list=['colorloop'], is_deconz_group=False, friendly_name=LED Strip Kinderzimmer, supported_features=63 @ 2020-06-08T15:46:10.400472+02:00> to <state light.led_strip_kinderzimmer=on; min_mireds=153, max_mireds=500, effect_list=['colorloop'], brightness=254, hs_color=(26.25, 43.922), rgb_color=(255, 191, 142), xy_color=(0.454, 0.371), is_deconz_group=False, friendly_name=LED Strip Kinderzimmer, supported_features=63 @ 2020-06-08T15:47:25.333773+02:00>
2020-06-08 14:47:25 DEBUG (SyncWorker_4) [custom_components.circadian_lighting.switch] light.led_strip_kinderzimmer XY Adjusted - xy_color: (0.367, 0.348), brightness: 254, transition: 1.0, white_value: 254
2020-06-08 14:47:25 DEBUG (SyncWorker_0) [custom_components.circadian_lighting.switch] light.led_strip_kinderzimmer change from <state light.led_strip_kinderzimmer=on; min_mireds=153, max_mireds=500, effect_list=['colorloop'], brightness=254, hs_color=(26.25, 43.922), rgb_color=(255, 191, 142), xy_color=(0.454, 0.371), is_deconz_group=False, friendly_name=LED Strip Kinderzimmer, supported_features=63 @ 2020-06-08T15:47:25.333773+02:00> to <state light.led_strip_kinderzimmer=on; min_mireds=153, max_mireds=500, effect_list=['colorloop'], brightness=254, hs_color=(26.667, 17.647), rgb_color=(255, 230, 210), xy_color=(0.367, 0.348), is_deconz_group=False, friendly_name=LED Strip Kinderzimmer, supported_features=63 @ 2020-06-08T15:47:25.333773+02:00>

so from the log it looks ok, and when I compare the set values (state) of the LED Strip with that of the light bulbs, the values are identical, but the color output of the two is so different. as said, the LED strip is very very blue, compared to the bulb.

So I assume you set the color in a different way than flux does?

I’m using this automation to compare the current color temperature of 3 lights to that of my ‘circadian sensor’. When they are not the same, I disable my ‘circadian’ switch. To clarify: I’m not using this circadian custom component but my own DIY alternative. But I think the basic principle can be applied for your request as well, the value templates might be useful.

- alias: 'Turn off automatic (circadian) colortemp' # after external change through Google Home or Tradfri app
  trigger:
    - platform: template
      value_template: >
        {{ states('light.keukentafel') == 'on' and (state_attr('light.keukentafel','color_temp')|float - states('sensor.colortemperature')|float) | abs | int > 10 }}
    - platform: template
      value_template: >
        {{ states('light.trio_woonkamer') == 'on' and (state_attr('light.trio_woonkamer','color_temp')|float - states('sensor.colortemperature')|float) | abs | int > 10 }}
    - platform: template
      value_template: >
        {{ states('light.woonkamer_plafond') == 'on' and (state_attr('light.woonkamer_plafond','color_temp')|float - states('sensor.colortemperature')|float) | abs | int > 10 }}
  condition:
    - condition: state
      entity_id: timer.light_colortemp_auto_set
      state: 'idle'
  action:
    - service: input_boolean.turn_off
      entity_id: input_boolean.automatic_colortemp

Edit: I forgot to mention the condition, added it above. In my DIY approach, whenever I’m changing a color temperature using a transition, I start a timer for the transition time (timer.light_colortemp_auto_set). While that timer is running, this automation won’t trigger.

2 Likes

It looks like you have the lights configured under lights_xy, have you tried one of the other options?

TY i try it. Don’t succeed for moment but i know where beggining

Seems the Gledopto driver is tricky in that it does not like multiple commands at once. It does not properly turn off for example, one has to do this a few times. At least when run with deCONZ

Going to replace them with Dresden electronic ones and report back. Thanks for your help so far!

Hi All
With the recent update, my light color does not seem to be updating correctly. Maybe the location is not being Referenced correctly?
Any help would be appreciated.
Thanks!

The new version does include an update that is supposed to normalize times/timezones. Does the sensor show color temperature changing? Also, take a look at the logs, they might shed some insight: https://github.com/claytonjn/hass-circadian_lighting/wiki/Debugging

Thank you @claytonjn. It looks like the circadian integration is controlling the brightness but not the color temperature of the Yeelight light bulbs. I did not change anything on the Yeelight configuration so I am not sure what happened here.

As far as logs - it looks like circadian is trying o change the color… but not doing anything.

So to confirm, at the time you pulled that log those three lights were not set to 157 mired, or they were set to 157 mired but that color was incorrect?

@claytonjn So I replaced the Gledopto Zigbee driver with a Dresden Electronic one and it behaves even more strange :slight_smile:

image

When I go to the details, I see that the color itself is set to white and color temperature is set to something very cool:

I set the mode to lights_ct, as mired is supported according to the screenshots above:

  - platform: circadian_lighting
    name: Blaues Zimmer
     #min_brightness: 100
    lights_ct:
      - light.kinderzimmer_kasten

and this I see in the log


2020-06-17 10:29:26 DEBUG (SyncWorker_18) [custom_components.circadian_lighting.switch] light.kinderzimmer_plafond change from None to <state light.kinderzimmer_plafond=unavailable; min_mireds=153, max_mireds=65535, effect_list=['colorloop'], friendly_name=Kinderzimmer Plafond, supported_features=63 @ 2020-06-17T11:29:26.120587+02:00>
2020-06-17 10:29:26 DEBUG (SyncWorker_16) [custom_components.circadian_lighting.switch] light.kinderzimmer_kasten change from None to <state light.kinderzimmer_kasten=unavailable; min_mireds=153, max_mireds=500, effect_list=['colorloop'], friendly_name=Kinderzimmer Kasten Lightstrip, supported_features=63 @ 2020-06-17T11:29:26.151186+02:00>

...


2020-06-17 10:24:40 DEBUG (SyncWorker_13) [custom_components.circadian_lighting.switch] light.kinderzimmer_kasten CT Adjusted - color_temp: 185, brightness: 254, transition: 60.0

the problem seems to be that the strip consists of two devices, one for the RBG Part and one for the White part. I tried the following:


  - platform: circadian_lighting
    name: Blaues Zimmer
     #min_brightness: 100
    lights_ct:
      - light.kinderzimmer_kasten
    lights_brightness:
      - light.kinderzimmer_led_strip
   

with a similar result in that the light is very bright and white:

image

as soon as I disable circardian and enable flux, it looks good:

image

I finally tried to create a group within deCONZ, consisting of an Innr Bulb and the dresden light strip controller. I then adressed the deCONZ group with circadian, like that:


  - platform: circadian_lighting
    name: Kinderzimmer
    lights_ct:
      - light.kinderzimmer

strangely enough, this does not work either and ends up with the ugly blue light for the LED strip

I’m not sure what the issue is related to exactly and there don’t appear to be any logs relating to it but since I updated from HA 0.110.7 to 0.111.x I’m noticing some erratic flickering and lights not going to the correct CL setting straight away.

Has anyone else noticed this?

Hmm, this is quite a mystery. The first thing that sticks out to me is this from the first line in the log: max_mireds=65535 - what is light.kinderzimmer_plafond, is that at all related? 65535 mireds is 15 kelvin, which I’m not even sure is a possible value for color temperature. It looks like flux uses mireds for it’s color temperature adjustment, which is also what CL uses. I have no idea what could result in the difference. Does flux have any logs that we could compare to?. I’m curious, if you have both flux and CL disabled for this light and you send two service calls, one with color_temp: 250 and one with kelvin: 4000, does the light look the same or does it give different results?

I personally haven’t but I somehow don’t have any “smart” lights in my home office where I’ve been spending all of my time.

good morning,

light.kinderzimmer_plafond is only related insofar, as it is controlled by the same circadian switch, but its an innr bulb that works perfectly fine with circadian.

I will try your suggestion in the evening, thanks

Anyone having issues with CL on HA 0.111.4 ? I just installed via HACS (and dobule checked MD5 sums of all files in custom_components/CL - OK), as soon as I add circadian_lighting: to my configuration.yaml HA cannot start completely and all entities are not loaded - all addons are OK but everything else is in loading mode for 5/10 mins even though it’s HASSio on VM 4 GB RAM / SSD…

No errors in logs - looks like component cannot be loaded up and stops all other components from loading up during that new startup process introduced in 0.111

It’s working for me (with issues, more on that in a separate comment in a moment) with 0.111.3. I haven’t tried 0.111.4 yet.

@claytonjn Have you thought about changing the on_level for lights rather than only changing the brightness? I have a poor-mans version of this module that I have been doing with programs on my ISY where I do that. It is much simpler than your module, I just change the on-level for a handful of lights at set intervals after sunset and before sunrise.

It seems like utilizing the on_level with Circadian Lighting would help solve the issue of lights turning on and then changing levels unexpectedly (i.e. I turn on my bathroom light in the evening, it comes on full brightness, then dims down once your module reacts to the on event).

And now the problems I’m having…

I’m currently on HA 0.111.3 with Circadian Lighting 1.0.13 installed from HACS.

I’m getting inconsistent lighting levels for lights in the same configuration in Circadian Lighting. For example, I have this configuration:

- platform: circadian_lighting
  name: circadian_lighting_main
  lights_xy:
    - light.piano_room_table_lamp
  lights_rgb:
    - light.piano_room_table_lamp
  lights_brightness:
    - light.great_room_table_lamplinc
    - light.great_room_switch
    - light.foyer_light_switch

However when I have both the great room table lamlinc and the great room switch (which controls my hall light) on, one might be at 60% and the other at 40%. Even stranger, last night at 8:30pm, it kept turning the table lamp back to 100% when i would turn it on. Here is the debug log from the table lamp:

2020-06-17 20:19:51 DEBUG (SyncWorker_8) [custom_components.circadian_lighting] now: 2020-06-17 20:19:51.051905-07:00
2020-06-17 20:19:51 DEBUG (SyncWorker_8) [custom_components.circadian_lighting] Astral location: name/region, tz=Europe/London, lat=37.30, lon=-121.76
2020-06-17 20:19:51 DEBUG (SyncWorker_8) [custom_components.circadian_lighting] today_sun_times: {'sunrise': datetime.datetime(2020, 6, 17, 5, 45, 55, tzinfo=<DstTzInfo 'America/Los_Angeles' PDT-1 day, 17:00:00 DST>), 'sunset': datetime.datetime(2020, 6, 17, 20, 30, 25, tzinfo=<DstTzInfo 'America/Los_Angeles' PDT-1 day, 17:00:00 DST>), 'solar_noon': datetime.datetime(2020, 6, 17, 13, 8, 10, tzinfo=<DstTzInfo 'America/Los_Angeles' PDT-1 day, 17:00:00 DST>), 'solar_midnight': datetime.datetime(2020, 6, 17, 1, 8, 21, tzinfo=<DstTzInfo 'America/Los_Angeles' PDT-1 day, 17:00:00 DST>)}
2020-06-17 20:19:51 DEBUG (SyncWorker_8) [custom_components.circadian_lighting] now_seconds: 1592450391.051905
2020-06-17 20:19:51 DEBUG (SyncWorker_8) [custom_components.circadian_lighting] sunrise_seconds: 1592397955.0
2020-06-17 20:19:51 DEBUG (SyncWorker_8) [custom_components.circadian_lighting] sunset_seconds: 1592451025.0
2020-06-17 20:19:51 DEBUG (SyncWorker_8) [custom_components.circadian_lighting] solar_midnight_seconds: 1592381301.0
2020-06-17 20:19:51 DEBUG (SyncWorker_8) [custom_components.circadian_lighting] solar_noon_seconds: 1592424490.0
2020-06-17 20:19:51 DEBUG (SyncWorker_8) [custom_components.circadian_lighting] h: 1592424490.0
2020-06-17 20:19:51 DEBUG (SyncWorker_8) [custom_components.circadian_lighting] k: 100
2020-06-17 20:19:51 DEBUG (SyncWorker_8) [custom_components.circadian_lighting] x: 1592451025.0
2020-06-17 20:19:51 DEBUG (SyncWorker_8) [custom_components.circadian_lighting] y: 0
2020-06-17 20:19:51 DEBUG (SyncWorker_8) [custom_components.circadian_lighting] a: -1.420240248550565e-07
2020-06-17 20:19:51 DEBUG (SyncWorker_8) [custom_components.circadian_lighting] percentage: 4.721125028941145
2020-06-17 20:19:51 DEBUG (SyncWorker_8) [custom_components.circadian_lighting] Circadian Lighting Component Updated
2020-06-17 20:19:51 DEBUG (SyncWorker_2) [custom_components.circadian_lighting.switch] circadian_lighting_main Switch Updated
2020-06-17 20:19:51 DEBUG (SyncWorker_2) [custom_components.circadian_lighting.switch] circadian_lighting_masterbath Switch Updated
2020-06-17 20:19:51 DEBUG (SyncWorker_2) [custom_components.circadian_lighting.switch] circadian_lighting_masterbath off - not adjusting
2020-06-17 20:19:51 DEBUG (SyncWorker_17) [custom_components.circadian_lighting.sensor] Circadian Lighting Sensor Updated
2020-06-17 20:20:26 DEBUG (SyncWorker_7) [custom_components.circadian_lighting.switch] light.great_room_table_lamplinc change from <state light.great_room_table_lamplinc=off; ramp_rate=4.5 seconds, on_level=70%, last_brightness=179, friendly_name=Great Room Table LampLinc, supported_features=1 @ 2020-06-17T20:19:25.789003-07:00> to <state light.great_room_table_lamplinc=on; brightness=179, ramp_rate=4.5 seconds, on_level=70%, last_brightness=179, friendly_name=Great Room Table LampLinc, supported_features=1 @ 2020-06-17T20:20:26.021602-07:00>
2020-06-17 20:20:26 DEBUG (SyncWorker_7) [custom_components.circadian_lighting.switch] light.great_room_table_lamplinc Brightness Adjusted - brightness: 254, transition: 1.0
- platform: digitalloggers
2020-06-17 20:20:26 DEBUG (SyncWorker_17) [custom_components.circadian_lighting.switch] light.great_room_table_lamplinc change from <state light.great_room_table_lamplinc=on; brightness=179, ramp_rate=4.5 seconds, on_level=70%, last_brightness=179, friendly_name=Great Room Table LampLinc, supported_features=1 @ 2020-06-17T20:20:26.021602-07:00> to <state light.great_room_table_lamplinc=on; brightness=254, ramp_rate=4.5 seconds, on_level=70%, last_brightness=254, friendly_name=Great Room Table LampLinc, supported_features=1 @ 2020-06-17T20:20:26.021602-07:00>
2020-06-17 20:20:27 DEBUG (SyncWorker_0) [custom_components.circadian_lighting.switch] light.great_room_table_lamplinc change from <state light.great_room_table_lamplinc=on; brightness=254, ramp_rate=4.5 seconds, on_level=70%, last_brightness=254, friendly_name=Great Room Table LampLinc, supported_features=1 @ 2020-06-17T20:20:26.021602-07:00> to <state light.great_room_table_lamplinc=on; brightness=255, ramp_rate=4.5 seconds, on_level=70%, last_brightness=255, friendly_name=Great Room Table LampLinc, supported_features=1 @ 2020-06-17T20:20:26.021602-07:00>
2020-06-17 20:21:50 DEBUG (SyncWorker_8) [custom_components.circadian_lighting.switch] light.great_room_table_lamplinc change from <state light.great_room_table_lamplinc=on; brightness=255, ramp_rate=4.5 seconds, on_level=70%, last_brightness=255, friendly_name=Great Room Table LampLinc, supported_features=1 @ 2020-06-17T20:20:26.021602-07:00> to <state light.great_room_table_lamplinc=off; ramp_rate=4.5 seconds, on_level=70%, last_brightness=255, friendly_name=Great Room Table LampLinc, supported_features=1 @ 2020-06-17T20:21:50.254788-07:00>

This morning I had something similar happen with my bathroom light, it kept dimming it down to 30% even though it was several hours after sun-up.

Any idea what might be going on?