Expressions Items not accessible

Hi, I’ve a long term openhab user and living with openhab3.1 on my raspberry satisfies my needs in smart home. as I have used it since openhab1.x I am still on a sitmaps navigation and on the shift to mpove to the pages. Here starts my struggle. My Items Dictionary seems completly empty.
This Otter_Absence is just one example - you see it’s value of 1.0 here:


Meanwhile in the Model explorer it’s not available:

Interestingly, in the tooltip of a page yaml I get the correct suggestion:

… and now I’m feeling dumb / because I am sure I missed something which I obviously can"t find out.

You’ve shown that the Item exists under Items.

You’ve shown that the Item exists in the Developer Sidebar.

You’s shown that the Item exists in the auto-completion dropdown.

So I think it’s pretty safe to say that the Item exists.

Even though you are an old hand with OH, definitely review the Getting Started Tutorial, in this case pay special attention to the Semantic Model. There is a lot of useful information there including

However, the model is not intended to represent all your Groups and Items…

Existing Items can be added to the model. Browse to the Item in the Items settings, click on Edit and choose an appropriate Semantic Class and Semantic Property. Then add the Point as a member of the appropriate Equipment or Location Group. If the Equipment Group doesn’t exist yet, create a Group and use the appropriate Equipment semantic tag first and add the Equipment to the appropriate Location Group.

If your Item doesn’t appear in the Model view then it has not been tagged with a semantic tag and therefore is not a part of your model.

Note that the above assumes the Items are managed. If they are defined in .items files you’ll need to add the tags and set the Group membership there and not through the UI.

thanks for the quick reply!
here is my little item:


I do not know if the tags are correct but I cannot get the prerequisites for this…

Check your item’s stateDescription metadata (it looks like you have a map transform on the item perhaps?). The list of items on the items page shows the state of the item, but the widget at the top of the item details page, by default shows the displayState of the item, or the state after it has been modified by various other options. So right now your Otter_Absence item has a state of 1.0 but for some reason your stateDescription is returning a null value from that 1.0 state.

The state is even available in the widget editor; you can see in the tooltip in your screen shot that the state is one. So items.Otter_Absence.state should give you 1.0, but items.Otter_Absence.displayState will continue to give you - until you figure out what is wrong with the stateDescription metatdata.

OK, based on that screenshot it is properly tagged as a Poit with a Property.

It’s a member of the Otter_Absense_Equipment. What location is Otter_Absense_Equipment placed in?

thanks for suggestion!
true - I had a transform map but I wasted it meanwhile. With your suggestion I created a stateDescription (which was empty) and entered the old mapping values without any effect on the state in the Expression

I made a Location tree as shown in the screenshot above / on the left side is the Model root


so it’s nested.

BUT to make this clear the expressions Items Dictionary does not contain ANY of my 410 items…

And this is the one thing you’ve not shown us. How are you trying to use the Items Dictionary? Where are you trying to use the Items Dictionary?

I would like to show but I dunno how?

So I tested a bunch of Items which all resulted in the state as above. when I use “=items” I get a “{ }” - thats my indication that it is empty…

Copy and paste where you’ve entered it. What field? What type of widget? I assume you are not in a rule. If you need to show context show the whole YAML code in the code tab.

In a Widget the expression starts with a = and then you have your expression. For example:

=(items["MyItem"].displayState === undefined) ? items["MyItem"],state : items["MyItem"].displayState

That expression will use the displayState for Item MyItem if it exists and uses state if it doesn’t exist. There is only displayState or state.

There is also an expression tester in the Developer Sidebar where you can enter and experiment with expressions.

There is all sorts of things that could be going wrong here but we don’t see what you’ve entered so :man_shrugging:

with the expression tester I cannot show as much options. so I tried the best with a page card


the orange card on the left shows the evaluated values which are all … unavailable or “-”

What options are you trying to show? It’s an expression tester. It tests the expressions. It shows what an expression returns. That’s what we want, right?

That’s exactly what we want to see with your “Otter_Absence” Item. Also note that the preview of a page while you are editing it does not update as the Items change state. Sometimes they don’t even show the current state when you first add them to the Page or as you make changes in then Custom Widget creator. You need to manually refresh to see updates and such. That’s why the Developer Sidebar is better for this sort of thing. As it is I can’t tell if it’s not working because it’s not working or because you haven’t refreshed.

see, that’s what I wanna show BUT
OH-ItemExpression

It’s the very same when using the dictionary syntax =items[“Otter_Absence”]

to clarify: I refreshed, I restarted openhab service, I changed browser - nothing:
the red scribbles the state of Otter_Absence:
OH-Page-Web

Meanwhile / on my android app:


so I looked in my firefox on mobile with the same result as the app… it presents the good result (as the Item state is 2 in the morning / believe me)

I restarted openhab, flushed browsers cache on my windows client and it still does not know about the state. now I do not feel dumb any more - but the error is somewhere out there. I have nothing in my openhab logs - where can I have a look to investigate further?

But that’s also the same result one gets if the Item exists but it’s state is NULL or UNDEF. So that’s not necessarily a good test for whether or not the Item exists. But it is informative.

If it’s showing in some browser/app but not other’s then the problem lies somewhere in the UI or the browser itself (perhaps an extension is blocking the SSE feed for example). At this point the best I can offer is to file an issue on the openhab-webui and gather logs from the browser.

On chrome, if I come back to a OH page I’ve left open for a while, I often find that I have lost the SSE feed. A page refresh is usually sufficient, though that doesn’t seem to be the case here.

What do you see if you click on the second button on the developer siderbar (the ~ image) and then press the Stream Events button?

What do you see in the sessions list if you click on the profile link in the bottom of the left panel?

I always asked myself what these Events are about and when do they appear bc I never get any. I clicked as you described and followed some links in the UI afterwards but not any event showed up. It is completly empty / what does this mean?

thats a good point! I used Firefox with a bunch of extensions and restrictions and MS Edge (chrome based) with default settings on . finally I installed chrome itself / all with the same result: missing state information of my items.
Maybe it’s some kind of firewall or so. to clarify: I use the same local adress from mobile phone (which works) and from windows client (which does not work). I’ve lost my SSL certificate so I will regenerate it and will try the remote address to check for differences

That’s crazy! on the windows machine it works in any browser when I use https (which I do mostly - but I was too lazy to repair the ssls).
OH-ItemSuccess

So I can close this issue and warn everybody to use the http port / even for testing!

Thank you for this very useful workaround when .displayState is unavailable for whichever reason.

One thing I don’t quite understand is the following:
.displayState becomes unavailable when .displayState would return the same result as .state.

See the following example:

Windboe1
Windboe2

with “%.0f %unit%” applied as stateDescription

How come .displayState does not return anything? Is this a bug?