I’m a doofus. I’ve long since stopped making excuses and just accpeted the fact that if a delicate item can be dropped, or an unintended system can be trigged, or a wrong button can pushed, I’m very likely going to drop, trigger, or push it. Case in point: I have a few buttons in my OH UI that are extremely useful, but only under very certain circumstances (for example, a button that turns off all the lights in the house). Naturally, I have the tendancy to occasionally press these buttons during other circumstances. My son is tired of being plunged into darkness while he’s doing homework, and my wife has a similar objection when she’s in the kitchen baking and everything goes dark just because I pushed the wrong button (again). So, I have to make sure that my “smart house” is smarter than me and fool-proof (me-proof) various parts of my OH UI.
For the particular problem of the important button that should not be pressed accidentally, I have created this widget: a button that requires a second confirmation push within a certain timeframe before the associated action is triggered.
Usage
This widget should be pretty close to a drop-in replacement for any basic oh-button
(except for the action definition, see Actions below). It takes some of the same relevant parameters, and takes it’s default style from the oh button classes.
When the user clicks on the button no action is taken, but the user is asked to confirm the activation of the button and a countdown starts (indicated by the decreasing progress bar on the bottom of the button). A second click during that countdown is required to confirm that the action should be executed. If no second click is made during the countdown then the button reverts back to its original condition.
Configuration
Parameter | Description | Default |
---|---|---|
barColor | Color of the displayed countdown bar | OH theme color |
confirmText | Text to display when confirmation is required | Confirm |
countdown | Countdown time (in seconds) | 10 |
raised | Same as oh-button raised property |
false |
style | Same as oh-button style property*
|
none |
text | Text to display on the basic button | none |
Actions
All the standard action configurations are accessible but must have the prefix confirmed_
added to the them. For example, to configure the button to send a command to an item you would use confirmed_acton
, confirmed_actionCommand
, and confirmed_actionItem
.
*
- The style
property can only be set when configuring the button in a code editor, it cannot be properly set using the Props dialog. This is because it must be an object which is easily defined using yaml but cannot currently be expressed via the dialog.
Changelog
Version 0.1
- initial release
Resources
https://raw.githubusercontent.com/JustinGeorgi/oh-public/main/widgets/confirm_button.yaml