Items[´xyz´] does not return the item xyz

  • Platform information:
  • Hardware: Raspberry Pi 4 Model B Rev1.2
  • openHAB version: 3.3.0
    I have a problem when creating a widget which uses OpenWeather to display Weather information.
    I show Items in a table and create that table in some repeat loops (oh-repeat).

That work fine, but if I try to access the icons in OpenWeather I can’t use items[‘xyz’] as with the loop below. (where xyz is the name of the icon). If I use xyz without items the icon is displayed.

In this case it seems that items[‘Wetterinformationen_ForecastDay2_Icon’] !== Wetterinformationen_ForecastDay2_Icon.
Is there an explanation for this effect?

TIA

Holger55

- component: f7-row
  config:
    class:
      - padding-left 1px
    style:
      background: =props.bgcolor
      border-top: 2px solid rgb(64, 60, 77)
  slots:
    default:
      - component: Label
        config:
          style:
            width: 16%
            background: = props.bgheadline
            height: 20px
          text: = "Morgens"
      - component: oh-repeater
        config:
          fragment: true
          for: loop
          in:
            - Today
            - Tomorrow
            - Day2
            - Day3
            - Day4
            - Day5
        slots:
          default:
            - component: Label
              config:
                style:
                  width: 12%
                  height: 20px
                text: = items[props.WI+"Forecast"+loop.loop+"_Morningtemperature"].state

Can’t say for sure unless you show us exactly what you’ve tried to do, but it depends on the combination of what kind of item it is and how you’re trying to show the image. Most of the weather icon channels provide the image directly and the item is therefore an image type item. This means that the state of the item is the raw 64-bit encoded image data (and the display state is just a short form object identifier that looks like this raw type (image/png): 3018 bytes). A few icon items give you a standard icon name and expect you have an icon library from which you extract the icon of that name.

Assuming that you have the image type item then most of the time you just need to supply the name of the item. For example the oh-image component has a built in item property. If you are using that then that property just takes the name of the item and will fetch the item state (the raw image data) itself. If you try to set the item property to the state of the icon value then the widget will try to look up an item named raw type (image/png): 3018 bytes which, of course, doesn’t exist.

Sorry , I thought I was clear enough my code example is one of the text items. I wanted to do the same with the icon Items.

Actually I use an oh-image control to show the I
icon.

      - component: oh-image
        config:
          style:
            padding-right: 40px
          item: Wetterinformationen_Current_Icon

instead I wanted to use

      - component: oh-image
        config:
          style:
            padding-right: 40px
          item: items['Wetterinformationen_Current_Icon']

This was my desired goal.

I thought the Item and the reference to the item through the items collection would return the same object. This seems to be wrong.

Thanks for answering tha fast.

Holger55