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:
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?
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.
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!
Edit: I’ve edited the above example to account for changes in v6 of button-card. Here’s the old example if curious, though it has been broken for some time even before v6:
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?
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:
Hi! Modifying your script I have managed to get a button to send an mqtt message shutting down the home theater and turn on the spotlights, so the room isn’t dark. But I would like to turn on the lights to a low brightness, so we do not get totally blinded. And I can’t get the brightness working. This is the code that works:
I tried removing the end bracket after entity ID and the start bracket before brightness, but that didn’t change anything. Do you know what I’m doing wrong here? I couldn’t find anything about multi calls on the Github page for the custom button integration. I can do it by making an automation and calling that, but I would like to call directly.
[Updated] [Requires: custom:button-card installed]
I had a similar situation that the one indicated in this post, and it seems there is no built-in solution yet (github-discussion #724).
For anyone interested, I manage to have 2 actions with a single tap including the delay by using button-card’s action: custom callback, or what it seems a better way, by using action: fire-dom-event but without the delay. (no idea how to do it)
Following the suggested template from this discussion (github-discussion #986)
I added a button that when clicked triggers an script, and navigate to another tab or dashboard.