Persistence restore wrong value

Hello,

installed is the OH 2.4.0.1, and the Persistence rrd4j. Also in the configuration system is set the rr4jd.

The rrd4j.persist is coded as follows:

Strategies{
 
    default = everyChange
}

Items{
    Wohnzimmer_Kamin_Betriebsstundenzaehler : strategy = everyUpdate, everyMinute, restoreOnStartup
}

My Item is:
Number Wohnzimmer_Kamin_Betriebsstundenzaehler “Betriebsstunden: [%d]”

There is a rule wich is counting the Item every hour, which is shown on sitemap very well.

After restart of the system i expected the same value again, but the values are wrong.
Shortly after the restart I get the following log message:
2019-12-12 11:19:41.360 [vent.ItemStateChangedEvent] - Wohnzimmer_Kamin_Betriebsstundenzaehler changed from NULL to 26100.0

Which is not my expected value. I expected in this case a number of 30.

How can is solve this.what I am duing wrong?

Thank you very much
Holgus

The rrd4j persistence MUST use the everyMinute strategiy
You have not defined it in the header of the file

See:

Your file:

Strategies{
    // for rrd charts, we need a cron strategy
    everyMinute : "0 * * * * ?" 
    default = everyChange
}

Items{
    Wohnzimmer_Kamin_Betriebsstundenzaehler : strategy = everyUpdate, everyMinute, restoreOnStartup
}

Thank you very much for the fast response.
I changed the rrd4j.persist to:

Strategies {
    // for rrd charts, we need a cron strategy
    everyMinute : "0 * * * * ?" 
    default = everyChange
}

Items {
    Wohnzimmer_Kamin_Betriebsstundenzaehler : strategy = everyUpdate, everyMinute, restoreOnStartup
}

But I have the same behaviour. The sitemap shows me 316800.0 in the Item.

I wrote a fix value (88) in the Item:
2019-12-12 13:53:53.527 [vent.ItemStateChangedEvent] - Wohnzimmer_Kamin_Betriebsstundenzaehler changed from 316800.0 to 88

After the restart I got this in the value:
2019-12-12 14:06:30.298 [vent.ItemStateChangedEvent] - Wohnzimmer_Kamin_Betriebsstundenzaehler changed from NULL to 316800.0

do you have another persistence service active with restoreonstartup?

No, only this the rrd4j.

You’ve restarted since changing your persist - so now the new settings are in effect to store data. Try again?

1 Like

Ah yes the good old restart after persist changes…

Before restart I set the item to 0.0.

Then I reboot the system (sudo reboot).
in the log I found:
2019-12-12 14:55:54.665 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model ‘rrd4j.persist’
2019-12-12 14:57:26.623 [vent.ItemStateChangedEvent] - Wohnzimmer_Kamin_Betriebsstundenzaehler changed from NULL to 9000.0

If you set a value and do a restart afterwards, you have to leave the system running long enough to let it persist the new value!
Did you check using the REST API which values are in the archive 1 of rrd4j?

I wait more then 5 Minutes between setting the value und reboot. I expect due to the “every Minute” strategy that I have only to wait this Minute or?
Sorry, the REST API I did not understand. How can I check the values in the archive of rrd4j?
Do I have to install a database under Linux or is that done with installing Persistent rr4j under OH?

REST API is an addon for openHAB, you can install it (if it isn’t already on your dashboard) by installing it under Addons - Misc -REST Documentation.
Having it go to Persistence and select the third blue GET ( persistence/items/{itemname}
On the following page fill in serviceID “rrd4j”, your item name AND a start time only one or two hours in the past (using the default would give you compressed data!). The most recent data will be shown at the end.
Note that a time in Z ( i.e. UTC) has to be given!

I started the GET on the Item Wohnzimmer_Kamin_Betriebsstundenzaehler. The output from the Response Body was as following:

{
  "name": "Wohnzimmer_Kamin_Betriebsstundenzaehler",
  "datapoints": "24",
  "data": [
    {
      "time": 1576252800000,
      "state": "5123978867990420"
    },
    {
      "time": 1576256400000,
      "state": "1.0"
    },
    {
      "time": 1576260000000,
      "state": "1.0"
    },
    {
      "time": 1576263600000,
      "state": "1.0"
    },
    {
      "time": 1576267200000,
      "state": "1.0"
    },
    {
      "time": 1576270800000,
      "state": "0.75"
    },
    {
      "time": 1576274400000,
      "state": "1.0"
    },
    {
      "time": 1576278000000,
      "state": "1.25"
    },
    {
      "time": 1576281600000,
      "state": "0.75"
    },
    {
      "time": 1576285200000,
      "state": "1.25"
    },
    {
      "time": 1576288800000,
      "state": "1.0"
    },
    {
      "time": 1576292400000,
      "state": "1.0"
    },
    {
      "time": 1576296000000,
      "state": "0.25"
    },
    {
      "time": 1576299600000,
      "state": "0.0"
    },
    {
      "time": 1576303200000,
      "state": "0.0"
    },
    {
      "time": 1576306800000,
      "state": "0.0"
    },
    {
      "time": 1576310400000,
      "state": "0.5"
    },
    {
      "time": 1576314000000,
      "state": "1.0"
    },
    {
      "time": 1576317600000,
      "state": "1.0"
    },
    {
      "time": 1576321200000,
      "state": "0.75"
    },
    {
      "time": 1576324800000,
      "state": "1.0"
    },
    {
      "time": 1576328400000,
      "state": "1.25"
    },
    {
      "time": 1576332000000,
      "state": "1.0"
    },
    {
      "time": 1576335600000,
      "state": "1196403.783611111"
    }
  ]
}

If I understand this correctly there are some correct values in the Item but after reboot there are broken values in the Item.
Is my interpretation correct?
How can I solve this, so that the correct vales are restored after the reboot?
However the counter works fine. Only the restore failed

You need to find out how and where these values are coming from
openHAB is only storing and restoring what it is given.

@vzorglub is correct!
Please note, assuming you are using the default setup of rrd4j, you were asking rrd4j for values older then a week! For that reason you get values only for every hour ( timedifference between readings is 3600000!)
It might be easier to find the cause when looking at the archive 1 which holds the data points by minute. Since this archive covers only 8 hours, the request has to be limited for that timeframe or even less!

here my request from today:
http://192.168.2.36:8080/rest/persistence/items/Wohnzimmer_Kamin_Betriebsstundenzaehler?serviceId=rrd4j&starttime=2019-12-14

{
  "name": "Wohnzimmer_Kamin_Betriebsstundenzaehler",
  "datapoints": "18",
  "data": [
    {
      "time": 1576278000000,
      "state": "1.25"
    },
    {
      "time": 1576281600000,
      "state": "0.75"
    },
    {
      "time": 1576285200000,
      "state": "1.25"
    },
    {
      "time": 1576288800000,
      "state": "1.0"
    },
    {
      "time": 1576292400000,
      "state": "1.0"
    },
    {
      "time": 1576296000000,
      "state": "0.25"
    },
    {
      "time": 1576299600000,
      "state": "0.0"
    },
    {
      "time": 1576303200000,
      "state": "0.0"
    },
    {
      "time": 1576306800000,
      "state": "0.0"
    },
    {
      "time": 1576310400000,
      "state": "0.5"
    },
    {
      "time": 1576314000000,
      "state": "1.0"
    },
    {
      "time": 1576317600000,
      "state": "1.0"
    },
    {
      "time": 1576321200000,
      "state": "0.75"
    },
    {
      "time": 1576324800000,
      "state": "1.0"
    },
    {
      "time": 1576328400000,
      "state": "1.25"
    },
    {
      "time": 1576332000000,
      "state": "1.0"
    },
    {
      "time": 1576335600000,
      "state": "1196403.783611111"
    },
    {
      "time": 1576339200000,
      "state": "209951999996624.7"
    }
  ]
}

This should be in Minutes … how can I read the “time” row?
However, sometimes with real values (every 15 minutes I incremented) and sometimes i make a reset on the Item (0.0).
Other questions:
Is there something what I have to configure in the rrd4j.cfg?
I read in the REST API that the Item is from data type string, but the Item is defined as a Number. Can this cause the failure?

example 1576278000000 Friday, December 13, 2019 11:00:00 PM (in GMT, you may need to correct for your timezone)

Those values are for every hour since start of day.
Your request was for starttime [2019-12-14] with no time, which makes it 00:00.
Using no endtime defaults to now, to me it looks like you are using a non default setup for rrd4j. Such a request using the default setting should give values every 4 minutes (that would be a time-difference of 240000 between the values).
What is the content of your file rrd4j.cfg?

No, that is the normal output.

Thanks a lot for all the answers, the REST API time things I am planning to check ASAP, but I need time to read and understand about that.
My rrd4j.cfg file has the following state:

# configure specific rrd properties for given items in this file.
# please refer to the documentation available at
# https://www.openhab.org/addons/persistence/rrd4j/
#
# default_numeric and default_other are internally defined defnames and are used as
# defaults when no other defname applies

#<defname>.def=[ABSOLUTE|COUNTER|DERIVE|GAUGE],<heartbeat>,[<min>|U],[<max>|U],<step>
#<defname>.archives=[AVERAGE|MIN|MAX|LAST|FIRST|TOTAL],<xff>,<steps>,<rows>
#<defname>.items=<comma separated list of items for this defname> 
#<defname>.items=Wohnzimmer_Kamin_Betriebsstundenzaehler

The last row was a test but this does not solve the issue.

So you are using the default settings of rrd4j, however the timedifference seen in your request does not match.