Why this code don't execute script?

I created an entities card, that have one automation and one script. If I turn them on one by one, both works fine., but If I turn heather button on, only the automation is executed. What am I doing wrong? this is the card
image
and this is the code

` type: entities
entities:

  • entity: automation.alarmas
    icon: mdi:door
  • entity: script.tapo_on_off
    tap_action:
    action: call-service
    service: script.turn_on
    name: Tapo Cam
    title: Activar alarmas
    show_header_toggle: true `

The header switch toggles the state of all switches, automations, and input_booleans in a card. Nothing else. Not scripts, not buttons, not covers, etc…

So, the best way is create an automation that call the script, right?

Yes and no.

Turning on an automation does not trigger it. It just enables it.

You would have to have a switch or input_boolean in the card that triggers the automation that calls the script.

No automation calls the script. I must execute the script directly, from the card, and I like the header switch do it too…
I created an input_boolean, but the script isn’t executed… this is the card now
image

and the code

type: entities
entities:
  - entity: automation.alarmas
    icon: mdi:door
  - entity: input_boolean.tapo_on_off
    tap_action:
      action: call-service
      service: script.tapo_on_off
title: Activar alarmas
show_header_toggle: true

As expected, the switch toggle don’t execute the scrip, only tapping on the text do it. Not sure what I am missing, how to execute the script when the switch change.

Remove the tap action from the input boolean. And write an automation.

The trigger is the input boolean turning on.

The action is to call your script.