New Adaptive Lighting Integration

Thank you so much Daniel! I feel welcome. I understand your confusion.

I’d like AL to change the color temperature but AL not to change the brightness. I have found the options for that, which are the same as you show in the printscreens. This is working just fine.

At the same time, i want the brightness to be adjusted via a lux-meter (which is a 1000 times better than using a generic sunrise/sunset schedule).

The challenge is that, normally, I set the brightness via multiple scenes. However, those scenes are containing color temperature settings (which i don’t want, i want to use color temperature from AL). AL is changing the color temperature for me as expected (i disabled “take over control” to make this happen). The problem with this, is that i first see color temperature X when activating the scene, and then color temperature Y from AL. I’d like to see color temperature Y directly, without a weird color temperature change ‘in between’ (X -> Y).

I hope it is somewhat more clear now :slight_smile:

Yes it is more clear.
Is it possible to remove the CT from the scenes?
What’s the code for your scenes?
Which platform are the lights in question?

I had a similar issue but the other way round. Bathroom light controlled by Magic Areas came on at 100% and then AL set them to xxx percent so I lowered the initial turn on brightness in Magic Areas and then let AL ramp them up to the set brightness. The other way round at 4 am was an eye opener…

Yeah, sometimes it is good to take step back and to reconsider the strategy, and/or to ask help from the community :slight_smile:

See below a small part of one of the scenes. I’m using LIFX and Philips Hue. Hopefully this comes in handy when finetuning/aggregating/separating any commands to solve this puzzle.

In below scenes.yaml, light.woonkamer_subwoofer = Hue, the other two are LIFX.

- id: '1606727517975'
  name: Overdag fel
  entities:
    light.woonkamer_subwoofer:
      min_mireds: 140
      max_mireds: 650
      effect_list:
      - colorloop
      brightness: 97
      color_temp: 217
      is_deconz_group: false
      friendly_name: Woonkamer subwoofer
      supported_features: 63
      state: 'on'
    light.tv_licht:
      min_mireds: 111
      max_mireds: 400
      effect_list:
      - effect_colorloop
      - effect_pulse
      - effect_stop
      friendly_name: Tv licht
      supported_features: 55
      state: 'off'
    light.bureau:
      min_mireds: 111
      max_mireds: 400
      effect_list:
      - effect_colorloop
      - effect_pulse
      - effect_stop
      brightness: 145
      color_temp: 217
      friendly_name: Bureau
      supported_features: 55
      state: 'on'

While looking at this YAML file, I got an idea: would it be possible to add the “color_temp” value as a variable, which comes from AL? This should solve it (in theory)?

You could try a template value based on the AL attribute color_temp_kelvin

Which component is - id: '1606727517975' listed under?
It likely may not accept a templated value…

I previously tried templating sunrise/sunset for AL but it failed. (that was in the main component setup)

Upon re-reading the above, I gather it’s in a scene so, you might be able to template the value…

color_temp: >
  {{ state_attr('switch.xxxx', 'color_temp_kelvin') }}

(that’s off the top of my head! I’m not great with templates yet, lots of trial and error…)

{{ state_attr('switch.adaptive_lighting_bathroom', 'color_temp_kelvin') }} resolved to 10000 for me
and {{ state_attr('switch.adaptive_lighting_office', 'color_temp_kelvin') }} resolved to 3200 for me in dev tools…

Regarding id: ‘1606727517975’, it is indeed a scene.
If i understand you correctly, ‘color_temp_kelvin’ is the variable from AL for color temperature? That sounds very promising

I’ve done some additional research.

alias: Woonkamer daglicht
sequence:
  - choose:
      - conditions:
          - type: is_illuminance
            condition: device
            device_id: e6502f308a92b4ec13ea3605e16f45de
            entity_id: sensor.lightlevel_19
            domain: sensor
            above: 140
        sequence:
          - scene: scene.woonkamer_uit
      - conditions:
          - type: is_illuminance
            condition: device
            device_id: e6502f308a92b4ec13ea3605e16f45de
            entity_id: sensor.lightlevel_19
            domain: sensor
            above: 50
            below: 140
        sequence:
          - service: script.overdag
            data: {}
      - conditions:
          - type: is_illuminance
            condition: device
            device_id: e6502f308a92b4ec13ea3605e16f45de
            entity_id: sensor.lightlevel_19
            domain: sensor
            below: 50
        sequence:
          - service: script.overdag_fel
            data: {}
    default: []
mode: single

When combining all these, it should work:

  1. Use the script above as the starting point
  2. Modify the script variables by adding two templates to it: one list containing the list of lights, one containing the color temperature value from AL as advised by you:
color_temp: >
  {{ state_attr('switch.xxxx', 'color_temp_kelvin') }}
  1. Modify the “script choose sequences” by using a service: light.turn_on (instead of service: script.xxx), and add the following stuff to it:
  • The template list of lights
  • The template color_temp from AL
  • The exact brightness value I like for each choose-option

I think this should work.

I’ve got it working. The theory turned out to be true.

  • The only thing that needed to change, is to use the kelvin service data attribute instead of color_temp (which is using mireds), because AL is providing the value in Kelvin.

See below the solution. Hopefully this will help others as well.

Thanks for your help Daniel! Your advice about the color_temp_kelvin state attribute of AL was vital to get to this solution.

alias: Woonkamer daglicht v2
variables:
  entities:
    - light.woonkamer_subwoofer
    - light.bureau
    - light.woonkamer_rechts
    - light.bank
    - light.eettafel
    - light.keukenblad
  color_temp: >
    {{ state_attr('switch.adaptive_lighting_woonkamer', 'color_temp_kelvin') }}
sequence:
  - choose:
      - conditions:
          - type: is_illuminance
            condition: device
            device_id: e6502f308a92b4ec13ea3605e16f45de
            entity_id: sensor.lightlevel_19
            domain: sensor
            above: 140
        sequence:
          - scene: scene.woonkamer_uit
      - conditions:
          - type: is_illuminance
            condition: device
            device_id: e6502f308a92b4ec13ea3605e16f45de
            entity_id: sensor.lightlevel_19
            domain: sensor
            above: 50
            below: 140
        sequence:
          - service: light.turn_on
            data:
              entity_id: "{{ entities }}"
              kelvin: "{{ color_temp }}"
              brightness: 80

      - conditions:
          - type: is_illuminance
            condition: device
            device_id: e6502f308a92b4ec13ea3605e16f45de
            entity_id: sensor.lightlevel_19
            domain: sensor
            below: 50
        sequence:
          - service: light.turn_on
            data:
              entity_id: "{{ entities }}"
              kelvin: "{{ color_temp }}"
              brightness: 200

    default: []
mode: single
1 Like

Congratulations! Glad I was able to help!

BTW, all 5 color attributes are in the switch.
(Developer Tools is your friend, especially States and Templates!)
Looks like you could have used color_temp_mired…

Awesome, thanks! I’ll keep that in mind for nex time :+1:

Noob question:
Is there any way to have the adaptive lighting only affect the color temperature, not the brightness?
I couldn’t find my answer in the documentation.

There’s no way in the configuration setup but…since it creates “switches” for the areas’ brightness and color temp, I believe you would just need to turn the brightness switch off for the area(s) that you want brightness adjustment disabled for.
image

1 Like

Ah wow.
That is a funky way of controlling this integration, I had no idea.
I will give it a try, thanks for the tip!

Might seem funky but this way the entities are controllable via automations…

i did the same thing you did here with adding the color_temp values to the turn_on service call. But my lights only turn on every second time i call the script and i dont know why.

i have 2 scripts. one for turning on one for turning off.
so

  1. script.lights_on -> lights turn on as expected
  2. script.lights_off -> lights turn off as expected
  3. script.lights_on -> nothing (i can even see that the script runs in the logbook and no error in the logs)
  4. script.lights_on -> lights turn on as expected

this is so weird

…and removing color_temp from the script resolves your on-off-on-off testing?

yes, it only happens if Iam using the script with the templates for color temp and brightness. and it’s reproduce able with other scripts