Working on cleaning up and optimising some of my automations. I have the automation below which slowly increases brightness based on sunset. It has been working fine for years but wondering if it can be optimized, in particulair if there is a way to combine multiple lights into the same automation with different max brightness. Currently I have multiple automations and input sliders for different lights in my living room.
- alias: Sunset transition living light 1
trigger:
platform: time_pattern
minutes: '/1'
condition:
condition: and
conditions:
- condition: time
after: '14:00:00'
before: '23:00:00'
- condition: numeric_state
entity_id: sensor.sun_elevation
above: 0
- condition: state
entity_id: 'person.me'
state: 'home'
- condition: template
value_template: '{{ (states.sun.sun.attributes.elevation | int) < (states.input_number.elevation_brightness.state | int) }}'
- condition: template
value_template: '{{(states.light.livingroom_right.attributes.brightness|default(0)) < ((states.input_number.light_living_right.state |int)-(states.sun.sun.attributes.elevation * ((states.input_number.light_living_right.state | int) / ((states.input_number.elevation_brightness.state | int)+1 ))) | round(0)) }}'
action:
- service: light.turn_on
entity_id: light.livingroom_right
data_template:
brightness: '{{(states.input_number.light_living_right.state |int)-(states.sun.sun.attributes.elevation * ((states.input_number.light_living_right.state | int) / ((states.input_number.elevation_brightness.state | int)+1 ))) | round(0)}}'