Blockly or script - how to get sum of item since now to date

If you are using rrd4j it’s going to add an entry periodically whether the Item changes or is updated or not.

If you are not using rrd4j, the .persist file is probably telling OH to save the value every hour as it’s strategy.

I use JDBC as primary persistence and save the values every hour.

Well, if you don’t want that for these Items you need to change the strategy so it doesn’t save every hour.

I want to save it every hour.
But there is something wrong…

For example:
This are the right values:
18.03.2022 11:00 +200
18.03.2022 12:00 -500
18.03.2022 13:00 -450
18.03.2022 14:00 +500
18.03.2022 15:00 -300

The negative item shows:
18.03.2022 12:00 -500
18.03.2022 13:00 -450
18.03.2022 14:00 -450 instead of “0”
18.03.2022 15:00 -300

The positive item shows:
18.03.2022 11:00 +200
18.03.2022 12:00 +200 instead of “0”
18.03.2022 13:00 +200 instead of “0”
18.03.2022 14:00 +500
18.03.2022 15:00 +500 instead of “0”

There is nothing wrong. OH is operating as designed and documented.

You cannot have it both ways. If you want to save it every hour then you will have an entry every hour. That entry will always be the Item’s current state. OH always saves the Item’s current state. It doesn’t care if the Item hasn’t changed state in the last hour or not.

You really don’t need those zero entries at all. So change the strategy on these two Items to only save on Item updates instead of every hour.

1 Like

This can be the solution :slight_smile:
I check this out and give a feedback !

Thank you all!
I have found the SOLUTION.
It is a little complicate to write, but now I can calculate the energy balanced :slight_smile:
I compared it with the network supplier, there are only +/- 0,1-0,2KWh per day difference.