MySQL periodic average

Hello Community,

Current behaviour

I ran into a Problem with my openHAB and MySQL. I have many Modbus Items some Switches, some Contacts and Text Items.
My Persist Strategy is basically to save all items every change and restore on start up.
This leads to a MySQL traffic of 100 MB per day. This is quite a lot and I would like to tune my Persistence Strategy.

Desired behaviour

I wish to tell openHAB / MySQL to collect data of a specific periodic time and calculate the average and put that calculated average into the MySQL Server.
This would minimize the data load for example my numerous Voltage(V) and Current(A) Modbus Items.

I hope some of you guys maybe got a nice starting point for my problem.

Thank you for reading this Topic

Well… to collect the data and then calculate the averages… you would need a persistence service.
OH2 (without persistence) doesn’t keep a history of the item states. And from what I know, you can’t put time rules in the everyChange strategy (e.g. collect for 1 hour all the changes, then stop collecting changes).
You could use only a cron scheduled strategy if you wanted.

You could try to store the numerical values in another persistence service (e.g. InfluxDB which is time series based) and then with a rule do what you want (calc avg and then post the result to MySQL persistence).

I am not a big fan of the above solution… I would have to think more about another recommendation here :slight_smile:

That’s enormous… so many changes are happening to your items’ states? wow…


389 Modbus Items :wink: ca 50% of them are Text items that measure something like Voltage, Lux etc. etc. etc.