Persistence query and filter

Platform information: RPi4
openHAB version: 3

Hello!
The persistence is up and runing. All values are requestable.
However, I would like to request the rain counter - wtih the persistence strategy every change - as follows:

  • total rain within a sertain period
  • last rain was at day x

The rain counter get a null value each day at 7 am.
The pesistence formula

PersistenceExtensions.sumSince(itemRegistry.getItem("RegenHeute"), ZonedDateTime.now().minusDays(7));

get a value back but this is a sum of all changes and not a valid value. What I need is to sum up the max value of each day in combination of a start date and end date.

Can sombody help me please how to do that?

Thank you!

The Persistence API is very basic. All it provides is the ability to sum up all the entries between now and the passed in date time. That’s it.

If you want anything different you’ll have some choices:

  1. create another Item that only persists those values you want to sum up
  2. use the OH REST API to query for all the values and figure out which ones to sum up yourself in a rule.

Persistence functions between two points in time will be available when Extend PersistenceExtensions with "between" methods by J-N-K · Pull Request #2931 · openhab/openhab-core · GitHub is merged.

That would solve part of the problem but OP wants to be able to “sum only the maximum value of a the day for days between two dates”.

1 Like

Thank you very much for the hint. Best regards!