Mobile Alert if door left unlocked automation question

I’d like to set up a mobile notification to trigger if I leave my home and my door us left unlocked.

I have an automation to run to turn off my lights and lock my door when I leave that runs pretty much 99% of the time but its failed maybe 2 times over the last 4 months so I’d just like to be alerted if the door is still unlocked.

The issue I have with the basic automation (attached) is it runs prior to my full leaving home automation finishing so I get the notification no matter what because the door hasn’t locked itself yet.

I think it could be as simple as a delay in the trigger or condition but I just can’t seem to wrap my head around where / what to add.

Please don’t post pictures of text. Actual text makes it much easier for us to copy / paste / edit a solution for you.

You could trigger on the lock being unlocked for: x minutes. With a condition that you are not home.

1 Like

What changes your trigger state to “not home”?

alias: Leaving Door Unlocked
description: Leaving Door Unlocked
trigger:
  - platform: state
    entity_id: person.ME
    to: not_home
condition:
  - condition: device
    device_id: XXXXXXX
    domain: lock
    entity_id: lock.front_door_lock
    type: is_unlocked
action:
  - service: notify.mobile_app
    data:
      message: Front door is unlocked!!
mode: single

So i am a bit lost on what triggers not home, in my original not home automation the trigger is the same (See below). My understanding is the home / not_home is set in the YAML with the longs / lats. I set up my HA a while ago and didn’t really start with automations until recently so i def am still in the learning curve.

But I think using the mobile phone as the trigger and making the area a bit wider could do the triple.

alias: Home Leaving
description: When I leave home
trigger:
  - platform: state
    entity_id: person.brianamartin
    to: not_home
condition: []
action:
  - service: script.front_door_off_lock
    data: {}
  - service: script.home_leaving
  - device_id: eb11c40c903d1a1ee400eb11e558fbfa