Temperature (Point) sometimes shows "undefined" on sitemap

Good morning,

I upgraded my openhab on a rapsberry pi 4 to 5.0.2.

I have one temperature item working fine (currently showing me cold -2.25 °C).

On a sitemap, this is linked with following label:

= "Außentemperatur: " + items [‘BewegungsmelderHaustureTemperatur_Temperatur’].displayState

So in general, this should show me the temperature.

The strange this is, that this was working always with OH4, but with OH5, sometimes it shows “undefined” instead of the label incl. the temperature.

An item just showing the temp (not within a label) works.

Do you know if I have to set it up another way to get it working correctly?

Thank you,

Best,

Christian

On a sitemap? To my knowledge sitemaps do not support expressions.

If you mean MainUI then use the shorthand =@'BewegungsmelderHaustureTemperatur_Temperatur'. That will show the displayState if that’s defined and state when it is not.

The problem is if the state matches the displayState, only the state is provided and displayState is undefined. Only if the state and displayState are different will displayState have a value.

See Widget Expressions & Variables | openHAB for details.

Thanks @rlkoshak !

I am talking about a Page > Layout setup – see some screens below.
The widget is a label card and both state and displayState are currently returning “unedfined”.

I also tried with @ (also once without quotations) and this returns a “-” instead of the temperature.

Summarized, currently no idea how to combine text and an item state within a widget label.

The code of the label card:

component: oh-label-card
config:
item: BewegungsmelderHaustureTemperatur_Temperatur
title: “Außentemperatur:”
trendItem: BewegungsmelderHaustureTemperatur_Temperatur
icon: temperature
label: ‘= "Außentemperatur: " + @BewegungsmelderHaustureTemperatur_Temperatur’

not that important to me, but the issue never came up with OH 3 and OH4 for me.

The quotes are required. @ needs a String to follow it. Your current code does not have quotes.

From the examples in the docs:

The @ symbol can be used in front of an Item name string as a shortcut to the displayState from the items dictionary with a fallback to the raw state:

footer: =@'Switch1'

is the same as

footer: =items['Switch1'].displayState || items['Switch1'].state

I now got it working, added the brackets and may be one or two spaces. Not sure, what exactly the issue was, but this code now does it.

= "myText: " + (@‘BewegungsmelderHaustureTemperatur_Temperatur’)

Thanks Rich, will mark this as solved for now

oh Jesus, you know what was my mistake?

One of the single quotes / prime was wrong (‘ and ´ mixed up…).
Might be that OH4 didn’t mind about this while OH5 does?

But it works now :slight_smile: