Custom button - 2 actions under 1 tap

Hi Guys,
Come time when I need to have one custom button card as button, but with two actions after single tap.
Found this part of code, which works for switches and lights:

tap_action:
  action: nothing
  multi_calls: |
    [[[
      hass.callService(
        "light",
        "turn_on",
        { entity_id: "light.my_light", brightness: 200 }
      );
      hass.callService(
        "switch",
        "turn_off",
        { entity_id: "switch.my_switch" }
      );
    ]]]

I need under one tap: one action of call service/switch off, but the second one should navigate to another tab of the dashboard. The best would be, if there could be included some few sec delay between them (but not necessary).
Can anyone point me out, how I can achieve this what I want, please?

Try browser_mod.

On your button make the tap action a script. In the script add your different actions using browser_mod. I’ve done similar to make a button that turns on a device and navigates to a different dashboard.

Try something like this:

type: custom:button-card
entity: switch.guitar_equipment_plug
tap_action:
  action: navigate
  navigation_path: dash
  multi_calls: |
    [[[
      hass.callService(
        "switch",
        "toggle",
        { entity_id: "switch.guitar_equipment_plug" }
      );
    ]]]

This doesn’t include any kind of delay though.

I use this flow on tablets for a kind of temporary “dialog” box flow. There’s a button on one dash view that takes you to another “dialog” view, and when any button on this “dialog” view is pressed you’re taken back to the original view while also running the action specified with hass.callService.

The code should be self explanatory, but lmk if anything doesn’t make sense!

1 Like

I had the same problem and couldn’t call “multi_calls”
Please help !

This only works with the card type

type: custom:button-card

Please see Installing the Custom Button Card? - #2 by qoheleth for assistance on installing button-card

Hi @scottg489 ,

This works perfect for combining a navigation and switching a toggle, Is it also possible to navigate and execute a script. I tried a few things but couldn’t get it to work. Maybe you have a solution for it?

Thanks
Kris

Yes, you’re just calling an action (previously “service call”) either way. So in my example I’m calling the switch.toggle action, you’d want to call your script’s action. So it may look something like:

  multi_calls: |
    [[[
      hass.callService(
        "script",
        "my_script"
      );
    ]]]

I haven’t actually tested this out myself, but I believe this is all you should need. What have you tried that hasn’t worked?

Hi @scottg489 ,

The example you provided just works great, but I forgot to mention that my script is receiving some data. Is that also possible?

Thanks a lot
Kris

Yeah, if you look in my original comment you can see there’s a third parameter which is a dictionary that represents the action call data.

1 Like