I want to trigger my garage door to close if
a. it is open
b. no one is home based on all_mobile_devices group which has device_tracker objects in it
here is my question, what triggers the event and how often does it run?
Do I trigger on a garage door state of open and have a condition that everyone is gone
or
do I trigger on everyone being gone and have a condition that the garage door is open?
There are the following test cases.
The last person in the house leaves the garage door open when they leave for the day.
Someone who is not tracked by all_mobile_devices group opens the garage door (my oldest son and his girl friend who live out of town, but come in occasionally for example).
So in test case 1 the trigger would be based on the person leaving. But in test case 2, it’s based on the door opening? If I code the trigger to look for the last person leaving, how often will the trigger check to see if the garage door is opening, because there isn’t a state change in the members of all_mobile_devices?
So I’ll have two automations for this, one to trigger on the garage door being open, and one to trigger on the house becoming empty. Not a problem, just making sure I can’t do it with one automation.
Sure. I use multiple triggers often. In this example, it’s essentially the same trigger three times, you get the syntax.
What it does: lock my front door after 5 min. But I had cases where someone might be standing with the door open for more than 5 min, so I have backups at 10 and 15. Each time, it checks to make sure that the door is closed first.
- alias: Auto Lock Front Door
trigger:
- platform: state
entity_id: lock.front_door_deadbolt
state: 'unlocked'
for:
minutes: 5
- platform: state
entity_id: lock.front_door_deadbolt
state: 'unlocked'
for:
minutes: 10
- platform: state
entity_id: lock.front_door_deadbolt
state: 'unlocked'
for:
minutes: 15
condition:
condition: and
conditions:
- condition: state
entity_id: binary_sensor.front_door
state: 'off'
- condition: state
entity_id: input_boolean.house_guest
state: 'off'
action:
- service: lock.lock
entity_id: lock.front_door_deadbolt