Rrd4j persistence once a day issue

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.

Hi,
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?

thanks

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.

Alright, you’re trying to back-project your value n time. I really don’t think you’ll have much luck trying to do that in rrd4j.

openHAB persistence service is all about storing values represent “now”,not past or future events. There was a recent thread about posting updates using low-level API for arbitrary timestamps,might help you.

The much simpler alternative remains to use another db, and persist to it by rule at 23:59

Yes. Which db do you suggest? I am using a PI3 with 1GB of RAM.

Personally I don’t use any other than rrd4j and mapdb. Influxdb seems popular and flexible.

You allready know how to use xxx.persist files to select what to do when, don’t let default settings persist everything to every database or you’ll lose performance.

I did not read the whole chain (hopefully this is relevant :wink:) but I use mysql/maria/jdbc to store a daily KWH reading on a Pi3. Some pictures


jdbc

Sorry to spam the topic, but the pictures are easier than trying to explain. There are some “getting going” issues with mysql. I also have an Excel spreadsheet that pulls from the DB for further calculations.

Bob

1 Like

Actually, I am not trying to change the date of my data.
Infact I am collecting the value of the item at 23:57.
What I wanted to do was to store that single value in the db before midnight.
Apparently it’s not possible with rrd4j?

That’s easy, put your value in an Item that is not persisted at all automatically. Allow a 100mS or so for the Item to update properly, then call yourItem.persist from a rule that runs at 23:57.

I’m not sure that will give whatever end effect it is you are trying to achieve though. There may be only the one value recorded at the end of each day … but that means the value assumed for the rest of the day beforehand will be the previous day’s value, in charting etc.

1 Like

There is a difference between what openHAB is providing to be persisted by a persistence service and what the special persistence service is doing with those values.

openHAB uses either a strategy (like everyMinute etc…) to provide a state to be persisted . This provided value will only be changed at the selected events (a chang of state within a minute will not be provided unless an everyChange strategy is used). How often the provided value is actuaaly used (stored, sampled…) by the respective persistence service is up to this service.
rrd4j always takes samples in timesteps as configured or the service (sample rate). These timesteps are completly seperated from the openHAB strategies.

In other words the plan from @oppo1967p is not possible.