How to show the average of all values in the same group

(Cj Cassarino) #1

Hi everyone,

I am looking for a way to show on my sitemap the average value for ,lets say, my temperature sensors. I have all my sensors under the same group “temperature” so I kinda thought that this would work:

Group:Number:AVG Temperature "Avg. Room Temperature [%.1f °C]" <temperature> (Status)

However it doesn’t show anything.

Anyone know what I need to do?

Variable Maths
(Thomas Bail) #2

There should be a function to calculate the average on Groups. See the wiki. And then persist the group and thats it.


(Cj Cassarino) #3

Ive been looking. and I can’t find anything, or I just don’t understand enough to notice it. The only thing I can find is what I posted, and it doesn’t work plus im not sure if I understand it correctly. If someone could interpret what I have to see if that is even correct or the right path that would be great, or if you know where in the wiki I can look specifically, I can re-read, but I have been searching and can’t find anything.

(Thomas Bail) #4

Here ist the links to the Wiki. Just check the table under groups keyword is avg. Hope this brings you a little bit forward.

Wiki Link


(Andreas) #5

In this case the Group “Temperature” will show the average of all Items within the group (Temperature). Does work definitely that way!

Number Item1 … (Temperature) = value 2
Number Item2 … (Temperature) = value 4
Number Item3 … (Temperature) = value 6

Group:Number:AVG Temperature … value would be = 4

(Cj Cassarino) #6

So whatever is in parentheses is where it looks for the values? So maybe it doesn’t show because I have it named the same?

(Cj Cassarino) #7

So it still isn’t working. But just to be clear:

Group:Number:AVG **Temperature** "Avg. Room Temperature [%.1f °C]" <temperature> (Status)

The Temperature is the group that it averages the values for, and in the parenthesis is what? I have tried different variations and none of them give me a value.

(David Luther) #8

make sure you don’t have Temperature group defined somewhere else in your items files if there is two it will not work.

// Group Temprature (All) <---Must be dissabled

Group:Number:AVG 				Temperature	"Avg. Indoor Temperature [%.1f °F]" 	<temperature>	(Status)

(Cj Cassarino) #9

Haha, I literally just thought of that and did that as I looked at your reply. Works now, thank you so much.

(Julian) #10

Hi there,

I´m afraid I´m being dense atm, but I don´t get it …

You said, i hope I´m putting it right, that in the items configuration should be this

Group:Number:AVG Temperature “Avg. Room Temperature [%.1f °C]” (Status)
The “(Status)” the end means, that this group is a member of group “Status”, right ?

My temp-sensor items are configured like this
Number itmTempEGWZ “Temperature [%.1f °C]” (Temperature) { knx=“4/0/6+<4/7/1” }

and in sitemap (basicui for me) this:

Text item=Temperature
Text item=itmTempEGWZ

The items, that are supposed to show me single room temps are working correctly, but the average doesn´t work :frowning:

Thanks guys and greetings,


(Cj Cassarino) #11

So the (Status) in my case sets this Item for the average to a group called status. I used this to track all my averages in a single group that I could call anywhere in my sitemap.

So for your item EGWX you have it set to a group called Temperature, this is the same as mine. So if you copied my example it should be averaging all values in the temperature group to a number and assigning that to a group called status.

MAKE SURE YOU DO NOT HAVE TEMPERATURE BEING DEFINED AS A GROUP ANYWHERE ELSE. See what LexLuther has shown as he commented out the Group Temperature (ALL)

And then I think you show the average value in your site map by doing Group item=Temperature.

Edit: Forgive me a little, as I haven’t really touched OpenHAB since last June after I graduated. I have been meaning to copy over what I had developed for my own personal use by I haven’t had the time or money to gather the resources I had while I as in school. I do have all my items/sitemaps files and such if maybe that would help you?

(Julian) #12

Hey @CJ_Cassarino … many thanks for your quick answer. As I´m in work at the moment i can´t test your suggestions now, but I will do that tonight.

I´d appreciate your items and sitemap files, if they don´t have any secret infos in it :slight_smile:

(Julian) #13

Ok, now … full example ,… I don´t get it :frowning:

Group:Number:AVG Temperature	"Avg. Indoor Temperature [%.1f °C]" 	<temperature>	(Status)

Number    temperature_erdgeschossbuerobuero  "Temperature [%.1f °C]" <temperature> (TEMPERATURE) { knx="4/1/2+<4/1/8" }
Number    temperature_erdgeschosskuechekueche  "Temperature [%.1f °C]" <temperature> (TEMPERATURE) { knx="4/1/0+<4/1/6" }
Number    temperature_erdgeschosswohnzimmerwohnzimmer  "Temperature [%.1f °C]" <temperature> (TEMPERATURE) { knx="4/1/1+<4/1/7" }
Number    temperature_erdgeschossflurflur  "Temperature [%.1f °C]" <temperature> (TEMPERATURE) { knx="4/1/4+<4/1/9" } 


Text item=Temperature label="Durchschnitt Erdgeschoss"

Text shows “- °C” … but nothing else…
I waited a frew minutes, but nothing :frowning:

(Julian) #15

Hast du jetzt einen Fehler drin oder bin ich bl…

Die Gruppe heisst doch jetzt “Temperatur” und in den Items verweist du in den “()” auf “Temperature”…

Und am Schluss das “(Status)” hat hier keinen Effekt, oder ?

(Julian) #17

Hmmm…somewhere I have another problem, then…
It doesn´t work the way it should …
I made it exactly the way you guys described…

I have some errors showing up in my logs, but they doesn´t hint at a problem with this group.

The single room temp items also work properly (showing the same temperatures as the sensor display does)

Still a long way to go for me here :slight_smile:

It seems I didn´t even scratch the surface of OH2, yet :slight_smile:

Vice versa … it scratched me :slight_smile:

(Martin Tamke) #19

Did you find out in the meantime?
You wrote the group in capital letters. Oh2 is case sensitive- so always write items and groups in a consistent way

(Martin Tamke) #20

One more remark for all, who are trying the group function and stumble on this discussion:
The functions do not work with nested groups.
One has to declare the membership of each item one wants to include in the group the function should operate on.
(Lazy thinking and declaring a group to be part of the group where the function should work on doesn’t work… :frowning: )

(Cj Cassarino) #21

Hey sorry I never responded to you. This was for a project I completed way back when and I just stumbled across this due to mdnx comment below.

I tried to go back to my code and to look at what you had but I can’t figure out why it wouldn’t work the same. That being said I haven’t used Openhab in over a year now. Sorry bud.

(The BOFH) #22

How would one go about getting AVG as an integer?

I have

Group:Dimmer:AVG gLights_GF_clr “All ground floor colourtemps” (gLights_ALL_clr)

but in a rule,

clrLevel=gLights_GF_clr.state as DecimalType

shows as a float which seems to cause a lot of java backtraces in the logs

(Vincent Regaud) #23

Please open a new topic
See: How to ask a good question

Publish your items and rule and log errors. Thanks