thanks that solves the problem! Here the final meteravg.rules
rule "Power average"
when
Time cron "0 0/5 * * * ?"
//Time cron "0 * * * * ?" //for debug
then
var Number PowerAverage = Consumption.averageSince(now().minusMinutes(5)) as Number
ConsumptionAvg.postUpdate(PowerAverage) // assumes values are still in rrd4j
// logDebug("consumptionAvg", "Cons average {}", ConsumptionAvg.state)
PowerAverage = SolarPowerTot.averageSince(now.minusMinutes(5)) as Number
SolarPowerAvg.postUpdate(PowerAverage) // assumes values are still in rrd4j
// logDebug("SolarAvg", "Solar average {}",SolarPowerAvg.state)
end
rule "SecPower average"
when
Item ConsumptionAvg changed or
Item SolarPowerAvg changed
then
if(SolarPowerAvg.state > ConsumptionAvg.state ) {
var Number diff = SolarPowerAvg.state as Number - ConsumptionAvg.state as Number
ImmissionAvg.postUpdate(diff)
SelfConsumptionAvg.postUpdate(ConsumptionAvg.state as Number)
FetchEnergyAvg.postUpdate(0)
}
else if (SolarPowerAvg.state < ConsumptionAvg.state ) {
ImmissionAvg.postUpdate(0)
SelfConsumptionAvg.postUpdate(SolarPowerAvg.state as Number)
var Number diff = ConsumptionAvg.state as Number - SolarPowerAvg.state as Number
FetchEnergyAvg.postUpdate(diff)
}
end
EDIT: I followed the guide on this community for Openhab with InfluxDB+Grafana and I wrote down what i have done to achieve this result in my little blog here. I’m sorry for the Italian in the “article” but i think google translate will make the stuff.
I’ll share this for everyone will face off with my same problems.
Thank again for all the help!