Turn light/switch OFF if forgot, based on not detected motion (with time range condition)

Based on system HA motion activated light but improved with only off option.
I manually turn on a switch but if i forgot i needed to automatically turn it off after amount of time with no motion detected.

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

For example i use this blueprint for turn off my heavy consuming appliances (controlled by a smart switch)

More info here on GitHub Repo

blueprint:
  name: Motion-activated Light Switch Off only
  description: Turn off a switch when motion is not detected anymore.
  domain: automation
  source_url: https://github.com/fabiosoft/HA-Motion-deactivated-Light-Switch/
  input:
    motion_entity:
      name: Motion Sensor
      selector:
        entity:
          domain: binary_sensor
          device_class: motion
    light_target:
      name: Light Switch
      selector:
        target:
          entity:
            domain: switch
    no_motion_wait:
      name: Wait time
      description: Time to leave the light on after last motion is detected.
      default: 120
      selector:
        number:
          min: 0
          max: 3600
          unit_of_measurement: seconds
    start_time:
      name: Start Time
      description: Time action should start
      default: "17:00:00"
      selector:
        time:
    end_time:
      name: End Time
      default: "00:00:00"
      description: Time action should stop
      selector:
        time:

# If motion is detected within the delay,
# we restart the script.
mode: restart
max_exceeded: silent

trigger:
  platform: state
  entity_id: !input motion_entity
  from: "off"
  to: "on"
condition:
  alias: "Time 17~00"
  condition: time
  # At least one of the following is required.
  after: !input start_time
  before: !input end_time
action:
  #- service: switch.turn_on
  #  target: !input light_target
  - wait_for_trigger:
      platform: state
      entity_id: !input motion_entity
      from: "on"
      to: "off"
  - delay: !input no_motion_wait
  - service: switch.turn_off
    target: !input light_target

3 Likes

Hi, the description shows that the automation is for LIGHT/SWITCH but I am only able to select switches as the device to turn off.
Can you change this?

Hello.
this is a great blueprint. but i have a question. i want to set it that if there is no motion it should turn of the lights after 10 mins, but the question if there was movement with in those 10 mins will the timer start again or it will turn off after 10 mins from the first time there was no movement?