Number item has no value in Sitemap

Hey everyone,

I have a strange issue. I have a number item which doesn’t display it’s value in the sitemap even if it has the exact same configuration as another similar item.

I have a mini PV system which socket is attached with a shelly pm to see the watts the PV system produces. But as the shelly normally is made for reading the energy usage of the attached machine the value for energy production is negativ. Of course I want to read it as a positive value. So what I have done is that I created one number item which reads the values of the shelly via MQTT. So this items number value is always 0 or a negativ number. On every change of this item I send it’s value to a similar number item but before that i calculate *-1 so it always has the same value as the other item but it’s always 0 or a positiv number. So far so good. Checking it in the openhab userinterface both have a value but in the sitemap only the item which receives it’s data directly from the shelly displays it’s data.

Data in UI


Screenshot was made in the dark. By day it’s working perfectly fine so for example value of first item is 200 and value of second item is -200. Value of first item is the value that won’t be displayed.

Data in App

Interesting is that the charts are although using the data from the item which values won’t be displayed.

Item Config

//PV Anlage und drum herum
Number                              PV_Anlage_Produktion                            "Stromproduktion PV Anlage Originalwert"             <solarplant>         {channel="mqtt:topic:mqttbroker:PVAnlage:PVStromproduktion"}
Number                              PV_Anlage_Produktion_Positiv                    "Stromproduktion PV Anlage"                         <solarplant> 

Sitemap config

Text label="PV Anlage" icon="solarplant" {
			Default item=PV_Anlage_Produktion label="Aktuelle Produktion (Echtwert)"
			Default item=PV_Anlage_Produktion_Positiv label="Aktuelle Produktion"
			Chart item=PV_Anlage_Produktion_Positiv period=D refresh=30000
			Chart item=PV_Anlage_Produktion_Positiv period=M refresh=30000
			Chart item=PV_Anlage_Produktion_Positiv period=Y refresh=30000
		}

Rule that sends data to the itmes

rule "PV Wert positiv machen"
when
    Item PV_Anlage_Produktion changed
then
    PV_Anlage_Produktion_Positiv.sendCommand((PV_Anlage_Produktion.state as DecimalType) * -1)
end

Any idea what may be the cause of this?

I haven’t fully read your description of the problem, but try adding the format specifier in the label, i.e. adding [%.1f]

Text label="PV Anlage" icon="solarplant" {
			Default item=PV_Anlage_Produktion label="Aktuelle Produktion (Echtwert) [%.1f]"
			Default item=PV_Anlage_Produktion_Positiv label="Aktuelle Produktion [%.1f]"
		}
1 Like

I seem to think this happens with items that aren’t bound to things. @JimT’s solution will work.

If you’re on OH3/4, you can instead add state-description metadata to the item. I can’t remember what the syntax is for that in a text file, but I can look it up later if you want.

1 Like

Hi, try

Default item=PV_Anlage_Produktion_Positiv label="Aktuelle Produktion [%d]"

Maybe

Default item=PV_Anlage_Produktion_Positiv label="Aktuelle Produktion [%d Watt]"

Greets

2 Likes

Number items not linked to any channel require a state pattern.

Note that it has just changed, there is now a default provided. This change will be part of 4.2 Milestone 3.

2 Likes

Thanks everyone. That fixed it. Didn’t know that for number items which aren’t linked to a channel (which is the case for that item) a state pattern is mandatory. THANKS!