UI icon indicating copy to clipboard operation
UI copied to clipboard

Enhancement: Conditional Confirmation

Open mwolter805 opened this issue 3 years ago • 7 comments

Recommend adding the following to every card. No reason not to and adds simple protection for critical devices.

If the variable is included in the card, the confirmation text is displayed. If the variable is not included, the card operates normally.

Card

variables:
  custom_card_mwolter_power_outlet_confirm_text: Toggle the eGPU power?

Template

tap_action:
  action: toggle
  confirmation: '[[[ return variables.custom_card_mwolter_power_outlet_confirm_text == null ? false : {"text": variables.custom_card_mwolter_power_outlet_confirm_text} ]]]'
hold_action:
  action: more-info

mwolter805 avatar Nov 04 '21 20:11 mwolter805

I think it's a good idea, but I'm not happy with the way of implementing it. It is additional code where we don't know how many people are really using it.

I'd suggest, we think of a better way to use that, something where the user can enable or disable it easily. But to be honest, how we should do that, I have no idea (yet). :)

If we can't find a better way, we should do it the mentioned way. :)

Thoughts?

EDIT: while thinking about it, should we just do a seperate card for that? We could just inherit the template from the card without confirmation and add a suffix for every card...

I'll write down some kind of code example as a POC (proof of concept) and put it in here.

Paddy0174 avatar Nov 07 '21 14:11 Paddy0174

Here we go, does that sound like a solid idea to go on with?

(Almost) every card gets a new template added, naming with a suffix like "_confirm". The new template would look something like this:

# button_card_templates.yaml
card_xy:
  the code

card_xy_confirm:
  templates:
    - card_xy
  variables:
    ulm_card_xy_confirm_message: 'Really? Turning the light off in the middle of the evening?'
  only new confirmation code added here

Paddy0174 avatar Nov 07 '21 16:11 Paddy0174

Looks good, and provides the option to assign tap_action: in the original card. But the variable should be in the actual lovelace yaml and not in a template, no?

mwolter805 avatar Nov 08 '21 20:11 mwolter805

Yes and no. :) The variable has to be in the "view" file, but to set a default, the variable will be definied in the template code as well. If the variable is set in "view", the other one will be overridden.

I've created a new branch for this feature and will work on it in the next days. But it may take some time, can't give any estimates.

Paddy0174 avatar Nov 08 '21 21:11 Paddy0174

ahh, right...thanks!

mwolter805 avatar Nov 08 '21 22:11 mwolter805

Is this possible the the Room Cards side entities? (entity_1, entity_2 etc.) A confirmation option would be nice!

ds-sebastian avatar May 09 '22 15:05 ds-sebastian

Just adding my support to this request, particularly the Room Card side entities. I'd like a confirmation before turning off a switch.

scoobydoofus avatar Aug 23 '22 10:08 scoobydoofus

I also would love to have this feature specifically for the Room card. I have some switches I'd like double checked before turning on. Unsure if there is a way to achive this rn since I'm very new to ULM, but already in love!

EhrleMirror avatar Jan 02 '23 23:01 EhrleMirror

@Paddy0174 what is the progession on this function? I would like to use it on my power outlet cards.

JRTax avatar Jun 04 '23 21:06 JRTax