Automate cancel arming when away

I have a person entity group set up to arm my alarm when everyone leaves the house. I added in a push notification to allow us to cancel that for 2 minutes, for example if we forgot and had a baby sitter or house cleaner at the house when we left. I have it working but it doesn’t seem like its the best approach. I did it by cancelling an automation with enable/disable. I could redo it to make my cancel event set a boolean and then check the boolean as a condition afterwards and let the automation finish. This is because I don’t see a clean stop automation service call.

Any have any thoughts?

- id: '1619986218414'
  alias: Arm alarm when everyone is away
  description: ''
  trigger:
  - platform: state
    entity_id: group.family
    to: not_home
  condition:
  - condition: state
    entity_id: alarm_control_panel.alarm_panel
    state: disarmed
  action:
  - service: notify.mobile_app_all_phone
    data:
      message: Everyone is gone, arming alarm away in 2 minutes
      data:
        ttl: 0
        priority: high
        actions:
        - action: CANCELARMAWAY
          title: Cancel
  - delay:
      hours: 0
      minutes: 2
      seconds: 0
      milliseconds: 0
  - service: alarm_control_panel.alarm_arm_away
    entity_id: alarm_control_panel.alarm_panel
    data:
      code: '1234'
  mode: single
- id: '1620487950934'
  alias: Cancel arm alarm away
  description: ''
  trigger:
  - platform: event
    event_type: mobile_app_notification_action
    event_data:
      action: CANCELARMAWAY
  condition: []
  action:
  - service: automation.turn_off
    target:
      entity_id: automation.arm_alarm_when_away
  - service: automation.turn_on
    target:
      entity_id: automation.arm_alarm_when_away
  - service: notify.mobile_app_all_phone
    data:
      message: Arm alarm away cancelled
      data:
        ttl: 0
        priority: high
  mode: single

I think it would be a bit neater if you just make a helper that you set via the cancel event. In the arm automation you just check if this is set and also clear it.

And maybe use a tag to replace the first notification with the canceled notification? Also, you might want to use mode: restart on the first automation. And you could also add “auto-cancel” if somebody gets home within the the 2 minutes.

Think you end up with something like:

- id: '1619986218414'
  alias: Arm alarm when everyone is away
  description: ''
  trigger:
    - platform: state
      entity_id: group.family
      to: not_home
  condition:
    - condition: state
      entity_id: alarm_control_panel.alarm_panel
      state: disarmed
  action:
    - service: notify.mobile_app_all_phone
      data:
        message: Everyone is gone, arming alarm away in 2 minutes
        data:
          ttl: 0
          priority: high
          tag: 'alarm-arm'
          actions:
          - action: CANCELARMAWAY
            title: Cancel
    - service: input_boolean.turn_on
      target:
        entity_id: input_boolean.about_to_arm
    - delay:
        hours: 0
        minutes: 2
        seconds: 0
        milliseconds: 0
    - choose:
        - conditions:
            - condition: state
              entity_id: input_boolean.about_to_arm
              state: 'on'
          sequence:
            - service: alarm_control_panel.alarm_arm_away
              entity_id: alarm_control_panel.alarm_panel
              data:
                code: '1234'
      default: []
    - service: input_boolean.turn_off
      target:
        entity_id: input_boolean.about_to_arm
  mode: restart

- id: '1620487950934'
  alias: Cancel arm alarm away
  description: ''
  trigger:
    - platform: event
      event_type: mobile_app_notification_action
      event_data:
        action: CANCELARMAWAY
    - platform: state
      entity_id: group.family
      to: home
  condition:
    - condition: state
      entity_id: input_boolean.about_to_arm
      state: 'on'
  action:
    - service: input_boolean.turn_off
      target:
        entity_id: input_boolean.about_to_arm
    - service: notify.mobile_app_all_phone
      data:
        message: Arm alarm away cancelled
        data:
          ttl: 0
          priority: high
          tag: 'alarm-arm'
  mode: single

thanks! I figured there was a cleaner way, I like this a lot