Some items don't persist

Hello all, some items do not persist, I’m using mapdb & rrd4j, and mapdb is my default service
I update items from ui , but they are not persist.
And I turned Logging for persistance I’m getting this error

2020-09-20 18:46:22.057 [ERROR] [sistence.rrd4j.internal.RRD4jService] - Could not create rrd4j database file '/var/lib/openhab2/persistence/rrd4j/Relay02.rrd': Read failed, file /var/lib/openhab2/persistence/rrd4j/Relay02.rrd not mapped for I/O

here is my configurations:

rrd4j.persist

Strategies {
    // for rrd charts, we need a cron strategy
    everyMinute : "0 * * * * ?"
    everyHour   : "0 0 * ? * *"
    everyDay    : "0 0 0 * * ?"     // Every day at midnight - 12am
    default = everyChange
}

Items {
    Control* : strategy = everyUpdate, everyMinute
}

mapdb.persist

Strategies {
    default = everyChange
}

Items {
    // persist Control items on every change
    Control*,  ControlPeriod, Sensors* : strategy = everyUpdate, restoreOnStartup
}

runtime.cfg

################ PERSISTENCE ####################

#  The persistence service to use if no other is specified.
#
org.eclipse.smarthome.persistence:default=mapdb

items
Only Relay01, Relay02 are persist

Group Control               "Control"                    <switch>

Switch Relay01          "Relay01"           <switch>          (Control)               ["Relay"]       {gpio="pin:2"}
Switch Relay02          "Relay02"           <switch>          (Control)               ["Relay"]       {gpio="pin:3"}
Switch Relay03          "Relay03"           <switch>          (Control)               ["Relay"]       {gpio="pin:17"}
Switch Relay04          "Relay04"           <switch>          (Control)               ["Relay"]       {gpio="pin:4"}
Switch Relay05          "Relay05"           <switch>          (Control)               ["Relay"]       {gpio="pin:27"}

Persistence REST API

http://openhabip:8080/rest/persistence/items/Relay02?serviceId=rrd4j
{
"name": "Relay02",
"datapoints": "0",
"data": []
}

---------------------------
http://openhabip:8080/rest/persistence/items/Relay01?serviceId=rrd4j
{
"name": "Relay01",
"datapoints": "1101",
"data": [
{
"time": 1600561380000,
"state": "ON"
},
{
"time": 1600561440000,
"state": "ON"
},
{
"time": 1600561440000,
"state": "ON"
},
{
"time": 1600561500000,
"state": "ON"
},.............................

I wonder if the rrd file(s) for the wonky item(s) got messed up when you had other persistence settings.
I believe if you stop openHAB, delete the suspect rrd files, and restart, they should get recreated cleanly.

2 Likes

Hello again @rossko57 my savior ,

I wonder if the rrd file(s) for the wonky item(s) got messed up when you had other persistence settings.

yup , I guess so, I was messing up with persistence till you guided me to a better approach

I believe if you stop openHAB, delete the suspect rrd files, and restart, they should get recreated cleanly.

How can I do that ? :sweat_smile:

The error message tells where your rrd files are located, go there and delete them after you stopped openhab, restart afterwards.

You are using rrd4j on a switch item although this database is for numeric values only!

2 Likes

is this command will work for stopping openhab ?

sudo systemctl stop openhab2

:+1:

1 Like