hass-circadian_lighting icon indicating copy to clipboard operation
hass-circadian_lighting copied to clipboard

Breaks transitions when turning lights on

Open oxan opened this issue 4 years ago • 9 comments

I've a few scripts that turn lights on with a transition, e.g.

service: light.turn_on
entity_id: light.living_space_lights
data:
  brightness: 255
  transition: 900

(I have disabled the brightness adjustment in circadian lighting)

Unfortunately, the circadian lighting breaks the transition, since it immediately issues another light.turn_on call without a transition, which overrides the transition I just supplied.

oxan avatar Apr 09 '20 14:04 oxan

As far as I know there's nothing that can be done about this. You would just have to disable Cl before turning on with a transition.

claytonjn avatar Apr 09 '20 19:04 claytonjn

Yeah, I was afraid so :(

However, I had another idea (without looking too much at the code). I can of course set the initial color temperature myself using the sensor:

service: light.turn_on
entity_id: light.living_space_lights
data:
  brightness: 255
  transition: 900
data_template:
  kelvin: "{{ state_attr('sensor.circadian_values', 'color_temp') }}"

Would it be possible for CL to detect whether the colortemp is already correct (based on the current state of the light) and if so not issuing another light.turn_on command? That'd still override the transition if the color temperature changes during the transition, but I can live with that.

Btw, thanks for your work on this component! It's a really nice feature, and even without transitions this works much better than the homegrown automation-based spaghetti I used before!

oxan avatar Apr 10 '20 13:04 oxan

Would it be possible for CL to detect whether the colortemp is already correct (based on the current state of the light) and if so not issuing another light.turn_on command?

That I could do pretty easily. I'll have to think through if there would be any negative side effects but I'll keep this open and add it to my list of enhancements.

claytonjn avatar Apr 10 '20 13:04 claytonjn

Just for reference, same is true if a light is turned off with the use of a transition. CL would kick in and the light would stay on. As a workaround: Disabling CI for turning off lights with transition works fine, though.

voydz avatar Apr 10 '20 16:04 voydz

CL checks to make sure a light is on before adjusting but if a light is sent an off command with transition but the state doesn't update until the transition is done then CL has no way of knowing it's turning off so it adjusts.

That might also be an issue with checking color temp before adjusting - if the state attribute doesn't change to the new value until transition is complete CL would still trigger and override the transition.

claytonjn avatar Apr 10 '20 19:04 claytonjn

It could have problematic effects in your use case, but would the initial_transition: option help you? You could set it to be longer than your transition. (Although 900 seconds would be a long time to wait if you didn't want a transition...).

DoloresHA avatar Sep 06 '20 18:09 DoloresHA

As a side note, maybe have the option not to adjust the colour temp until the brightness is at least X set in the config. Tho that would then cause issues with auto brightness adjustment.

cooljimy84 avatar Oct 16 '20 06:10 cooljimy84

I usually turn my lights on with {"brightness_pct":100} so it ignores whatever it was set to when I turned it off. However, Cl overrides this with the command it sends, so usually my lights get stuck at about 25% and I have to turn them off and on again to get 100%.

Would it be a fix for this be to have a (configurable) delay from when Cl detects a light to when it issues the command? Like a 500ms or 1 second delay should (at least for me) be enough to issue a brightness-change along with turning the light on before Cl kicks in and changes the color.

Jopinder avatar Nov 05 '20 15:11 Jopinder

@Jopinder, https://github.com/basnijholt/adaptive-lighting should fix that issue.

basnijholt avatar Nov 05 '20 16:11 basnijholt