[98_statistics] Modul hinkt scheinbar hinterher

Begonnen von andi11, 01 November 2021, 08:05:34

Vorheriges Thema - Nächstes Thema

andi11

mögliche Varianten die mir so einfallen:
-Attribut für Tageswechseluhrzeitverstellung abschalten
-02:00 und 03:00 im Attribut verweigern
-Monatswechselcheck entkoppeln vom Tageswechsel
-Überprüfung ändern auf "war vor 2Stunden der gleiche Monat?"
-Sonderbehandlung siehe dem "Ach heute ist Tageswechseltag"

Simulation geht glaube ich nur wenn auch die Systemzeit verstellt wird.

rob

Zitat von: andi11 am 08 November 2021, 17:37:50
Simulation geht glaube ich nur wenn auch die Systemzeit verstellt wird.
yepp, genau da dran fummle ich testweise rum  ;D

VG
rob

rob

Mmh. Keine Ahnung, ob ich hier eine Hilfe bin. Ich habe ein wenig rumprobiert, bekomme das Problem aber noch nicht reproduziert. Also muss wir etwas wichtiges fehlen. Leider habe ich kein Stat-Modul bislang im Einsatz.

Zum Testszenario:
Habe ein at angelegt, das fest alle 10sec. einen Pseudocounter in einem Dummy bedient. Im Dummy noch ein UserReading, was den Counter aufsummiert als Total und ein Log für den Dummy. Dann habe ich ein Statistik-Device angelegt, welches Counter und Total vom Dummy "überwacht". Attr dayChangeTime erst weggelassen und dann gesetzt auf 02:00 und 03:00. Systemzeit zurückgestellt auf 31.10. 22:58Uhr, per EventMonitor beobachtet und laufen lassen. Nach jedem Übergang habe ich die Zeit vorgestellt, und den nä. Übergang abgewartet.

Alle Events waren regelmäßig und parallel im Log alle Einträge unauffällig. Insbesondere der jew. Übergang auf 00:00, 02:00 und 03:00 war unauffällig.
Beim Vorstellen der Zeit von z.B. 02:15Uhr auf 2:58Uhr gab es Sprünge im Count - das dürfte aber allein am at liegen und ist nicht das gesuchte Problem.

Wenn Ihr mir RAW-Definitionen geben mögt, womit ich das Problem nachbauen soll, bastle ich die gerne rein. Sollte meine Testerei nicht wirklich nützlich sein, halte ich mich natürlich zurück :)



Testumgebung ist einfach ein FHEM in Docker. Aufbau in FHEM schaut so aus (list -r):

define FileLog_hupe FileLog ./log/hupe_1-%Y.log hupe:.*

define Statistik statistics hupe
attr Statistik dayChangeTime 02:00
attr Statistik deltaReadings mytotalcnt
attr Statistik verbose 1

define hupe dummy
attr hupe event-on-update-reading .*
attr hupe readingList counter, mytotalcnt
attr hupe userReadings mytotalcnt {\
my $tmp=ReadingsVal("hupe","mytotalcnt","0");;\
my $newcnt=ReadingsVal("hupe","counter","");;\
$tmp+$newcnt;;\
}\

attr hupe verbose 4

define myAT at +*00:00:10 set hupe counter 1

setstate FileLog_hupe active
setstate FileLog_hupe 2021-11-09 07:43:46 linesInTheFile 14240

setstate Statistik Updated stats for: hupe
setstate Statistik 2021-11-09 07:43:46 .hupe:mytotalcnt LastValue: 7235 ShowDate: 3 DecPlaces: 0
setstate Statistik 2021-11-08 17:24:43 .hupe:stateDay counter_1: 1370 (since: 2021-11-08_17:01:53) counter_1_Count: 1 lastTime: 1636388683 showDate: 1 lastState: counter_1
setstate Statistik 2021-11-08 17:24:43 .hupe:stateMonth (since: 2021-11-08_17:01:53) counter_1: 1370 counter_1_Count: 1 lastTime: 1636388683 showDate: 1 lastState: counter_1
setstate Statistik 2021-11-08 17:24:43 .hupe:stateYear showDate: 1 lastTime: 1636388683 lastState: counter_1 counter_1: 1370 (since: 2021-11-08_17:01:53) counter_1_Count: 1
setstate Statistik 2021-11-09 07:40:46 monitoredDevicesdummy hupe
setstate Statistik 2021-11-09 07:40:47 nextPeriodChangeCalc 2021-11-09 07:59:55
setstate Statistik 2021-11-09 07:43:46 state Updated stats for: hupe

setstate hupe counter 1
setstate hupe 2021-11-08 17:18:43 counter 1
setstate hupe 2021-11-09 07:43:46 mytotalcnt 7236
setstate hupe 2021-11-08 17:25:23 statCounterDay 1: 00:16:00 1_Count: 1 (since: 2021-11-08_17:09:23)
setstate hupe 2021-11-08 17:25:23 statCounterHour 1: 00:16:00 1_Count: 1 (since: 2021-11-08_17:09:23)
setstate hupe 2021-11-08 17:25:23 statCounterMonth 1: 00:16:00 1_Count: 1 (since: 2021-11-08_17:09:23)
setstate hupe 2021-11-08 17:25:23 statCounterYear 1: 00:16:00 1_Count: 1 (since: 2021-11-08_17:09:23)
setstate hupe 2021-11-09 07:43:46 statMytotalcnt Hour: 40 Day: 40 Month: 40 Year: 7210 (since: 2021-11-08_17:24:53 )
setstate hupe 2021-11-01 01:59:55 statMytotalcntLast Hour: 1443 Day: 7170 Month: 7170 Year: - (since: 2021-11-08_17:24:53 )
setstate hupe 2021-11-08 17:24:43 statStateDay counter_1: 00:22:50 counter_1_Count: 1 (since: 2021-11-08_17:01:53)
setstate hupe 2021-11-08 17:24:43 statStateMonth counter_1: 00:22:50 counter_1_Count: 1 (since: 2021-11-08_17:01:53)
setstate hupe 2021-11-08 17:24:43 statStateYear counter_1: 00:22:50 counter_1_Count: 1 (since: 2021-11-08_17:01:53)
setstate hupe 2021-11-09 07:43:46 state counter 1

setstate myAT Next: 07:43:56
setstate myAT 2021-11-09 07:43:46 state Next: 07:43:56

Beta-User

Hier mal ein vereinfachtest Modell mit einem at, das einen Zähler an sich selbst (minütlich) hochzählt, und einer statistics-Instanz, die nur dieses eine Gerät mit dem einen Reading überwacht:
defmod at_stat at +*00:01 {my $count = ReadingsNum('at_stat','count',0)+1;; fhem("setreading at_stat count $count")}

defmod statistic statistics at_stat
attr statistic deltaReadings count

Das sollte dann am at ein weiteres Reading erzeugen nach dem Muster:
statCount Hour: 4 Day: 4 Month: 4 Year: 4 (since: ...)
Weitere Readings sollte es am statistics-Device geben, aus denen man erkennen kann, wann die nächsten Perioden-Änderungen sind usw.

Das sollte eigentlich schon reichen, bitte erst mal die genannten Sonderfälle außen vor lassen.
Server: HP-elitedesk@Debian 12, aktuelles FHEM@ConfigDB | CUL_HM (VCCU) | MQTT2: MiLight@ESP-GW, BT@OpenMQTTGw | MySensors: seriell, v.a. 2.3.1@RS485 | ZWave | ZigBee@deCONZ | SIGNALduino | MapleCUN | RHASSPY
svn: u.a MySensors, Weekday-&RandomTimer, Twilight,  div. attrTemplate-files

rob

#34
OK, ist angelegt und zählt nun vor sich hin.
Edit: ...und habe es durchlaufen lassen, um eine gewisse  Statistik zu erhalten. Logs anbei. List nachstehend festgehalten. Jetzt dreh ich an der Zeit und stelle sie auf 30.10. 22:59Uhr und lasse es mal laufen.




define at_stat at +*00:01 {my $count = ReadingsNum('at_stat','count',0)+1;; fhem("setreading at_stat count $count")}
attr at_stat verbose 4

define statistic statistics at_stat
attr statistic deltaReadings count
attr statistic verbose 4

setstate at_stat Next: 06:54:21
setstate at_stat 2021-11-10 06:53:21 count 1096
setstate at_stat 2021-11-10 06:53:21 statCount Hour: 54 Day: 414 Month: 414 Year: 414 (since: 2021-11-10 )
setstate at_stat 2021-11-10 05:59:55 statCountLast Hour: 60 Day: 681 Month: - Year: - (since: 2021-11-09_12:38:21 )
setstate at_stat 2021-11-09 12:37:32 statStateDay Next:_12:38:21: 00:00:00 Next:_12:38:21_Count: 1 (since: 2021-11-09_12:37:32)
setstate at_stat 2021-11-09 12:37:32 statStateMonth Next:_12:38:21: 00:00:00 Next:_12:38:21_Count: 1 (since: 2021-11-09_12:37:32)
setstate at_stat 2021-11-09 12:37:32 statStateYear Next:_12:38:21: 00:00:00 Next:_12:38:21_Count: 1 (since: 2021-11-09_12:37:32)
setstate at_stat 2021-11-10 06:53:21 state Next: 06:54:21

setstate statistic Updated stats for: at_stat
setstate statistic 2021-11-10 06:53:21 .at_stat:count LastValue: 1096 ShowDate: 5 DecPlaces: 0
setstate statistic 2021-11-09 12:37:32 .at_stat:stateDay lastState: Next:_12:38:21 lastTime: 1636457852 Next:_12:38:21_Count: 1 Next:_12:38:21: 0 showDate: 1 (since: 2021-11-09_12:37:32)
setstate statistic 2021-11-09 12:37:32 .at_stat:stateMonth showDate: 1 (since: 2021-11-09_12:37:32) lastTime: 1636457852 lastState: Next:_12:38:21 Next:_12:38:21_Count: 1 Next:_12:38:21: 0
setstate statistic 2021-11-09 12:37:32 .at_stat:stateYear lastTime: 1636457852 lastState: Next:_12:38:21 Next:_12:38:21_Count: 1 Next:_12:38:21: 0 showDate: 1 (since: 2021-11-09_12:37:32)
setstate statistic 2021-11-09 12:37:32 monitoredDevicesat at_stat
setstate statistic 2021-11-10 05:59:55 nextPeriodChangeCalc 2021-11-10 06:59:55
setstate statistic 2021-11-10 06:53:21 state Updated stats for: at_stat

rob

So, nun hatte ich wie geschrieben die Zeit zurückgedreht und alles ab 30.10. 22:58 laufen lassen bis 31.10. 04:00Uhr (in Echtzeit).
LOG imho unauffällig. Insbesondere der Rücksprung von 02:59 auf 02:00 schaut doch eigentl. gut aus. Logs anbei.

autom. Zeitumstellung im LOG

2021.10.31 02:58:42.380 4: statistics statistic: doStatisticDelta.703 Calculating delta statistics for 'at_stat:count = 1340'
2021.10.31 02:58:42.381 4: statistics statistic: doStatisticDelta.703 Calculating delta statistics for 'at_stat:count = 1340'
2021.10.31 02:59:42.368 4: statistics statistic: doStatisticDelta.703 Calculating delta statistics for 'at_stat:count = 1341'
2021.10.31 02:59:42.370 4: statistics statistic: doStatisticDelta.703 Calculating delta statistics for 'at_stat:count = 1341'
2021.10.31 02:59:55.005 4: statistics statistic: PeriodChange.342 Next period change will be calculated at 2021-10-31 02:59:55
2021.10.31 02:59:55.005 4: statistics statistic: PeriodChange.376 Calculating statistics at startup
2021.10.31 02:59:55.005 4: statistics statistic: DoStatisticsAll.395 Doing statistics (period 0) for device 'at_stat'
2021.10.31 02:59:55.005 4: statistics statistic: doStatisticDelta.703 Calculating delta statistics for 'at_stat:count = 1341'
2021.10.31 02:00:42.367 4: statistics statistic: doStatisticDelta.703 Calculating delta statistics for 'at_stat:count = 1342'
2021.10.31 02:00:42.368 4: statistics statistic: doStatisticDelta.703 Calculating delta statistics for 'at_stat:count = 1342'

Beta-User

 :) Sieht auch imo gut aus. Jetzt warten wir mal ab, was der "Monatswechsel" macht, oder?
Server: HP-elitedesk@Debian 12, aktuelles FHEM@ConfigDB | CUL_HM (VCCU) | MQTT2: MiLight@ESP-GW, BT@OpenMQTTGw | MySensors: seriell, v.a. 2.3.1@RS485 | ZWave | ZigBee@deCONZ | SIGNALduino | MapleCUN | RHASSPY
svn: u.a MySensors, Weekday-&RandomTimer, Twilight,  div. attrTemplate-files

rob

War hoffentl. kein Missverständnis: die LOGS sind alle ungepatcht entstanden.
Es sollte ja zunächst ein Vergleichsstand entstehen mit ggf. reproduziertem Problem, um zu sehen, was der Patch dann macht.
Wenn das so passt, würde ich patchen und den Test damit wiederholen.

Braucht es für den Monatswechsel nur den Sprung von 31.10. 22:59Uhr zu 01.11. 03:00Uhr? Dann müsste ich nur das laufen lassen. Ansonsten muss ich wissen, welcher Zeitraum sinnvoll ist.
Diesen Monatswechsel würde ich ebenfalls erst ungepatcht machen und dann gepatcht wiederholen.

Zitat von: Beta-User am 10 November 2021, 13:23:06
...warten wir mal ab, was der "Monatswechsel" macht...
Natürlich in Echtzeit  ;D

Beta-User

Hmm, seltsam. Der fragliche Tageswechsel sieht jedenfalls auch ungepatcht i.O. aus. Hier bei statistics war das Hauptproblem gewesen, dass der Monatswechsel ausgefallen war. Nach einem Blick in den Code meine ich, dass man das nachstellen kann, wenn man erst kurz vor dem Monatswechsel losläuft, und einen Versuch wäre es wohl wert.
Ein Eintrag alle 10 Min würde es vermutlich auch tun.
Server: HP-elitedesk@Debian 12, aktuelles FHEM@ConfigDB | CUL_HM (VCCU) | MQTT2: MiLight@ESP-GW, BT@OpenMQTTGw | MySensors: seriell, v.a. 2.3.1@RS485 | ZWave | ZigBee@deCONZ | SIGNALduino | MapleCUN | RHASSPY
svn: u.a MySensors, Weekday-&RandomTimer, Twilight,  div. attrTemplate-files

rob


Beta-User

#40
...ok, aber jetzt ist mir doch noch was aufgefallen, was imo (auch) nicht paßt:
Zitat2021.10.31 02:59:55.005 4: statistics statistic: PeriodChange.376 Calculating statistics at startup

Bin daher nochmal über das ganze drüber und würde mal mit dem hier ins Rennen gehen:
sub statistics_PeriodChange($)
{
   my ($hash) = @_;
   my $name = $hash->{NAME};
   my $dummy;
   my $val;
   
   my $curPeriodChangeTime = $hash->{fhem}{nextPeriodChangeTime};
   $curPeriodChangeTime = gettimeofday() unless defined $curPeriodChangeTime;
   my $periodChangePreset = AttrVal($name, "periodChangePreset", 5);
   my $isDayChange = ( ReadingsVal($name, "nextPeriodChangeCalc", "") =~ /Day Change/ );
   
  # Determine the next day change time
   my @th=localtime();
   my $now = gettimeofday();
   my $dayChangeDelay = 0;
   my $dayChangeTime = timelocal(0,0,0,$th[3],$th[4],$th[5]+1900);
   if (AttrVal($name, "dayChangeTime", "00:00") =~ /(\d+)\d+)/ && $1<24 && $1 >=0 && $2<60 && $2>=0) {
      $dayChangeDelay = $1 * 3600 + $2 * 60;
      if ($dayChangeDelay == 0) { $dayChangeTime += 24*3600; } # Otherwise it would always lay in the past
      $dayChangeTime += $dayChangeDelay - $periodChangePreset;
   }
   my $dstcorr = HOURSECONDS * ($th[8] - (localtime($now + DAYSECONDS))[8]);
   $dayChangeTime += $dstcorr;
   
   RemoveInternalTimer($hash);
# Run period change procedure each full hour ("periodChangePreset" second before).
   my $periodEndTime = 3600 * ( int(($now+$periodChangePreset)/3600) + 1 ) - $periodChangePreset ;
# Run procedure also for given dayChangeTime 
   $val = "";
   if ( $now<$dayChangeTime && $dayChangeTime<=$periodEndTime ) {
      $periodEndTime = $dayChangeTime;
      $val = " (Day Change)";
   }
   $val = strftime ("%Y-%m-%d %H:%M:%S", localtime($periodEndTime)) . $val;
   InternalTimer( $periodEndTime, "statistics_PeriodChange", $hash, 1);

   readingsSingleUpdate($hash, "nextPeriodChangeCalc", $val, 0);
   $hash->{fhem}{nextPeriodChangeTime} = $periodEndTime;

   statistics_Log $hash, 4, "Next period change will be calculated at $val";

   return if( AttrVal($name, "disable", 0 ) == 1 );
   
# Determine if time period switched (day, month, year)

   my $periodSwitch = 0;
   my $yearLast;
   my $monthLast;
   my $dayLast;
   my $hourLast;
   my $hourNow;
   my $dayNow;
   my $monthNow;
   my $yearNow;

   if ($isDayChange) {
      statistics_Log $hash, 4, "Calculating day change";
     # get time values for 50 seconds before a new day
      ($dummy, $dummy, $hourLast, $dayLast, $monthLast, $yearLast) = localtime ($curPeriodChangeTime - $dayChangeDelay + $periodChangePreset - 59);
     # get time values for next day
      ($dummy, $dummy, $hourNow, $dayNow, $monthNow, $yearNow) = localtime ($now + $periodChangePreset);
      $periodSwitch = -2;
      if ($yearNow != $yearLast) { $periodSwitch = -4; }
      elsif ($monthNow != $monthLast) { $periodSwitch = -3; }
      # Positiv Value if periode changes at full hour
      $periodSwitch = abs($periodSwitch)     if $dayChangeDelay % 3600 == 0;
   } else {
      ($dummy, $dummy, $hourLast, $dummy, $dummy, $dummy) = localtime ($now );
      ($dummy, $dummy, $hourNow, $dummy, $dummy, $dummy) = localtime ($now + $periodChangePreset);
      if ($hourNow != $hourLast || $hourNow == $hourLast && $dstcorr) {
         $periodSwitch = 1;
         statistics_Log $hash,4,"Calculating hour change";
      } else {
         statistics_Log $hash,4,"Calculating statistics at startup";
      }
   }

   statistics_DoStatisticsAll $hash, $periodSwitch;

   return undef;
}


EDIT: hatte noch ein "time" gefunden und durch "$now" ersetzt...
Server: HP-elitedesk@Debian 12, aktuelles FHEM@ConfigDB | CUL_HM (VCCU) | MQTT2: MiLight@ESP-GW, BT@OpenMQTTGw | MySensors: seriell, v.a. 2.3.1@RS485 | ZWave | ZigBee@deCONZ | SIGNALduino | MapleCUN | RHASSPY
svn: u.a MySensors, Weekday-&RandomTimer, Twilight,  div. attrTemplate-files

rob

Gerne. Auf welcher Rennbahn? Den Wechsel zur Winterzeit, den Monatswechsel oder beides? Wahrscheinlich erstmal noch ungepatcht  :)

Beta-User

Darf gerne direkt gepatcht losgehen, und von besonderem Interesse ist dann der 2. 02:00-Uhr-Eintrag sowie eben der Monatswechsel (der erst mal ungepatcht weiterlaufen darf, damit wir ggf. mal das Log begutachten können; vielleicht gibt es doch Auffälligkeiten).
Server: HP-elitedesk@Debian 12, aktuelles FHEM@ConfigDB | CUL_HM (VCCU) | MQTT2: MiLight@ESP-GW, BT@OpenMQTTGw | MySensors: seriell, v.a. 2.3.1@RS485 | ZWave | ZigBee@deCONZ | SIGNALduino | MapleCUN | RHASSPY
svn: u.a MySensors, Weekday-&RandomTimer, Twilight,  div. attrTemplate-files

rob

Soweit bin ich jetzt durch  :)
1) Monatswechsel ungepatcht, 2) Zeitumstellung gepatcht und 3) Monatswechsel gepatcht. Verwendet habe ich den Patch aus Post #40 (Klammer gesetzt) - imho alles unauffällig. Reicht ggf. ein symmetrischer Zähler nicht zum Simulieren? In der Realität senden die Zähler ja meist unsymmetrisch.

VG
rob


Log 1) Monatswechsel ungepatcht
fhem-2021-10-31.log

2021.10.31 23:39:49.770 4: statistics statistic: doStatisticDelta.703 Calculating delta statistics for 'at_stat:count = 1'
2021.10.31 23:39:49.770 4: statistics statistic: doStatisticDelta.719 Initializing statistic of '.at_stat:count'.
2021.10.31 23:39:49.771 4: statistics statistic: doStatisticDelta.703 Calculating delta statistics for 'at_stat:count = 1'
2021.10.31 23:49:49.759 4: statistics statistic: doStatisticDelta.703 Calculating delta statistics for 'at_stat:count = 2'
2021.10.31 23:49:49.760 4: statistics statistic: doStatisticDelta.703 Calculating delta statistics for 'at_stat:count = 2'
2021.10.31 23:59:49.769 4: statistics statistic: doStatisticDelta.703 Calculating delta statistics for 'at_stat:count = 3'
2021.10.31 23:59:49.770 4: statistics statistic: doStatisticDelta.703 Calculating delta statistics for 'at_stat:count = 3'
2021.10.31 23:59:55.005 4: statistics statistic: PeriodChange.342 Next period change will be calculated at 2021-11-01 00:59:55
2021.10.31 23:59:55.005 4: statistics statistic: PeriodChange.374 Calculating hour change
2021.10.31 23:59:55.006 4: statistics statistic: DoStatisticsAll.395 Doing statistics (period 1) for device 'at_stat'
2021.10.31 23:59:55.006 4: statistics statistic: doStatisticDelta.703 Calculating delta statistics for 'at_stat:count = 3'
2021.10.31 23:59:55.006 4: statistics statistic: doStatisticDelta.787 Shifting current hour in last value of 'statCount'.
2021.10.31 23:59:55.007 4: statistics statistic: doStatisticDelta.807 Set 'statCountLast'='Hour: 2 Day: - Month: - Year: - (since: 2021-10-31_23:39:49 )'


fhem-2021-11-01.log

2021.11.01 00:09:49.758 4: statistics statistic: doStatisticDelta.703 Calculating delta statistics for 'at_stat:count = 4'
2021.11.01 00:09:49.760 4: statistics statistic: doStatisticDelta.703 Calculating delta statistics for 'at_stat:count = 4'
2021.11.01 00:19:49.768 4: statistics statistic: doStatisticDelta.703 Calculating delta statistics for 'at_stat:count = 5'
2021.11.01 00:19:49.769 4: statistics statistic: doStatisticDelta.703 Calculating delta statistics for 'at_stat:count = 5'
2021.11.01 00:29:49.758 4: statistics statistic: doStatisticDelta.703 Calculating delta statistics for 'at_stat:count = 6'
2021.11.01 00:29:49.759 4: statistics statistic: doStatisticDelta.703 Calculating delta statistics for 'at_stat:count = 6'
2021.11.01 00:39:49.767 4: statistics statistic: doStatisticDelta.703 Calculating delta statistics for 'at_stat:count = 7'
2021.11.01 00:39:49.768 4: statistics statistic: doStatisticDelta.703 Calculating delta statistics for 'at_stat:count = 7'
2021.11.01 00:49:49.756 4: statistics statistic: doStatisticDelta.703 Calculating delta statistics for 'at_stat:count = 8'
2021.11.01 00:49:49.757 4: statistics statistic: doStatisticDelta.703 Calculating delta statistics for 'at_stat:count = 8'
2021.11.01 00:59:49.766 4: statistics statistic: doStatisticDelta.703 Calculating delta statistics for 'at_stat:count = 9'
2021.11.01 00:59:49.768 4: statistics statistic: doStatisticDelta.703 Calculating delta statistics for 'at_stat:count = 9'
2021.11.01 00:59:55.005 4: statistics statistic: PeriodChange.342 Next period change will be calculated at 2021-11-01 01:59:55
2021.11.01 00:59:55.005 4: statistics statistic: PeriodChange.374 Calculating hour change
2021.11.01 00:59:55.006 4: statistics statistic: DoStatisticsAll.395 Doing statistics (period 1) for device 'at_stat'
2021.11.01 00:59:55.006 4: statistics statistic: doStatisticDelta.703 Calculating delta statistics for 'at_stat:count = 9'
2021.11.01 00:59:55.006 4: statistics statistic: doStatisticDelta.787 Shifting current hour in last value of 'statCount'.
2021.11.01 00:59:55.006 4: statistics statistic: doStatisticDelta.807 Set 'statCountLast'='Hour: 6 Day: - Month: - Year: -'
2021.11.01 01:09:49.756 4: statistics statistic: doStatisticDelta.703 Calculating delta statistics for 'at_stat:count = 10'
2021.11.01 01:09:49.757 4: statistics statistic: doStatisticDelta.703 Calculating delta statistics for 'at_stat:count = 10'
2021.11.01 01:19:49.763 4: statistics statistic: doStatisticDelta.703 Calculating delta statistics for 'at_stat:count = 11'
2021.11.01 01:19:49.764 4: statistics statistic: doStatisticDelta.703 Calculating delta statistics for 'at_stat:count = 11'
2021.11.01 01:29:49.775 4: statistics statistic: doStatisticDelta.703 Calculating delta statistics for 'at_stat:count = 12'
2021.11.01 01:29:49.776 4: statistics statistic: doStatisticDelta.703 Calculating delta statistics for 'at_stat:count = 12'
2021.11.01 01:39:49.763 4: statistics statistic: doStatisticDelta.703 Calculating delta statistics for 'at_stat:count = 13'
2021.11.01 01:39:49.763 4: statistics statistic: doStatisticDelta.703 Calculating delta statistics for 'at_stat:count = 13'
2021.11.01 01:49:49.756 4: statistics statistic: doStatisticDelta.703 Calculating delta statistics for 'at_stat:count = 14'
2021.11.01 01:49:49.758 4: statistics statistic: doStatisticDelta.703 Calculating delta statistics for 'at_stat:count = 14'
2021.11.01 01:59:49.762 4: statistics statistic: doStatisticDelta.703 Calculating delta statistics for 'at_stat:count = 15'
2021.11.01 01:59:49.764 4: statistics statistic: doStatisticDelta.703 Calculating delta statistics for 'at_stat:count = 15'
2021.11.01 01:59:55.001 4: statistics statistic: PeriodChange.342 Next period change will be calculated at 2021-11-01 02:59:55
2021.11.01 01:59:55.001 4: statistics statistic: PeriodChange.374 Calculating hour change
2021.11.01 01:59:55.001 4: statistics statistic: DoStatisticsAll.395 Doing statistics (period 1) for device 'at_stat'
2021.11.01 01:59:55.001 4: statistics statistic: doStatisticDelta.703 Calculating delta statistics for 'at_stat:count = 15'
2021.11.01 01:59:55.001 4: statistics statistic: doStatisticDelta.787 Shifting current hour in last value of 'statCount'.
2021.11.01 01:59:55.002 4: statistics statistic: doStatisticDelta.807 Set 'statCountLast'='Hour: 6 Day: - Month: - Year: -'
2021.11.01 02:09:49.771 4: statistics statistic: doStatisticDelta.703 Calculating delta statistics for 'at_stat:count = 16'
2021.11.01 02:09:49.772 4: statistics statistic: doStatisticDelta.703 Calculating delta statistics for 'at_stat:count = 16'
2021.11.01 02:19:49.761 4: statistics statistic: doStatisticDelta.703 Calculating delta statistics for 'at_stat:count = 17'
2021.11.01 02:19:49.762 4: statistics statistic: doStatisticDelta.703 Calculating delta statistics for 'at_stat:count = 17'
2021.11.01 02:29:49.762 4: statistics statistic: doStatisticDelta.703 Calculating delta statistics for 'at_stat:count = 18'
2021.11.01 02:29:49.763 4: statistics statistic: doStatisticDelta.703 Calculating delta statistics for 'at_stat:count = 18'
2021.11.01 02:39:49.761 4: statistics statistic: doStatisticDelta.703 Calculating delta statistics for 'at_stat:count = 19'
2021.11.01 02:39:49.762 4: statistics statistic: doStatisticDelta.703 Calculating delta statistics for 'at_stat:count = 19'
2021.11.01 02:49:49.765 4: statistics statistic: doStatisticDelta.703 Calculating delta statistics for 'at_stat:count = 20'
2021.11.01 02:49:49.766 4: statistics statistic: doStatisticDelta.703 Calculating delta statistics for 'at_stat:count = 20'
2021.11.01 02:59:49.757 4: statistics statistic: doStatisticDelta.703 Calculating delta statistics for 'at_stat:count = 21'
2021.11.01 02:59:49.758 4: statistics statistic: doStatisticDelta.703 Calculating delta statistics for 'at_stat:count = 21'
2021.11.01 02:59:55.005 4: statistics statistic: PeriodChange.342 Next period change will be calculated at 2021-11-01 03:59:55
2021.11.01 02:59:55.005 4: statistics statistic: PeriodChange.374 Calculating hour change
2021.11.01 02:59:55.006 4: statistics statistic: DoStatisticsAll.395 Doing statistics (period 1) for device 'at_stat'
2021.11.01 02:59:55.006 4: statistics statistic: doStatisticDelta.703 Calculating delta statistics for 'at_stat:count = 21'
2021.11.01 02:59:55.006 4: statistics statistic: doStatisticDelta.787 Shifting current hour in last value of 'statCount'.
2021.11.01 02:59:55.006 4: statistics statistic: doStatisticDelta.807 Set 'statCountLast'='Hour: 6 Day: - Month: - Year: -'
2021.11.01 03:09:49.770 4: statistics statistic: doStatisticDelta.703 Calculating delta statistics for 'at_stat:count = 22'
2021.11.01 03:09:49.771 4: statistics statistic: doStatisticDelta.703 Calculating delta statistics for 'at_stat:count = 22'
2021.11.01 03:19:49.759 4: statistics statistic: doStatisticDelta.703 Calculating delta statistics for 'at_stat:count = 23'
2021.11.01 03:19:49.760 4: statistics statistic: doStatisticDelta.703 Calculating delta statistics for 'at_stat:count = 23'
2021.11.01 03:29:49.764 4: statistics statistic: doStatisticDelta.703 Calculating delta statistics for 'at_stat:count = 24'
2021.11.01 03:29:49.765 4: statistics statistic: doStatisticDelta.703 Calculating delta statistics for 'at_stat:count = 24'
2021.11.01 03:39:49.758 4: statistics statistic: doStatisticDelta.703 Calculating delta statistics for 'at_stat:count = 25'
2021.11.01 03:39:49.759 4: statistics statistic: doStatisticDelta.703 Calculating delta statistics for 'at_stat:count = 25'




Log 2) Zeitumstellung gepatcht
fhem-2021-10-30.log

2021.10.30 23:36:25.531 4: statistics statistic: PeriodChange.346 Next period change will be calculated at 2021-10-30 23:59:55
2021.10.30 23:36:25.532 4: statistics statistic: PeriodChange.378 Calculating hour change
2021.10.30 23:36:25.532 4: statistics statistic: DoStatisticsAll.400 Doing statistics (period 1) for device 'at_stat'
2021.10.30 23:36:25.532 4: statistics statistic: doStatisticDuration.957 Calculating duration statistics for 'at_stat:state = Next: 23:46:14'
2021.10.30 23:46:14.511 4: statistics statistic: doStatisticDelta.708 Calculating delta statistics for 'at_stat:count = 1'
2021.10.30 23:46:14.511 4: statistics statistic: doStatisticDelta.724 Initializing statistic of '.at_stat:count'.
2021.10.30 23:46:14.513 4: statistics statistic: doStatisticDelta.708 Calculating delta statistics for 'at_stat:count = 1'
2021.10.30 23:56:14.516 4: statistics statistic: doStatisticDelta.708 Calculating delta statistics for 'at_stat:count = 2'
2021.10.30 23:56:14.517 4: statistics statistic: doStatisticDelta.708 Calculating delta statistics for 'at_stat:count = 2'
2021.10.30 23:59:55.053 4: statistics statistic: PeriodChange.346 Next period change will be calculated at 2021-10-31 00:59:55 (Day Change)
2021.10.30 23:59:55.053 4: statistics statistic: PeriodChange.378 Calculating hour change
2021.10.30 23:59:55.053 4: statistics statistic: DoStatisticsAll.400 Doing statistics (period 1) for device 'at_stat'
2021.10.30 23:59:55.053 4: statistics statistic: doStatisticDelta.708 Calculating delta statistics for 'at_stat:count = 2'
2021.10.30 23:59:55.053 4: statistics statistic: doStatisticDelta.792 Shifting current hour in last value of 'statCount'.
2021.10.30 23:59:55.053 4: statistics statistic: doStatisticDelta.812 Set 'statCountLast'='Hour: 1 Day: - Month: - Year: - (since: 2021-10-30_23:46:14 )'


fhem-2021-10-31.log

2021.10.31 00:06:14.511 4: statistics statistic: doStatisticDelta.708 Calculating delta statistics for 'at_stat:count = 3'
2021.10.31 00:06:14.513 4: statistics statistic: doStatisticDelta.708 Calculating delta statistics for 'at_stat:count = 3'
2021.10.31 00:16:14.512 4: statistics statistic: doStatisticDelta.708 Calculating delta statistics for 'at_stat:count = 4'
2021.10.31 00:16:14.514 4: statistics statistic: doStatisticDelta.708 Calculating delta statistics for 'at_stat:count = 4'
2021.10.31 00:26:14.522 4: statistics statistic: doStatisticDelta.708 Calculating delta statistics for 'at_stat:count = 5'
2021.10.31 00:26:14.523 4: statistics statistic: doStatisticDelta.708 Calculating delta statistics for 'at_stat:count = 5'
2021.10.31 00:36:14.523 4: statistics statistic: doStatisticDelta.708 Calculating delta statistics for 'at_stat:count = 6'
2021.10.31 00:36:14.524 4: statistics statistic: doStatisticDelta.708 Calculating delta statistics for 'at_stat:count = 6'
2021.10.31 00:46:14.519 4: statistics statistic: doStatisticDelta.708 Calculating delta statistics for 'at_stat:count = 7'
2021.10.31 00:46:14.520 4: statistics statistic: doStatisticDelta.708 Calculating delta statistics for 'at_stat:count = 7'
2021.10.31 00:56:14.507 4: statistics statistic: doStatisticDelta.708 Calculating delta statistics for 'at_stat:count = 8'
2021.10.31 00:56:14.509 4: statistics statistic: doStatisticDelta.708 Calculating delta statistics for 'at_stat:count = 8'
2021.10.31 00:59:55.002 4: statistics statistic: PeriodChange.346 Next period change will be calculated at 2021-10-31 01:59:55
2021.10.31 00:59:55.002 4: statistics statistic: PeriodChange.363 Calculating day change
2021.10.31 00:59:55.002 4: statistics statistic: DoStatisticsAll.400 Doing statistics (period 2) for device 'at_stat'
2021.10.31 00:59:55.002 4: statistics statistic: doStatisticDelta.708 Calculating delta statistics for 'at_stat:count = 8'
2021.10.31 00:59:55.002 4: statistics statistic: doStatisticDelta.783 Shifting current day in last value of 'statCount'.
2021.10.31 00:59:55.002 4: statistics statistic: doStatisticDelta.792 Shifting current hour in last value of 'statCount'.
2021.10.31 00:59:55.002 4: statistics statistic: doStatisticDelta.812 Set 'statCountLast'='Hour: 6 Day: 7 Month: - Year: - (since: 2021-10-30_23:46:14 )'
2021.10.31 01:06:14.515 4: statistics statistic: doStatisticDelta.708 Calculating delta statistics for 'at_stat:count = 9'
2021.10.31 01:06:14.517 4: statistics statistic: doStatisticDelta.708 Calculating delta statistics for 'at_stat:count = 9'
2021.10.31 01:16:14.523 4: statistics statistic: doStatisticDelta.708 Calculating delta statistics for 'at_stat:count = 10'
2021.10.31 01:16:14.524 4: statistics statistic: doStatisticDelta.708 Calculating delta statistics for 'at_stat:count = 10'
2021.10.31 01:26:14.526 4: statistics statistic: doStatisticDelta.708 Calculating delta statistics for 'at_stat:count = 11'
2021.10.31 01:26:14.527 4: statistics statistic: doStatisticDelta.708 Calculating delta statistics for 'at_stat:count = 11'
2021.10.31 01:36:14.516 4: statistics statistic: doStatisticDelta.708 Calculating delta statistics for 'at_stat:count = 12'
2021.10.31 01:36:14.517 4: statistics statistic: doStatisticDelta.708 Calculating delta statistics for 'at_stat:count = 12'
2021.10.31 01:46:14.527 4: statistics statistic: doStatisticDelta.708 Calculating delta statistics for 'at_stat:count = 13'
2021.10.31 01:46:14.528 4: statistics statistic: doStatisticDelta.708 Calculating delta statistics for 'at_stat:count = 13'
2021.10.31 01:56:14.528 4: statistics statistic: doStatisticDelta.708 Calculating delta statistics for 'at_stat:count = 14'
2021.10.31 01:56:14.529 4: statistics statistic: doStatisticDelta.708 Calculating delta statistics for 'at_stat:count = 14'
2021.10.31 01:59:55.002 4: statistics statistic: PeriodChange.346 Next period change will be calculated at 2021-10-31 02:59:55
2021.10.31 01:59:55.002 4: statistics statistic: PeriodChange.378 Calculating hour change
2021.10.31 01:59:55.002 4: statistics statistic: DoStatisticsAll.400 Doing statistics (period 1) for device 'at_stat'
2021.10.31 01:59:55.002 4: statistics statistic: doStatisticDelta.708 Calculating delta statistics for 'at_stat:count = 14'
2021.10.31 01:59:55.003 4: statistics statistic: doStatisticDelta.792 Shifting current hour in last value of 'statCount'.
2021.10.31 01:59:55.003 4: statistics statistic: doStatisticDelta.812 Set 'statCountLast'='Hour: 6 Day: 7 Month: - Year: - (since: 2021-10-30_23:46:14 )'
2021.10.31 02:06:14.529 4: statistics statistic: doStatisticDelta.708 Calculating delta statistics for 'at_stat:count = 15'
2021.10.31 02:06:14.530 4: statistics statistic: doStatisticDelta.708 Calculating delta statistics for 'at_stat:count = 15'
2021.10.31 02:16:14.516 4: statistics statistic: doStatisticDelta.708 Calculating delta statistics for 'at_stat:count = 16'
2021.10.31 02:16:14.517 4: statistics statistic: doStatisticDelta.708 Calculating delta statistics for 'at_stat:count = 16'
2021.10.31 02:26:14.516 4: statistics statistic: doStatisticDelta.708 Calculating delta statistics for 'at_stat:count = 17'
2021.10.31 02:26:14.517 4: statistics statistic: doStatisticDelta.708 Calculating delta statistics for 'at_stat:count = 17'
2021.10.31 02:36:14.532 4: statistics statistic: doStatisticDelta.708 Calculating delta statistics for 'at_stat:count = 18'
2021.10.31 02:36:14.534 4: statistics statistic: doStatisticDelta.708 Calculating delta statistics for 'at_stat:count = 18'
2021.10.31 02:46:14.533 4: statistics statistic: doStatisticDelta.708 Calculating delta statistics for 'at_stat:count = 19'
2021.10.31 02:46:14.534 4: statistics statistic: doStatisticDelta.708 Calculating delta statistics for 'at_stat:count = 19'
2021.10.31 02:56:14.512 4: statistics statistic: doStatisticDelta.708 Calculating delta statistics for 'at_stat:count = 20'
2021.10.31 02:56:14.513 4: statistics statistic: doStatisticDelta.708 Calculating delta statistics for 'at_stat:count = 20'
2021.10.31 02:59:55.005 4: statistics statistic: PeriodChange.346 Next period change will be calculated at 2021-10-31 02:59:55
2021.10.31 02:59:55.005 4: statistics statistic: PeriodChange.378 Calculating hour change
2021.10.31 02:59:55.005 4: statistics statistic: DoStatisticsAll.400 Doing statistics (period 1) for device 'at_stat'
2021.10.31 02:59:55.005 4: statistics statistic: doStatisticDelta.708 Calculating delta statistics for 'at_stat:count = 20'
2021.10.31 02:59:55.005 4: statistics statistic: doStatisticDelta.792 Shifting current hour in last value of 'statCount'.
2021.10.31 02:59:55.006 4: statistics statistic: doStatisticDelta.812 Set 'statCountLast'='Hour: 6 Day: 7 Month: - Year: - (since: 2021-10-30_23:46:14 )'
2021.10.31 02:06:14.535 4: statistics statistic: doStatisticDelta.708 Calculating delta statistics for 'at_stat:count = 21'
2021.10.31 02:06:14.536 4: statistics statistic: doStatisticDelta.708 Calculating delta statistics for 'at_stat:count = 21'
2021.10.31 02:16:14.513 4: statistics statistic: doStatisticDelta.708 Calculating delta statistics for 'at_stat:count = 22'
2021.10.31 02:16:14.514 4: statistics statistic: doStatisticDelta.708 Calculating delta statistics for 'at_stat:count = 22'




Log 3) Monatswechsel gepatcht
fhem-2021-10-31.log

2021.10.31 23:38:37.716 4: statistics statistic: PeriodChange.346 Next period change will be calculated at 2021-10-31 23:59:55
2021.10.31 23:38:37.716 4: statistics statistic: PeriodChange.380 Calculating statistics at startup
2021.10.31 23:38:37.716 4: statistics statistic: DoStatisticsAll.400 Doing statistics (period 0) for device 'at_stat'
2021.10.31 23:38:37.716 4: statistics statistic: doStatisticDelta.708 Calculating delta statistics for 'at_stat:count = 8'
2021.10.31 23:48:26.713 4: statistics statistic: doStatisticDelta.708 Calculating delta statistics for 'at_stat:count = 9'
2021.10.31 23:48:26.715 4: statistics statistic: doStatisticDelta.708 Calculating delta statistics for 'at_stat:count = 9'
2021.10.31 23:58:26.709 4: statistics statistic: doStatisticDelta.708 Calculating delta statistics for 'at_stat:count = 10'
2021.10.31 23:58:26.710 4: statistics statistic: doStatisticDelta.708 Calculating delta statistics for 'at_stat:count = 10'
2021.10.31 23:59:55.010 4: statistics statistic: PeriodChange.346 Next period change will be calculated at 2021-11-01 00:59:55
2021.10.31 23:59:55.010 4: statistics statistic: PeriodChange.378 Calculating hour change
2021.10.31 23:59:55.010 4: statistics statistic: DoStatisticsAll.400 Doing statistics (period 1) for device 'at_stat'
2021.10.31 23:59:55.010 4: statistics statistic: doStatisticDelta.708 Calculating delta statistics for 'at_stat:count = 10'
2021.10.31 23:59:55.010 4: statistics statistic: doStatisticDelta.792 Shifting current hour in last value of 'statCount'.
2021.10.31 23:59:55.011 4: statistics statistic: doStatisticDelta.812 Set 'statCountLast'='Hour: 2 Day: 7 Month: - Year: - (since: 2021-10-30_23:46:14 )'


fhem-2021-11-01.log

2021.11.01 00:08:26.716 4: statistics statistic: doStatisticDelta.708 Calculating delta statistics for 'at_stat:count = 11'
2021.11.01 00:08:26.718 4: statistics statistic: doStatisticDelta.708 Calculating delta statistics for 'at_stat:count = 11'
2021.11.01 00:18:26.714 4: statistics statistic: doStatisticDelta.708 Calculating delta statistics for 'at_stat:count = 12'
2021.11.01 00:18:26.715 4: statistics statistic: doStatisticDelta.708 Calculating delta statistics for 'at_stat:count = 12'

Beta-User

#44
Hmm, irgendwie nicht gut, finde ich...

Der gepatchte Tageswechsel findet zu spät statt, und der Monatswechsel fällt weiter aus - da müßte was stehen von "Shifting current month ...". Hatte irgendwie vorausgesetzt, dass statistics bzgl. der Tageswechsel in die Zukunft rechnet, aber das war wohl eine Fehlannahme. Das macht das ganze nochmal komplizierter, jedenfalls, wenn man nicht die ganze Logik auseinandernehmen will.

Anbei ein neuer Versuch, dieses Mal in Richtung Vergangenheit geschaut, mal sehen ob das klappt (falls jemand einen Logikfehler auch ohne die Testerei erkennen kann, ist mir eine direkte Korrektur übrigens lieber.).

Sorry für den Aufwand!


Server: HP-elitedesk@Debian 12, aktuelles FHEM@ConfigDB | CUL_HM (VCCU) | MQTT2: MiLight@ESP-GW, BT@OpenMQTTGw | MySensors: seriell, v.a. 2.3.1@RS485 | ZWave | ZigBee@deCONZ | SIGNALduino | MapleCUN | RHASSPY
svn: u.a MySensors, Weekday-&RandomTimer, Twilight,  div. attrTemplate-files