No One is At Home Trigger with Zones

It doesn’t look like HA lets you trigger with AND statements, so I’m running into a bit of a challenge with this one. I’m also a bit of a newbie to HA so I may be overlooking something obvious.

Basically I want the alarm to set automatically if there is no presence in the home and the alarm is not armed. If I could use an AND statement it would be easy, but no joy there. This is what I’m looking to do.

If my phone and my wife’s phone leave zone ‘Home’ and the alarm is not Armed_Away, set the alarm to Alrmed_Away.

Any ideas?

The automagion should be like this:
Trigger: person A OR person B leaves home
Conditions: No one is home AND alarm is not armed
Action: Set alarm

1 Like

Thanks for your help.

I’m not sure how to define ‘No one is home’ in the condition.

You can do an “AND” in a trigger, but you have to use a template trigger to do so.

Also, why would you check if the alarm was not armed away before setting it to armed away? For most types of entities, changing it to the same state it’s already in basically does nothing.

So, you could do something like this:

- trigger:
  - platform: template
    value_template: >
      {{ not is_state('person.me', 'home') and
         not is_state('person.wife', 'home') }}
  action:
  - service: alarm_control_panel.alarm_arm_away
    entity_id: alarm_control_panel.PANEL

This automation will trigger whenever the last person leaves home, and won’t trigger again until at least one person comes home, and then when the last person leaves again.

FWIW, I don’t use an alarm_control_panel integration, so I’m not sure about the automation actions.

EDIT: The other way this is typically done is to create a group of the person entities you care about. The group’s state will be 'home' when anyone in the group is home, and will be 'not_home' when nobody in the group is home. Then you can trigger the automation on the group entity becoming 'not_home'.

3 Likes

@pnbruckner

Thanks for the feedback. I agree with going with the group route. Seems to be the better solution. However, I’m new and a bit unfamiliar with creating groups. I’ve looked for articles but I’m having a bit of trouble. Do you mind pointing me in the right direction?

You don’t need “articles.” Just look at the official documentation:

@pnbruckner Thanks! Super helpful. I got everything up and running.

I am new with home assistant so I am reading a lot a playing with stuff and so I came across this topic.
However I am not sure how to create a group of people (or phones for that matter), if I use helper to create it, there is no option to add person or phone. Could you please direct me what am I missing?

1 Like

Hi Martin,

This post if very old, and HA has moved on in its implementation of groups. They work differently now than they used to, including dropping support for device tracker entities.

However, having said that, the older style group implementation is still available. You can find out more here:

Oh I see. Never mind, thank you anyway for your response.

I was reading about it and still can’t figure out how to group people or their trackers.
Please could you point me somewhere?

The link I provided above (Old style groups) shows exactly how to do this. In fact, it even includes a group of device_tracker entities in the examples. Can you maybe ask a more specific question? Or give an example of what you’ve tried that didn’t work?

I am sorry for confusing.

I am trying to detect presence of people at home based on asus router device present of wifi reporting, since geolocation is very unreliavle for some resons.

I need to know when nobody is at home (no phone present on wifi).

If I don’t want to use old style groups, how am I supposed to do it with new style gropus, or other methods?

Edit: after yet more reading I came across this very simple solution

states('zone.home') | int 

it does exactly what I need, thanks for your patience.

I know this is old, but in my deployment - 2023.3, the group becomes “away” when all members of there group are not home. Heads up for whoever gets here through search.