OH3 dynamic icons not working

OpenHab 3.1.0 with Azul Zulu 11

I have created an item for the valve of my heating through the UI. I assigned the icon “heating” to it:

org.openhab.core.items.Item.json:

  "Heating_Valve": {
    "class": "org.openhab.core.items.ManagedItemProvider$PersistedItem",
    "value": {
      "groupNames": [
        "Heating"
      ],
      "itemType": "Number:Dimensionless",
      "tags": [
        "Measurement"
      ],
      "label": "Valve",
      "category": "heating"
    }
  },

org.openhab.core.items.Metadata.json:

  "stateDescription:Heating_Valve": {
    "class": "org.openhab.core.items.Metadata",
    "value": {
      "key": {
        "segments": [
          "stateDescription",
          "Heating_Valve"
        ],
        "uid": "stateDescription:Heating_Valve"
      },
      "value": " ",
      "configuration": {
        "pattern": "%d %%",
        "readOnly": true
      }
    }
  },

Currently, the item shows a value of “0 %”. But the main UI is always loading the icon “heating”, which is not dynamic. I would expect that the UI loads “heating-0” (or “heating-30” for the value “30 %”), just as it did in OpenHab 2.5.

For reference, this item definition in OpenHab 2.5 is loading the correct dynamic icon:

Dimmer   Heating_Valve   "Valve [%d %%]"   <heating>   (Heating)

I already tried several modifications on the item in OpenHab 3: Changing to Number or Dimmer did not work. Removing the “State Description” did not work.

What part of MainUI are you looking at? The Category pretty much only controls what icon is shown on the Settings → Items page. The icons shown there are not dynamic.

To have dynamic openHAB icons on widgets which are showing on Pages (including the automatically generated Locations, Equipment, and Properties tabs of the Overview Page) you need to set the icon on the Widget. Navigate to the Item, add “Default List Widget” Item metadata. That will bring up a form which should be self explanatory. In particular you want to set the openHAB label and openHAB label depends on state options for the widget.

See Search results for 'default list item widgets' - openHAB Community for examples.

Thank you.

IMHO a little bit confusing, that OH 1 and OH 2 default behavior is now behind a “show advanced” toggle.

The OH 1 and 2 default behavior is still there in the parts of OH that existed in OH 1 and OH 2. MainUI is completely new to OH 3 and works completely differently from those legacy UIs.