Button Card, change button colors for a second if pressed

Hello,

I tried to find a way, how to do this.
I have some switches, which acts as momentary switch, (for example rf433 gate, alarm arm if home), and for these switches i cannot check if it was pressed or not.
I tried in button card, without success, because if it call the switch turn on service the switch command runs, but the swich really never turned on or off because its a template, not a real switch.

Is there any way to make it work ?

                      - type: custom:button-card
                        name: Garage Mazda
                        icon: mdi:garage
                        entity: switch.template_gate_emulation

#                        tap_action:
#                          action: call-service
#                          service: switch.turn_on
#                          service_data: 
#                            entity_id: switch.template_gate_emulation

                        color: rgb(255, 128, 199)
                        state:
                          - value: 'on'
                            color: rgb(28, 0, 0)
                        styles: 
                          name: 
                            - icon:
                              - animation: blink 2s ease infinite 
                            - text-transform: capitaliz
                            - font-size: 10px
                            - font_weight: bold
                            - align-self: end
1 Like

Use input booleans.

Use a script with a short delay to turn the switch on/off.
Add this script as entity in the button card and call it with the tap_action.

      - type: custom:button-card
        entity: script.your_script
        tap_action:
          action: call-service
          service: homeassistant.turn_on
          service_data:
            entity_id: script.your_script