Hello
At midnight I calculate an average temperature coming from a persistence rrd4j and I record it in an influxdb presitence. The problem is that the date of the recording is the day of the calculations of the average. I would like the date to be the 1 day before. Is it possible ? How to do ?
rule "Daily temp average"
when
Time cron "0 0 0 * * ?"
then
tempBedroomAvg.postUpdate(tempBedroom.averageSince(now.minusDays(1))) //tempBedroom persistence : rrd4j
tempBedroomAvg.persist("influxdb")//store with time "today at 00:00" I would like "yesterday at 00:00"
end
rule "Daily temp average"
when
Time cron "58 59 23 * * ?"
then
tempBedroomAvg.postUpdate(tempBedroom.averageSince(now.withTimeAtStartOfDay())) //tempBedroom persistence : rrd4j
tempBedroomAvg.persist("influxdb")//store with time "today at 00:00" I would like "yesterday at 00:00"
end
InfluxDB is a time point database, you canât insert values with arbitrary timestamps without manipulating the database calls in an SQL type query.
What you basically want to do is go back in time. InfluxDB doesnât like that. Itâs possible but not easy nor elegant.
Okay ! Thank you ! This is the first use of influxdb I did not know
is it possible with another type of persistence?
If so, what is the best persistence for this? MardiaDB/MySQL?
Again, openHAB will store the value with a time stamp of when the value was stored so you will need to use an custom SQL query.
I donât understand you issue very well though. The date is correct now. How can you calculate the average temperatures of a day without having the data. It needs to be done around midnight.
By persisting just before midnight you date is correct.
I want to calculate the average between 14 and 15h if I do the cron at 14h30 I do not know the temperature between 14h30 and 15h
it works with
sendHttpPostRequest (âhttp: // localhost: 8086 / write? db = openhabâ, ââ, âtempChMobHouryAvgH value =â + tempChMobHouryAvgP.state.toString + ââ + ((now.getMillis () - 30 * 60 * 1000) * 1000000) .toString) // store every hour with time HH-1: 29: 58
but I do not find very elegant.