Motion-activated light AND switches

A goal of this, purposefully basic, blueprint is to for users who love the default “Motion-activated light” blueprint, but want to use switches too. I have elected to switch to an Entity selector instead of the Target selector used in the original (see note below for explanation).

Feel free to post any issues you discover, I will happily attempt to correct them. However, please do not post requests to add features… as stated, one of the primary goals of this blueprint is to keep simple and on par with the original.

Open your Home Assistant instance and show the blueprint import dialog with a specific blueprint pre-filled.

2024-12-14:

  • Corrected config error.

2024-12-21:

  • Switched to independent triggers to avoid the Wait in the automation.

Note: Explanation of selector change

The use of Area and Device targets will effect all light and/or switch entities in the respective Area/Device. Because the original blueprint could only target lights, there was only a small chance that would have any substantial, negative effects. However, many devices and integrations create virtual switches to cover secondary functions. Haphazardly turning on and off functions like “reset” or “Do Not Disturb” could cause serious issues for users.

blueprint:
  name: Motion-activated Light and Switch
  description: Turn on a light and/or switch when motion is detected.
  domain: automation
  input:
    motion_entity:
      name: Motion or Occupancy Sensor
      selector:
        entity:
          multiple: false
          filter:
            - device_class: occupancy
              domain: binary_sensor
            - device_class: motion
              domain: binary_sensor
    light_target:
      name: Light
      selector:
        entity:
          multiple: true
          filter:
            - domain:
                - light
                - switch
    no_motion_wait:
      name: Wait time
      description: Number of seconds motion must be undetected for the light to be turned off.
      default: 120
      selector:
        number:
          min: 0
          max: 3600
          unit_of_measurement: seconds

max_exceeded: silent
triggers:
  - trigger: state
    entity_id: !input motion_entity
    from: "off"
    to: "on"
    id: "on"
  - trigger: state
    entity_id: !input motion_entity
    from: "on"
    to: "off"
    for:
      seconds: !input no_motion_wait
    id: "off"
actions:
  - alias: "Turn the light on or off based on motion trigger ID"
    action: "homeassistant.turn_{{ trigger.id }}"
    target: 
      entity_id: !input light_target

Thank you for posting this blueprint, it’s exactly what I want to use because my Light is plugged into a smart switch, thus I need to be able to target a Switch. However, upon trying to import the blueprint, the Preview shows errors as such:

while scanning a simple key in “”, line 55, column 1: ^ could not find expected ‘:’ in “”, line 56, column 1:

<a href="https://my.home-assi … ^

It does not let me import. When I view the blueprint text there really is no line 55 or 56… :face_with_raised_eyebrow:

Any help you can offer?

It looks like the importer didn’t like something about the way I had the update notes below the configuration block… It’s importing properly for me now. Let me know if it’s still failing.

It imported fine for me. The only thing it really lacks is a way to restrict the light coming on during the day, since you don’t really need the light to come on then.