Button Press one entity, show state of another

I have a Sonoff momentary relay hooked up to my garage door opener to open and shut it. I also have a MyQ garage door sensor to monitor the open/shut status. My garage door isn’t compatible with MyQ so I can’t use it to open and shut the door.

Is it possible to make a button that shows the garage door status (icon + text) but when I click on it, it activates the Sonoff switch?

Here’s my current vertical stack code showing the Garage Door status:

type: vertical-stack
cards:
  - type: button
    tap_action:
      action: toggle
    entity: cover.garage_door
    show_state: true

And the button currently working with Sonoff:

type: button
tap_action:
  action: toggle
entity: switch.sonoff_1000439309

Thank you very much.

Template switch

Value_template as the sensor value, turn on/off actions to toggle the switch.

What do I have to change in my code above?

You have to make a new template switch, and put it on your lovelace somewhere.

Hi tuckerm,
Did you ever get this resolved as I’m trying to do the same thing with a gate?
Bit of newbie so didn’t quite understand the answer given.

Yup, I did. Here’s my code using custom button card in a vertical stack. You can see the entity is the sensor of the garage and tapping it will activate the sonoff switch.

type: vertical-stack
cards:
  - type: custom:button-card
    entity: binary_sensor.truck_garage
    show_icon: true
    show_name: false
    tap_action:
      action: call-service
      service: switch.turn_on
      service_data:
        entity_id: switch.sonoff_1000439309
    icon: hass:garage
    aspect_ratio: 2/1
    state:
      - value: 'off'
        color: green
        icon: hass:garage
        aspect_ratio: 2/1
      - value: 'on'
        icon: hass:garage-open
        aspect_ratio: 2/1
        styles:
          card:
            - animation: blink 2s ease infinite
        color: red