Rrd4j Persistence last value

I use rrd4j persistance. I want to save the value of the Number Item only when the value changes. In this case, the previous value is stored instead of the new value. Whats is wrong?

Strategies {
everyMinute : “0 * * * * ?”
}

Items {
* : strategy = everyChange
}

test.def=GAUGE,600,U,U,10
test.archives = LAST,0.5,1,360:LAST,0.5,6,10080:LAST,0.5,90,36500:LAST,0.5,360,43800:LAST,0.5,8640,3650
test.items = TestaNumurs

rrd4j doesn’t work like that. In order to maintain a fixed size, it has to periodically compress the data by replacing every N entries with the average of those entries as the data gets older. In order for that to work, rrd4j must save a value every minute given it’s default configuration in OH.

If you don’t use at least an everyMinute strategy with rrd4j, rrd4j breaks.

So your end goal is likely not going to work anyway.

This part probably has to do with the timing. Saving the state of an Item to the database takes some time. Consequently if you try to pull the lastState in a rule triggered by the Item changing, the old value will probably be returned because the new value hasn’t been saved yet. That’s why the implicit variables exist.

Thanks for the help.
Can this problem be solved using another service like mysql? Maybe have some suggestions?

Sure, only rrd4j has this once per minute requirement. However, it will still be the case that if you are in a rule and you immediately try to pull the previous state of the Item from persistence right after the Item changed the new value will likely not have been saved yet and you’ll get the old value.