Adaptive lighting YAML configuration

I am trying to configure an adaptive lighting setup in the YAML file.
I have created a sensor to output next sunset in 00:00:00 format.

How can i include a entity value in this code:

adaptive_lighting:
  - name: "Test"
    lights:
      # ... (other configurations)
    sunrise_time: sensor.tid_soloppgang
    # ... (other configurations)

This code gices me this error:

Invalid config for [adaptive_lighting]: Invalid time specified: sensor.tid_soloppgang for dictionary value @ data['adaptive_lighting'][0]['sunrise_time']. Got 'sensor.tid_soloppgang'. (See /config/configuration.yaml, line 122).

Note: If i set the sunrise_time to 08:00:00 it works.

Youā€™d have to use template format for this value to be populated.

${{ states(ā€˜sensor.tid_soloppgangā€™) }}

1 Like

That did not work. Got this error:

Invalid config for [adaptive_lighting]: Invalid time specified: ${{ states(ā€˜sensor.tid_soloppgangā€™) }} for dictionary value @ data['adaptive_lighting'][0]['sunrise_time']. Got '${{ states(ā€˜sensor.tid_soloppgangā€™) }}'
Invalid time specified: ${{ states(ā€˜sensor.tid_soloppgangā€™) }} for dictionary value @ data['adaptive_lighting'][0]['sunset_time']. Got '${{ states(ā€˜sensor.tid_soloppgangā€™) }}'. (See /config/configuration.yaml, line 122).

My configuration.yaml file code :

adaptive_lighting:
- name: "Test"
  lights:
    - light.spilevegg_spot_1
    - light.spilevegg_spot_2
    - light.spilevegg_spot_3
    - light.gang_vegg_spot_1
    - light.gang_vegg_spot_2
    - light.dimmable_light_1
    - light.downligts_spotkasse
    - light.gang_tak
    - light.kjokken_tak
    - light.soverom_tak
    
  prefer_rgb_color: false
  brightness_mode: 'tanh'
  transition: 45
  initial_transition: 1
  interval: 90
  min_brightness: 30
  max_brightness: 89
  min_color_temp: 2000
  max_color_temp: 5500
  sleep_brightness: 1
  sleep_color_temp: 1000
  brightness_mode_time_dark: 3700
  brightness_mode_time_light: 1
  sunrise_time: ${{ states(ā€˜sensor.tid_soloppgangā€™) }}
  sunrise_offset: 0
  sunset_time: ${{ states(ā€˜sensor.tid_soloppgangā€™) }}
  sunset_offset: 0 # in seconds or '00:30:00'
  take_over_control: true
  detect_non_ha_changes: false
  only_once: false

My sensor.yaml file:

- platform: template
  sensors:
    tid_soloppgang:
      value_template: "{{ as_timestamp(state_attr('sun.sun', 'next_rising')) | int | timestamp_custom('%H:%M:%S') }}"
      
    tid_solnedgang:
      value_template: "{{ as_timestamp(state_attr('sun.sun', 'next_setting')) |  int | timestamp_custom('%H:%M:%S') }}"

I added a $ where I shouldnā€™t have, try without it

1 Like

Not allowed:

Code:

adaptive_lighting:
- name: "Test"
  lights:
    - light.spilevegg_spot_1
    - light.spilevegg_spot_2
    - light.spilevegg_spot_3
    - light.gang_vegg_spot_1
    - light.gang_vegg_spot_2
    - light.dimmable_light_1
    - light.downligts_spotkasse
    - light.gang_tak
    - light.kjokken_tak
    - light.soverom_tak
    
  prefer_rgb_color: false
  brightness_mode: 'tanh'
  transition: 45
  initial_transition: 1
  interval: 90
  min_brightness: 30
  max_brightness: 89
  min_color_temp: 2000
  max_color_temp: 5500
  sleep_brightness: 1
  sleep_color_temp: 1000
  brightness_mode_time_dark: 3700
  brightness_mode_time_light: 1
  sunrise_time: {{ states(ā€˜sensor.tid_soloppgangā€™) }
  sunrise_offset: 0
  sunset_time: {{ states(ā€˜sensor.tid_solnedgangā€™) }
  sunset_offset: 0 # in seconds or '00:30:00'
  take_over_control: true
  detect_non_ha_changes: false
  only_once: false

Error in yaml:

missed comma between flow collection entries (154:3)

 151 |   brightness_mode_time_dark: 3700
 152 |   brightness_mode_time_light: 1
 153 |   sunrise_time: {{ states(ā€˜sensor ...
 154 |   sunrise_offset: 0
---------^
 155 |   sunset_time: {{ states(ā€˜sensor. ...
 156 |   sunset_offset: 0 # in seconds o ...