Automations not_home

First, apologies for my English

I’m starting to use home assistant and I have a question
I need to create an automation only when the house stays empty we are only 2 people and I have several zones configured. When I do the automation, it does not help if I put it to run when our location is “not_home” because “BP” is another location, so I have to put, each location as a condition, I need something easier
here the example:

  • id: ‘1551734681101’
    alias: Loc OT sale CARI fuera
    trigger:
    • entity_id: device_tracker.iphonex
      event: leave
      platform: zone
      zone: zone.home
      condition:
      condition: or
      conditions:
      • condition: state
        entity_id: device_tracker.iphonema
        state: not_home
      • condition: zone
        entity_id: device_tracker.iphonema
        zone: zone.asv
      • condition: zone
        entity_id: device_tracker.iphonema
        zone: zone.gimnasio

Thanks!

1st, can you update your post and format your code correctly. See the top of the page for how to do that.

2nd. So what is your goal? I think you want something to happen when everyone leaves the house? Like turn off lights, locks doors, arm security, etc?

If that is your goal, then you might want to try creating a group, and adding your device trackers to that group. The group will not show zones, just home or not_home.

This runs when all devices are away from home. It utilizes the home assistant made group all_devices of which in your case would include you and the other person. I dont use the zone but I think this will still work.

- alias: Leaving home
  trigger:
  - entity_id: group.all_devices
    platform: state
    to: not_home
  action:
  - service: ...
1 Like