I’ve been trying to set up an automation based on both me and my partners phones not being home where it will send us a notification if we are both “away” to arm the alarm if it is currently in disarmed state, I’ve set up an automation but it doesn’t seem to trigger when we both have left and I just can’t work out why…
alias: Notify to arm when nobody home
description: ''
trigger:
- platform: device
device_id: 0793e13e8ba65fbce762960e48b561b4
domain: device_tracker
entity_id: device_tracker.sophies_iphone
type: leaves
zone: zone.home
- platform: device
device_id: ddfe6dba49fd39f7b41b0c04abe604ec
domain: device_tracker
entity_id: device_tracker.iphone
type: leaves
zone: zone.home
condition:
- condition: not
conditions:
- condition: device
device_id: 96d6e167acf8351208fdaf6e82615dae
domain: device_tracker
entity_id: device_tracker.sophies_iphone_2
type: is_not_home
- condition: not
conditions:
- condition: device
device_id: ddfe6dba49fd39f7b41b0c04abe604ec
domain: device_tracker
entity_id: device_tracker.iphone
type: is_not_home
- condition: time
after: '06:00:00'
before: '21:00:00'
- condition: state
entity_id: alarm_control_panel.alarmo
attribute: arm_mode
state: disarmed
action:
- service: notify.alarm_notify_group
data:
message: 'Everybody left home, arm the alarm ? '
title: Nobody is Home
mode: single
I don’t use device triggers so struggle with the terminology here but I think your logic is incorrect as you have the 2 device triggers of leaving the home zone and then have conditions to prevent the automation running if the same devices are not is not home!
There are two much simpler options in my opinion:
1: make a group to include both yours and your partners device trackers and simply trigger off of this group not being home. The groups state will only show not_home when both phones have left.
Therefore you won’t need the separate conditions.
2: if there are only the 2 phones (or people) and I am guessing this is the case as you are looking to arm the alarm then you could also simply trigger on the state of the home zone going to zero (devices / people)
Need to add a group and don’t think you can do this for device trackers in the Ui at preset, so would need to add something similar to this to your config.yaml (or elsewhere if you have split you yaml)
group:
person1_person2: # rename as you see fit
name: "Both Of Us" # rename as you see fit
entities:
- device_tracker.one # your device trackers
- device_tracker.two
Then you can trigger like this based on the group:
platform: state
entity_id:
- group.person1_person2
to: not_home
for:
hours: 0
minutes: 2
seconds: 0
Or without the need for a group simply use the number of device trackers registered in the home zone
Example 2:
platform: state
entity_id:
- zone.home
to: '0'
for:
hours: 0
minutes: 2
seconds: 0
Tried this today and unfortunately nothing, can you see what’s wrong with it ? If I trigger it by pressing “run automation” it all works as expected but I presume something is wrong with the zone trigger
alias: Notify to arm when nobody home
description: ''
trigger:
- platform: state
entity_id:
- zone.home
to: '0'
for:
hours: 0
minutes: 2
seconds: 0
condition:
- condition: time
after: '06:00:00'
before: '21:00:00'
- condition: state
entity_id: alarm_control_panel.alarmo
attribute: arm_mode
state: disarmed
action:
- service: notify.alarm_notify_group
data:
title: Nobody Home
message: 'Arm The Alarm ? '
data:
actions:
- action: ALARMO_FORCE_ARM
skip_delay: true
title: Arm Alarm
event_type: ios.notification_action_fired
icon: sfsymbols:alarm.fill
destructive: true
mode: away
force: true
mode: single
That’s because you’re not using the correct states in Alarmo. The mode in Alarmo is armed_away or armed_home, but not away. And as already noted, I’d remove the “attribute: arm_mode”, it’s normally not needed, as the state of alarm_control_panel.alarmo should reflect that.
Oh you mean the condition? That one is, as said above, not working because of the attribute. Sorry for the confusion, I was a little more underneath with the state.
This will not work, as it checks only the attribute arm_mode. You should check the state, not the attribute. The attribute is only set (according to the docs), if the state is something like armed_??, but it is set to null, if it is disarmed. So your condition never passes, because the attribute is not filled, when in state disarmed.
Just leave it out, it is not needed anyway, as the state gives the correct value.
Gotcha, funnily enough I had just tried remove the attribute before reading here and it worked, hopefully now tomorrow when we are both away this automation will work il keep you both posted, thanks
No, the first post wasn’t changed. You can see that for yourself as there is no pencil left to the posting data. If it would have been changed, you could check yourself for the former version(s). Just for future reference.
So what is it, that you need/want?
Here is a corrected version from above, maybe it already helps you:
alias: Notify to arm when nobody home
description: ''
trigger:
- platform: state
entity_id:
- zone.home
to: '0'
for:
hours: 0
minutes: 2
seconds: 0
condition:
- condition: time
after: '06:00:00'
before: '21:00:00'
- condition: state
entity_id: alarm_control_panel.alarmo
state: disarmed
action:
- service: notify.alarm_notify_group
data:
title: Nobody Home
message: 'Arm The Alarm ? '
data:
actions:
- action: ALARMO_FORCE_ARM
skip_delay: true
title: Arm Alarm
event_type: ios.notification_action_fired
icon: sfsymbols:alarm.fill
destructive: true
mode: away
force: true
mode: single
Hey Paddy,
you’ve got a point there which I could’ve noticed myself Thank you for posting the code and also welcoming me to the forum.
As I’m fairly new to HA I’ll give it a try and see if I can manage to get the code working for my needs. Meaning basically just notifying me and my wife to arm the alarm once we’re all out of the house.
Thanks again,
Helge
Oh, no, no, that pencil is something even long registered users tend to overlook (aka me)
But back to the notification: I can see your point, but why aren’t you arming it automatically? If nobody is at home, the house could/should take care of its own. That is what I call the difference between an automated and a smart home. Automation is in this case you or somebody has to do something to start an automated plan, smart would be, to let your home decide, that you’re out and it should take care of what’s necessary while you’re away.
I personally find that easier, and in the end more reliable. Chances are much higher, that my good configured home knows what’s going on, while my wife or I forget to click the notification, or we don’t have ceel coverage (yeah, I know, in countries outside of Germany this wording is long gone, but here we are) or, or, or…
Haha okay well I’ll most likely do this also a few more times.
Automatically arming it would be even better, but I thought that is not a do-able scenario/action with alarmo. If you could point me into the right direction or even provide the solution that would be great.
Thanks
Sometimes having pets or if somebody is at home that isn’t a registered user on the app, also occasionally HA doesn’t update straight away or even at all, options are options dependant on the end user, don’t use this anymore as the actual arm option on the notification doesn’t work anyway
It is just a service call like in any other automation, combined with some additional infos.
You should make yourself a plan, on how to handle these “presence” things. Imho this is the essential part in your home. If your presence detection isn’t working on spot, you are blocked for so many things. After you have presence working, you can easily add a ton of automations to it. Lights turning on or off, closing covers, starting the vacuum robot or whatnot.
I personally do my presence with a point system, where I combine different sensors and values into an input_select that reflects my state (home, just arrived, just left, away, vacation). This state is then used to set a “residence state” (wife and/or me are home, someone else is home, nobody is home, alarm). And the automation is triggered by the “residence state”. If all are out, arm the system.