blueprint: name: Motion-activated Light NEW description: Turn on a light when motion is detected NEW. domain: automation source_url: https://github.com/home-assistant/core/blob/dev/homeassistant/components/automation/blueprints/motion_light.yaml author: Tiziano Trabattoni input: motion_entity1: name: Motion-sensor1 selector: entity: filter: device_class: motion domain: binary_sensor motion_entity2: name: Motion-sensor2 selector: entity: filter: device_class: motion domain: binary_sensor light_target: name: Light selector: target: entity: domain: light no_motion_wait: name: Wait time description: Time to leave the light on after last motion is detected. default: 20 selector: number: min: 0 max: 300 unit_of_measurement: seconds # If motion is detected within the delay, # we restart the script. mode: restart max_exceeded: silent triggers: - trigger: state entity_id: !input motion_entity1 from: "off" to: "on" id: motion_entity1_on - trigger: state entity_id: !input motion_entity2 from: "off" to: "on" id: motion_entity2_on - trigger: state entity_id: !input motion_entity1 from: "on" to: "off" id: motion_entity1_off - trigger: state entity_id: !input motion_entity2 from: "on" to: "off" id: motion_entity2_off variables: light_target_var: !input light_target motion_entity1_var: !input motion_entity1 motion_entity2_var: !input motion_entity2 actions: - choose: - conditions: - condition: trigger id: - motion_entity1_on - motion_entity2_on sequence: # POSSIBILE baco, dovrebbe essere come di seguito ma la condizione dell'IF non funziona con le variabili qui ma e' ok nella validazione del templating # - if: # - condition: template # value_template: "{{ states( light_target_var) == 'off' }}" # then: # - alias: "Turn on the light" # action: light.turn_on # target: !input light_target - alias: "Turn on the light" action: light.turn_on target: !input light_target - conditions: - condition: trigger id: - motion_entity1_off - motion_entity2_off sequence: - if: - alias: "None of motion sensor are detected" condition: not conditions: # - condition: template # value_template: "{{ is_state('binary_sensor.presenza_alta_scala_mansarda_occupancy', 'on') }}" # - condition: template # value_template: "{{ is_state('binary_sensor.presenza_bassa_scala_mansarda_occupancy', 'on') }}" - condition: template value_template: "{{ is_state(motion_entity1_var, 'on') }}" - condition: template value_template: "{{ is_state(motion_entity2_var, 'on') }}" then: - alias: "Wait for delay set before turn off" delay: !input no_motion_wait - alias: "Turn off the light" action: light.turn_off target: !input light_target