Alarm Arm/Disarm Automation Based on Multiple Device Trackers

Hi everyone,

I need some help with automation in Home Assistant that I’ve been struggling to get right. I search on the forums and in fact, that allowed me to get until the current point but still isn’t working as expected.

Current Setup:
Home Assistant OS installed on baremetal (13.0) with Alarmo installed.
We all have the Home Assistant Companion App installed with tracker enabled (working fine in all devices)

I have an automation that arms or disarms “Alarmo” based on the proximity of mobile devices with the Home Assistant app installed. There are a total of three devices that we track:

  • When Person 1’s device enters the defined location radius, the alarm is disarmed.
  • When Person 1’s device leaves the radius, the alarm is armed.

This setup works fine for single users, but I have run into an issue when multiple people are involved.

The Problem:

Let’s say Person 1 leaves the location, but Person 2 or Person 3 is still within the radius. As the automation is currently set up, the alarm would arm even though there are still people in the location, which is not what I want.

I understand that I could potentially solve this with a series of AND/OR conditions, checking whether the other devices are home or not before arming the alarm. However, since there are three people involved, this approach would require multiple combinations and could become quite complex.

What I’m Looking For:

I’m seeking a solution that can evaluate the state of “nobody home” in a more straightforward way, ensuring that the alarm only arms when none of the devices are within the defined location. We all have the Home assistant companion App.

Should I create a Group (helpers, under Devices) for that or is not a secure option?

Additional Context:

  • I cannot use Wi-Fi-based tracking because the Wi-Fi coverage is insufficient to reliably detect if someone is home, as the location is in a rural area.

Any suggestions on how to best implement this would be greatly appreciated!

Use the state of zone.home

It contains the count of person objects that have device trackers reporting home.

So when zone.home == 0 someone’s (edit) not home and when > 0 it’s occupied.

All you have to so is assign appropriate device tracker to correct person and as long as the trackers are accurate So is zone.home.

1 Like

I think you mean no one is home :slightly_smiling_face:

1 Like

Yes as Wonka says… Strike that, reverse it

More coffee.

0= vacant.

Point is use the state of the home zone that’s what it’s there for.

1 Like

Thanks to all for your fast and efficient reply.

Indeed I missed the zone.home entity!!. In that case, I will have 2 automation:

1-Arm when leaving

2-Disarm when arriving

My question now is: Should I use the Entity zone.home as Trigger or Condition? I think adding as a Trigger can make it easier to maintain but don’t know if that’s the recommended way.

This is how it looks the second automation: “Arm when leaving”. Based on github link (Home Assistant Hot Tip of the day: home occupancy · GitHub):

Right now (I have 3 devices and I just deleted the device_id). I added the zone.home as condition.

alias: Arm when leaving
description: ""
trigger:
  - platform: device
    device_id: xx
    domain: device_tracker
    entity_id: xx
    type: leaves
    zone: zone.home
  - platform: device
    device_id: xx
    domain: device_tracker
    entity_id: xx
    type: leaves
    zone: zone.home
  - platform: device
    device_id: xx
    domain: device_tracker
    entity_id: xx
    type: leaves
    zone: zone.home
condition:
  - condition: state
    entity_id: zone.home
    attribute: persons
    state: "0"
action:
  - data: {}
    target:
      device_id: xx
    action: alarm_control_panel.alarm_arm_away
mode: single