Get maximum value for every of the last 5 days

Hello community,

I’ve placed a sensor in my garden and integrated it into OH. By now, these values are persisted to an InfluxDB on every change.

Currently I’m working on a python rule in which I want to process the highest measured outdoor temperature per day. But I could not find a way yet, to achieve this with a single command like maximumSince().

Alternative solutions that already came to my mind:

  • Calculate the maximum at midnight and persist that value, too
  • Build a InfluxDB query dynamically and use the REST API
  • Use my Node-RED instance to build a simple API just to get the values out of InfluxDB

Is there something I missed?

The docs explain how one can find the maximum value over a given period, e.g. 5 days (=1 value). But how to get the maximum value of each single one of the last 5 days (5 values)?

My goal is to calculate the average of the maxima.

You can’t do that in rules using the Persistence actions directly. You can only get the maximum from now. You will have to do one of the following:

  • keep track of the maximums yourself using rules to update and rotate the maximums at midnight
  • figure out how to query the database yourself (which should be easier to do in Jython rules as you can install the database’s driver library)
  • query the openHAB REST API for all the entries, parse the JSON and sort through them yourself.