Conditional State triggers for arming cameras

I’m looking at arming/disarming some Blink cameras when we (well, our phones) leave the house during the day.
Basically , if neither phone is connected to the network, then arm.
If someone is still at home (or comes home), then disarm.

I’m just wondering if there is a neater way than having four automations:
IF Phone1 is not_home, AND Phone 2 is not_home between 0516-2259, ARM.
IF Phone2 is not_home, AND Phone 1 is not_home between 0516-2259, ARM.
IF Phone1 IS home between 0516-2259, DISARM.
IF Phone2 IS home between 0516-2259, DISARM.

alias: Day Blink1
description: “Phone1 Arm”
trigger:

  • platform: state
    entity_id:
    • device_tracker.phone1
      from: home
      to: not_home
      condition:
  • condition: device
    device_id: bd41a30eefab774f064cd58ed5ed6f90
    domain: device_tracker
    entity_id: device_tracker.phone2
    type: is_not_home
  • condition: time
    after: “05:16:00”
    before: “22:59:00”
    weekday:
    • mon
    • tue
    • wed
    • thu
    • fri
    • sat
    • sun
      action:
  • device_id: 0c52bf28a9fbf2a729f1af3930def1ff
    domain: alarm_control_panel
    entity_id: alarm_control_panel.blink_bean
    type: arm_away
    mode: single

I’ve already got a timed record schedule between 2300-0515, without other conditions.

The following automation will arm the alarm panel when the last person leaves but only if the time is between 5:16 and 22:59.

alias: example
trigger:
  - platform: state
    entity_id:
      - device_tracker.phone1
      - device_tracker.phone2
    from: 'home'
    to: 'not_home'
condition: 
  - condition: state
    entity_id: device_tracker.phone1
    state: 'not_home'
  - condition: state
    entity_id: device_tracker.phone2
    state: 'not_home'
  - condition: time
    after: '05:16:00'
    before: '22:59:00'
action:
  - service: alarm_control_panel.alarm_arm_away
    target:
      entity_id: alarm_control_panel.blink_bean

You can create a second automation, very similar to the one above, to disarm the system. Just reverse the from/to values in the State Trigger, change the state of the State Conditions to ‘home’ and logically OR them (because either person arriving should be sufficient cause to disarm), and change the service call to alarm_control_panel.alarm_disarm.

Let me know if you need more assistance.

1 Like

Yep, just like that. So you’ve got device_tracker.phone1 and device_tracker.phone2 in both Trigger and Condition. That makes much better sense, thanks.

You’re welcome!

Please consider marking my post above with the Solution tag. It will automatically place a check-mark next to the topic’s title which signals to other users that this topic has been resolved. This helps users find answers to similar questions.

For more information about the Solution tag, refer to guideline 21 in the FAQ.

I was just making sure it was working in the correct order and that it still worked with extra devices - such as turning off lights and down heating - which it does, so that’s great.

1 Like