Can I get a custom button, to activate different switches, based on the state of a sensor?

Trying to get a button on my dashboard to control my garage door, depending on the state it is in.

I have a template sensor named “garagedoor_statesensor” which has three possible states: open, closed, ventilation

If the state is “closed” I want the button to toggle switch1 on tap, and switch2 on double tap.
If state is “open” I want the button to toggle switch1 on tap, and switch2 on double tap.
If state is “ventilation” I want the button to toggle switch2 on tap, and switch1 on double tap.

I simply can’t get my head around the script and the involvement of two switches - anyone with any pointers?

The button as it is right now, when it only activates switch1, regardless of sensor-state

  - type: custom:button-card
    entity: switch.garage_portabner_switch1
    show_name: false
    show_icon: false
    tap_action:
      action: toggle
    style:
      top: 49.3%
      left: 20.2%
    styles:
      card:
        - width: 115px
        - height: 15px
        - opacity: 0

why not do something like this:

- type: custom:button-card
    entity: switch.garage_portabner_switch1
    show_name: false
    show_icon: false
    tap_action:
      action: call-service
      service: script.garage_button_tap
    double_tap_action:
      action: call-service
      service: script.garage_button_double_tap

have have those two scripts do the conditionals… sure, you can put it all in the button, but i tend to believe in more of a separation between ui and logic. holler if you need help with those subsequent automation scripts, but i think those you can do really pretty straight forward via the ui.

you could, of course also make it one automation instead of 2, and pass in the action…

Good idea

Works like a charm. Thanks