PIR sensor notification with delay

Hi all,
I have a PIR sensor and a bluetooth device tracker.

What I want to do it a “small security” system for my home, that send me a notification if PIR sensor detects a motion when no one is at home.
the problem is that my device tracker needs around 60 seconds to understand that I’m at home, so I can trigger the PIR sensor before the device tracker updated the fact that I’m at home.

How can I do an automation that send me a notification if PIR sensor is triggered but only if I’m not at home?
A simple condition is not enough. the condition should wait 60 seconds to give the device tracker to understand if I’m at home or not.

thanks

automation:
  alias: Security alert
  trigger:
    platform: state 
    entity_id:
      - LIST
      - OF
      - PIRS
    to: DETECT_MOTION
  action:
    - delay: '00:01:00'
    - condition: state
      entity_id: YOUR _DEVICE _TRACKER 
      state: 'not_home' 
    - service: notify.notify
      data:
        message: 'Burglars on the rampage!' 

thjanks for the answer.

is there a smarter way to not launch thousands of delay when I’m at home?
as far as I understood in that way every time the PIR sensor detects a movement he starts a delay and than evaluate the condition if I’m home or not.

is it possible to not start a delay if I’m at home?

in any case the automation seems to not work properly.
the notification is sent as soon as PIR detect a movement even if I set a delay of one minutes, I don’t understand why…

- id: '1546568397602'
  alias: Intrusione
  trigger:
  - entity_id: binary_sensor.sr501pir
    from: 'off'
    platform: state
    to: 'on'
  condition: []
  action:
  - condition: state
    entity_id: device_tracker.droidstar
    state: not_home
  - condition: state
    entity_id: device_tracker.nexus_5x
    state: not_home
  - delay: 60
  - condition: state
    entity_id: device_tracker.droidstar
    state: not_home
  - condition: state
    entity_id: device_tracker.nexus_5x
    state: not_home
  - data:
      message: Intrusione rilevata.
    service: notify.hassio_notifier
  - data:
      language: it
      message: Intrusione rilevata, chiamata alle autorità in corso!
    service: tts.google_say

this is my automation. what’s wrong?

If you want a full alarm system with customisable entry and exit delays you could install this custom component:

I would like to produce a simple automation but thanks
Is there someone who can help with that automation?

Did you try the actual code that @anon43302295 posted above in the same format but with your details inserted?

If you look at the automation that he posted then look at your automation you should hopefully see the differences and likely why it’s not working.

“- delay: 60” 60 what? That doesn’t follow any of the syntax examples listed in the docs:

and you left out the ’ marks around not_home in your conditions.

And I’m not sure why you need the same conditions listed twice - once before the delay and once after?

1 Like