FHEM Forum

FHEM => English Corner => Thema gestartet von: Mario am 17 Mai 2017, 11:09:15

Titel: 24-hour average
Beitrag von: Mario 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)

Titel: Antw:24-hour average
Beitrag von: fruit 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 (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 (http://www.ply.me.uk/bits_and_pieces/fhem_snippets.html) may help
Titel: Antw:24-hour average
Beitrag von: mumpitzstuff 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
Titel: Antw:24-hour average
Beitrag von: Frank_Huber 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