motion_light.yaml 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. blueprint:
  2. name: Motion-activated Light
  3. description: Turn on a light when motion is detected.
  4. domain: automation
  5. source_url: https://github.com/home-assistant/core/blob/dev/homeassistant/components/automation/blueprints/motion_light.yaml
  6. input:
  7. motion_entity:
  8. name: Motion Sensor
  9. selector:
  10. entity:
  11. domain: binary_sensor
  12. device_class: motion
  13. light_target:
  14. name: Light
  15. selector:
  16. target:
  17. entity:
  18. domain: light
  19. no_motion_wait:
  20. name: Wait time
  21. description: Time to leave the light on after last motion is detected.
  22. default: 120
  23. selector:
  24. number:
  25. min: 0
  26. max: 3600
  27. unit_of_measurement: seconds
  28. # If motion is detected within the delay,
  29. # we restart the script.
  30. mode: restart
  31. max_exceeded: silent
  32. trigger:
  33. platform: state
  34. entity_id: !input motion_entity
  35. from: "off"
  36. to: "on"
  37. action:
  38. - alias: "Turn on the light"
  39. service: light.turn_on
  40. target: !input light_target
  41. - alias: "Wait until there is no motion from device"
  42. wait_for_trigger:
  43. platform: state
  44. entity_id: !input motion_entity
  45. from: "on"
  46. to: "off"
  47. - alias: "Wait the number of seconds that has been set"
  48. delay: !input no_motion_wait
  49. - alias: "Turn off the light"
  50. service: light.turn_off
  51. target: !input light_target