Analyzer for custom items

Dear all,
I am starting with Openhab and trying to create my first own widgets.
What do I want to do: I just want to show the analyzer if I click on an icon. A “direct statement” to the item is working, but not when I try to link it to a corresponding property.

Maybe in some more details:

This is working (but it is not dynamical):

component: f7-card
config:
slots:
  default:
    - component: f7-row
      config:
      slots:
        default:
          - component: f7-col
            slots:
              default:
                - component: oh-icon
                  config:
                    action: analyzer
                    actionAnalyzerItems:
                      - RollladenArbeitszimmerVorne_Pos

But when I replace “RollladenArbeitszimmerVorne_Pos” with the corresponding item from the props selection (“Rollladen Arbeitszimmer vorne, Position (RollladenArbeitszimmerVorne_Pos)”), nothing is shown in the analyzer page.

I searched and tried quite a lot, but I don’t have a clue how to get it running. If someone could help I would be very happy.
BR
Wolf

  • Platform information:
    • Hardware: Docker on Synology DS218+
    • openHAB version: 3.3.0

Hi Wolf, welcome to the forums!

This is an obscure, but known, limitation at the moment. The expression parser, the piece of the UI that lets you use dynamic code in the widgets, doesn’t work for yaml arrays (any part of the yaml where lines start with a - ).

The solution is to bypass the yaml array syntax, and just set the actionAnalyzerItems property to an array directly using an expression. Because the expression parser is based on javascript, an array is a comma-separated list of values between [ and ]. Since you’ve only got one value at the moment that you want, it’s a fairly simple expression:

actionAnalyzerItems: =[props.your-variable-name-here]

If you ever want more than one dynamic item in an analyzer, then just put commas between them:

actionAnalyzerItems: =[props.your-variable-name-here, props.other-variable]

If you want to add a static item name to the list it has to be a string of the item name (i.e., between quotes):

actionAnalyzerItems: =[props.your-variable-name-here, props.other-variable, "actual_name_of_Item"]
1 Like

Hi Justin,

many thanks for you quick reply! And your explanation helped me a lot!!

At first I wanted to state that this was one of the solutions I tried without success :thinking:. But then I was more persistent :wink: and found out, that only refreshing of the browser page was showing the intended result. Unfortunately, I have to set then the props for testing every time, but it is working now :grin:!

Do you have a tip when this step of refreshing is mandatory? Otherwise I will do that in the future more often or as soon as I expect different results.

Refreshing the widget editor page is almost never necessary, in my experience. I frequently use the Redraw button in the lower right corner (or just press ctrl + r) but that does not cause the chosen properties to reset.

Pretty much the only times I ever find that I have to refresh the widget editor page are: 1) when I want to reset the variables in the widget back to null so that I can test how the widget handles its startup condition, or 2) when there’s been some interruption to the event stream for that window and the items stop responding. It sounds like maybe that second one was your issue, but it is not common, so you shouldn’t have to do it regularly.

Many thanks, I will keep an eye on it.