- Platform information: Ubuntu 16.04
- Hardware: DELL 8core with 8GB of RAM
- OS: Ubuntu 16.04
- Java Runtime Environment: java version “1.8.0_171”
- openHAB version: 2.3.0
- Issue of the topic: How to apply persistance
I am trying to calculate the average net power consumption (PC generation - usage) over minutes.
In a rules file, which is generally working well (triggered time based every minute), I made the following statement:
var net_avg_consumption = SolarLogMeter_ConsumptionPAC.averageSince(now.minusMinutes(avg_time)) -
SolarLogMeter_PDC.averageSince(now.minusMinutes(avg_time))
Whereas “SolarLogMeter_ConsumptionPAC” and “SolarLogMeter_PDC” are defined items in Paper UI and I can read them.
I defined persistence in paper UI using rrd4j as the default persistence service (in Configuration/System)
In /etc/openhab2/persistence i created a file named rrd4j.persist with the following content:
Strategies {
// if no strategy is specified for an Item entry below, the default list will be used
default = everyChange
}
Items {
// persist the Item states of items indicated below on every change and restore them from the db at startup
TeslaModelS_Charge, SolarLogMeter_ConsumptionPAC, SolarLogMeter_PDC: strategy = everyChange, restoreOnStartup
}
Based on that, the result of the above calculation is always “null”. Hence I assume, that there are no values.
If I add in the rules file, the following statements:
SolarLogMeter_PDC.persist
SolarLogMeter_ConsumptionPAC.persist
The above average calculation works. But I think this is not the right way to implement it - is it?
Can someone help me to correctly implement that?
Thanks
Heinz