Getting 10 Minute Average From Persistence

  • Platform information:
    • Hardware: OpenHABian on Pi 3B
    • OS: Current
    • Java Runtime Environment:
    • openHAB version: 2.4

I am trying to get a 10 minute average of an item persisted by influxDB.

I have a rule that looks like this:

rule "Basement Dryer Update"
when
    Item SonoffDryer_AmpUsage changed
then
    logInfo("Averaging", "Dryer")
    N_Dryer10minAverage.postUpdate(SonoffDryer_AmpUsage.averageSince(now.minusMinutes(20)))
end

The value is coming from a SonoffPOW2, which I’m not sure is relevant, but anyway…

Both the updated value and the 10 minute average show the same value on the sitemap. I changed the calculation to a 20 minute average, but that too shows the same value (eliminating how the Sonoff calculates its reported value).

What am I missing? Am I wrong about how persistence should work?

Show your persistence config. Are you sure there’s more than one value persisted in a 10 or 20 minutes timeframe ? Enable persistence debugging to find out.

Thanks Marcus: here’s the config. I’ll try to figure out how to enable logging a bit later, but I do get fancy graphs in Grafana for these items:

 SonoffWashingMachine_Power : strategy = everyChange, everyMinute
 SonoffWashingMachine_Reachable : strategy = everyChange, everyMinute
 SonoffWashingMachine_WiFiSignalStrength : strategy = everyChange, everyMinute
 SonoffWashingMachine_AmpUsage : strategy = everyChange, everyMinute
   
 SonoffDryer_Power : strategy = everyChange, everyMinute
 SonoffDryer_Reachable : strategy = everyChange, everyMinute
 SonoffDryer_WiFiSignalStrength : strategy = everyChange, everyMinute 
 SonoffDryer_AmpUsage : strategy = everyChange, everyMinute

… and did the rule trigger ?

Yes, the rule is posting its logInfo…

I just enabled logging, hopefully correctly, from the Karaf console. Now I need to know where to look for stuff…

openhab> log:set DEBUG org.openhab.persistence.influxdb

Thanks again for the reply.

DEBUG logging seems to be working:

2019-04-01 17:19:29.582 [DEBUG] [.internal.InfluxDBPersistenceService] - got DecimalType value 0.16
2019-04-01 17:19:29.638 [DEBUG] [.internal.InfluxDBPersistenceService] - got DecimalType value 0.16

These are the original item, and the one that is intended to display the calculated average…

Partially solved, and another wasted evening on something that seems like it should be simple.

I had mapdb persisting all items for restore on startup as well as influxes, and I think it was averaging the single data point from there.

However, now I get a little more data - the average is just half of the actual value.

Any ideas?

Had to change my default persistence service, and it seems to now be working.