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 trigger_variables: _light_target: !input light_target # motion_entity1_var: # entity_id: !input motion_entity1 # motion_entity2_var: # entity_id: !input motion_entity2 # # 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 # {% set light_target_var = 'light.test_lamp1' %} # {{ is_state(light_target_var, 'on') }} actions: - choose: - conditions: - condition: trigger id: - motion_entity1_on - motion_entity2_on sequence: - if: - condition: template value_template: "{{ states( 'light.test_lamp1' ) == 'off' }}" then: - 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: state # entity_id: !input motion_entity1 # state: true #- condition: state # entity_id: !input motion_entity2 # state: true 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