Circadian Lighting [Custom Component]

@claytonjn - Hiya, thanks for your help.
I made the changes you suggested, but HASS wasn’t a fan of me using

(state_attr('sensor.circadian_values','colortemp') | float )

I got an error saying it needs an int, not a float.

Invalid data for call_service at pos 1: expected int for dictionary value @ data['kelvin']

I’ve changed this to stop the errors …

kelvin: "{{ (state_attr('sensor.circadian_values','colortemp') | int ) }}"

… but cant help feel that I’m also maybe losing some colour temp accuracy by converting from float to int.

When the CL component adjusts the colour temperature for lights_ct, does it also do it as an int or is it able to adjust using a float?

Thanks again! :+1:t2:

I have some RGBW downlights and an RGBW LED strip all setup as XY lights in CL. The LED strip gives a daytime colour that I expect, near full white, however the downlights are never white, but pink. The only difference I can tell between the two types is that the LED strip needs the brightness set to at least 1 in order to show any white value (ie: white value at max but colour brightness 0 gives no light at all) whereas the downlights will happily give a white light with the colour brightness at 0 and then the white brightness is controlled with the while value.

Any ideas what I can change to get the downlights to give white light during the day (other than disabling CL)

Sorry, was out on the roof all day and a bit sloppy with the copy/paste. CL converts to int, but it sends mired not Kelvin so to match exactly you’d actually want to do:

color_temp: "{{ ((1000000/state_attr('sensor.circadian_values','colortemp')) | int ) }}"

I’d be very surprised if you could tell the difference between rounded and non-rounded Kelvin values though or the difference between rounded and non-rounded mireds (which inherently has less accuracy because it’s a smaller range).

1 Like

The only real options you have are to try different adjustment methods (ct/rgb/xy). The challenge is that color temperature (kelvin/mired) and color (rgb/xy/hs) don’t represent the same thing so there is a bit of estimation to get a color representation of a color temperature. Also, a great deal depends on the lights themselves, how accurate they are, and if they were calibrated for color temperature adjustments or if they are just intended for colors.

1 Like

That makes perfect sense - thank you again @claytonjn.

I’ve replaced kelvin with color_temp for now, and will give it a shot tonight once we hit sunset. Have a great day!

I have the same issue that my LIFX, Innr and China RGBW strips don’t Match in Color. Should’ve sticked to one make :joy:

I will try to adjust the lifx and China LEDs not automatically but via an automation to adjust the color temp to match better. Maybe that works for you?

This makes sense, it’s just that is seems odd that the LED strip will be completely white (or close enough) in the middle of the day yet the downlights will still be pink…

I’ll have a play around and see if I can get them any better…maybe the downlights just aren’t very good

Continuing the discussion from Circadian Lighting [Custom Component]:

I tried Flux…omg, it does not reflect the actual outside color temp at all. E.g. now it is raining, the ambient color temp is really something else that the estimated. It just does not fit, doesn’t feel natural lightning at all. The same must be with the Circadian light.
Wish, really come on, more people would understand what it means to replicate the outside light color temp!
Just connected the VEML6040… here are the results for the ambient light – delay between the each value is one second(!). Pay attention to the CCT-value:
467 BLUE: 223 WHITE: 2189 CCT: 3291 AL: 29.38
RED: 732 GREEN: 647 BLUE: 301 WHITE: 2747 CCT: 3533 AL: 40.71
RED: 962 GREEN: 905 BLUE: 422 WHITE: 3549 CCT: 3813 AL: 56.94
RED: 996 GREEN: 948 BLUE: 453 WHITE: 3633 CCT: 3920 AL: 59.65
RED: 1011 GREEN: 958 BLUE: 456 WHITE: 3635 CCT: 3890 AL: 60.28
RED: 1022 GREEN: 967 BLUE: 461 WHITE: 3647 CCT: 3886 AL: 60.84
RED: 1134 GREEN: 1060 BLUE: 503 WHITE: 3958 CCT: 3820 AL: 66.70
RED: 949 GREEN: 787 BLUE: 358 WHITE: 3674 CCT: 3237 AL: 49.52
RED: 4362 GREEN: 4662 BLUE: 2511 WHITE: 11843 CCT: 4898 AL: 293.33
RED: 6327 GREEN: 6915 BLUE: 4365 WHITE: 17274 CCT: 5795 AL: 435.09
RED: 3669 GREEN: 3849 BLUE: 2055 WHITE: 9436 CCT: 4751 AL: 242.18
RED: 1317 GREEN: 1120 BLUE: 502 WHITE: 4860 CCT: 3313 AL: 70.47
RED: 1335 GREEN: 1225 BLUE: 547 WHITE: 4890 CCT: 3621 AL: 77.08
RED: 1365 GREEN: 1251 BLUE: 549 WHITE: 5042 CCT: 3586 AL: 78.71
RED: 1382 GREEN: 1263 BLUE: 554 WHITE: 5142 CCT: 3573 AL: 79.47
RED: 1398 GREEN: 1273 BLUE: 561 WHITE: 5199 CCT: 3566 AL: 80.10
RED: 1401 GREEN: 1281 BLUE: 564 WHITE: 5257 CCT: 3581 AL: 80.60
RED: 1402 GREEN: 1283 BLUE: 563 WHITE: 5277 CCT: 3579 AL: 80.73
RED: 1405 GREEN: 1284 BLUE: 563 WHITE: 5293 CCT: 3572 AL: 80.79
RED: 1401 GREEN: 1275 BLUE: 563 WHITE: 5294 CCT: 3566 AL: 80.22
RED: 1400 GREEN: 1279 BLUE: 560 WHITE: 5295 CCT: 3568 AL: 80.47
RED: 1399 GREEN: 1275 BLUE: 561 WHITE: 5297 CCT: 3566 AL: 80.22
RED: 1402 GREEN: 1283 BLUE: 569 WHITE: 5301 CCT: 3597 AL: 80.73
RED: 1397 GREEN: 1269 BLUE: 566 WHITE: 5289 CCT: 3576 AL: 79.85

I’m not sure what your use-case is for wanting to replicate current outdoor lighting conditions, but the point of this component is to use lighting to maintain a Circadian Rhythm. This means that the point is to be consistant and emulate the lighting that would be occurring on the average day so that your body isn’t jarred from day to day breaking that rhythm. If you want lights that dim when clouds go by or it’s raining or turn off when there’s a solar eclipse then this is definitely not the right solution for you. It seems you could easily just take the CCT values your detecting and write an automation to set lights to those values.

EDIT: Perhaps I should reword the first post a bit to make this more clear.

True, circadian rhytm is not really what I’m after, after all :slight_smile: – I’m after the most natural feeling lightning. Not really about the brightness, but to “replicate” the feel (cct mainly) of the artificial light to be as similar to the outside ambient light conditions. An example would be a fake window that one cannot differentiate the light coming from that from normal window.
Just got the sensor working, need to find out how to deliver the data to the HA – being a newbie…
Thanks for your reply!

Hello,
I have two questions about this component:

  1. can this component update light continuosly even when it is turned off?
    There are devices which accepts colour changes all the time, then turn on the light with recently retrieved attributes
  2. Can this cycle be suspended for selected light? I would like to have possibility to force light values (using another automation) preventing overwriting the light params by Circadian component

thank you in advance

No, as far as I know those devices use non-standard service calls to set those values. I could add this ability at some point in the future but it’s low priority because it’s a limited use-case and there are other options to get the lights to turn on with correct values that work across the board.

Yes, each instance is a switch entity so when the switch is off CL has no effect. Just configure a different switch instance for each light or group of lights you want to be able to control individually.

Don’t know how services work and what is considered non-standard. But there are devices like Shelly RGBW2 or LifX lights which can work this way.
I’m just starting which this but I can imagine that turning on the light during sunset when the recently remembered light attributes are from midday might cause light flash.

Yes, found it in docs after posting my OP. However this approach means creating additional sensor for each lamp which is far from optimal. Maybe it could be done without it somehow. Service call or so?

Thank you for fast responce.

Edit: I just learnt that I can run circadian component against virtual (mqtt) light, then send its values to my lights applying custom logic I need. It should give results I’m expecting

That’s not how this works. The colour temp and brightness attributes are updated globally all the time (as per the update interval) and then the light turns on to whatever they are when you turn the light on. I think the confusion was that you gave the impression there are lights which know what colour etc you want them to be before turning them on. :ie sending colour data while off, then simply sending an On command. If you have a CL light setup and turn it ON, it should be the correect colour and brightness straight away.

You can have as many lights under a single CL switch as you want / need. You don’t HAVE to have a separate one for each physical device

Yes I would like to have option to disable CL for each lamp separatelly leaving others untouched at the same time. this is the point of this use case. Why should I disamble CL in alk rooms if I’m trying to find a lost screw in one of them?

Now I’m confused. I think you’re considering turning it on from HA only. What if I turn it on using smart relay? This is how Shellys work (dimmer, rgbw2) independently from HA. those can be triggered by physical switch (common wall switch). In such case those just turn light on (with recently known attributes). So either they must already know the colour or it has to be sent immediately after CL detects state change to on. For the first case those attributes must be updated all the time when light is off. In the secons case there might be a delay in applying CL colours. Am I wrong?

Well you complained that the setup like this was:

It will turn on to whatever CL settings are for that time of day, as long as the CL ‘switch’ for that light is ON.

Possibly a very minor delay in retrieving the data from HA, depending on how slow your network is

[Edited to pack more info into original post]

I was excited to discover this add-on, but I can’t even get it to run in the first place.

Running HA 0.114.3 on a RPi4. Followed the install directions closely:

  • Installed HACS into HA v0.114.3.
  • Restarted HA.
  • Waited the requisite hour.
  • Installed CL v1.0.13 via HACS.
  • Restarted HA, got the error message plus one about timezonefinder.
  • Spent some time researching and reading in this forum.
  • Uninstalled CL v1.0.13.
  • Restarted HA
  • Installed CL v1.0.11 via HACS
  • Restarted HA. Got the error messages below. (But I did not see one about timezonefinder this time.)

2020-08-31 09:35:22 WARNING (MainThread) [homeassistant.components.switch] SwitchDevice is deprecated, modify CircadianSwitch to extend SwitchEntity
2020-08-31 09:35:22 ERROR (MainThread) [homeassistant.setup] Error during setup of component circadian_lighting
Traceback (most recent call last):
File “/usr/src/homeassistant/homeassistant/setup.py”, line 191, in _async_setup_component
result = await task
File “/usr/local/lib/python3.8/concurrent/futures/thread.py”, line 57, in run
result = self.fn(*self.args, **self.kwargs)
File “/config/custom_components/circadian_lighting/init.py”, line 92, in setup
conf = config[DOMAIN]
KeyError: ‘circadian_lighting’
2020-08-31 09:35:22 ERROR (MainThread) [homeassistant.setup] Unable to prepare setup for platform circadian_lighting.switch: Unable to set up component.

My HA install is only a few days old, so I don’t think I’ll notice if I roll back to an earlier version before SwitchDevice was deprecated (which should I choose?) but I don’t necessarily want to do that if I’m going to be playing Log Whack-A-Mole either. Thoughts/suggestions very welcome! Thanks in advance. Looking forward to getting this working.

Did you install via HACS? or Manual?

Installed both versions via HACS. (1.0.13 and 1.0.11) I’m neither smart nor creative enough to do anything other than the primary recommended method. :wink: