Hi everyone, I’m new here and I’m a newbie.

My powermeter (owl inyuition) have a counter for the total consumption and i want to calculate the consumption for each day (in kW). I have modified a rule that i found in this forum:

```
rule "Imposta il consumo min e max giornaliero"
when
Item Pow_2 changed or
Time cron "0 0 0 * * ?" or
System started
then
val max = (Pow_2.maximumSince(now.withTimeAtStartOfDay, "rrd4j").state as DecimalType).doubleValue
val min = (Pow_2.minimumSince(now.withTimeAtStartOfDay, "rrd4j").state as DecimalType).doubleValue
if( max != null && min != null) {
Consumo_max.postUpdate(max)
Consumo_min.postUpdate(min)
Consumo_giornaliero.postUpdate((max - min) /1000)
}
end
```

Everythings seems to work fine, but the problem is that sometimes the value become “zero” so the calculation become wrong.

Can anyone give me a suggestion?

Should I look for another kind of approach?