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.
Changing the Rule isn’t going to change past data already stored in the database. It will only prevent new 0s from being stored in the database. You need to manually remove the 0s from the data already in the database.