adaptive-lighting icon indicating copy to clipboard operation
adaptive-lighting copied to clipboard

Synchronize brightness with sun position

Open bnason opened this issue 2 years ago • 3 comments

I'm not sure if this has been asked before as I couldn't find anything in a search and this is how I assumed adaptive lighting actually worked without really reading the the readme.

Effectively, I would like my lights to turn on to min brightness at sunrise and rise to max brightness at solar noon. Optionally, keeping the lights at min brightness all night or turning them off.

I'm not sure if this "mode" would be better added directly in or if a fork would be preferred.

bnason avatar Mar 10 '22 21:03 bnason

So I figured out a poor mans way of doing this using some custom helpers, sensors and automations. Note, I have a night time sensor that's basically inverted so I can control my patio lights. I'm also very new to home assistant so excuse me if there is a better way to even do this workaround.

The major problem with this implementation is the lack of override controls as well as the lights not consistently being updated as the automation doesn't seem to run all the time for me.

Custom helpers

input_number.lights_max_brightness input_number.lights_min_brightness

Custom sensors

- platform: template
  sensors:
    solar_lighting_brightness:
      unit_of_measurement: "%"
      value_template: >
        {{ (states('input_number.lights_max_brightness')|int - states('input_number.lights_min_brightness')|int) * (max(0, min(100, states('sensor.adaptive_lighting_sun_position')|float)) / 100) + states('input_number.lights_min_brightness')|int }}

- platform: template
  sensors:
    solar_lighting_brightness_night:
      unit_of_measurement: "%"
      value_template: >
        {{ (states('input_number.lights_max_brightness')|int - states('input_number.lights_min_brightness')|int) * (max(0, min(100, (states('sensor.adaptive_lighting_sun_position')|float) * -1)) / 100) + states('input_number.lights_min_brightness')|int }}

Day Time Automation

alias: Solar Light Brightness
description: ''
trigger:
  - platform: state
    entity_id: sensor.solar_lighting_brightness
condition: []
action:
  - service: light.turn_on
    data:
      brightness_pct: '{{ states(''sensor.solar_lighting_brightness'')|float }}'
    target:
      device_id:
        - xxx
        - yyy
mode: single

Night Time Automation

alias: Solar Light Brightness Night
description: ''
trigger:
  - platform: state
    entity_id: sensor.solar_lighting_brightness_night
condition:
  - condition: sun
    before: sunrise
    after: sunrise
    before_offset: '3599'
    after_offset: '2599'
action:
  - service: light.turn_on
    data:
      brightness_pct: '{{ states(''sensor.solar_lighting_brightness_night'')|float }}'
    target:
      device_id:
        - zzz
mode: single

Card View

color_thresholds_transition: smooth
entities:
  - entity: sensor.adaptive_lighting_sun_position
    name: Sun Position
    show_state: true
    show_fill: false
    color: rgb(231, 76, 60)
  - entity: sensor.solar_lighting_brightness
    name: Day Brightness
    show_state: true
    show_fill: false
    color: rgb(255, 152, 0)
    y_axis: secondary
  - entity: sensor.solar_lighting_brightness_night
    name: Night Brightness
    show_state: true
    show_fill: false
    color: rgb(52, 152, 219)
    y_axis: secondary
font_size: 80
group: false
name: Brightness vs Sun Position
hours_to_show: 24
hour24: true
line_width: 2
points_per_hour: 2
lower_bound: -100
upper_bound: 100
lower_bound_secondary: -100
upper_bound_secondary: 100
show:
  extrema: false
  fill: fade
  labels: false
  name: true
  state: true
type: custom:mini-graph-card

Screenshot from 2022-03-16 19-14-06

bnason avatar Mar 14 '22 13:03 bnason

I really like this idea of having two different curves...one for daytime and one for nighttime, that can be adjusted. Adaptive lighting currently only has one curve input: the circadian rhythm sun curve, but it is not really adaptable or modified by the user.

rsnodgrass avatar Apr 28 '22 14:04 rsnodgrass

I'd also love to see this. I have a few rooms in my house where the natural light is very good and during the daytime I essentially don't need light but in the evening I'd like the light value to be at 100%. Essentially I'd love to see an option that does 100 - $StandardAdaptiveBrightnessValue and sends that brightness value to the light instead.

Side note: This may be a duplicate of #88 if I follow that thread enough

jak119 avatar Sep 12 '22 14:09 jak119

@bnason Can you implement this yourself by swapping the positions of sunrise_time and sunset_time? Once #443 is implemented you should be able to do this with automations/scripts.

th3w1zard1 avatar Mar 23 '23 16:03 th3w1zard1