2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-03-03 10:46:53 +00:00

76_SolarForecast.pm: contrib 0.56.8

git-svn-id: https://svn.fhem.de/fhem/trunk@25118 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
nasseeder1 2021-10-25 18:02:05 +00:00
parent e354b8887a
commit 54e6a065ea
2 changed files with 85 additions and 60 deletions

View File

@ -120,6 +120,7 @@ BEGIN {
# Versions History intern
my %vNotesIntern = (
"0.56.8" => "25.10.2021 change func ___csmSpecificEpieces as proposed from Max : https://forum.fhem.de/index.php/topic,117864.msg1180452.html#msg1180452 ",
"0.56.7" => "18.10.2021 new attr flowGraphicShowConsumerDummy ",
"0.56.6" => "19.09.2021 bug fix ",
"0.56.5" => "16.09.2021 fix sub ___csmSpecificEpieces (rows 2924-2927) ",
@ -2900,14 +2901,24 @@ sub ___csmSpecificEpieces {
my $name = $paref->{name};
my $c = $paref->{consumer};
my $etot = $paref->{etot};
my $t = $paref->{t};
my $type = $hash->{TYPE};
if(ConsumerVal ($hash, $c, "onoff", "off") eq "on") {
if(ConsumerVal ($hash, $c, "onoff", "off") eq "on") { # Status "Aus" verzögern um Pausen im Waschprogramm zu überbrücken
$data{$type}{$name}{consumers}{$c}{lastOnTime} = $t;
}
my $offTime = defined $data{$type}{$name}{consumers}{$c}{lastOnTime} ?
$t - $data{$type}{$name}{consumers}{$c}{lastOnTime} :
99;
if($offTime < 300) { # erst nach 60s ist das Gerät aus
my $epiecHist = "";
my $epiecHist_hours = "";
if(ConsumerVal ($hash, $c, "epiecHour", 0) < 0) { #neue Aufzeichnung
if(ConsumerVal ($hash, $c, "epiecHour", -1) < 0) { # neue Aufzeichnung
$data{$type}{$name}{consumers}{$c}{epiecStartTime} = $t;
$data{$type}{$name}{consumers}{$c}{epiecHist} += 1;
$data{$type}{$name}{consumers}{$c}{epiecHist} = 1 if(ConsumerVal ($hash, $c, "epiecHist", 0) > $epiecHCounts);
@ -2915,11 +2926,11 @@ sub ___csmSpecificEpieces {
delete $data{$type}{$name}{consumers}{$c}{$epiecHist}; # Löschen, wird neu erfasst
}
$epiecHist = "epiecHist_".ConsumerVal ($hash, $c, "epiecHist", 0);
$epiecHist = "epiecHist_".ConsumerVal ($hash, $c, "epiecHist", 0); # Namen fürs Speichern
$epiecHist_hours = "epiecHist_".ConsumerVal ($hash, $c, "epiecHist", 0)."_hours";
my $epiecHour = floor (ConsumerVal ($hash, $c, "minutesOn", 0) / 60) + 1;
my $epiecHour = floor (($t - ConsumerVal ($hash, $c, "epiecStartTime", $t)) / 60 / 60) + 1; # aktuelle Betriebsstunde ermitteln, ( / 60min) mögliche wäre auch durch 15min /Minute /Stunde
if(ConsumerVal ($hash, $c, "epiecHour", 0) != $epiecHour) {
if(ConsumerVal ($hash, $c, "epiecHour", 0) != $epiecHour) { # Stundenwechsel? Differenz von etot noch auf die vorherige Stunde anrechnen
my $epiecHour_last = $epiecHour - 1;
$data{$type}{$name}{consumers}{$c}{$epiecHist}{$epiecHour_last} = $etot - ConsumerVal ($hash, $c, "epiecEstart", 0) if($epiecHour > 1);
@ -2929,13 +2940,13 @@ sub ___csmSpecificEpieces {
my $ediff = $etot - ConsumerVal ($hash, $c, "epiecEstart", 0);
$data{$type}{$name}{consumers}{$c}{$epiecHist}{$epiecHour} = $ediff;
$data{$type}{$name}{consumers}{$c}{epiecHour} = $epiecHour;
$data{$type}{$name}{consumers}{$c}{$epiecHist_hours} = $ediff ? $epiecHour : 0;
$data{$type}{$name}{consumers}{$c}{$epiecHist_hours} = $ediff ? $epiecHour : $epiecHour - 1; # wenn mehr als 1 Wh verbraucht wird die Stunde gezählt
}
else { # Durchschnitt ermitteln
if(ConsumerVal ($hash, $c, "epiecHour", 0) > 0) { # Durchschnittliche Stunden ermitteln
my $hours = 0;
for my $h (1..$epiecHCounts) {
for my $h (1..$epiecHCounts) { # durchschnittliche Stunden über alle epieces ermitteln und aufrunden
$hours += ConsumerVal ($hash, $c, "epiecHist_".$h."_hours", 0);
}
@ -2943,18 +2954,27 @@ sub ___csmSpecificEpieces {
$data{$type}{$name}{consumers}{$c}{epiecAVG_hours} = $hours;
delete $data{$type}{$name}{consumers}{$c}{epiecAVG}; # Durchschnitt für epics ermitteln
for my $hour (1..$hours) {
for my $h (1..$epiecHCounts) {
for my $hour (1..$hours) { # jede Stunde durchlaufen
my $hoursE = 1;
for my $h (1..$epiecHCounts) { # jedes epiec durchlaufen
my $epiecHist = "epiecHist_".$h;
if(defined $data{$type}{$name}{consumers}{$c}{$epiecHist}{$hour}) {
if($data{$type}{$name}{consumers}{$c}{$epiecHist}{$hour} > 5) {
$data{$type}{$name}{consumers}{$c}{epiecAVG}{$hour} += $data{$type}{$name}{consumers}{$c}{$epiecHist}{$hour};
}
$data{$type}{$name}{consumers}{$c}{epiecAVG}{$hour} = $data{$type}{$name}{consumers}{$c}{epiecAVG}{$hour} / $epiecHCounts;
$hoursE += 1;
}
}
$data{$type}{$name}{consumers}{$c}{epiecHour} = -1;
}
$data{$type}{$name}{consumers}{$c}{epiecAVG}{$hour} = sprintf('%.2f',$data{$type}{$name}{consumers}{$c}{epiecAVG}{$hour} / $hoursE); # Durchschnitt ermittelt und in epiecAVG schreiben
}
}
$data{$type}{$name}{consumers}{$c}{epiecHour} = -1; # epiecHour auf initialwert setzen für nächsten durchlauf
}
return;

View File

@ -36,6 +36,7 @@ eval "use FHEM::Meta;1" or my $modMetaAbsent = 1;
# Versions History by DS_Starter
our %SMAEM_vNotesIntern = (
"4.3.1" => "25.10.2021 compatibility to Softwareversion 2.07.5.R ",
"4.3.0" => "06.12.2020 attribute serialNumber may contain multiple serial numbers, extend logging with serial number ",
"4.2.0" => "14.04.2020 delete 'use bignum' ",
"4.1.0" => "17.03.2020 add define option <interface> ",
@ -380,6 +381,10 @@ sub SMAEM_Read {
$socket->recv($data, 656);
my $dl = length($data);
if(substr(unpack('H*', $data), 32, 4) ne "6069") { # ab Softwareversion 2.07.5.R nötig - https://forum.fhem.de/index.php/topic,51569.msg1181952.html#msg1181952
return;
}
if($dl == 600) { # Each SMAEM packet is 600 bytes of packed payload
$model = "EM / HM 2.0 < 2.03.4.R";
}