Calculate avarage and send it to influxdb as series/item value

Dear All!

I have some temperature sensors. I would like to calculate avarage value from these.
Openhab2 > influxdb > grafana.
Grafana cant calclate avg from different measurements, so I thought that i create a virtual item (avgTemp), and send it to grafana as a series (as normal Item value).
Is this possible?
Or do you have other suggestions for this problem?

Best regards,
Tamas Kiss

Grafana can’t but influxdb can. See the influx docs on how to build a query that you can then put into grafana for plotting.

openHAB won’t send values directly to the database. You’ll have to add a proxy (=virtual) item for averages. Then update them in a rule everytime one of the real items changes - and add the proxy item to your persistence.

Basically the scenario you described a bit more explained.

Create a Group using the AVG aggregation function and make sure to add that Group Item to your persistence. Add each of your sensors to the Group. Here are my average indoor temps Items and persistence.

Group:Number:AVG gIndoorTemps "Average Indoor Temp [%.0f °F]" <temperature>

Number vNest_Temp "Main Floor Ambient Temp [%d °F]"
    <temperature> (gChart, gIndoorTemps)
    { nest="<[thermostats(Entryway).ambient_temperature_f]" }
// gChart causes this Item to be persisted

Number vMBR_Temperature  "Master Bedroom Temperature [%.0f °F]"
    <temperature> (gChart, gIndoorTemps, gResetExpire)
    {mqtt="<[mosquitto:rfm69/uber_sensors/mbr/temperature:state:default]", expire="5m,state=NULL" }

Strategies {
  default = everyChange
Items {
        gChart*,gIndoorTemps,gIndoorHumidity,vIsCloudy : strategy = everyUpdate
        gHistory: strategy = everyUpdate

better yet! you won’t need that rule anymore! Groups bring that ootb! great! (classic Rich!)

1 Like

Hi guys!

Thank you!
I will try to do this with GROUP!

Best regards,
Tamas Kiss