šŸ’” 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

I ran into something else funnyā€¦

I have a group of lights set up for the master bedroom. And a set of custom sliders to control the individuals or the group. When I turn them on via the individuals they turn on to the correct AL brightness and color. However when I turn them on via the group they turn on brighter and a different color.

I tried using both calling light.toggle, and I made a script to call light.turn_on or off depending on the group state. Neither work as desired. Any ideas what Iā€™m missing?

Itā€™s the first action_button that I havenā€™t got worked out.

type: entities
entities:
  - entity: light.master_bedroom_lights
    type: custom:slider-button-card
    min: 1
    max: 100
    hide_state: true
    colorize: true
    attribute: brightness
    slider:
      use_percentage_bg_opacity: true
      direction: left-right
      background: solid
      show_track: true
    icon:
      tap_action:
        action: call-service
        service: script.light_nightlight
        target: {}
      use_state_color: true
    action_button:
      mode: custom
      show: true
      tap_action:
        action: call-service
        service: script.toggle_master_lights
        target: {}
      hold_action:
        action: more-info
    show_state: false
    compact: true
  - entity: light.master_fan_lightbulb
    type: custom:slider-button-card
    min: 1
    max: 100
    hide_state: true
    colorize: true
    attribute: brightness
    slider:
      use_percentage_bg_opacity: true
      direction: left-right
      background: solid
      show_track: true
    icon:
      tap_action:
        action: calls-service
        service: script.light_nightlight
        target: {}
      use_state_color: true
    action_button:
      mode: custom
      show: true
      tap_action:
        action: toggle
      hold_action:
        action: more-info
    show_state: false
    compact: true
    name: Master Fan Light
  - entity: light.1lamp_bulb
    type: custom:slider-button-card
    min: 1
    max: 100
    hide_state: true
    colorize: true
    attribute: brightness
    slider:
      use_percentage_bg_opacity: true
      direction: left-right
      background: solid
      show_track: true
    icon:
      tap_action:
        action: call-service
        service: script.light_nightlight
        target: {}
      use_state_color: true
    action_button:
      mode: custom
      show: true
      tap_action:
        action: toggle
      hold_action:
        action: more-info
    show_state: false
    compact: true
    name: 1's Lamp
  - entity: light.2_lamp_bulb
    type: custom:slider-button-card
    min: 1
    max: 100
    hide_state: true
    colorize: true
    attribute: brightness
    slider:
      use_percentage_bg_opacity: true
      direction: left-right
      background: solid
      show_track: true
    icon:
      tap_action:
        action: call-service
        service: script.light_2nightlight
        target: {}
      use_state_color: true
    action_button:
      mode: custom
      show: true
      tap_action:
        action: toggle
      hold_action:
        action: more-info
    show_state: false
    compact: true
    name: 2's Lamp
  - entity: script.bedtime
    name: Lights Out / Bed Heaters for 1 Hour
state_color: true
show_header_toggle: false
title: Master Bedroom

Hereā€™s a video of what Iā€™m talking about. Something is intermittently interfering with only the group. It was pretty consistent last night, but this morning Iā€™ll occasionally get a desired outcome (like the first time I hit the button at 0:01, however you may notice it paused midway up for a moment. Then later it stops at the same mid way location.

Maybe nothing to do with AL. How do I get into the logs that would show whatā€™s going on?

Side question. Is there a better way to share a video?

I think that is what I will have to do (automating switching off manual control). I had just thought it was automatic when turning off the light.

Yes this is with the ā€˜ā€™ā€˜take_over_controlā€™ā€˜ā€™ flag on. I often leave it off as I never manually change lights, but for some I do turn it on.

Thinking on the issue you reported, adaptive lighting offers the ā€˜applyā€™ service that will turn on lights with the correct settings. Try calling that instead of turning on the light group. Also, there is the ā€˜interceptā€™ setting in adaptive lighting configuration.

For me, lights revert to automatic once turned off and on again :person_shrugging:

1 Like

Thanks for the idea, but it didnā€™t work out. Iā€™m getting what seems to me like an odd error.

I used the GUI to generate it, but hereā€™s the yaml.

type: entities
entities:
  - entity: light.master_bedroom_lights
    type: custom:slider-button-card
    min: 1
    max: 100
    hide_state: true
    colorize: true
    attribute: brightness
    slider:
      use_percentage_bg_opacity: true
      direction: left-right
      background: solid
      show_track: true
    icon:
      tap_action:
        action: call-service
        service: script.light_1s_nightlight
        target: {}
      use_state_color: true
    action_button:
      mode: custom
      show: true
      tap_action:
        action: call-service
        service: adaptive_lighting.apply
        target: {}
        data:
          entity_id: switch.adaptive_lighting_x_lighting
          lights:
            - light.master_bedroom_lights
          turn_on_lights: false
          adapt_brightness: false
          adapt_color: false
          transition: '.5'
      hold_action:
        action: more-info
    show_state: false
    compact: true

Is this possibly related to the slider card doing something funny with the formatting of the yaml? I just tried to switch back to the light.turn_on service call, and itā€™s giving an error about not passing the entity. I think I had to manual troubleshoot that before to get it working (as it was working in the video - intermittent incorrect brightness/color).

ā€¦ 10 minutes later ā€¦

I modified my ā€œtoggleā€ script to use the adaptive_lighting.apply service instead of light.turn_on. I had to use the turn on if off, and the adapt brightness and color options. That all works. Whoo hoo! Thanks @euinor!

I am getting something funny where my transition on the adaptive_lighting.apply and light.turn_off parts of my toggle script is ignored unless itā€™s 2 seconds or more.

I think I figured out part of the issue with the color and brightness being intermittently adaptedā€¦

Iā€™d recently made a color_profiles.csv to apply a default transition to any light. I wondered if that was impacting this current issue so I changed the file name and restarted.

Now the color and brightness is adapting as intended, however at the expense of the loss of default transition value.

Since the adapts are working when I address the individual lights, but not as a group (or even if I break the group apart but call them all at once) Iā€™m led to think that someone AL is missing itā€™s take over when all of the lights are turned on at the same moment.

@euinor, I just noticed the setting autoreset_control_seconds on the AL configuration. Iā€™m not sure if that could be helpful in your case, but thought it worth mentioning.

Thanks for confirming. It is helpful to know the normal behaviour. I must have some automation setting it on permanently. Iā€™ll investigate further.

Good tip, Iā€™ll take a look!

Edit: I think I have found the issue. I had an automation that would toggle the light group for the room when a button was pressed. This triggered the manual control every time the lights were switched on. Iā€™ve changed the automation to turn on the lights individually (using the same lights as in the adaptive lighting configuration) and it seems to work now.

Funny, I had read the instructions on to use individual lights and not change groups. I must have forgotten about that when setting up the automation.

Great to hear!

So light groups are problematic? I couldnā€™t find any mention of that in the documentation.

Just a thought: Are those zigbee? What are those bulbs / zigbee stick? Is this ZHA or Z2M or something else?

I ran into something similar a long time ago, and (for me) it was my zigbee light group not being reliable. So just a thought.

1 Like

Yes thatā€™s correct. Zigbee light groups will only work well if you only ever make changes to the complete group and not to the individual lights.

This is because there is no associated lights.turn_on event for individual lights in a Zigbee group.

We should make this more clear in the documentation though!

@k8gg @basnijholt not ZigBee. Theyā€™re TPLink Kasa KL125 wifi bulbs.

Hello @basnijholt
Thanks very much for the amazing adon.

I have Philips Hue and Iā€™m noticing that if I activate any hue scene, the addon starts adapting immediately even though I have the option in the configuration to only adapt on bare turn_on (see screenshot below).

This service call reproduces the problem

service: scene.turn_on
target:
  entity_id: scene.north_bedroom_arctic_aurora

Am I misunderstanding how your integration is supposed to work, or this is a bug? Thanks very much!

Configuration:

I just noticed a whole bunch of these errors in my HA log:

2024-03-21 06:58:38.836 ERROR (MainThread) [homeassistant] Error doing job: Task exception was never retrieved

Traceback (most recent call last):

File "/config/custom_components/adaptive_lighting/switch.py", line 2389, in state_changed_event_listener

await switch._respond_to_off_to_on_event(

File "/config/custom_components/adaptive_lighting/switch.py", line 1522, in _respond_to_off_to_on_event

await self._update_attrs_and_maybe_adapt_lights(

File "/config/custom_components/adaptive_lighting/switch.py", line 1417, in _update_attrs_and_maybe_adapt_lights

assert isinstance(adapt_color, bool)

AssertionError

Anyone else getting this?

Dear community, is there an easy way to configure adaptive lighting to have two bright phases (evening and morning) with darker inbetween? I want the lights in my kids room to be at:

  • 20% between sunset and 8:00 pm
  • 5% between 8:30 pm and 6:00 am
  • 20% between 6:00 am and sunrise
    (with gradual transitions inbetween)

I would prefer not to have to manually press a sleep mode button (in case sleep mode is the solution, Iā€™ve not used it yet). Thanks!

Can you use an automation or the scheduler card to toggle the sleep switch?

Yes, while Iā€™m unfamiliar with the details of a ā€œsleep switchā€, I could automate turning that on at 8pm and off at 6am. Until now I didnā€™t assume there was a transition to the sleep mode, but as youā€™re now asking I assume there is a way to slowly transition to/from sleep mode over e.g. 15 minutes?

It looks like it. sleep_transition. I havenā€™t tested it, but the description seems like it would do what you want.

Has someone else noticed unwanted behaviour after upgrading HA core to 2024.3.x (from 2024.2.x)? Iā€™m guessing there have been some changes in the light.turn_on service call.

  1. Transition time is not honored anymore with the lights that have adaptive lighting enabled. The following service call turns the light instantly (< 2 s) on. In the previous HA core versions, the specified transition duration was used (60 s in the example).

    service: light.turn_on
    data:
      transition: 60
    target:
      entity_id: light.example_light
    
  2. When turning light on with the service call the adaptation now begins from the previous state. So, if the previous brightness was 100 % and the adaptive lighting sets the brightness to 10 % the brightness goes first to 100 % for a short period and then changes to 10 %. This can be really annoying in the late evening. In the previous HA core versions the adaptation started from 0 % brightness to the current brightness.

adapt_delay and initial_transition are set to the default values (0 and 1 respectively). adapt_only_on_bare_turn_on is set to true (default false). I tried to change them but it didnā€™t resolve the above mentioned issues.

I have not changed anything in adaptive lighting settings so this must be related to the HA core update. Has anyone come up with a solution?