Specific Button Style during automation

Dear Community I’m using HomeAutomartion for a while now and try to implement an animation on a custom-button card while an automation is running. I looked up many posts and read the github docs of course.
But because the whole programming style is new to me, I can’t translate it into my use case.

I have an automation, that triggers 4 switches one after the other with a 20 seconds time gap in between each device. The automation is working fine, and I now want to create a button on the dashboard to trigger the automation.
I figured out, how to define the on and of state as read and green, but want to have the button blinking orange during the time of the automation.

This is my custom button so far:

type: custom:button-card
entity: input_boolean.power_stage
name: Power Stage
show_name: true
show_icon: true
show_state: false
tap_action:
  action: call-service
  service: input_boolean.toggle
  service_data:
    entity_id: input_boolean.power_stage
state:
  - value: "on"
    styles:
      card:
        - background-color: rgba(0, 128, 0, 0.3)
      icon:
        - color: darkgreen
  - value: "off"
    styles:
      card:
        - background-color: rgba(255, 0, 0, 0.3)
      icon:
        - color: darkred
styles:
  card:
    - border-radius: 15px
    - height: 100px
  name:
    - font-size: 16px
  state:
    - font-size: 14px

I created a helper “power_stage”, which tapping on it turns it on or of. This triggers the automation to start.

Within the automation, I have another helper-switch be turned on at the start and turned of at the end, so the button know, if the process is still running. This is the “automation_running” Helper Switch in the Script above.

With the help of ChatGPT i got this far to have the switch turn orange (without blinking) when I switch it on, but turning it of puts it directly to the red colour

type: custom:button-card
entity: input_boolean.power_stage
name: Power Stage
show_name: true
show_icon: true
show_state: false
tap_action:
  action: call-service
  service: input_boolean.toggle
  service_data:
    entity_id: input_boolean.power_stage
triggers_update:
  - input_boolean.automation_running
state:
  - operator: template
    value: |
      [[[
        return entity.state === 'on';
      ]]]
    styles:
      card:
        - background-color: |
            [[[
              if (states['input_boolean.automation_running']?.state === 'on') {
                return 'orange';
              } else {
                return 'rgba(0, 128, 0, 0.3)';
              }
            ]]]
      icon:
        - color: |
            [[[
              if (states['input_boolean.automation_running']?.state === 'on') {
                return 'darkorange';
              } else {
                return 'darkgreen';
              }
            ]]]
  - operator: template
    value: |
      [[[
        return entity.state === 'off';
      ]]]
    styles:
      card:
        - background-color: rgba(255, 0, 0, 0.3)
      icon:
        - color: darkred
styles:
  card:
    - border-radius: 15px
    - height: 100px
  name:
    - font-size: 16px

I assume that the error is in the if-statement, but cant’fix it myself.

So thank you in advance for your help!