RestoreOnStartup when updating items file

Is it possible to restore the values after changing something to a items file?
When I add a new or change an item in one of my .items file, all values are gone. Some of my rules don’t like this :slight_smile:
I know I can manually add some lines to the rules to grab the values, but maybe there are other possibilities?

http://docs.openhab.org/configuration/persistence.html

Works for both OH startup and reload of .items files.

  • restoreOnStartup: load and initialize the last persisted state of the Item on openHAB startup (if the Item state is undefined (UNDEF)).

Nothing is mentioned about reload of .items files… or do I miss something?

I also noticed that items with values ON or OFF are not restored.

maybe good to know: I use JDBC with Mariadb

Depending on the database Switch Items should also be restored. I have no experience with JDBC. I use MapDB for restoreOnStartup.

I was also thinking to use mapdb. Do you only add restoreOnStartup as strategy? And mapdb needs to be configured as default persistence, right?

Half right. I use restoreOnStartup for the strategy on *. MapDB does not need to be the default persistence.

See

Thanks, I’ll check this.

It seems t be working, but since I installed mapdb, my graphs are ony displaying a flat line. I checked my jdbc persistence (mariadb), and there are still new entries logged every 5 minutes.
But it looks like the charts are taking the mapdb data… I only removed the restoreOnStartup strategy for my jdbc persistence

 Text label="Graph" icon="line" {
 				Switch item=General_ChartPeriod label="Choose time period" mappings=[0="Hour", 1="Day", 2="Week", 3="Month", 4="Year"]
 				Chart item=Grp_Xiaomi_Temp_0 period=h refresh=600 visibility=[General_ChartPeriod==0]
 				Chart item=Grp_Xiaomi_Temp_0 period=D refresh=900 visibility=[General_ChartPeriod==1, General_ChartPeriod=="NULL"]
 				Chart item=Grp_Xiaomi_Temp_0 period=W refresh=3600 visibility=[General_ChartPeriod==2]
 				Chart item=Grp_Xiaomi_Temp_0 period=M refresh=3600 visibility=[General_ChartPeriod==3]
 				Chart item=Grp_Xiaomi_Temp_0 period=Y refresh=3600 visibility=[General_ChartPeriod==4]
 
 				Chart item=Grp_Xiaomi_Hum_0 period=h refresh=600 visibility=[General_ChartPeriod==0]
 				Chart item=Grp_Xiaomi_Hum_0 period=D refresh=900 visibility=[General_ChartPeriod==1, General_ChartPeriod=="NULL"]
 				Chart item=Grp_Xiaomi_Hum_0 period=W refresh=3600 visibility=[General_ChartPeriod==2]
 				Chart item=Grp_Xiaomi_Hum_0 period=M refresh=3600 visibility=[General_ChartPeriod==3]
 				Chart item=Grp_Xiaomi_Hum_0 period=Y refresh=3600 visibility=[General_ChartPeriod==4]
 			}

What is your default persistence? It sounds like it is trying to chart from MapDB which only keeps the most recent value so a flat line would be the result.

Make sure that jdbc is set as your default or add service="jdbc" to your Charts

Chart item=Grp_Xiaomi_Temp_0 period=h refresh=600 service="jdbc" visibility=[General_ChartPeriod==0]

By adding service="jdbc" to the chart item, the issue is solved.
jdbc is set as default in conf/services/runtime.cfg & in the paper UI. I already restarted OpenHAB
################ PERSISTENCE ####################

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

image