Need some help with modifying an automation to an "or" situation for my use case (probably easy for someone that knows what their doing)

Can someone give me a little help in modifying the below automation to where it will work if any of my 3 doors are opened. It looks like it is only working for if the back door is opened. I see where the trigger value template needs to be changed or expanded I believe but don’t really know the proper language to use to update it. Thank you all so much for your help with this simple one I believe!

  - id: security_breach_door
    alias: Security Breach Doors
    trigger:
      - platform: state
        entity_id:
          - binary_sensor.front_door
          - binary_sensor.garage_entry_door
          - binary_sensor.back_door
        to: "on"
    condition:
      - condition: state
        entity_id: input_boolean.sentry_mode
        state: "on"

    action:
      - choose:
          - conditions:
              - condition: template
                value_template:
                  '{{ trigger.to_state.attributes.friendly_name == "Back Door"
                  }}'
              - condition: state
                entity_id: input_boolean.dog_mode
                state: "on"
            sequence:
              - service: script.text_notify
                data:
                  who: "parents"
                  message: "Dog Mode enabled, bypassing back door sensor."
        default:
          - service: script.jarvis_alert
            data_template:
              message: "My security protocols are being overidden,, The {{ trigger.to_state.attributes.friendly_name }} has been opened."
          # - service: script.text_alert
          #   data:
          #     who: parents
          #     title: "Security Alert!!"
          #     message: "{{ trigger.to_state.attributes.friendly_name }} has been opened."
          # - service: input_boolean.turn_on
          #   entity_id: input_boolean.security_issue
    initial_state: true

There is an ‘Or’ condition card, in which you can place other conditions, and it will return true if at least one of them is true.

Alternatively, if I’m understanding your automation correctly, you could change the template to something like:

{{ trigger.to_state.attributes.friendly_name in ["Back Door", "Garage Entry Door", "Front Door"] }}

This creates an array, a list, and checks if the name of the opened door is in that list.

Thank you for helping me @Abragus . Very thankful for that.

So this is what I ended doing but it seemed laborous (and I didn’t like it because of that-- code repeats, etc.) and I knew there should be some way to modify the trigger to area to make this happened, I just didn’t know how to.

This is exactly what I wanted to do… Thank you so much @Abragus Very appreciative again!!

1 Like