Is there a way of defining an automation trigger for a door sensor that goes from closed to open for a time period such as between 2 and 5 seconds?
I can only see the open for x time option which I have set at 2 seconds so anytime longer than this also triggers. I have a postbox delivery notification automation. My postbox has a delivery flap with a sensor and retrieval door with a sensor. However, I have to open the flap in order to open the access door which sends me a new notification that I have mail when I’m emptying it. If I can set a maximum trigger time for post received that is less than the longer time it takes for me to unlock and open the front door then this will work perfectly.
alias: Postbox new post delivery
description: notify when post has been delivered
mode: single
triggers:
- entity_id:
- binary_sensor.post_box_flap
from: "off"
to: "on"
for:
hours: 0
minutes: 0
seconds: 2
trigger: state
conditions: []
actions:
- data: {}
target:
entity_id: input_boolean.you_have_post
action: input_boolean.turn_on
- data:
datetime: "{{ now().strftime('%Y-%m-%d %H:%M') }}"
target:
entity_id: input_datetime.postman_time
action: input_datetime.set_datetime
- action: counter.increment
metadata: {}
data: {}
target:
entity_id: counter.post_count
- variables:
postman_time: >-
{{as_timestamp(states('input_datetime.postman_time')) |
timestamp_custom('%A at %H:%M')}}
post_count: "{{states('counter.post_count')}}"
- data:
message: |-
You have new post now {{post_count}}
times since emptying
The postman last delivered {{postman_time}}
title: New Post
action: notify.mobile_app_lews_iphone
- data:
target:
entity: null
enabled: false
action: notify.alexa_media