action:
- alias: Turn on the light
  service: light.turn_on
  target: !input 'light_target'
- alias: Wait until there is no motion from device
  wait_for_trigger:
    entity_id: !input 'motion_entity'
    from: 'on'
    platform: state
    to: 'off'
- alias: Wait the number of seconds that has been set
  delay: !input 'no_motion_wait'
- alias: Turn off the light
  service: light.turn_off
  target: !input 'light_target'
blueprint:
  description: Turn on a light when motion is detected.
  domain: automation
  input:
    light_target:
      name: Light
      selector:
        target:
          entity:
            domain: light
    motion_entity:
      name: Motion Sensor
      selector:
        entity:
          device_class: motion
          domain: binary_sensor
    no_motion_wait:
      default: 120
      description: Time to leave the light on after last motion is detected.
      name: Wait time
      selector:
        number:
          max: 3600
          min: 0
          unit_of_measurement: seconds
  name: Motion-activated Light
  source_url: https://github.com/home-assistant/core/blob/dev/homeassistant/components/automation/blueprints/motion_light.yaml
max_exceeded: silent
mode: restart
trigger:
  entity_id: !input 'motion_entity'
  from: 'off'
  platform: state
  to: 'on'
