Entity Button card confirmation

I may be writing in wrong section, in that case feel free to move my post.

Can someone please tell me how to implement a confirmation dialog on the lovelace Entity Button card?

1 Like

This is a loaded question. What are you expecting the confirmation dialog to do? are you expect it to suppress your action unless you click ā€œOKā€?

I have a input boolean that i toggle with that button but sometimes I press it by mistake.

This would require a custom card then because you need to suppress the on/off action. I suggest looking through custom cards provided in HACS. There are cards that allow you to loc buttons or entity rows. This means you have to press and hold to unlock it, then press again to click it.

I think this is what youā€™re looking for. I use these for my dependent Docker container switches. https://github.com/thomasloven/lovelace-toggle-lock-entity-row

But there is a confirmation option on the the entity button card. See here https://www.home-assistant.io/lovelace/entity-button/ but there is no example on how to use it.

2 Likes

Using the example at the bottom of the docs, this is what the yaml would look likeā€¦ I suggest you read up on yaml if you canā€™t figure out the docs. I was unaware of this new option.

type: entity-button
name: Turn Off Lights
tap_action:
  action: call-service
  service: script.turn_on
  service_data:
    entity_id: script.turn_off_lights
  confirmation:
    text: Are you sure you want to press this button?
    exemptions:
    - user: petro
entity: script.turn_off_lights

Itā€™s not spelled out well in the docs. Just read through them moreā€¦

Last EDIT: This option does not exist for the entities card. Good feature request.

4 Likes

Excellent questions and points

I had the same problem as Denis and that link lead me to Restriction Card which was the solution I was looking for. It even has entity: cover.garage_door in one of the examples which is why I needed the solution. Thanks for the link!

I came across the same doubt and found this topic.

Iā€™m sharing my implementation using only ā€œofficialā€ components and a slightly modified version of petro in case someone finds it useful.

This is to control the motor of my garage, so I really needed to be extra careful to no activate it involuntarily. Basically I have double (triple?) protection: I ignore single and double tap and even when long pressing, I still ask for confirmation.
Iā€™ve also updated to type: button since I believe entity-button has been deprecated (or I just canā€™t find it):

type: button
name: Activate garage motor
entity: switch.garage_motor
tap_action:
  action: none
double_tap_action:
  action: none
hold_action:
  action: call-service
  service: switch.turn_on
  service_data:
    entity_id: switch.garage_motor
  confirmation:
    text: Are you sure you want to do it?

This generates an error when adding directly to Lovelace, but just save itā€¦ It works anyway.

5 Likes

Is there an option only to display the tekst when switching ā€˜onā€™ perhaps?

confirmation:
    text: Are you sure you want to do it?

I use this opther to explain what te button does to the users, no need for that when switching off

thx

Yes that should be possible: first find a way to use templates in stock cards, if needed. Consider ā€œConfig Template Cardā€ for example. Then write a template based on your entity state:

  • if state is off: confirmation with your text
  • otherwise: confirmation set to false

By this the confirmation dialog should only appear when state is ā€œoffā€ and someone wants to turn it on.