Custom:button-card execute a script fails with "action xyz not found"

I have a grid of custom:button-card buttons whose icon is dynamic and that are made visible based on some sensor state (a sensor for radio presets). That part works fine for me and my setup.

I tried to do the same for a friend. The sensors, … are the same, but the tap action is slightly different.

For me (working), I have this:

      tap_action:
        action: call-service
        service: rest_command.bluos_play
        service_data:
          url: |
            [[[
              return states['sensor.bluos_preset_1'].attributes['@url']
            ]]]

That’s rest_command with a url parameter that is configured in Configuration.yaml. So far so good.

Now, for my friend, I don’t have a rest_command but the equivalent is sequence of actions I configured in the UI under Parameters > Automations and Scenes > Scripts.

The script has id script.lecture_parametree_sur_bluesound_node and is configured like that (just fyi):

sequence:
  - action: script.allumer_onkyo_sur_bluesound
    metadata: {}
    data: {}
    enabled: true
  - action: rest_command.bluos_play
    data:
      url: "{{ url }}"
    enabled: true
alias: Lecture paramétrée sur Bluesound NODE
description: ""
icon: mdi:folder-play
fields:
  url:
    description: URL du flux BluOS
    example: ""

So I want to adapt my tap_action in that context to basically run that “script” and pass the same sensor attribute @url to the url parameter.

I tried this:

      tap_action:
        action: call-service
        service: script.lecture_parametree_sur_bluesound_node
        service_data:
          url: |
            [[[
              return states['sensor.bluos_preset_1'].attributes['@url']
            ]]]

but this fails with “action script.lecture_parametree_sur_bluesound_node not found”.

So, based on the YAML configuration of the corresponding script and seeing how another script is actually called right as an action, I tried to change to:

      tap_action:
        action: script.lecture_parametree_sur_bluesound_node
        data:
          url: |
            [[[
              return states['sensor.bluos_preset_1'].attributes['@url']
            ]]]

There is no errors, but nothing happens and when I go to Settings… Scripts, the last trigger always shows “never”.

So obviously I don’t get what “action” to be invoked or do I just “execute” a script… and I’m just unable to find the answer by looking around. Somehow custom:button-card seems to be slightly different in how it works and it’s hard for me at this stage to figure out how to adapt.

Is the one for your friend also using custom:button-card?

I think a more correct syntax is as follows:

      tap_action:
        action: perform-action
        perform_action: script.lecture_parametree_sur_bluesound_node
        data:
          url: |
            [[[
              return states['sensor.bluos_preset_1'].attributes['@url']
            ]]]
1 Like