Simple example oh-repeater rquiered

Hello dear community,
I am using openHAB 4.2.1 on my Raspberry Pi 5 and wanted to try out a widget in the widget designer with a repeater for the first time. Unfortunately, without success.

Grateful for any help.

freeET

your uid: GUI_TEST
tags: []
props:
  parameters:
    - context: item
      label: Item 1
      name: item1
      required: true
    - context: item
      label: Item 2
      name: item2
      required: true
timestamp: Dec 5, 2025, 3:03:22 PM
component: f7-card
config:
  title: Simple Repeater
slots:
  default:
    - component: oh-repeater
      config:
        sourceType: array
        in:
          - =props.item1
          - =props.item2
      slots:
        default:
          - component: f7-row
            slots:
              default:
                - component: Label
                  config:
                    text: =items[loop].label || loop
                - component: Label
                  config:
                    text: =items[loop].state
code goes here

You have three errors; two of them are related:

  1. loop is a general object that contains several different sub-objects so you cannot just use items[loop] you have to use items[loop.someLoopVariable]. But, how do you know what someLoopVariable actually is?
  2. Your repeater is missing a critical property which sets the name of the loop variable: for.

So the correct combination looks something like this:

- component: oh-repeater
  config:
    for: myVariable
    sourceType: array
...rest of config

and then

- component: Label
  config:
    text: =items[loop.myVariable].state

The third error is that items['Some Item Name'].label will not return anything. The items object is not a complete representation of an Item (that much data transfer for every use of items in the UI would cause a very slow and buggy interface). The items object only provides the State of the Item (as a string) and a few other often useful pieces of information such as the type of the Item and the State of the Item as a number (if it is a number type Item).

Hello JustinG,

Thank you for the clear explanation. It worked immediately. Can you also tell me what is the best way to display a label or defined text for each item in the array?

Greetings freeET

The repeater has two source options that directly query the API for full information about Items:

So, you can use either the itemsInGroup or itemsWithTags source types to get an array of the complete information about those Items. Of course, this means putting the Items you want in a group or giving them all some consistent tag first.

In this case, once you have that true item array then loop.myLoopVariable.label will, in fact, contain the actual label of the item.

Beware: your array will also include an Item State (loop.myLoopVariable.state), but this is NOT a dynamic value. It is the value of the State at the time the repeater makes the API call and it will not change unless you refresh the repeater and it makes a new API call. You still must use the items object to get a value that will change in real time with the State of the Item (items[loop.myLoopVariable.name].state).

Thank you very much. You made my day. :grinning_face:

1 Like