Docs for props in custom widgets

I spent hours to find a list of possible values for props and parameters like "context: ", "type: " and so on for customizing the “Set Props” dialog.
Where can I find a (detailed) documentation about widget-properties? The following page doesn’t really answer all of my questions regarding properties of custom widget:
root-components-props

For example, I would like to set a boolean value through a checkbox, or set a string through a selection in a dropdown field with predetermined values (in the “Set Props” dialog).

Are there more options than…

context: item

I don’t think there is a help page on this.

You can get some idea of the available types and the context values associated with those by looking through the source code of the parameter viewer:

For example from there you can see that types is just TEXT, INTEGER, DECIMAL, or BOOLEAN. Your boolean value will be a toggle switch and not a checkbox but just set type to BOOLEAN.

Context then only really applies to all the different TEXT types.

This was my initial mistake and it put me on the wrong path

easy solution and I’m sure, I did it in other widgets before, but this time, I was to silly to get this working.

If you’re not familiar with it, it’s hard to extract useful values ​​from your linked documentation, especially if you don’t know whether it’s even the right documentation.
Maybe there will be more user-friendly documentation soon.

Im still missing a solution for the dropdown field with predetermined values. This could be a good tool to provide the community with easy-to-manipulate widgets.

You are 100% correct. Unfortunately when an easy solution isn’t available hard solutions must be sufficient.

Until someone volunteers to write this particular documentation, it’s the best we’ve got.

That can be achieved with a simple TEXT property and the options key:

  parameters:
    - name: prop1
      label: Prop 1
      type: TEXT
      description: A text prop
      options:
        - value: as7g987gs
          label: Channel 1
        - value: gfhj4gfh9
          label: Channel 2

image

I posted a rule template that I left up exploring as many of these as I could. @stue you can find it here:

The same evaluation engine is used for both rule templates and widgets (and add-ons for that matter).

There used to be a doc page that covered these but it seems like we lost it in OH 4? I can only get back to it in the v34 docs and before.

Maybe we have something broken in the docs?

3 Likes

I had forgotten about that! That’s going in my bookmarks this time so I don’t forget again.

Nice. This offers me some stuff for my try and error lesson this evening :grin:
Thanks again :+1:

Whilst you are trying, do you mind just adding them to a post (maybe the first post of this thread) as a collection of what you have seen in the widgets and arrange them in a summery quick glance or cheat sheet style? Then someone can update docs easier if someone has started the work in the forum. There is also a solutions area of the forum which may be better place to publish a work in progress collection for others to post and contribute to your collection if you do not mind collating them.

My link above was fairly comprehensive at the time of it’s creation in OH 3.2 IIRC. [Do not install] Rule Template Parameters Experiments and Examples

I certainly am missing a few text contexts (IP address, email, stuff like that) which may be more relevant to a UI widget than a rule template but a lot of the contexts are not going to be relevant.

But the true source for documentation for this used to exist. Configuration Descriptions | openHAB

A search in the latest docs shows that the search index at least still thinks this page is there. But it leads to a 404 instead of the actual page. But I was able to find it by browsing through the links. Configuration Descriptions | openHAB

I’m not sure why search is broken.

I think the best way forward would be to link to this reference from the “Building Custom Widgets” page (maybe elsewhere?) along with perhaps a short description on how to map the table to YAML.

The YAML follows the same hierarchy as shown in the XML examples on that page so it’s not too hard.

Note, at least for rule templates, filtering doesn’t appear to work. If you only want Group Items and set a filter to do that, you’ll still get a list of all Items.