openHAB Safety Button

I wanted to have a common button that had the following features:

  • Not be triggered easily, but was easy to use (the standard openHAB prompts can get tiresome on a lot of buttons)
  • could be used to connect to the backend device supporting it
  • could show the power consumed buy the switch (both via text and easy visual)
  • supported both normal (tablet/PC) and Mobile devices
  • had a validation that it had been tested
  • supported all openHAB icon formats
  • optionally could support energy meters(which do not have a relay)

So i have this “Safety Button” that you click the safety cover (and it lifts) and then because your finger is already there you can press the button (and not have to read a message and find the button) , I have thought about adding a “double safety” message - if thats interesting let me know) ) or if you were scrolling you can close the Safety Cover) All safety covers are closed when the page starts again (unless the safety is false)

If the Icon is clicked and the settingsUrl is defined then it will launch a webpage to that device

If the “userValidated” is NOT set there is a red (pink because it displays on Dark and Light mode) Title Text to remind you that you may need to test that the button actually does what you meant it to before letting loose in the wiild.

Features:

The switch supports the following:

itemSwitch: The ON/FF Item for the Switch

itemPower: The Power measured by the switch (or a different item)

itemPowerMin: The minimum power to determine if the switch shows active) it will display ligh blue when there is power flowing , green when now (or less that itemMinPower) or red when off

title: The Name of the switch

safetyText: (the text to display on the Button safety Shield)

safety: Use the Safety Shield (or not)

iconVisible: If the Switch displays an icon

userValidated: Have you tested this is production???

configOnly: If there is no ON/OFF component but you want/need to display alongside other switches

iconName: the icon name - e.g. energy, oh:energy, iconify:arcticons:homewizard-energy, etc

settingsUrl: this launches to the URL for managine the switch - e.g. Tasmota or shelly ip address (http://192.168.1.54) NOTE this utilises “Right Click” (Desktop) or Long Press (phone/tablet) to avoid mis-presses while scrolling

iconSize: self explanatory

compact: Standard Widget Size or something supporting a Mobile Phone

Screenshots

Standard View(blurred effect on button)

The Lifted Safety Screen (blurred effect on title)

The Compact View

Unvalidated Switch

Changelog

Version 1.1.6

  • initial release

Resources

Very clever.
Now I just need to find a use for it.
Thanks

Hi!

I like the idea of ​​the “button”—it could potentially be adapted for medications or other care procedures that need to be followed in a specific sequence.

Each “button” would represent a medication or procedure that would first need to be “unlocked” and then clicked to confirm that it has been taken or performed.

Essentially, it would function as a visual checklist.

A few adjustments would be needed, for example:

  1. Once a button is unlocked and pressed, it could only be unlocked again after a specific condition is met—governed by a rule, for instance.

  2. In this setup, each button could only be activated once per cycle, with the cycle being reset by a rule triggered at specific times of the day, week, etc.

The page could be divided into morning, afternoon, and evening sections, with each section containing as many buttons as necessary for the medications or procedures required during that time of day.

Thank you for your idea and contribution!

Hi @ricardoj
Thanks for your comments.

that seems like a definite use case you have there, you could even keep the support data for the “rules” for each button as meta data on the button itself so that the rule can be more generic

Hi!

I set up a URL—first as an internal path (/static/images/something), and then I also tested it using “http://192.168.X.Y”—but I haven’t figured out how to trigger it. Where should I click to invoke the configured URL?

I assumed that the “configOnly:” parameter was meant to prevent the ON/OFF action from being triggered; however, it still triggers every time I click the button (after unlocking it), regardless of how the “configOnly:” parameter is set.

I am performing all my tests from my computer.

Could you please help me with this?

Hi @ricardoj you trigger by clicking on the icon that is displayed on the top left.(note that it should launch in a new window)

I had test config only but i will confirm that again tomorrow and report back.

Hi @BrettLHolmes !

When I click the top left icon nothing happens.

See widget YAML.

component: widget:vision_safety_button
config:
  compact: false
  configOnly: false
  iconName: f7:snow
  iconVisible: true
  itemPower: Tomada_LAB02_Consumo_W
  itemSwitch: Tomada_LAB02_Status
  safety: true
  safetyText: Protegido
  settingsUrl: http://192.168.58.15
  title: Geladeira
  userValidated: true

Thank you.

@ricardoj

I have updated the button yaml thanks for pointing this out
I have left left that option off when removing some personalised info - EDIT: if you copy the entire YAML again from github and paste over the exiting widget definition it will give you the update
2)
for the activating the URL - On a desktop its the Right Mouse Click or on the Phone/Tablet its a “long press” - this was done intentionally to avoid mispresses while scrolling - I will update the instructions above . Please try and let me know

PS i could make an option. to let it use a normal click if that is desired (rather than a right click/long press/long click) - let me know

Hi @BrettLHolmes!

Thank you for your response and the explanations.

I’ve tested it, and everything is working as expected.

Regarding the standard click option, I believe it could be useful in certain scenarios.

The “configOnly” control could also be linked to an “Item,” which would allow for enabling or disabling clicks on the button based on specific conditions or criteria.

In this setup, if an Item is configured, it would take precedence over the widget’s own control setting; if no Item is configured (i.e., left blank), the control would be governed by the option selected in the widget’s settings. If that’s feasible, of course.

Once again, thank you very much for your help and for creating this widget.