Autor Thema: 24-hour average  (Gelesen 450 mal)

Offline Mario

  • New Member
  • *
  • Beiträge: 6
24-hour average
« am: 17 Mai 2017, 11:09:15 »
Hello, it is possible to calculate 24-hour average with fhem and/or helper module ?

fhem average helper calculate "current day" average which means it has limited accuracy by most of a day
=> and is almost correct only about 1 sec before midnight ;-)

found also https://wiki.fhem.de/wiki/Gleitende_Mittelwerte_berechnen_und_loggen
which mislead to be avergaing for given time but only uses 25 for sample buffer so it is way off for update rates greater then one per hour,
(it result with ~4 minutes average for 10 sec sampling period for requested 86400 s average)
(not sure about load/performance effect after hacking to use needed 1440 sample buffer)


Offline fruit

  • Full Member
  • ***
  • Beiträge: 286
Antw:24-hour average
« Antwort #1 am: 17 Mai 2017, 21:59:46 »
If you are wanting a list of daily averages you could grab and save that value just before midnight each day.

There is also a useful utility myDiff, see https://wiki.fhem.de/wiki/HM-WDS100-C6-O_Funk-Kombi-Sensor_OC3 and there is an example of calculating rainfall over 24 hours, RegenmengeLast24Hours

The myDiff utility should be placed in 99_myUtils.pm, if you are not sure about that http://www.ply.me.uk/bits_and_pieces/fhem_snippets.html may help
Feel free to follow up in German if you prefer

Offline mumpitzstuff

  • Full Member
  • ***
  • Beiträge: 287
Antw:24-hour average
« Antwort #2 am: 17 Mai 2017, 23:49:51 »
Search for event-aggregator within the Fhem command ref.

attr mySunMeter event-aggregator SUN_INTENSITY_24H::const:integral:86400

Online Frank_Huber

  • Sr. Member
  • ****
  • Beiträge: 918
Antw:24-hour average
« Antwort #3 am: 18 Mai 2017, 10:13:42 »
Hi,

I do it that was wit a "at" timer and write teh average outside temperature into a dummy named "Verbrauch" into Reading "Durchschnittstemperatur.
to calculate I also use the average helper module inside my device "Aussen_Temp".

define Durchschnittstemperatur_Tag at *23:59:30 {\
my $wert1=ReadingsVal("Aussen_Temp","temperature_avg_day","--");;\
fhem("setreading Verbrauch Durchschnittstemperatur $wert1");;\
}

br
Frank

 

decade-submarginal