Switch with security question?

Hello everybody.

I have a 3D printer on a Smart Wifi plug, this is set up in HA and I can switch it. I have also created an automation system that turns off the printer when printing is complete. Everything was great!!

Unfortunately it has happened to me several times that I accidentally pressed the “Switch” and the printer was switched off during the printing process. Is there the possibility to set a security query, and only when this has been confirmed with “Yes” does the “plug” switch off?

Or is there maybe another idea or possibility?

I would be grateful for help

greetings

Hi,
I am looking for such a security question as well. Doesn’t anyone know a solution?

Thank you!

I had the same problem and solved it using a button with a confirmation attached (which is not possible for a switch). I wrapped the button in a conditional card so it is only shown when the printer is on but thats not required of course. Here is the full lovelace yaml of the conditinal card (add a card and then choose ‘show code editor’ when editing it):

type: conditional
conditions:
  - entity: switch.3d_printer
    state: 'on'
card:
  show_name: false
  show_icon: true
  type: button
  tap_action:
    action: call-service
    service: switch.turn_off
    service_data:
      entity_id: switch.3d_printer
    confirmation:
      text: Are you sure you want to turn the 3D Printer off?
  name: Switch 3D Printer off
  icon: mdi:printer-3d-off

A less verbose option is to add a button row to an Entities card, but this will not be conditional:

type: entities
entities:
  - type: button
    tap_action:
      action: call-service
      service: switch.turn_off
      service_data:
        entity_id: switch.3d_printer
      confirmation:
        text: Are you sure you want to turn the 3D Printer off?
    name: Switch 3D Printer off
    icon: mdi:printer-3d-off
    action_name: Turn off!