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?
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?
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.
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.
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.
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:
By this the confirmation dialog should only appear when state is āoffā and someone wants to turn it on.
I used this code to generate a confirmation on my Shelly smart plug that turns on and off my 3D printer power supply:
show_name: true
show_icon: true
type: button
tap_action:
action: perform-action
confirmation:
text: Are you sure?
perform_action: switch.toggle
target:
entity_id: switch.shellyplugs_4
name: 3DP
icon: mdi:printer-3d-nozzle
show_state: true
entity: switch.shellyplugs_4