Circadian Lighting [Custom Component]

I’m not sure how easy it would be to implement that option to be honest - when a switch entity is off it can’t really do anything, including turning itself on.

There are a few ways you can control the switch:

  • Add it to Lovelace or view it under Unused entities
  • View it on the States page of Developer Tools
  • Call the turn_on services on the Services page of Developer Tools
  • Use an automation to call the turn_on service
  • Use Node-RED to call the turn_on service
  • etc…

Once you’ve switched it on, it should stay on until turned off again. If you want to you could also have an automation turn it on when HA starts to make sure it’s on.

Great, thanks. Up and running and couldn’t be more thrilled. Thank you again for building this!

Hello there. What calculations are the xy-values based on?

I maybe have missed something. But 0.561,0.39 translates to 1733 Kelvin? That in combination with colortemp: 2362 doesn’t make sense to me.

The homeassistant.util.color function color_temperature_to_rgb() is used to convert the color temperature to RGB, then color_RGB_to_xy() is used to convert the RGB value to XY.

Those functions can be found here: https://github.com/home-assistant/home-assistant/blob/1de002013fbb11bc2dc988743a5c17a81fa6cdbf/homeassistant/util/color.py

I appreciate all the work you’ve done to bring us this component, I’ve been wanting something like this for a long time!

I’ve just recently set up some new lights, I’m using deCONZ on a Conbee 2, with Philips Hue White Ambiance bulbs. I have also set up the “power on” default values for the Hue lights with a warm white and 50% brightness (my goal is to have the default value be “night time safe”, so that the delay between the bulb powering on and Circadian Lighting taking control of the light can be covered without accidentally being a cool white temperature at night).

My understanding from the wiki and from your post from Nov 12, 2018, is that when the light comes online after receiving mains power, that Circadian Lighting should be listening for the light to be detected as on in HA, and then update the light to the correct light values based on the time of day.

This is not the behavior I’m seeing, however, if I turn on power to one of the lights, it’s status goes from “unavailable” to On very quickly, and the HA card even shows the warm white color, so it’s definitely detecting that the light is on and the current color temperature, however the Circadian Lighting does not update the color temperature of the bulb when this happens, instead it only updates on the next “interval” (I’m using the default value, so every 5 minutes). This means when I power on a bulb it takes up to 5 minutes for the correct color to be shown, which is not the behavior I want… obviously I could set the “interval” setting to be much shorter, but it seems like that shouldn’t be necessary given the descriptions of how the component is supposed to “listen” for the bulb on “event”.

Even if I turn the “not yet colored correctly” bulb off (and pause for 30 seconds) and then back on using the HA switch, Circadian Lighting doesn’t pick up the state change and update the color… (but turning the “Circadian Lighting” switch off and back on does correctly update all bulbs).

I know you said the recommendation is to leave the bulbs “hot at all times”, but since I currently rent I can’t easily change the switch out, and getting a separate “smart switch” to use instead of the normal bedroom lightswitch isn’t really going to fly with the wife. I can accept that there may be a delay between the light getting mains power and Circadian Lighting updating it with the correct color (that’s why I specifically got the Hue lights so I can set the default power on value), but it seems like the component isn’t working the way it’s supposed to with regards to “listening” to the “light on” event.

Any assistance you can offer to me for getting this component to function the way I’m wanting (or clarification if I’ve misunderstood something about how it’s intended to work) would be appreciated.

Are the circadian switches that you created, on? Please check this in Developer Tools - States.

When yes, please show us your configuration.

Aha! I only have one Circadian Switch created, but in reviewing it I realized I had added the light groups to this switch, instead of the individual lights, which explains why it wasn’t picking up the power-on “event”, because the group itself wasn’t actually changing state (since there were other lights still on in the group). Updating my configuration to list the individual bulbs below the circadian_lighting switch resolved the issue, and my lights now properly adjust within seconds of being turned on.

Thanks for the quick response on this, sorry I somehow missed that while troubleshooting, but hopefully my issue will help others in the future who maybe make the same mistake! :wink:

Hi,

I just started using this custom component and it works nicely with my sensor based lighting.

I will be adding physical buttons (hue dimmmer) later and want them to override Circadian Lighting for the lights the button turns on until turned off again. I tried to search the topic but couldn’t find a solution for this. I know there is disable_state option to use but that disables the Circadian Lighting switch completely. I would like it to disable only for certain entities when hue dimmer is turned on. Is there anyone who has done this and can help out?

E: I just figured out the solution to this. I will make switches for all the groups of lights controlled by physical buttons. That way I can disable the switch for only the lights I want while the rest remain on when I use physical button.

Is it possible to set parameters like min. brightness per light - i.e. I have a few lights in the living room and would like to have at least one remain a bit brighter than the rest?

Yup, just configure that light in a different CL switch.

1 Like

hey folks, i used to use this on my hue (worked great!) but recently moved to MQTT Tasmota lights which use a color temp range 183 (white) - 500 (warm). Also as the light is MQTT it can take the

I cant seem to figure out if the conversion is done in the HA backend (as the custom component requires an integer greater than 1000

The configuration is in kelvin and I’m guessing the Tasmota range is in mireds. The conversion should happen in the backend, but to know what values to use in CL you just have to use the formula kelvin = 1,000,000 / mireds. So 183-500 mired would be 2000-5464 kelvin.

1 Like

excellent, thank you :smiley:

Any thoughts on integrating this into an official integration? I wonder if a user could set this up with the new integration UI.
It could be set up through the drop down menu by selecting ‘Circadian Lighting’, and then show every light available. The user could then add the values they want for each light (or not enable it for a certain light)?
Seems like a highly used component, and well written to!

I would love to. The biggest issue is that it really shouldn’t be creating switch entities because those are intended for physical switches (plus the frontend would ideally have a toggle for both brightness and color temp adjustment, allowing to disable one or the other or both). I’ve asked around a bit in discord for suggestions on what would be best for official integration but there didn’t seem to be a whole lot of interest so I gave up.

EDIT: I believe the UI integration setup could be implemented without being an official integration, but I just haven’t had time to look into that.

oh no, that’s a shame you didnt get more help :frowning: I feel like the integration UI seems to be the way to go for simple implementation aligning to HA’s strategy.

Do users actually use the switches for this? or are they just using the sleep setting?
Was the feedback not to use switches? as I have created a bunch of switches that control stuff like turning on Netflix on my Fire TV so i can create a button on my Lovelace UI.
I guess you could have a setting in each light within the integration…

light.blah
#Integration settings...
color temp min:2000
color temp max: 5464
sleep brightness: 6
sleep color temp: 5464
sleep entity: input_boolean.blah
enable brightness switch entity: false
enable colortemp switch entity: true

this way the switch entity can may or may not be created based on user preference?

Right now the team is working really hard to make things easy to use out of the box. The issue with switches is that novice users expect a switch to turn something “physical” on/off. There are a lot of switches that don’t follow that paradigm, but based on the feedback I got from the main developer of the Flux integration (which is the closest thing to this) there has been expressed displeasure about switch entities being used. These type of components are in a grey area, where they’re really like Automations or Scripts, but those are defined completely differently.

Really the best solution is for CL to be integrated to the level of something like Automations where it has a separate section in the Configuration page. Unfortunately I just don’t have time to devote to figuring all that out.

Fair enough - well I appreciate you building this either way! Very nice, and in fact so good the family don’t notice it happening.

As a side note back from the SmartThings days I seem to remember a few different switch types (momentary switch, switch). Maybe there is room for a new switch that other developers could leverage.

Like others have earlier mentioned, this component doesn’t work correctly with Ikea Trådfri color temperature lights, because they can only adjust either color or brightness within one command, but not both simultaneously.
I didn’t have luck with the proposed solution for splitting Ikea Trådfri lights into “CT Circadian” and “Brightness Circadian”.
But what I did, and had success, was defining Circadian lighting only for the ‘brightness’ and Flux Light Adjustment for ‘color temperature’:

Is there something that could be done to Circadian lightning component that could give the same results that these two combined?

switch:
  - platform: flux
    lights:
      - light.ikea_light_1
      - light.ikea_light_2
      - light.ikea_light_3
    name: Ikea Lights Colour
    stop_time: '00:00'
    start_colortemp: 5000
    sunset_colortemp: 3000
    stop_colortemp: 2000
    disable_brightness_adjust: true
    mode: xy
    transition: 5
    interval: 30

  - platform: circadian_lighting
    name: Ikea Lights Brightness
    lights_brightness:
      - light.ikea_light_1
      - light.ikea_light_2
      - light.ikea_light_3
    min_brightness: 7
    max_brightness: 100

I actually just had a thought, that may fix this issue without significant negative impact. I could have the brightness adjustment and the color temperature adjustment staggered. For example, if you have an interval configured of 10 minutes, the brightness adjustment and the color temperature would be offset by 5 minutes, each individually adjusting every 10 minutes.

What do people think, would that be a good change?

  • Yes
  • No

0 voters

I diy built this using automations. I think a configurable delay would be nice. First change brightness, that should take priority in my opinion, above color temperature. My delay is just 5 seconds,then color temperature shifts. Works great for Tradfri.

1 Like