Automation Question- When person arrived home

I have presence detection set up via phone connection to router. I’ve created an automation when state changes to home then unlock door. The problem I’m having is if the phone drops from the router randomly and reconnects in unlocks the door in middle of the night. Are there any way around this without changing the type of presence detection?

I tried to put a condition if person was not-home for 10min, but it doesn’t seem to work because the current condition is home when it was triggered. I think the best way would be if (Condition): state changed to home in the last 3 minutes and (trigger) motion is detected (action) open the front door. But have no idea how to set up the condition for last 3 minutes.

Welcome to the community forums!

Basically, such a condition could look like the following:


  condition:
    - "{{ now() - states.device_tracker.me.last_changed < timedelta(minutes=3) }}"

Thank you, I tried plugging it in but I get an error when I test it.
I put it in like this

condition:
    - "{{ now() - states.device_tracker.unifi_ae_2d_2f_18_e9_ee_default.last_changed < timedelta(minutes=3) }}"

Where am I making a mistake?

What kind of error?
Please post your code.

condition: template
value_template: "{{ now() - states.device_tracker.unifi_ae_2d_2f_18_e9_ee_default.last_changed < timedelta(minutes=3) }}"

Error:
template value should be a string for dictionary value @ data[‘value_template’]. Got None

Ah, ok, I didn’t think of that (I use packages for my automations). That is a bug, see here:

You can try to edit the automations.yaml file directly.