Avoiding Multiple Motion Detections

First posting here, please be gentle; I barely understand using the HA GUI and have even less experience with yaml, but here goes anyway.

I’ve looked at several posts, most to all providing good details but aren’t addressing the specificity of my topic. Not sure if my topic is relative to yaml in HA or the sensor itself.

I have two PIR sensors (setup with ESPhome in HA) functioning as triggers turning on led stair lights (one at the top & bottom of the stairs). This setup is functional and works. The problem I’m trying to resolve, is when another person follows directly after me, the PIR sensor detects the next person, which turns off the lights.

I’m seeking help to figure out how to get the sensors to stop detecting motion for a brief amount of time (i.e. 4 or 5 seconds); still allowing the lights to turn on for the existing HA Helper: Timer (15 seconds). I’m not sure if the HA automation can do it, or if the actual PIF sensors need to be coded. Either way, I have no idea how to make this kind of specific adjustment.

Most motion sensors do this anyway. When motion is detected the sensor turns on, then after about 10 seconds it turns off again, so that it’s ready to detect the next movement.

A lights automation should only use this as a trigger. The simplest possible automations (one for on and one for off) would be something like…

For on:

triggers:
  - trigger: state
    entity_id:
      - binary_sensor.your_motion_sensor
    to: "on"
actions:
  - action: light.turn_on
    target:
      entity_id: your_light

And for off:

triggers:
  - trigger: state
    entity_id:
      - binary_sensor.your_motion_sensor
    to: "off"
    for:
      hours: 0
      minutes: 10        # Change this to whatever delay you want
      seconds: 0
actions:
  - action: light.turn_off
    target:
      entity_id: your_light

You don’t need a timer.

Welcome to the community! :grin:

Whilst this doesn’t really answer your scenario (you use ESPhome, ZHA and 2 gang light switches?), I’ve posted some musings on a pinned topic

If you use an automation, you can also use a condition rule to only re-trigger the automation, if it hasn’t been triggered in the last X amount of seconds

I use this quite a bit for all movement based triggers, I have configured to prevent spamming of alerts, flashing lights on & off etc.

conditions:
  - condition: template
    value_template: >-
      {{ now() -
      state_attr('automation.automation_kitchen_light_screen_on_motion'
      , 'last_triggered') | default(now(), true) > timedelta(seconds=60) }}

Thank you! I’m going to for sure dive into this. Being new to the coding, I’m working on a hit & miss kind of testing.

Oh wow! This for sure has my wheels turning. Now I’ll be stumbling around the GUI to try and see how I can apply it. I like the idea of trying to resolve this conundrum using conditions; my beginner-brain seems to be letting this aspect jell to it :upside_down_face: