How to add two (or more) actions to a single Button-card?

Hi All,
I’m trying to have two actions performed when a button card i clicked in Lovelace UI.
This issue her is not the actions themselves. Both works perfectly in their own, but combining them into a single YAML fails.
This is my first attempt:

type: button
name: test1
tap_action:
  - action: call-service
    service: remote.turn_on
    service_data:
      activity: 41122377
      entity_id: remote.harmony
  - action: call-service
    service: media_player.play_media
    service_data:
      entity_id: media_player.stue_ac_lms
      media_content_id: 'https://p7.p4groupaudio.com/P07_MH'
      media_content_type: music
entity: media_player.stue_ac_lms

This does not give any error message, but absolutely nothing happens when I click the button card. No log entries of any kind.
The I tried another variation, but this one gives syntax error “Bad indentation at line 5” and thus cannot be tested or saved:

type: button
name: test2
tap_action:
  action: call-service
    - service: remote.turn_on
      service_data:
        activity: 41122377
        entity_id: remote.harmony
    - service: media_player.play_media
      service_data:
      entity_id: media_player.stue_ac_lms
        media_content_id: 'https://p7.p4groupaudio.com/P07_MH'
        media_content_type: music
entity: media_player.stue_ac_lms

I need help to get this right

I don’t think you can do this. You need to create a script that executes these actions and then call the script from the button.

Ok, thanks - I’ll try that.
But how are we to know what can and what can’t be done in the UI ?
It seems like there are lots of YAML limitations when used in the UI, while not so many when used in an automation and even less when used in a script. I thought YAML was YAML. If that’s not the case, where are these limitation documented ?

@Burningstone is right, you can’t do this (yet).

The documentation about buttons and actions always reads like there’s only one supported, but I get your point, it isn’t 100% clear.

However - there is an open pull request in the frontend repository, you could give that a thumbs up if you have a github account.
Seems like the PR is lacking documentation as well, if you want to contribute.

1 Like

I don’t know of any limitations of automations vs. Scripts?

The frontend is pretty limited, but I assume its intentional, because more complex scenarios should be handled by the backend.

1 Like

I like to think about possibilities, not limitations, and all of those are very well documented at home-assistant.io/docs
There are no limitation differences between automations and scripts. The only “limitation” I could think of is that you can’t manually execute an automation easily.
YAML is just the language, the syntax. There’s no tap_action in automations, so I don’t really know where you’re coming from here.

Thank you all for answers and guidance.
So, to sum up - It isn’t possible to add two (or more) actions to a singel button-card, unless i turn to scripting (which I did - and it works)

alias: Play Radio
sequence:
  - service: remote.turn_on
    data:
      activity: 41122377
    entity_id: remote.harmony
  - service: media_player.play_media
    data:
      media_content_id: https://p7.p4groupaudio.com/P07_MH
      media_content_type: music
    entity_id: media_player.stue_ac_lms
mode: single
icon: 'mdi:panda'

Currently - no. Again, someone is working on it and if this gets merged, you could do this natively.

I can’t believe this is still an issue in 2023: I want one dashboard button to tun on a switch while simultaneously navigating to another screen. Scripts don’t have the navigate function. Pah!

They have a navigate function but then you have to install browser-mod.

settings:
  alias: settings
  sequence:
  - service: alarm_control_panel.alarm_arm_home
    data: {}
    target:
      entity_id: alarm_control_panel.open_settings
  - service: browser_mod.navigate
    data:
      path: /lovelace/instellingen/
  mode: single

I’d like my front door lock wake button (Yale lock) to be pressed when I navigate to the section of my UI for my front door so I have an up-to-date status whenever I check, but don’t have to create unnecessary battery drain by automating the wake button to be pressed every few minutes.