Test for alarm status before opening cover

I would really like to disarm my alarm automatically when I press the open door button on my remote in the car. I forget every time and set the alarm off. I think I just need some kind of condition that only disarms the alarm if it is actually armed and then opens the door regardless whether it was armed or not. That is the bit I don’t quite get. This automation only opens the door if the alarm was armed.

- alias: Remote 3 Button 3
  trigger:
    platform: state
    entity_id: binary_sensor.remote3b3
    to: 'on'
  action:
  - condition:
      condition: state
      entity_id: alarm_control_panel.home
      state:
        - armed_away
        - armed_home
  - service: alarm_control_panel.alarm_disarm
    data:
      entity_id: alarm_control_panel.home_alarm
      code: 123456
  - service:  cover.open_cover
    data:
      entity_id: cover.garagedoor

Here you go, that is exactly what you want:

Clearly my search skills also need help. Thanks that is exactly what I am looking for. Now just got to understand it.

This function is kinda new, I’d say only a few months old. :slight_smile: Once you get the hang on it, you’ll love it.

It is, simply spoken, an if/else statement, in your case it would be:

- alias: Remote 3 Button 3
  trigger:
    platform: state
    entity_id: binary_sensor.remote3b3
    to: 'on'
  action:
    - choose:
        - conditions:
            - condition: state
              entity_id: alarm_control_panel.home
              state:
                - armed_away
                - armed_home
          sequence:
            - service: alarm_control_panel.alarm_disarm
              data:
                entity_id: alarm_control_panel.home_alarm
                code: 123456
    - service:  cover.open_cover
      data:
        entity_id: cover.garagedoor

EDIT: I’d additionally set a short delay between the disarm and the open cover. Maybe three or five seconds?

Like so:

- alias: Remote 3 Button 3
  trigger:
    platform: state
    entity_id: binary_sensor.remote3b3
    to: 'on'
  action:
    - choose:
        - conditions:
            - condition: state
              entity_id: alarm_control_panel.home
              state:
                - armed_away
                - armed_home
          sequence:
            - service: alarm_control_panel.alarm_disarm
              data:
                entity_id: alarm_control_panel.home_alarm
                code: 123456
    - delay: "00:00:05"
    - service:  cover.open_cover
      data:
        entity_id: cover.garagedoor