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.
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'.
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?
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?
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:
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 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).
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.