I have created a button which toggles an input_boolean. The input_boolean triggers an automation. The automation runs a pump for 30 minutes and switches it off, also the input_boolean is switched to "off" after 30 minutes.
The problem is: While the automation is running I can switch the button on and off, this does not affect the pump which is intended (the pump must! run 30 minutes)
I am aiming at blocking the button also for 30 minutes so to have an identical visual state for pump and button at any time.
I tried with a tap action in the button card configuration:
One very brute force method would be to have to versions of the button. One that actually toggles the input boolean, and one that does nothing. Then you could set a visibility condition that would show the right button at the right times.
I don't know if there is a condition for an automation running, so you might have to get clever about using the existing input boolean, or create yet another one that is only used to tell if you are in that 30 minute window.
call-service was renamed to perform-action, but both work. I suggest you use the newer terminology in your code in case call-service ever gets deprecated.
Tried it, but this failed. Maybe I have to be more precise:
I just want the button to be blocked in its "on"-state while the automation is working, the button should not react to any second or third touch with the finger. In other words: Once setted "on" (color of button changes) it should stay in this state as long as the automation sets it "off".
Then follow @pkscout's advice and use a conditional card (the Visibility option in card setup) with 2 cards. You can use the state of the pump as a condition, since you cannot check whether an automation is running in the conditional .
The automation is to run a pump for 30 minutes. It is triggered by three differnt entities, one of them is the button in HA. So I can trigger the automation by pressing the buuton (state changes from off to on). But since then the button is not synchronized with the pump as the pump runs for 30 minutes but the button can be toggled (although toggling of the button has no impact on the automation any more - which is intended!)
Another option could be to add a conditional action to the automation that immediately switches the button on again when it is pushed to the off state, under the condition: while the input_boolean is on.
What does your automation look like? Do you have a delay there of 30 min? This is typically not a good idea in HA. If so, consider using a timer instead. Let your automation trigger on the timer being started to turn on the pump, and another to turn it off. Have your button start the timer. You can still use David's idea above (which I think is the neatest) by having the switch's state template check the timer's state.
Indeed I use a custom:button-card.I tried your suggestion with my card, but it does not work. Note: The "input_boolean.power_zirkpump" turns on my pump.
If by "doesn't work" you mean that the button doesn't reflect input_boolean's state (icon color and state field), then set the entity field to that input_boolean as well:
I mean, when pressing the button, nothing happens, nor color changes. Checking the state of the entity says for input_boolean.power_zirkpump "off", although I have pressed the button.
I understand Maybe your version of the custom button is very old, so things still have the old names. AFAIR "perform-action" used to be called "call-service" and "perform_action" was simply called "service"? Other than that, I don't see why it wouldn't work.
Edit: I see you actually used the old names in your first post. So you can try with tap_action looking as this:
Oops, I thought it worked. I was still in the editing mode of the dashboard when the button turned red (I changes the colors) and the pump was in operation. But then I reloaded all the yaml-configurations and as a result I get the same error as in the beginning (see my first post).
By the way: The button works well, without the lines beginning with "tap_action". Of course with the behaviour that it can be toggled all while the automation is running.
You have an apostrophe at the end. After removing it, the card works for me! After clicking it, it changes color from blue to red (and becomes non-clickable). P.s. you can check you button-card version in HACS. Don't update, just check.