šŸ’” Adaptive Lighting automatically adapts the brightness and color of your lights based on the sun's temperature but stops when you manually make a change

After a looooong period of inactivity where I got a new job and moved to a different continent, I finally made the time to start working on Adaptive Lighting again! :tada:

I solved quite a few bugs in the last week and introduced a new feature where you can select the sleep_mode color in RGB:

Update to 1.1.0 to get the latest and greatest.

I am planning to add custom color curves too in some way. I am still thinking about how to do it.

8 Likes

Iā€™m an avid user over 20 instances of this solution and youā€™ve made my year with some of these updates! Thank you for stopping the errors and adding color to sleep mode!

While youā€™re thinking about custom color curves, can we have a way to detect/combat cloudy day syndrome?

AL works great until you have a cloudy day and then the lights are overly bright/weird CT for it being nearly dark outside. Itā€™s not the softwareā€™s fault because how does it know its a rainy day BUT if we had an option for an illuminance sensor to say "its the middle of the day, but the illuminance is < ā€˜xā€™ lux, adjust AL by ā€˜xā€™ percentage or ā€˜xā€™ sunset hours offset to give the illusion that its adapting to cloudy day.

The illuminance sensors are already in my home for cloudy day syndrome (triggering lights based on illuminance vs time of day). It seems like we could use a similar qualifier to tweak the AL throughout the day as needed for when the conditions outside become dark and the lights inside are not 90%/6500k.

Later as the illuminance sensor detects normal light levels, the AL offset can be turned off.

Iā€™m capable of entering a PR, just wanted to talk to you about it first :slightly_smiling_face:

1 Like

Is it possible to pass a custom sunrise to an adaptive lighting instance? Iā€™d like to be able to do "If alarm set > make adaptive lighting sunrise at alarmtime minus 25minutes, else make adaptive sunrise at 9am.

I can see how to change the value of sunset/sunrise in the configuration, but Iā€™d like to update it automatically according to my work schedule. (you can take my weekend lie-ins from my cold dead hands)

Itā€™s really interesting youā€™ve asked this.
Iā€™ve been working with a popular blueprint to make a wake-up sunrise alarm, and have had a couple of really rude mornings with it conflicting with adaptive lighting. Waking up to a strobe light wasā€¦ unpleasant.
Iā€™ve since turned off adaptive lighting as an automation around when it would be running, but I also really dislike how the blueprint is using warm light. Adaptive lighting has a much better handle on the actual light spectrum our circadian rhythm is expecting, but is pretty bad at providing it at a set time or custom sunrise time. I attempted to jjust turn on my lights and let adaptive lighting serve a sunrise (as set in the config) but it came on at 40% brightness.

I think Iā€™m going to ditch the blueprint and use a simple automation that turns off adaptive lighting brightness, and then increases the brightness by 1% every 5 seconds or something and just let adaptive lighting control the colour temp, since it does that really well.

This is all very off topic from why I actually came to this thread, which was for @basnijholt to add a wish list of ā€œcould you integrate a wake-up ā€˜sunrise effectā€™ alarmā€ into this component.

The other thing that would be nice is if the entity field for the config could be text-editable, as if you delete or rename an entity in there currently it bugs out and wonā€™t let you unselect/uncheck the entity that doesnā€™t exist - workaround it to delete & remake.

Edit: yeah ran into the same issue again where there seems to be an upper limit on transition effects, forgot thatā€™s why I didnā€™t use it in the first place, it needs scripting to get a fluid/prolonged transition effect.

This is literally what Iā€™m here for, too. I want to understand sleep_transition and if that can be used as a wake-up transitions for this very purpose.

Right now, I just turn off the Adaptive Lighting, and let Hue do the wake-up automation. Then, 35 mins after my alarm time, my automation re-enables Adaptive Lighting. I was wondering if there was a way to leverage sleep_mode and sleep_transition for a similar affect.

I might do this, although it might be better as a separate integration.

I already have a ā€œwake up lightā€ in both AppDaemon (home-assistant-config/wake_up_light.py at 497307cea429344e63406bf332a28dbb6a65a05c Ā· basnijholt/home-assistant-config Ā· GitHub) and PyScript (home-assistant-config/wake_up_light.py at 497307cea429344e63406bf332a28dbb6a65a05c Ā· basnijholt/home-assistant-config Ā· GitHub). However, a proper Home Assistant integration might be better to share.

Version 1.2 is released!

See the latest release at Releases Ā· basnijholt/adaptive-lighting Ā· GitHub

Most importantly it includes: PR: Add max_sunrise_time and min_sunset_time overrides.

2 Likes

This small update is great!

Iā€™ve been using this all summer, but now that the winter days in the UK are much shorter, Iā€™ve been finding that the lighting is getting too dim too quickly. Iā€™ll be using this new feature to extend the evenings a bit. Thanks! :smiley:

1 Like

just want to say thanks - adaptive lighting (and its predecessors on other platforms) have been the single most effective bit of Home Automation iā€™ve implemented.

My family have never even noticed it. I was talking to my wife about it the other day and she said she wouldnā€™t notice the difference, so I turned it off and showed her normal brightness for our kitchen when dark outside. She was pretty stunned.

My parents complain its too dark at night!

2 Likes

So Iā€™ve set it up for me and fiddling around with it and Iā€™m encountering some issues where Iā€™m not sure what goes wrong.

I have a philips hue color bulb in the bathroom. I set up Adaptive Lighting to handle it with the following settings. The idea is itā€™ll stay the same cool white temperature throughout the day, and when sleep mode is turned on in the night itā€™ll have 1% brightness and the warmest color it can.



image

Behind the (dumb) momentary switch to control the bathroom light is a smart relay from Fibaro relay. From what I understand, that supplies the light bulb constantly with electricity, itā€™s just when the switch is pressed it sends a short pulse to the fibaro relay, which in turn just toggles its state (and the state of the bulb) to the other state, so off->on and on->off.

The issue I have is that sometimes when I press the switch, the Philips Hue turns on with pretty warm colors, not the 4500K I set it to in the adaptive lighting automation. After turning on warm the bulb quickly transitions to 4500K, but still not sure why itā€™s even doing that. When sleep mode is on and I toggle the light switch, sometimes the bulb will turn and off dimmed and then suddenly start up with high brightness again, only to then quickly dim down to 1%. While I toggle it with the light switch, I can see in HA that the bulb itself stays in the on state. If I only toggle the Philips Hue light bulb in HA, that behavior doesnā€™t seem to happen.

Anyone know whatā€™s happening?

Side question: just wondering how everybody else set up their adaptive lighting. Iā€™m now at the point that sleep mode with 1% brightness will only be activated for hallway+bathroom, not the other rooms. During the day, everywhere the brightness will only go down to min. 60% otherwise it becomes to dark and strenous for the eyes

Excellent update!
I went to modify a program and found it, thought I needed glasses for a second!

Would it be hard to include both max and min sunset times? Now that Iā€™ve got a taste I want more!

I have the opposite problem of the winter issue - very long days here in summer so sunset is currently close to 9pm, so the automation is still quite bright when we want to wind down. I had a fixed time for 1800 which works well enough though, but runs into the winter conundrum if a fixed time.

Edit: ah I just realised it would only require a bit of math to replicate this with an offset+minimum time combo
Not quite the same, but softens the transition to red light better than a static set time.

I notice the same behaviour, I assume itā€™s turning on to the last known memory (so if last on at noon bright white with high brightness) at which point adaptive Lighting grabs it and tells it to adjust which brings it to the correct setting with a transition effect.

If the lights have been on recently the effect isnā€™t noticable.

I suspected itā€™s intended behaviour, as having adaptive Lighting intercept the command before the lights come on would introduce a perceptible delay in the lights responding to input from the wall switch?

Same for me. It doesnā€™t seem, that it remembers the last state of brightness, because it also happens after the dimming to e.g. 1% had already be done once or more often.

Hello, I have a problem with this integration, I donā€™t know how to set it up. I have an RGB bulb, so I forced the RGB control. The light bulb changes color and brightness, but never to a minimum of ā€œ0%ā€ and does not start from ā€œ0%ā€. No matter what I try, it will never fade. What am I doing wrong? The bulb is a GLEDOPTO 12W RGB CCT Zigbee 3.0 bulb E26 E27 Pro. Please help.

After a bit of testing I have a suspicion the lighting behaviour is related to the change from home assistant using mireds to accepting kelvin.

I wrote a simple script to turn off adaptive lighting, turn on the light setting the levels I wanted and then turned adaptive lighting back on. I activate this with my switch automation, which passes through the variables desired for that room to the script.

- alias: Set up variables for _AL_Switch brightness
  variables:
    _albrightness: '{{ state_attr(_AL_switch,''brightness_pct'') | default(''1'')}}'                
- service: switch.turn_off
  data:
    entity_id: "{{ _AL_switch }}"
- service: light.turn_on
  data:
    brightness_pct: "{{ _brightness_sleep | default('1') }}"
    color_temp: "{{ _color_temp_sleep | default('500') }}"
    transition: "{{ _transition_on | default('0') }}"
  target:
    entity_id: "{{ _target_entity }}"
- service: switch.turn_on
  data:
    entity_id: "{{ _AL_switch }}"

Using anything other than mireds caused a transition effect of turning on to the last known state before changing color to the desired color after the transition period finished.

Setting my light switch automations to call the script when sleep mode is enabled has it working well. It turns on at 1% brightness and with 500 mireds. I have one hue bulb that flashed me with white light last night, so ymmv, but Iā€™ve used this for 2 weeks without any others misbehaving.

I attempted to extrapolate this and use maths to obtain a mired value from adaptive lighting, but ran into some errors that just werenā€™t worth it for me to try trouble shoot - instead I have an overly complicated script that could very very easily be optimised by someone who is better at coding than I am. It checks against the time of day and turns it on at preconfigured levels IF the lightā€™s last_changed state is > than 3600 seconds.

Edit: actually now that I tested it while home during the day, it does seem that telling the lights to come on at a mired of 153 doesnā€™t avoid a transition from flashing mired 500 before transitioning to mired 153. So this might not actually be the reason for the behaviour. Regardless of color though, it definitely fixes the issue with brightness coming on at 100% and dimming down to xyz%, so Iā€™m still happy with the work around.

Those Gledopto bulbs are RGB-CCT, so this component will work better if you donā€™t force RGB mode. The ā€œCCTā€ means correlated color temperature, which is what Adaptive Lighting uses to set color temperature using the bulbā€™s warm white and cool white LEDs that are present in addition to the RGB LEDs.

I have Adaptive Lighting running using those same Gledopto bulbs, and here is the integration setup that works for me:

prefer_rgb_color: FALSE
initial_transition: 5
sleep_transition: 5
Transition when applying a change to the lights: 45
interval: 90
min_brightness: 50%
max_brightness: 100%
min_color_temp: 2200
max_color_temp: 5500
sleep_brightness: 1%
sleep_rgb_or_color_temp: RGB
sleep_rgb_color: [a nice warm orange]
[sunrise and sunset settings are all defaults, no overrides]
only_once: FALSE
take_over_control: FALSE
detect_non_ha_changes: FALSE
separate_turn_on_commands: FALSE
send_split_delay: FALSE
adapt_delay: 2

These settings have worked well for me, but there is a downside: it will take the full transition time (45 seconds) for the lights to come to full brightness when turned on, and also to fully turn off when turned off. I set this long transition time because without it, I would notice each transition occurring (as a sort of perceptible ā€œblinkā€) during the day as the temperature/brightness automatically changes.

Good luck!

Unsure if you are still looking for an answer but I just tackled this the other day lol. I have four rooms that have dumb switches but smart bulbs and was experiencing exactly what you described. I used the following automation to achieve my desired result:

- id: '6c3a74c553b94f29afb5c492792d1235'
  alias: Guest Room Lights Adaptive Lighting
  description: ''
  trigger:
  - entity_id: light.guest_lights
    platform: state
    to: 'on'
    from: unavailable
    for: '00:00:15'
  condition: []
  action:
  - service: adaptive_lighting.apply
    data:
      entity_id: switch.adaptive_lighting_guest_lights
      lights: light.guest_lights
      transition: 30

Thank you for your help. Your settings work great. I also wrote to GLEDOPTO about their bulb (GLEDOPTO 12W RGB CCT Zigbee 3.0 E26 E27 Pro). I got a vague answer confirming different brightness depending on RGB on/off mode.
This is confirmed by my observations and control of energy consumption. Itā€™s not bad for today, Iā€™ll do the rest of the functionality in Node-RED.
Thank you again.

Crosspost from the older thread, sorry

hassjay

40m

Iā€™ve just purchased a Hue Play Bar and installed the Adaptive Lighting component to use as a sunrise and sunset simulator.

Iā€™ve set sleep_transition to 300, sleep_brightness to 1%, sleep_rgb_color_or_temp to rgb_color and sleep_rgb_color to Red.

Iā€™ve created a script that checks the light is on and sleep mode is off, then turns sleep mode on, waits 300 seconds (for the light to transition to 1% red) and then turns the light off. This will be called manually when I go to bed.

A second script that check the light is off and sleep mode is on, turns the light on and sleep mode off. This will be called by an automation before Iā€™m due to wake up or manually if I wake up earlier.

Is anyone else doing something similar? I guess Iā€™ve missed some exceptions. What should I look out for? Waiting for the transition before turning the light off feels a bit clunky.

I would love to know how to enable sleep mode for all integrations with 1 simple toggle on the dashboard to force and than also auto turn on based on a time, would be fantastic.

Would also like sleep mode to turn off based on alarm time.