Motion activated lights automation

Since not all motion sensor return to an ‘off’ state, you might end up with using a delay.
In that case, you need to put the automation in restart mode, so it will reset the delay when re-triggered.
f.e. my mqtt motion detector:

alias: Hallway Downstairs Light on Motion
description: Off when no motion for 3 mins
trigger:
  - alias: When motion detected hallway downstairs Pir] was trigged by MQTT
    platform: mqtt
    topic: Tasmota/tele/RESULT
    payload: D4A0EF
    value_template: '{{ value_json.RfReceived.Data}}'
condition: []
action:
  - service: light.turn_on
    target:
      entity_id: light.hallway_downstairs
  - delay:
      hours: 0
      minutes: 3
      seconds: 0
      milliseconds: 0
  - service: light.turn_off
    data: {}
    target:
      entity_id: light.hallway_downstairs
mode: restart

2 Likes