I am trying to set up an automation to set my alarm when me and my wife leave the home zone. I used life360 device tracking state in my condition step. I want to alarm to be set only when me and my wife are both not home.
Here is my automation below. This works when I remove the condition step. But obviously it’s not ideal since I keep setting the alarm when I leave for work in the morning when my wife is still at home!
So the condition step is where I’m going wrong. Can anyone help me with where I’m going wrong with the config? Thanks in advance.
HA version 102.2 on Rpi 3+
alias: Alarm Arm
description: Set Alarm
trigger:
- entity_id: device_tracker.life360_xxx
event: leave
platform: zone
zone: zone.home
- entity_id: device_tracker.life360_xxx
event: leave
platform: zone
zone: zone.home
condition:
- condition: and
conditions:
- condition: state
entity_id: device_tracker.life360_xxx
state: moving
- condition: state
entity_id: device_tracker.life360_xxx
state: moving
action:
- code: xxxx
device_id: xxxxxx
domain: alarm_control_panel
entity_id: alarm_control_panel.xxxxalarm_control_panel
type: arm_away
I did it using a custom group and then trigger off the state of that group becoming “not_home”. Each person in the group is a defined Person in HA with a Life360 device tracker and also a phone tracker via the iPhone detect integration.
You could do the same thing by creating a Life360 group and triggering on “not_home” (as the Life360 device tracker returns not_home when away). That way, you can do away with the condition entirely.
I agree with @code-in-progress, triggering on a group of trackers is better. If those are the only two trackers then there is already a group named group.all_devices you can use. Otherwise create your own. The only slight difference I would recommend is triggering on changing from 'home' instead of to 'not_home'.
trigger:
- platform: state
entity_id: group.all_devices
from: 'home'
I do exactly this…
I also turn off lights, and send a notification (so I know when the alarm is set).
I also disarm the alarm if someone opens the front door with a valid door code, here’s my code:
- alias: Arm Alarm when Away
trigger:
- entity_id: group.parents
from: home
platform: state
to: not_home
action:
- service: alarm_control_panel.alarm_arm_away
entity_id: all
- service: light.turn_off
entity_id: group.interior_lights
- service: notify.pushover
data:
message: Alarm Active