OH3 - oh-repeater use stateDescription of item

Hey guys,
I tried to work on a popover widget to select a hue scene. This is my actual code:

uid: scene_select
tags: []
props:
  parameters:
    - context: item
      description: Item an welches die Szene gesendet wird
      label: Szene
      name: itemScene
      required: true
      type: TEXT
    - description: Vordefinierte Szenen
      label: Vordefinierte Szenen
      name: itemScene_select
      required: true
      type: TEXT
component: f7-card-content
config:
  padding: false
  class:
    - margin-vertical
    - display-flex
    - flex-direction-column
    - flex-justify-content-flex-start
    - flex-align-items-center
slots:
  default:
    - component: f7-list
      slots:
        default:
          - component: oh-repeater
            config:
              for: preset
              in: =props.itemScene_select.split('|')
              fragment: true
            slots:
              default:
                - component: f7-list-item
                  config:
                    title: =loop.preset.split(";")[1]
                    visible: =loop.preset != ""
                  slots:
                    after:
                      - component: oh-button
                        config:
                          text: 'Anwenden'
                          actionItem: =props.itemScene
                          actionCommand: '=loop.preset.split(";")[0].toString()'
                          action: command
                          class:
                            - popup-close
    - component: oh-button
      config:
        popupClose: true
        round: true
        fill: true
        large: true
        text: 'Abbrechen'
        class:
          - margin-horizontal

I can add scenes like:

cybRt-6DWuJQ49s;scene1|qQDnR8betNS0OuL;scene2 

The openHAB API explorer gives me the following stateDescription (commandDescriptions are the same values):

"stateDescription": {
    "pattern": "%s",
    "readOnly": false,
    "options": [
      {
        "value": "cybRt-6DWuJQ49s",
        "label": "Energie tanken"
      },
      {
        "value": "qQDnR8betNS0OuL",
        "label": "Entspannen"
      },
      {
        "value": "HMjIpLrIpk-O8SR",
        "label": "FrĂĽhlingsblĂĽten"
      },
      {
        "value": "61V3SbEuH8IEg9O",
        "label": "Gedimmt"
      },
      {
        "value": "-EL9hhL8FFh0Q4X",
        "label": "Hell"
      },
      {
        "value": "IcV4aE9kvXTTPE7",
        "label": "Konzentrieren"
      },
      {
        "value": "225KFWQ-tMT4Gix",
        "label": "Lesen"
      },
      {
        "value": "qxqIuCmQypoBZIQ",
        "label": "Nachtlicht"
      },
      {
        "value": "4VMKYdkj7JdT93G",
        "label": "Nordlichter"
      },
      {
        "value": "To9Vnqyy6dyqx4Q",
        "label": "Sonnenuntergang Savanne"
      },
      {
        "value": "ieHpE7GIUYpu5qi",
        "label": "Tropendämmerung"
      }
    ]
  },

Any ideas how I can use the stateDescription in oh-repeater? :thinking:

Thank you :slight_smile:

component: oh-repeater
config:
  sourceType: itemStateOptions # or itemCommandOptions
  itemOptions: =props.itemScene

The doc page has a bug due to unescaped quotes so you can’t see the possible options for sourceType - see the raw source https://raw.githubusercontent.com/openhab/openhab-webui/main/bundles/org.openhab.ui/doc/components/oh-repeater.md

1 Like

Thank you so much :slight_smile:

This is my actual solution:

    - component: f7-list
      slots:
        default:
          - component: oh-repeater
            config:
              sourceType: itemStateOptions
              itemOptions: =props.itemScene_select
              for: option 
            slots:
              default:
                - component: f7-list-item
                  config:
                    title: =loop.option.label
                    visible: =loop.option.label != ""
                  slots:
                    after:
                      - component: oh-button
                        config:
                          text: 'Anwenden'
                          actionItem: =props.itemScene
                          actionCommand: =loop.option.value
                          action: command
                          class:
                            - popup-close
1 Like