Automation that triggers when all residents are not home

Hi,

I am trying to create an automation that, if all residents leave (or when the final resident leaves rather so occupancy becomes zero) based on HA app geo location or all phones leaving the homes wifi/SSID, and if the door is left unlocked, then it will send me a notification.

I can not get any automation to work. Any help is appriciated.

Thank you!

Here is what I tried:

alias: Notification When Everyone Leaves And Door Is Unlocked
description: ""
trigger:
  - platform: state
    entity_id:
      - zone.home
    to: "0"
    from: null
condition:
  - condition: device
    device_id: 94bb955a91608334e7018cadb5ede0bd
    domain: lock
    entity_id: 58dae9b95bffc5d65cc84a41775700b2
    type: is_unlocked
action:
  - service: notify.notify
    data:
      message: 🔒🚨FRONT DOOR LEFT UNLOCKED🚨🔒
      title: 🔒🚨FRONT DOOR LEFT UNLOCKED🚨🔒
mode: single
1 Like

I did mine based on SSID:

As trigger use a person leaving.
Use as many triggers as you have persons.
As condition use:

  • nobody home anymore plus
  • door is still unlocked

Action: sent notification

What part doesn’t work?
Look at the traces!

Hi Frank. Thank you for the reply. I am kindof new and still learning HA. I just searched for a trigger called “person leaving” and do not see it. Is this option available in the GUI?

As I said, I use SSID - so I simply use the device tracker entity of the mobile of that
person and if that goes from home to not_home I consider the person gone.

Yes it is configurable in the GUI.

1 Like

:bangbang:

What you did will work if you’ve assigned a person entity to everybody and mapped the relevant device_tracker to that and you remove from: null.

I see that crop up a lot, causing problems. I’m curious whether you got that from a search, forum post, ChatGPT, or something else?

2 Likes

I did it through the GUI, then started trying to edit various things manually. I did search and did not find much that was very helpful.

1 Like

I think this is perfect! What was messing up for me was that when ANY trigger occurred, meaning ANYONE left, then it triggered even if people were still home. I did not think of correcting this issue with conditions. Will try this! Thanks so much!

1 Like

I would go with numeric state as trigger. If it goes under 0.5 for instance