Automation - Leaving Home Two Devices Action

Hi There!

I’m trying to create an automation that based on our phone presence is activating the Alarm Panel which for now only consists some Blink cameras. So far I have one that is decativating it when one person is coming home, I’m also able to activate the panel when one person is leaving. However, I have some issues for two people.
I want the automation to get triggered whenever both phones are leaving and it should check against the condition if both phones are out and not only one phone. I potentially have a misunderstanding of the logic.

I create the automation via the frontend but here is the code from my automation.yaml:

- id: 'xxx'
  alias: Leaving Home
  description: ''
  trigger:
  - entity_id: device_tracker.xx1
    from: home
    platform: state
    to: not_home
  - entity_id: device_tracker.xx2
    from: home
    platform: state
    to: not_home
  condition:
  - condition: state
    entity_id: device_tracker.xx2
    state: not_home
  - condition: state
    entity_id: device_tracker.xx1
    state: not_home
  action:
  - device_id: abc
    domain: switch
    entity_id: switch.jasco_products_14291_in_wall_smart_switch_switch_2
    type: turn_off
  - device_id: def
    domain: switch
    entity_id: switch.jasco_products_14291_in_wall_smart_switch_switch_2
    type: turn_off
  - data: {}
    entity_id: alarm_control_panel.blink_home
    service: alarm_control_panel.alarm_arm_away

Any ideas what I’m missing here?

After some digging I found a solution via the blink integration example.
It triggers the action when the state changes to not_home for all devices in the group group.family_members which usually are the tracking devices of the household in my case.

Here is the modified example code that activates the alarm panel:

- id: arm_blink_when_away
  alias: Arm Blink When Away
  trigger:
      platform: state
      entity_id: group.family_members
      to: 'not_home'
  action:
      service: alarm_control_panel.alarm_arm_away
      entity_id: alarm_control_panel.blink_my_sync_module

Further reading and source: https://www.home-assistant.io/integrations/blink/
Please note that I’m referring to this only for the automation part, the integration of Blink has been changed a couple of days ago.

1 Like

Hi, I’m trying to set this up for my Blink system and family. Right now HA can tell the status of my family members based on the information gathered by icloud.com integration.

I’m pretty new to HA, so this is all new for me. I read the instructions on how to create a GROUP using Helpers and I haven’t had any luck. Which option am I supposed to pick? None seem to allow me to create a group using the iphone id of my family members.

Also, where would I put this script you used?

Thanks