Add a confirmation popup in a widget

Hello,

I am using the garage door widget from rlkoshak (thanks!) and I would like to add a confirmation popup. This is in case I accidently click on the widget. Here is the code:

uid: rlk_garagedoor_list
tags:
  - list
  - garagedoor
props:
  parameters:
    - description: Door name
      label: Name
      name: name
      required: false
      type: TEXT
    - context: item
      description: Control Item
      label: Control Item
      name: control_item
      required: false
      type: TEXT
    - context: item
      description: Sensor Item
      label: Sensor Item
      name: sensor_item
      required: false
      type: TEXT
  parameterGroups: []
component: oh-list-item
config:
  icon: '=(items[props.sensor_item].state == "CLOSED") ? "f7:house" : "f7:house_fill"'
  iconColor: '=(items[props.sensor_item].state == "CLOSED") ? "green" : "red"'
  title: =props.name
  action: command
  actionItem: =props.control_item
  actionCommand: ON
  badgeColor: '=(items[props.sensor_item].state == "CLOSED") ? "green" : "red"'
  badge: '=(items[props.sensor_item].state == "CLOSED") ? "closed" : "open"'

I did find some info about popups in widgets but I have no idea how to apply the solutions I found to this widget, I am a newbie with widgets.

Thanks for the help.

I’ve not done this but I think what you need at a minimum is to change the action to popup and then add the actionModal properties which point to the widget to show when it’s clicked. That widget will need to be defined separately and in that widget you’ll need two buttons, one which cancels and does nothing but close the dialog and the other which commands the Item.

Beyond that general outline I’m not going to be of much help. It’s not something I’ve tried.

Thanks, I will try to figure this out with your suggestion. When you’re a beginner with widgets and YAML it’s not easy to understand all this.

If you are on a recent OH4 version, then you can do this automatically just by using the actionConfirmation property.

If you have something more complex than a simple confirmation dialog box, then you will need to go with the action: popup settings. You can find description and examples here:

1 Like

Just tried it, that was so easy! I should have looked it up in the docs …

Thanks!