Average temperature across Sensors

I’ve got three sensors I want to take an average temperature of at that point (so their current readings). To give me a “house average” point, so I can then work with it.

I’ve made a new group for them (a subset of the main temperatures group). Now working on the average.

I assume I could just make a rule that iterates over that group, counts the number of items, adds them together and divide by the number and push it into a new item.

I guess I’m wondering if there’s a one line/item only way of doing it. Persistence is on at the higher temperature group (each reading goes into it’s own table).

Group:Number:AVG avgTemps

The state of avgTemps will be the average of all of its members.

Sorrry, what is that that you’ve posted.

Is that an item definition?
eg Number averagetemp “My Average %s” { Group:Number:AVG avgTemps }?
I’m not sure how ti incorporate that into the system.

That is a Group definition.

Add your temperature Items to this Group. Treat this Group as a Number Item in your Rules and your Sitemap.

http://docs.openhab.org/configuration/items.html#groups

Thanks, I had a quick google after posting and found something like that.

So unsure if this will be an issue or not.
I have groups

Group g_temperature
Group g_temperature_average “Average Temp” (g_temperature)

And items that are in g_temperature, and 3 that are in g_temperature and g_temperature_average.

That wont cause OH to get into some loop:

Number bm1_temperature “Andoni Bedroom Temperature [%.1f °C]” (g_temperature,g_bm,g_bm1,g_bm1_temperature , g_temperature_average) [“CurrentTemperature”] {mqtt=“<[frodo:e08586c94ef4/temperature:state:default]”}

So given the above group defintions and items my item should be:
Group:Number:AVG g_temperature_average "Average Temperature [%.1f °C]" <temperature> (g_temperature)

And if I want it in the sitemap, i use:
Text item=g_temperature_average
For example?

And lastly (will stop bothering you now :D)

To persist that average temperature (not the group) when I already have:

g_temperature*  : strategy = everyChange, restoreOnStartup

for the individual readings.

Would that group item already be persisted?

It won’t be an issue.

Looks good to me. Sitemap entry looks right as well.

Unfortunately not (discovered this myself just the other day). You need to add g_temperature_average (without the *) separately.

g_temperature*, g_temparature_average  : strategy = everyChange, restoreOnStartup

You may need to restart OH after making all of these changes for everything to work as it should. There is some weird behavior with Groups in OH right now.

thanks for all your help.

I had a play and did is as rule as well, just to further rule coding.

For persistance strategies, this would be valid in cron, but seems to get an error in openhab:
every15Mins : "*/15 * * * * ?"
is the / not allowed? Seems to complain of a mismatched delimiter

I’ve not used cron expressions in .presist files. None of the examples use the slash notation.

But “0,15,30,45 * * * * ?” should give you every 15 seconds.

with Group:Number:AVG avgTemps it works but with:

Group:Number:AVG avgHumidity “Umidita’ media [%.1f%]” (avghumidity)

and the related items, report error