@jwelter wrote:
I have the below automation that works fine. It uses conditions to only trigger on the desired state events.
But is there a better way to do this? I tried using a template trigger (the condition that counts the lights on) and use that as a trigger when it changes but that didn’t work well – too much lag.
It just seems dirty to trigger on all state changes but perhaps I am over-thinking this.
########################################################## ## Update brightness when light turned on ########################################################## - alias: Adjust brightness as lights are turned on initial_state: True trigger: - platform: event event_type: state_changed condition: # Only look at lights going off to on - condition: template value_template: "{{ trigger.event.data is defined }}" - condition: template value_template: "{{ trigger.event.data.entity_id.split('.')[0] == 'light' }}" - condition: template value_template: "{{ trigger.event.data.new_state.state == 'on' }}" - condition: template value_template: "{{ trigger.event.data.old_state.state == 'off' }}" # Don't change these lights. # - condition: template # value_template: >- # {{ trigger.event.data.entity_id != 'switch.outdoor_front_switch' }} - condition: template value_template: "{{ states.sensor.target_brightness_inside.state is defined }}" - condition: template value_template: "{{ states.light | selectattr('state','==','on') | map(attribute='entity_id') | list | count >= 1 }}" action: - service: light.turn_on data_template: entity_id: >- {{ states.light | selectattr('state','==','on') | map(attribute='entity_id') | join(',') }} brightness_pct: >- {{ states('sensor.target_brightness_inside')|int }} transition: 2
Posts: 2
Participants: 2