Rrd4j persistence once a day issue

I am having an issue with rrd4j persistence.
It works for most of the items but for 4 specific items it doesn’t work and I cannot see the values in a chart.


Strategies {
    everyMinute    : "0 * * * * ?"
    everyHour      : "0 0 * * * ?"
    everyDay       : "0 0 0 * * ?"
    everyEndDay    : "0 59 23 * * ?"
    everyBeginDay  : "10 0 0 * * ?"

    // if no strategy is specified for an item entry below, the default list will be used
    default = everyChange

Items {
    gPersistRRDMinute* : strategy = everyMinute, restoreOnStartup
    gPersistRRDHourly* : strategy = everyHour
    gPersistRRDDaily* : strategy = everyDay, restoreOnStartup
    gPersistRRDEndDaily* : strategy = everyEndDay, restoreOnStartup
    gPersistRRDBeginDaily* : strategy = everyBeginDay, restoreOnStartup
    gPersistRRDChange*  : strategy = everyChange, restoreOnStartup
    gPersistRRDUpdate*  : strategy = everyUpdate, restoreOnStartup


Group   gPersistRRDMinute
Group   gPersistRRDHour
Group   gPersistRRDEndDaily
Group   gPersistRRDBeginDaily
Group   gPersistRRDDaily
Group   gPersistRRDUpdate
Group   gPersistRRDChange

Number nDaily_energy_to_grid_yesterday   "Daily energy to grid yesterday [%.2f kWh]"    (gPersistRRDEndDaily,gSolar)
Number nDaily_energy_from_grid_yesterday "Daily energy from grid yesterday [%.2f kWh]"  (gPersistRRDEndDaily,gSolar)
Number nMeter_energy_to_grid_yesterday   "Meter energy to grid yesterday [%.2f kWh]"    (gPersistRRDEndDaily,gSolar)
Number nMeter_energy_from_grid_yesterday "Meter energy from grid yesterday [%.2f kWh]"  (gPersistRRDEndDaily,gSolar)

I can see the current values in my sitemap, but the values are not persisted.
No errors in the log regarding these items, nor for the rrd4j service.

Any idea?


Which openHAB version are you running?

Did you check for persisted values using the API-Explorer? If you did please state the timeframe you used.

Note that rrd4j is a special database which used to need an “everyminute” strategy ( before openHAB 3). I am not sure if the created daily strategies would work in openHAB 3.
In order to persist daily values I use a proxy item that is set via a (cron) rule once a day (or at whichever needed timestep).

Here is the sitemap:

Text label="Charts" {
  Chart item=nDaily_energy_from_grid_yesterday label="From Grid - 2W" service="rrd4j" period=2W refresh=60000 legend=true			
  Chart item=nDaily_energy_to_grid_yesterday   label="To Grid - 2W"   service="rrd4j" period=2W refresh=60000 legend=true			

And here the current value:

And the chart:

Those screeshots just tell that you are using openHAB 3.
Do any other items which are using a “daily…” strategy show persisted values?

No. All items with daily strategy do not show persisted values.
Items with a minute strategy work fine and charts are displayed.

Here the reply from API-explorer:

  "name": "nDaily_energy_to_grid_yesterday",
  "datapoints": "0",
  "data": []

This requst uses the default timframe ( the last 24 houres). Did the persistence run for more then 24 houres?

Yes. It has been running for a week.

In this case it seems that rrd4j is still in need of a strategy with smaller timesteps.
I am using my setup as with openHAB 2 ( customized archive setup AND (proxy) items that are set only once in the persisted timestep (like daily).
How often are your items with the daily strategy updated? If they are updated only once you could use the everyMinute strategy.

The items are updated only once a day. It’s actually a counter that counts the accumulated daily energy that resets to zero at midnight.

How can I use the everyMinute strategy?
Or how did you implemeted the proxy?


If your item is update once a day only once it would not harm to persist this value more often. Hence the use of the standard settings would work.

Not exactly:
This counter grows during the day and I am interested only in the value at the end of the day. And needs to be associated to the day it refers to.
So I can’t take intermediate values.

You probably really don’t want to use rrd4j at all then, with its averaging effects.

But if you must, you can create an Item and a rule that updates it only at 00:01 or similar. Then it doesn’t matter if the Item is persisted regularly in the standard rrd4j config (and averaging effects will be pretty minimal until to get to decades, I think)

Those two statements don’t fit together.

yes sorry, I understand the confusion in my statements…
What I mean is that the daily item value grow during the day and I want to store it in a new item only at the end of the day and soon after reset to zero the daily item.

That’s what I do.
At midnight I read the value of the daily countern and store it in the “yesterday” counter. One update every day.
But it doesn’t work.

You have to clear about what doesn’t work.
Does your Item hold your desired value until the next midnight?
If so, you can put in on a standard persistence strategy of e.g. everyMinute.

What doesn’t work is that it does not store the value inside the rrd4j persistence.

Yes, the item holds the desired value until the next midnight.
I thought about it, but I cannot use everyMinute until the next midnight otherwise I will get the counter with the value on the wrong date.

In other words, I want this:
Daily counters of imported/exported energy (kWh) = starts from 0 and grows from 0:00 to 23:57
At 23:57 I store (update the value) the daily counter values into hystorical Items (i.e. nDaily_energy_to_grid_yesterday).
What I haven’t been abe to do is to persist the hystorical Items associating them to the current day.
Then I reset the counters

I don’t really follow the objection here. Perhaps I wasn’t clear - create a new "dummy"Item and have a rule update at 00:01 or whatever.
If your Item is updated to NNN at 00:01, it stays at NNN all day, until next 00:01. It doesn’t matter if you record the new value at 00:01, or 00:05, or 08:00, or indeed every minute - that’s all the same value for that day.

If you want to record it just once, that is trivial (you can invoke persist in your midnight rule) but this is much easier to do in some other database.
rrd4j is based on preconfigured timeslots or pigeonholes, not arbitrary events. That’s great for e.g. sensor readings and plotting charts -but you’re fighting against its structure here.

It’s possible to define some special archiving strategy for select Items in rrd4j, maybe something something with one-day size pigeonholes would work. I don’t have the skills to do that, but it is likely tobe fiddly.

Me, I’d just make a dummy daily Item and let default settings handle it. Items are free.

1 Like

Hi @rossko57 ,
I did understood your suggestion, but doing the way you are suggesting will record the value on the wrong day:
If my counter reaches 10 at 23:57 today, I want to store number 10 for today’s date.
Using your approach, I would store value 10 every minute on tomorrow’s date.
So I wouldn’t get the match between the vallue and the date.