tap_multi_calls - a new community contribution #986
Replies: 6 comments 14 replies
-
|
@il77781 As discussed. Here is what I was thinking of in our pevious discussion (Option 3). |
Beta Was this translation helpful? Give feedback.
-
|
@lisz8 I guided you here to understand more about how the actions work regarding hacking in javascript. Basically its a by product of how button-card recursively renders templates in *_action and is not intended as a feature. Confirmation of an action is a Home Assistant Frontend function, not something button-card controls. So there is no standard way to achieve running javascript after confirmation without a hack like presented here. I understand you wish to run javascript, but not sure if that is just your example or you actually wish to just set a button red on tap - not sure what that use case really would be for in Home Assistant. Anyhow, this hack could be extended to just run javascript rather than call Home Assistant actions, though I really need to understand your use case. As per the intro to this, I am sharing the hacks as a community member, not as a maintainer of button-card. These are hacks and will always be regarded as hacks. Just to be clear. |
Beta Was this translation helpful? Give feedback.
-
|
This should break in 5.0.0 as actions are evaluated at render time also now (to know if the button and/or the icon are actionable). It would fire the events directly during the first render. We could make *_action support array of actions, but again... I really think this should be handled by a script in the backend. |
Beta Was this translation helpful? Give feedback.
-
|
NOTE: This has been tested with v5 dev9. I did note if using along with another button that uses |
Beta Was this translation helpful? Give feedback.
-
|
#1041 👀 |
Beta Was this translation helpful? Give feedback.
-
|
Official support with some goodies released in 5.1.0-dev.2. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
All button-card
*_actionsections are processed at time of action. This means you can hack into an action to do some extended features. In the past there has been themulti_callshack that has been misunderstood as a feature. It has it's limitations. Here I show how to extended the premise of that hack into somthing a bit more templatable.Supports:
tap-multi-callsas a button-card template.tap_multi_callsvariable which is an object includingactionsarray/list andconfirmationobject.[]pair).toggleaction actually gets its entity for the card config, and this template only passes atap_action,action: togglewill not work. Instead useaction: perform-actionwithperform_action: switch.toggle,perform_action: light.toggleetc. and atarget(see example).hold_actionetc. If anyone is interested I will provide (pretty much change any reference to 'tap' to 'hold'.Important
Template
Place in
button_card_templatesin your dashboard raw configuration.Example
An example, toggling the button-card entity switch, another switch, and navigating to `/lovelace'. I use these examples as they are clear and easy to test in your environment with a few simple changes to the entities.
Beta Was this translation helpful? Give feedback.
All reactions