[SOLVED] OH2: persist group, rather then items

OH 2.4.0 on rPi3 Stretch, apt-get install

I think I shot myself in the foot.

I created a group gWeather
have a bunch of items associated to this group.

I added this group gWeather to gPersist_rrd4j in the hope that all weather items are being persisted.
But when I restart OH, these items are NULL, and because I check for them and if NULL set them to 0, I lose my previously persisted setting(s).

I am now wondering, whether the values where persisted in the first place, or whether I reset them, because persistence was not restored before I check and reset them.

I reckon it is the former, which causes endless trouble.

Is there a way to stop rule execution until items are loaded and values are restored?

  1. Did you already install the persistence service itself?
  2. You have to define all items to persist inside the file rrd4j.persist, not with a group gPersist_rrd4j.
  3. You have to persist the members of the group, not the group itself. :slight_smile:
    Use gWeather* instead of gWeather in the rrd4j.persist file.

Note that you have to specify if you want restoreOnStartup, it doesn’t happen automatically.

  1. yes
  2. ? really?
  3. yes…

And apologies for my crappy post…
Here what it looks like:

  gPersist_rrd4j*         : strategy = everyMinute, restoreOnStartup, everyChange


// ----- 190810 MaxG: created
// ----- AccuRite 5in1 outdoor weather station
Group    gAccuRite																		(gAll, gPersist_rrd4j)

// AccuRite Weather Charts
Group    gAccuRiteTemp_Chart
Number   gAccuRiteTemp_Chart_Period

Group    gAccuRiteHumi_Chart
Number   gAccuRiteHumi_Chart_Period

Group    gAccuRiteWind_Chart
Number   gAccuRiteWind_Chart_Period

Group    gAccuRiteRain_Chart
Number   gAccuRiteRain_Chart_Period

// data received
String   ar_DataReceived		"AccuRite data"														{mqtt="<[mymosquitto:ArgyleCourt/Property/AcuRite5in1:state:default]"}
DateTime ar_LastUpdated			"AccuRite: Last update [%1$td/%1$tm %1$tH:%1$tM]"	<calendar>		(gAccuRite, gLUP)

// data being extracted
Number   ar_Temperature			"Outdoor temperature [%.1f °C]"						<temperature>	(gAccuRite, gAccuRiteTemp_Chart, gSensors_Temperature)
Number   ar_Humidity				"Outdoor Humidity [%.0f %%]"							<temperature>	(gAccuRite, gAccuRiteHumi_Chart)
Number   ar_WindSpeed				"Wind speed at present [%.0f km/h]"	    	<wind>				(gAccuRite, gAccuRiteWind_Chart)
Number   ar_WindDir		    	"Wind direction [%.0f°]"			    				<wind>				(gAccuRite)
String   ar_WindDirText	    "Wind direction [SCALE(wind_direction.scale):%s]" <wind>	(gAccuRite)
String   ar_Battery		    	"AccuRite Battery [%s]"		    						<battery4>		(gAccuRite)
Number   ar_RainTotal				"Rain Total [%.0f mm]"										<clouds_rain>	(gAccuRite)

// data being derived / calculated
Number   ar_TemperatureMin	"Outdoor temperature minimum [%.1f °C]"		<temperature>	(gAccuRite, gAccuRiteTemp_Chart)
Number   ar_TemperatureMax	"Outdoor temperature maximum [%.1f °C]"		<temperature>	(gAccuRite, gAccuRiteTemp_Chart)
Number   ar_HumidityMin			"Outdoor humidity minimum [%.0f %%]"			<temperature>	(gAccuRite, gAccuRiteHumi_Chart)
Number   ar_HumidityMax			"Outdoor humidity maximum [%.0f %%]"			<temperature>	(gAccuRite, gAccuRiteHumi_Chart)
Number   ar_Humidex					"Outdoor Humidex [SCALE(humidex.scale):%s]"							(gAccuRite)
Number   ar_WindSpeedMin	  "Wind speed minimum [%.0f km/h]"    			<wind>				(gAccuRite, gAccuRiteWind_Chart)
Number   ar_WindSpeedMax		"Wind speed maximum [%.0f km/h]"    			<wind>				(gAccuRite, gAccuRiteWind_Chart)
Number   ar_RainToday				"Rainfall today [%.2f mm]"								<clouds_rain>	(gAccuRite, gAccuRiteRain_Chart)
Number   ar_RainLast24H			"Rainfall last 24 hours [%.2f mm]"				<clouds_rain>	(gAccuRite)
Number   ar_RainYesterday		"Rainfall yesterday [%.2f mm]"						<clouds_rain>	(gAccuRite)
Number   ar_RainWeek				"Rainfall last 7 days [%.2f mm]"					<clouds_rain>	(gAccuRite)
Number   ar_RainMonth				"Rainfall last 30 days [%.0f mm]"					<clouds_rain>	(gAccuRite)
Number   ar_RainQuarter			"Rainfall last 90 days [%.0f mm]"					<clouds_rain>	(gAccuRite)
Number   ar_RainYear				"Rainfall last 365 days [%.0f mm]"				<clouds_rain>	(gAccuRite)

The interesting bit:

Group    gAccuRite	(gAll, gPersist_rrd4j)

Since all items are a member of gAccuRite these should be persisted?!

Otherwise I would have to add gPersist_rrd4j to all items?
Is there no better way?

(It looks like I am not ‘getting’ this)

Unfortunately not. The only way to persist the state of a Group is to list it in the .persist file directly.

Yes, you have to add it to all Items. The .persist file config is not recursive. Only direct members of gPersist_rrd4j that are not Group Items themselves will be persisted.

1 Like