[OH3] Custom Widget same behavior as action select as in a item-list action

I am trying to do a custom widget there I select and item, action and type a command.

I have successfully added the item via the find and select box

I want the action to behave like it is in the basic widget list-item there you can select an action instead like in my custom widget action where I only can type it in as a text.

Here is the custom widget, parameters

uid: sample_widget
tags: []
    - context: item
      description: Item we are executing our command through
      label: Action Item
      name: actionItem
      required: true
      type: TEXT
    - description: Action to perform when the element is clicked
      label: Action
      name: action
      required: true
      type: TEXT
    - description: An action you wish to perform
      label: Action Command
      name: actionCommand
      required: true

Here i show the a screenshot on list-item set prop dialog


And after clicking on action

Any suggestions on how I accomplish that?

[UPDATE 2021-04-02 17:51]
I have figured out to get same flow as list-item i need to use parameterGroups

uid: sample_widget
tags: []
    - name: buttonAction
      context: action
      label: Button Action


and then use it on my button


component: oh-button
    actionPropsParameterGroup: buttonAction

But say I wish to use the same action and actionItem on all my buttons and a different actionCommand on each button how do I set that up, I don’t want the user to specify which command?

The custom widget hierarchy

  • my_custom_remote (Specify actionitem and select action, with same ui as picture as above without displaying Action command)
    • my_custom_button (Use my my_custom_remote actionItem and action but specify only actionCommand)
    • my_custom_button (Use my my_custom_remote actionItem and action but specify only actionCommand)
    • my_custom_button (Use my my_custom_remote actionItem and action but specify only actionCommand)
    • my_custom_button (Use my my_custom_remote actionItem and action but specify only actionCommand)

I don’t think you can invoke the actions popup directly in the custom widget parameters, but you can build your own clone by using options and limitToOptions.

    - name: testAction
      label: Action options?
      type: TEXT
        - value: navigate
          label: Navigate to page
        - value: command
          label: Send command
        - value: toggle
          label: Toggle item
        - value: options
          label: Command options
        - value: rule
          label: Run rule
        - value: popup
          label: Open popup
      limitToOptions: true


options sets a mapped list of possible values for the parameter. But this will just render as a text box with autocomplete suggestions. To get the radio buttons you have to set limitToOptions to true.

If you have six or more items in the options map then it will automatically generate the popover for the radio button list as in the image above. If you have five or fewer it will just render them directly on the page.

1 Like

Thanks for The reply!

Sounds like a workaround I can do for now to make the widget easier for the user to use.

  • But it would be nice to have the opportunity to just take a couple of steps or directly call action popups in the future :slight_smile:

I feel like this is a workflow that someone more than me would ask for.

Should I open an issue for this in openhab-webui, what do you think?

I have a follow up question on options…

Is it possible to load options dynamic with something like this?

   - name: myActionItem
     context: item
     type: TEXT
   - name: myActionCommand
     options: '=(props.myActionItem) ? props.items[props.myActionItem].stateDescription ? UNDEFINED'
     limitToOptions: true

Alas, there are a couple of reasons why that won’t work. 1) I don’t think you can access the props or items objects within the parameters section, but I don’t know for sure, 2) even if you can access the items object, it does not contain the information about each item, it only contains a string of the item state and (if configured for the item) the display state. So you cannot get to an item’s metadata that way.

Ok so we are stuck defining constants twice :slight_smile:
It would be nice to have one source of truth, so we don’t need to update it manually?

Do you know why it is decoupled in that way?

My Thoughts:

  • speed things up?
  • Can see one thing if we change it on the fly we will store props that don’t validate no more, but I suppose that are the case even with manual handling?

What I am thinking ‘Set props’ part would it not be nice to have the meta data as well or am I in deep water thinking like that?

I would do some testing see what I can access on items.

This topic was automatically closed 41 days after the last reply. New replies are no longer allowed.