I have an automation that unlocks the front door when we ring the bell, but only if one of us has arrived home within the last two minutes or the car has arrived home in the last four (since it takes a bit of extra time from ESPresense picks us up until we have parked and get to the door). This only happens once during two minutes, so nobody can sneak in right after us. This is the one for me:
alias: Unlock the dor when Mastiff comes home
description: ""
triggers:
- trigger: mqtt
topic: eg/Doorbell 1
enabled: true
- trigger: mqtt
topic: eg/Doorbell 2
enabled: true
conditions:
- condition: or
conditions:
- condition: and
conditions:
- condition: state
entity_id: device_tracker.mastiff
state: home
- condition: template
value_template: >-
{{ now() - states.device_tracker.mastiff.last_changed <
timedelta(minutes=2) }}
- condition: template
value_template: >-
{{ now() - states.device_tracker.mastiffmobilen.last_changed <
timedelta(minutes=4) }}
- condition: template
value_template: >-
{{ now() - state_attr('automation.unlock_the_door_when_mastiff_comes_home',
'last_triggered') > timedelta(minutes=2) }}
actions:
- data:
entity_id: lock.dor_nede
action: lock.unlock
mode: single
I have similar for six other people (our kids and their spouses), and I’d like to consolidate them into one. Is that possible/easy/doable or all of the above?