Circadian Lighting [Custom Component]

Update: I fixed the issue by adding

circadian_lighting:
  ...
  elevation: 0.0
  ...

in configuration.yaml.

Please note: do not use quotes around the number.

The process requires 2 steps:

  • update to the new files, restart HA
  • place the elevation-line in configuration.yaml, restart HA
    After this, it works.

I just updated to the new versions. HA version: 0.91.0

Result:

019-04-05 15:17:07 ERROR (MainThread) [homeassistant.setup] Error during setup of component circadian_lighting
Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/homeassistant/setup.py", line 154, in _async_setup_component
    component.setup, hass, processed_config)  # type: ignore
  File "/usr/local/lib/python3.7/concurrent/futures/thread.py", line 57, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/config/custom_components/circadian_lighting/__init__.py", line 111, in setup
    interval, transition)
  File "/config/custom_components/circadian_lighting/__init__.py", line 137, in __init__
    self.data['percent'] = self.calc_percent()
  File "/config/custom_components/circadian_lighting/__init__.py", line 202, in calc_percent
    today_sun_times = self.get_sunrise_sunset(now)
  File "/config/custom_components/circadian_lighting/__init__.py", line 170, in get_sunrise_sunset
    location.elevation = self.data['elevation']
  File "/usr/local/lib/python3.7/site-packages/astral.py", line 678, in elevation
    self._elevation = int(elevation)
TypeError: int() argument must be a string, a bytes-like object or a number, not 'NoneType'
2019-04-05 15:17:08 ERROR (MainThread) [homeassistant.setup] Unable to set up dependencies of circadian_lighting.switch. Setup failed for dependencies: circadian_lighting
2019-04-05 15:17:08 ERROR (MainThread) [homeassistant.setup] Unable to prepare setup for platform circadian_lighting.switch: Could not set up all dependencies.
2019-04-05 15:17:08 ERROR (MainThread) [homeassistant.setup] Unable to set up dependencies of circadian_lighting.switch. Setup failed for dependencies: circadian_lighting
2019-04-05 15:17:08 ERROR (MainThread) [homeassistant.setup] Unable to prepare setup for platform circadian_lighting.switch: Could not set up all dependencies.
2019-04-05 15:17:08 ERROR (MainThread) [homeassistant.setup] Unable to set up dependencies of circadian_lighting.switch. Setup failed for dependencies: circadian_lighting
2019-04-05 15:17:08 ERROR (MainThread) [homeassistant.setup] Unable to prepare setup for platform circadian_lighting.switch: Could not set up all dependencies.
2019-04-05 15:17:08 ERROR (MainThread) [homeassistant.setup] Unable to set up dependencies of circadian_lighting.switch. Setup failed for dependencies: circadian_lighting
2019-04-05 15:17:08 ERROR (MainThread) [homeassistant.setup] Unable to prepare setup for platform circadian_lighting.switch: Could not set up all dependencies.
2019-04-05 15:17:08 ERROR (MainThread) [homeassistant.setup] Unable to set up dependencies of circadian_lighting.switch. Setup failed for dependencies: circadian_lighting
2019-04-05 15:17:08 ERROR (MainThread) [homeassistant.setup] Unable to prepare setup for platform circadian_lighting.switch: Could not set up all dependencies.
2019-04-05 15:17:08 ERROR (MainThread) [homeassistant.setup] Unable to set up dependencies of circadian_lighting.switch. Setup failed for dependencies: circadian_lighting
2019-04-05 15:17:08 ERROR (MainThread) [homeassistant.setup] Unable to prepare setup for platform circadian_lighting.switch: Could not set up all dependencies.
2019-04-05 15:17:08 ERROR (MainThread) [homeassistant.setup] Unable to set up dependencies of circadian_lighting.switch. Setup failed for dependencies: circadian_lighting
2019-04-05 15:17:08 ERROR (MainThread) [homeassistant.setup] Unable to prepare setup for platform circadian_lighting.switch: Could not set up all dependencies.
2019-04-05 15:17:08 ERROR (MainThread) [homeassistant.setup] Unable to set up dependencies of circadian_lighting.switch. Setup failed for dependencies: circadian_lighting
2019-04-05 15:17:08 ERROR (MainThread) [homeassistant.setup] Unable to prepare setup for platform circadian_lighting.switch: Could not set up all dependencies.
2019-04-05 15:17:08 ERROR (MainThread) [homeassistant.setup] Unable to set up dependencies of circadian_lighting.switch. Setup failed for dependencies: circadian_lighting
2019-04-05 15:17:08 ERROR (MainThread) [homeassistant.setup] Unable to prepare setup for platform circadian_lighting.switch: Could not set up all dependencies.
2019-04-05 15:17:08 WARNING (MainThread) [homeassistant.loader] You are using a custom component for circadian_lighting.sensor which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you do experience issues with Home Assistant.
2019-04-05 15:17:08 ERROR (MainThread) [homeassistant.setup] Unable to set up dependencies of circadian_lighting.sensor. Setup failed for dependencies: circadian_lighting
2019-04-05 15:17:08 ERROR (MainThread) [homeassistant.setup] Unable to prepare setup for platform circadian_lighting.sensor: Could not set up all dependencies.

Elevation = 0 in configuration.yaml.

I had to roll back to the old versions.

Could you test this version of __init__.py

For the test, please remove your elevation: 0.0 line from the circadian_lighting configuration. Let me know if it works and I’ll push to master.

Yes, the updated code works without the elevation-line.

Thanks, pushed the update.

Updated the code and it’s working.

A little oddity: sensor.circadian_values is showing up on my Map :thinking:

:laughing: Indeed it is! It appears that just because it has latitude and longitude attributes it shows up. Are you sure this is new behavior though? The CL sensor has has latitude and longitude attributes since inception.

The way I built the component it includes all configuration options as attributes of the sensor; mostly just for easy reference in the front end. If I’m going to rework the code so that lat/long aren’t included (so the sensor doesn’t show up on the map) I’ll probably change the behavior so that only calculated values are exposed as attributes. I’m interested in everyone’s thoughts on this.

  • Keep all configuration options as attributes (CL sensor will be included in HA Map)
  • Only include calculated values as attributes (percent, colortemp, rgb_color, xy_color, hs_color, unit_of_measurement, friendly_name, icon)
0 voters

Sorry, I should have mentioned that this isn’t linked to the updated code but I only just got around to mentioning it. It’s not a big deal so it might not be worth it to re-work the whole thing just to remove the lat/long if it’s too much effort.

That said, the lat/long might not be worth including if they’re just part of the setup and don’t need to be read by users (though as you wrote in the OP some people might want to configure it for different locations and keep track of that. Seems like a bit of an edge case though).

Has anyone try this component with a philips downlight? It can change brightness, but I cannot make it to change its temperature. What am I doing wrong? I tried with rgb, xy and ct modes with no luck.

EDIT: With an Aqara led bulb happens the same, only brightness, no color temperature.
With yeelights and rgb mode is working great.

after a few hours of playing with this, i am so impressed and thankful for this addition to my home assistant setup. i have noticed in my setup and others screen shots that sunset doesn’t seem to display in the sensor. does that mean it’s not detecting the sunrise / sunset time from ha?

Are you able to set color temperature or color with the light.turn_on service call?

Are you referring to sunrise time and sunset time? If so, that just displays your hard-coded values if you have them set. I’m thinking about removing the manually configured variables from attributes and posts a poll asking for opinions here: Circadian Lighting [Custom Component] - #355 by claytonjn. I’m going to give it a bit more time but it looks like I’ll probably be cleaning it up.

my vote would be to show all the values in the sensor and then have the hard coded overrides be there only if used. i am using this sensor report to see if my configuration.yaml is coded and formatted correctly, so i have made several changes and then check the results here. it definitely helped me know what was working and what wasn’t, so please don’t remove the location info. it does not bother me that it shows up in the map, unless it’s doing some harm that i can’t perceive.

a feature request from my perspective would be the ability to configure the temperature color and other values in the gui, in the same way i now control the color led bulbs and group lights.

thanks again, this is really great stuff. i also vote :+1::+1::+1: for integrating this into home assistant.

lovelace

Yes, I just tried it and it works without problems with “kelvin” and “brightness_pct”

Two more questions:

  • How can I set up min and max color temperature if I have different bulbs? Because they are declared as global variables when declaring circadian_lighting right? (my yeelight have a wide range color temperature than philips downlights)

I have an aqara led bulb (ZNLDP12LM) controlled with zigbee2mqtt and if I have enabled your component, I cannot turn off the light. It is like the component is always sending turn_on commands, so if I try to switch it of, it tries but then turn on again. What can I do with that?

Thanks for your time developing and answering all this, I came from flux and this is waaaay better.

now i am really getting into this, and i see the limitation of what i want this to do. i am wondering if possibly there is an easy fix? using lights_rgb, i seem to get almost perfect output on my lights from daylight to night, and i can tweak color output with min/max colortemp and min/max brightness.

the brightness and color are perfect at the bottom of the spectrum around midnight - rgb=255,0,0. but not in the top of the spectrum around noon. i would greatly prefer rgb=255,255,153 - a shift to much warmer daytime color.

my lights are 5 channel so it may be ideal to be able to set the color and brightness directly with my own custom ranges on each channel. the channels of the lohas color rgb bulbs i am working with are R,G,B,CW,WW, expressed in a range from 0-200, so the daytime color recipe is 200,200,0,0,100, and i think the night time recipe is something like 50,0,0,0,0.

the limitation imho, seems to be from the use of mired light calculations. to be fair, it is the most accurate way to do what you set out to do, but i want to override that on my setup so that i can shift between red and yellow instead of red and blue, as mired does. (the planet i live on shifts between red and yellow, instead of the red and blue on your planet, lol. simple, right? lol. hopefully. thanks!

If that’s the case, we’ll have to dig into the logs a bit. Instructions for enabling logs are here: Debugging · claytonjn/hass-circadian_lighting Wiki · GitHub

Your color temperature range is determined by the “weakest link”. In order to keep color temperature of all lights in sync, if you have light A that has range 2000-5500 and light B with range 2500-6000, you should set your min_colortemp to 2500 and max_colortemp to 5500.

This is a pretty common issue. I’ve addressed it in the thread before but it’s pretty broken up so I added this to the FAQs here: Frequently Asked Questions · claytonjn/hass-circadian_lighting Wiki · GitHub

You must have a very small min_colortemp (less than 6?) to get pure red ([255, 0, 0]). Even with max_colortemp at 6500 the red and green channels should still be maxed out, so you wouldn’t be in the blue range yet (6500 should be close to pure white, anything less and you’re still red/yellow).

nope, here’s my config…

circadian_lighting:
  min_colortemp: 1500
  max_colortemp: 3700

switch:
  - platform: circadian_lighting
lights_rgb:
  - light.lohas_color1
  - light.lohas_color1_2
  - light.lohas_color1_3
  - light.lohas_color1_4
  - light.lohas_color1_5
min_brightness: 15
max_brightness: 90

as i said, this works well for the midnight color, but i would need a different approach than mired to get the color i want at noon.

With that configuration your lights should go from ~ [255, 108, 0] to [255, 198, 151]. Are you sure CL is setting your lights to [255, 0, 0]?

Regardless, I’m not sure exactly what you want or how it could be implemented in CL. The whole basis of CL is to follow the kelvin/mired CT scale - if you want something different this probably isn’t the best solution.

ok, thanks

Wow, thank yout very much @claytonjn for these updates!
Btw, how I can add this to the custom updater?
Or is this a function that does not yet exist?

1 Like