Is it possible to prompt "are you sure" after pushing a button in custom device type?

I’m working on a custom device type for an auto door closer. The hardware has an object detection circuit to prevent the door from closing when an object is in the way. The hardware also has the ability to close and ignore the object pushing it out of the way. In my custom device type I would like to prompt the user with an (Are you sure you want to do this) Yes/No box after they push the button in the custom device type. Is this possible? If so can someone point me in the right direction?

I attempted doing something like this a while back for a panic button for my home alarm, but I never came back to it. There is no way to pop up a dialog (as far as I know), but my idea was to have a button that requires a second press via a state change. So in the device type there would be a button that has the following state changes:

  • Starts as “Panic” button
  • When pushed, changes to “Confirm”
  • When pushed, triggers the panic alarm, reverts back to “Panic” state
  • May also need another button to cancel, change “Confirm” back to “Panic” without triggering the alarm

I think you could use this same technique:

  • Starts as “Close” button
  • When pushed and obstacle is detected, change to “Obstacle”
  • When pushed, close the door and change back to closed
  • A separate cancel button as the “No” option
2 Likes

Humm so the cancel button would always be visible? Is there a way to hid a button and then show it on demand? I think that has been asked before and the answer is no.

Thanks for the suggestion!! Its very close to what I need but I think a separate cancel button always visible would confuse the user.

I think you’re right :frowning:. How about setting a timer to change back if it is not pressed in some timeout period. Or maybe just pressing any other button would cancel it?

Ohhh a timer! So If I can trigger a countdown timer some how couldn’t I have that send events to the button and have it count down to a cancel condition. For example the button could say (Push again to confirm! 10…9…8…7… ). Liking this idea!! Hate to ask but how do I trigger a timer in a custom device type. If you point me in the right direction I will read up on it!!!

Maybe someone else can chime in, but I don’t think you’ll be able to get the countdown showing on the button, as the timing available is not usually accurate down to the second. You could use runIn to schedule a method to run after some delay to change the button state. http://docs.smartthings.com/en/latest/smartapp-developers-guide/scheduling.html#schedule-from-now

1 Like