Allow Button Confirmations

It would be great to have the option to add a confirmation for button entities (from integration standpoint) when clicked in the UI by the user. Obviously, automations would not be affected. This would allow an integration developer to mark a button as requiring confirmation or as destructive to prevent a user from accidently activating it out of curiosity.

The issue is some buttons can be very destructive and not having a user confirmation can cause unintended harm to the user’s home automation platform.

A couple of examples of buttons that would need a confirmation:

  • A reboot/update button (especially for devices that should have high availability, such as a Security Camera)
  • A Delete/Remove/Unadopt button to remove the device completely from the upstream system

This already exists:

https://www.home-assistant.io/dashboards/actions/#confirmation

e.g.

type: button
name: Turn Off Lights
show_state: false
tap_action:
  action: call-service
  confirmation:
    text: Are you sure, this could be really bad?
  service: script.turn_on
  data:
    entity_id: script.turn_off_lights

I failed at mind reading again :frowning:

Nowhere in your FR did you mention that.

Keep in mind that, button action can be triggered by an automation using button.press service and there is no user interaction while executing these scripts and automations. I don’t think we should mess backend implementation (entities) and frontend representation (lovelace cards)

1 Like

That only works for action: call-service, right?
I need a confirmation for a action: toggle.
I get error “duplicated mapping key (10:7)” when I try to combine the confirmation with the toggle action.

Show your config.

The frontend uses an entity’s device class for customizing things like icon and such. I wouldn’t think it would be too difficult to implement one or more new ButtonDeviceClasses that the frontend could default to prompting to confirm. Then you just add that device class in the entity descriptions on the backend.

Looks like there’s 2 valid ButtonDeviceClasses right now: Button Entity | Home Assistant Developer Docs

type: horizontal-stack
cards:
  - show_name: true
    show_icon: true
    type: button
    tap_action:
      action: toggle
    entity: cover.garage
    show_state: true
  - show_name: true
    show_icon: true
    type: button
    entity: button.front_door
    name: front door
    icon: mdi:door
  - show_name: true
    show_icon: true
    type: button
    tap_action:
      action: call-service
      confirmation:
        text: Really?
      service: lock.open
      target:
        entity_id: lock.nuki_lock
      data: {}
    entity: lock.nuki_lock
    icon: mdi:door-closed
    show_state: true
    name: back door

In this example I can only ask for a confirmation for the last lock, not for the first ones (cover-toggle and button press).

Odd…

For the cover, try to make the action call-service and call cover.toggle. Otherwise, wrap cover.toggle in a script.toggle_cover call and see if that works (you’d need to hardcode the entity in the script, or better, pass it via data: as a parameter).

Also check GitHub to see if this is a known issue.