Alarm and Zone automation

Hey, I’m looking out for some help from an automation expert :wink:

I’m currently setting up an alarm within the home assistant manual alarm panel. But as I discovered, it’s hard getting everybody to turn on/off the alarm when getting home. So I started setting up device trackers on phones and tried to use zones to turn on the alarm when everybody has left home and vice versa…

However, the automation I made only turns on the alarm when one leaves, and not when everyone has left.

So can someone help me set up a condition which marks that everyone shall leave before activating the alarm??

Here is my current config:

entity_id:
  - device_tracker.xx
  - device_tracker.xx
  - device_tracker.xx
event: leave
platform: zone
zone: zone.home

action:
entity_id: alarm_control_panel.xx
service: alarm_control_panel.alarm_arm_away

Thanks in advance! :slight_smile:

Easiest way is put your device trackers into a group and use that to trigger your automation.

This is how I use a group to trigger the system:

- id: alarm_arm_unocc
  alias: '[Alarm] Arm Unocc'
  trigger:
  - platform: state
    entity_id: group.occ_card
    to: 'not_home'
  action:
  - service: alarm_control_panel.alarm_arm_away
    entity_id: alarm_control_panel.ha_alarm

- id: alarm_disarm_occ
  alias: '[Alarm] Disarm Occ'
  trigger:
  - platform: state
    entity_id: group.occ_card
    to: 'home'
  action:
  - service: alarm_control_panel.alarm_disarm
    entity_id: alarm_control_panel.ha_alarm

2 Likes

Thanks dude, you are a life saver! :smiley:

I do however want to state to anyone, who might run into this post in the future the last lines on the group docs

" By default when any member of a group is on then the group will also be on . Similarly with a device tracker, when any member of the group is home then the group is home . If you set the all option to true though, this behavior is inverted and all members of the group have to be on for the group to turn on as well."

1 Like

It’s a neat feature but the default should work. All people have to be not home in order for the group to be not home. Only one person will change the group to home.