Adaptive lighting but reverse (if that makes sense?)

Hey guys, Im a fond user of Adaptive Lighting integration.

But I have garden lights that I want to turn on when the sun is going down and increase brightness towards midnight and again decrease towards sunrise.

I just cant seem to get the integration to automate this in reverse.

Can someone push me in the right direction?

I was able to do just that as follows:

Do not attach lights to the configuration
That would change the lights through the component

Create 2 template sensors
Add the following lines to your configuration.yaml


  - platform: template
    sensors:
      adaptive_lighting_brightness:
        unique_id: "adaptive_lighting_brightness"
        friendly_name: "AL Brightness"
        unit_of_measurement: "%"
        value_template: "{{ 100 - state_attr('switch.adaptive_lighting_al', 'brightness_pct') }}"

  - platform: template
    sensors:
      adaptive_lighting_color_temp:
        unique_id: "adaptive_lighting_color_temp"
        friendly_name: "AL Color Temperature"
        unit_of_measurement: "Kelvin"
        value_template: "{{ 2127 + 6535 - state_attr('switch.adaptive_lighting_al', 'color_temp_kelvin') }}"

The numbers 2127 and 6535 represent the min_color_temp_kelvin and max_color_temp_kelvin respectively of the lights
You can get those numbers from Developer Tools > States > light.your_light
You should also set those values to the component’s configuration for min_color_temp and max_color_temp

No need to restart HA, just reload the templates from Developer Tools > Yaml

Once you have your sensors, create an automation triggered by your sensors changing, and then set the brightness_pct and color_temp to the values of the sensors:

alias: Adjust Adaptive Lighting
description: ""
trigger:
  - platform: state
    entity_id:
      - sensor.adaptive_lighting_brightness
  - platform: state
    entity_id:
      - sensor.adaptive_lighting_color_temp
condition: []
action:
  - service: script.g_adaptive_lighting
    data: {}
mode: single

Which calls this script:

alias: G - Adaptive Lighting
sequence:
  - service: light.turn_on
    data:
      kelvin: "{{ states('sensor.adaptive_lighting_color_temp') | int }}"
      brightness_pct: "{{ states('sensor.adaptive_lighting_brightness') | int }}"
    target:
      entity_id: light.all_lights
mode: single
icon: mdi:script-outline

And that’s it !

Enjoy

2 Likes

Wow, thanks a lot! That works!

Sorry for the late reply!