I’ve been setting up an OpenHAB2 install to possibly migrate my OH1 in the near future.
I set up a group number item (SUM) to add power from items that are on, and rules to define these values according to when they are ON or OFF. From the logs I can see values and sums are stored correctly, but I tried to plot a chart on the sitemap and all I get are straight lines.
So I have a gPotencia group which contains 3 group number items for each phase - gPotencia1, gPotencia2, gPotencia3. gPotencia is also a part of gHistorico group, which is defined in the RRD4J persistence file, as well as gPotencia (just in case).
In the persistence folder I have a persistence file for mapdb and another one from rrd4j, copied straight out of my OH1.x install, and persistence seems to be working for switch items, but I would say the straight line is a symptom that rrd4j persistence isn’t working, or am I missing something?
Also default persistence is set in PaperUI as mapdb.
default = everyUpdate
// persist all items on every change and restore them from the db at startup
* : strategy = everyChange, restoreOnStartup
// for rrd charts, we need a cron strategy
everyMinute : "0 * * * * ?"
default = everyChange
// additionally persist weather info every minute
gHistorico* : strategy = everyUpdate, everyMinute
gPotencia* : strategy = everyMinute, everyChange, restoreOnStartup
If I turn something ON or OFF, the SUM value for the corresponding group changes accordingly, and the line on the graphic changes to that value. So the last value and the ones before that aren’t being stored I think, because I only ever see a line with the current value.
Number Watts_LuzGab "Pot. Luz Gabinete [%.0f W]" <energy> (gPotencia2)
And a rule to set the value. It’s not the most efficient way to do this, but until I install actual meters, I can get pretty close with this.
rule "potencias estimadas LuzGab"
Item LuzGabinete changed
There are several similar items, and logs show the values for for each group changing as each item is changed.
2019-02-06 17:54:00.163 [vent.ItemStateChangedEvent] - Watts_ExtEstacion changed from 0 to 200
2019-02-06 17:54:00.167 [GroupItemStateChangedEvent] - gPotencia1 changed from 354 to 554 through Watts_ExtEstacion
2019-02-06 17:54:00.180 [vent.ItemStateChangedEvent] - Watts_ExtCartaz changed from 0 to 100
2019-02-06 17:54:00.183 [GroupItemStateChangedEvent] - gPotencia3 changed from 750 to 850 through Watts_ExtCartaz
But these changes aren’t stored. All I get is a line at the value it is currently.
If I understand correctly the actual change of a group to the value xx is shown as line on value xx for the whole time?
Does this actual value correspond with the values written in the log?
Yes, that is correct, and the values are correct. There are 3 lines, one for each of the sums of powers from each phase stored by gPotencia1, gPotencia2, gPotencia3 which all belong to group gPotencia which is set in the rrd4j persistence file as everyUpdate and everyMinute.
Should I set the default persistence on PaperUI to rrd4j? I thought it wasn’t recommended. On my OH1.x, I believe mapdb is used for every item state, apart from the numbers that belong to the gHistorico group, which is specified in the rrd4j persistence file and therefore handled differently.
As you use rrd4j, you must also apply the everyMinute persistence strategy. everyUpdate is NOT sufficient for rrd4j.
This is the exact same setup (albeit for temperatures) that I have on my OH1.9 system, and it works fine there. I copied the persistence files from there, and the rrd4j strategy is specified for groups gHistorico and gPotencia are everyMinute and everyUpdate.
If you do not specify the persistence in the Chart Definition, the Default persistence will be used! That might be mapDB in your case. Either set the used persistence in the Chart Definition or set rrd4j as the Default.
You solved one problem ( mapdb does store the last value only, hence the line). Now the problem is that the rrd4j database might not be storing (yet).
If you have REST Docs installed you could check if there are any values stored at all.
It migth only need a restart of openHAB to resolve, but let’s do one step after the other.