Circadian Lighting [Custom Component]

same problem with 0.81.2 here. keeping an eye out for your fix :slight_smile:

Couple fixes:

The following files were updated:

Sorry about the delay in the 0.81.2 fix, I use Hass.io and it took a while for the build to be available.

2 Likes

Hi @claytonjn This component looks great. I have just set it up but was trying to understand exactly how it integrates with my existing lights and hoping you could help explain it please.

I have the below in a package called circadian_lighting.yaml

#   https://community.home-assistant.io/t/circadian-lighting-custom-component/61246

circadian_lighting:


switch:
  - platform: circadian_lighting
    lights_rgb:
      - light.ensuite_light
      - light.bedroom_lamp

I have noticed that the following entities have been created upon HA restart:
sensor.circadian_values
switch.circadian_lighting_circadian_lighting

So in order to utilise this, do I just turn the lights on and off as normal and they will now be automatically set to the circadian values? or do I need to turn them on with a service call to include the circadian values?

It looks like it is time for my to ditch my very crude own custom component with this much better one. Couple of questions.

  • how can you easily find out which lamps support ct, xy or rgb? Is HA not supposed to hide these details for us and work anyway?
  • do you have a central place where I can find the latest most updated version of the 3 files? Or should I scroll down this post to find the most updated version?
  • should we help pushing to make this a part of HA by starting a post in Feature Request requesting this to be a standard part?

Just turn the lights on and off as normal, and they will be automatically set - as long as the CL switch is on. However, “smart” lights typically turn on to their previous setting by default, which can result in a very brief transition to the correct circadian setting when first turned on. This can be eliminated by a turn_on service call with the color and/or brightness attributes from the sensor and switch, but is completely optional. I tried to build in as much flexibility as possible to handle all use cases. Also, note that you can have multiple switches defined with different grouping of lights to provide more flexibility.

HA is supposed to hide these details, but I decided to add the configuration options because it’s there in the Flux component and I figured more flexibility couldn’t hurt. Also, I do have some lights that work with RGB/XY but not CT - I determined that with trial-and-error but you could also look at the code for every light integration you use, if you’re so inclined.

All of the links I’ve been posting go to the same address in GitHub, so the links in the first post or any in the thread will always post to the newest version unless I specifically state otherwise for some special case. I know I need a better system of versioning but I’ve been focusing on functionality.

I’m completely open to supporting CL as a standard component, so anything you want to do to push that is fine with me!

1 Like

Hello,

Since last night I upgraded HASS, the comoponent stopped working.
Log says that it unable to set up all depndencies:

Fri Nov 02 2018 08:45:24 GMT+0100 (közĂ©p-eurĂłpai tĂ©li idƑ)

Error during setup of component circadian_lighting
Traceback (most recent call last):
File “/usr/local/lib/python3.6/site-packages/homeassistant/setup.py”, line 148, in _async_setup_component
component.setup, hass, processed_config) # type: ignore
File “/usr/local/lib/python3.6/concurrent/futures/thread.py”, line 56, in run
result = self.fn(*self.args, **self.kwargs)
File “/config/custom_components/circadian_lighting.py”, line 106, in setup
load_platform(hass, ‘sensor’, DOMAIN)
TypeError: load_platform() missing 2 required positional arguments: ‘discovered’ and ‘hass_config’

Fri Nov 02 2018 08:45:25 GMT+0100 (közĂ©p-eurĂłpai tĂ©li idƑ)

Unable to set up dependencies of switch.circadian_lighting. Setup failed for dependencies: circadian_lighting

Fri Nov 02 2018 08:45:25 GMT+0100 (közĂ©p-eurĂłpai tĂ©li idƑ)

Unable to prepare setup for platform switch.circadian_lighting: Could not set up all dependencies.

Anyone with the same issue, or is it just appeared in my instalaltion?

Tahnks!

Hello.
Just one day after deploying circa lighting in my appartment.
I want to use the sunrise and sunset offset but I have not figure it out the format of the offset.

One addition nice to have to improve from circadian lighting to advanced lighting would the ability to define scenes in the same module. Just would need to add the fixed brightness and colour (not just colour temperature but colour coodinates) in one switch and them from automations we would be able to toggle the switches to get what we want.
For instance if I’m on the living room and the lights are on auto circadian ilumination and I want to see a movie then I would switch off the circadian lighting and switch on the movie lighting with movie settings.

It’s currently a great piece of software that with some small additions would be awesome.

I will try to understand your coding (no experience in python) and try to improve to get what I want (no promises I get there anytime)

Thanks a lot

Sergi

1 Like

This was fixed a few days ago, see post 104: Circadian Lighting [Custom Component]

I don’t want the feature set of this component to start creeping outside the circadian concept - the beauty of the HA platform is that there are a lot of components with specific purposes that work together to overall create a robust system. There are many ways already that you can create scenes in HA (https://www.home-assistant.io/components/scene/) so you can already have an automation switch off CL and enable a scene. In fact, I have that exact setup triggered by my Harmony remote.

Thanks for the answer. What about the offset format?

Sorry! Should be 'HH:MM' or 'HH:MM:SS'. You can also add - for negative offset.

Thanks a lot!!

I’m facing issues with group of lights.
My lights come from deconz and, let me explain better my usecase

Let’s imagine a room with lights 1 and 2, deconz send light.room and light.1 and light.2
If I make circadian controls lights 1 and 2 I can turn on and off the lights on my room but then if I check light.room the brightness and colour doesn’t match the ones from light1 and 2
If I make circadian controls light.room I can turn on perfectly but then turn off it’s a nightmare
My suggestion is to add an optional parameter on the switch to add a delay (let’s say in order of ms) to check lights status after a change. So when I turn off a group circadian waits to all the lights on the group are off.

Thanks again

I somewhat understand your issue, but not fully. I’m also not sure I understand the request for a delay - are you suggesting that if a light group is configured in CL that CL check that each of the lights in the group are on before making an adjustment?

If a group is configured in CL and that group is off, CL should not be making any adjustments - delay or not.

I don’t have any experience with deconz, but I use a lot of Hue lights with Hue groups. I’ve found it best to either use a group, or use individual lights, but not both. In my setup, if I have multiple bulbs in a fixture I ALWAYS use the group and completely hide the individual lights from HA (because I never want lights in a fixture to not match) however if I have multiple fixtures in a room I always address them individually and hide all room groups, because I may want fixtures in a room to be different.When you have light.1 and light.2 in CL does everything function correctly, and the only issue is that light.room doesn’t show what light.1 and light.2 are set to? If so, could you explain why this would be a problem?

but I use a lot of Hue lights with Hue groups

Are hue groups or homeassistant groups? In my case are groups created by deconz imported by homeassistant

When you have light.1 and light.2 in CL does everything function correctly, and the only issue is that light.room doesn’t show what light.1 and light.2 are set to? If so, could you explain why this would be a problem?

Yes it workes, the problem is if I check the status of light.room doesn’t match with light.1 neither light.2

Hue groups.

So my question is; does that really matter? If the lights were set to different colors there’d be no way of the group properly reflecting that so I would think in general looking at the status of a group would be pointless.

Also, I’m still not really clear what the problem you had with using the group was. Does the issue occur when you turn the lights off outside of the group?

I think I need multiple disable_states to use with a media_player as disable_entity. Using disable_state ‘on’ doesn’t catch states like paused, playing etc.

Edit: Not crucial as I am doing it using automations but a nice-to-have.

Does the issue occur when you turn the lights off outside of the group?

The issue is if I make cl control the group, if I try to turn off, after some attempts it will, but most of the time it turns on while bulbs are dimming off, so again they are on. As a workaround I have made an automation to capture the turn off, then switch off the related cl switch then turn off the light group, then wait 50ms, then turn on the related cl switch.

1 Like

Good point, I could probably modify disable_state to take in a list so that you could input multiple values. I’ll try to add that at some point! Like you said, you can also use automations to turn off the switch for more complex situations.