Dynamic icon not working in list item widget OH3

I’m trying out the examples from the location here: Building Pages - Components & Widgets | openHAB

In particular the one to have dynamic icons based on item state. Somehow it does not work for me. I tried to do some debug using the expression tester, this is the result:

The switch is clearly on but still the expression results in the wrong icon.

What am I doing wrong here? How can I solve this? Thanks!

When using the [ ] notation to access an object’s properties, the code inside the brackets must evaluate to a string. That means you either have to use a variable that is currently assigned a string value or put the actual text you want inside quotes. Right now the expression tester is trying to use ZWaveNDKantoor_Switch as a variable and since this variable doesn’t have a value you’re getting items[NULL].state which always evaluates to false. Try


Thanks, that did the trick, Perhaps a follow-up question. I’d like to the use props.item to avoid having to type in a lot of item names. Is that possible in the standard listWidget metadata? I cannot get it to work somehow. The expression always resolves to the else part.

For example, for icon color:

=(items[props.item].state == "ON") ? "orange" : "gray"

This always results in a gray icon color. Perhaps it is not possible with the standard OH widgets?

If you include a parameter with the name of item in a widget and assign that widget as the default standalone or list widget for an item, you don’t even need to configure the item property in the metadata, the UI will automatically populate the item parameter with the name of that item.

Here’s an example:
The parameters for my custom list item for blinds look like this:

    - description: Label to show
      label: Item Label
      name: Label
      required: false
      type: TEXT
    - context: item
      description: An item to control
      label: Item
      name: item
      required: false
      type: TEXT
  parameterGroups: []

In the metadata for one of my blinds items I have:

value: widget:widget_blinds_default
  Label: Bedroom Blinds

You can see that I configure the Label parameter but not the item parameter.

In the equipment list, my item is still properly displayed because the item parameter is automatically set by the UI.

Thanks. But what I’m trying to do is to keep the default OH widget and avoid custom widgets. When I use the default OH widget the breadcrumb works fine in the equipment tab. With a custom widget the breadcrumb does not seem to work. I guess I have to stick with the specific reference to an item name if I want to keep the default OH behavior.

Did you ever solve this?

I’m having the same issue. It seems that the expression


is not being evaluated.

Nope. I could not get it to work with the standard out of the box widget. It requires a custom widget but then some other features are not available (breadcrumb) or at least I could not get it to work so I gave up for now.