2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-02-25 16:05:19 +00:00

76_SolarForecast.pm: contrib 0.68.4

git-svn-id: https://svn.fhem.de/fhem/trunk@26460 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
nasseeder1 2022-10-01 19:08:04 +00:00
parent 07de99149f
commit fd7869d5fc

View File

@ -126,6 +126,7 @@ BEGIN {
# Versions History intern # Versions History intern
my %vNotesIntern = ( my %vNotesIntern = (
"0.68.4 "=> "01.10.2022 do ___setLastAPIcallKeyData if response_status, generate events of Today_MaxPVforecast.* in every cycle ",
"0.68.3 "=> "19.09.2022 fix calculation of currentAPIinterval ", "0.68.3 "=> "19.09.2022 fix calculation of currentAPIinterval ",
"0.68.2 "=> "18.09.2022 fix function _setpvCorrectionFactorAuto, new attr optimizeSolCastAPIreqInterval, change createReadingsFromArray ", "0.68.2 "=> "18.09.2022 fix function _setpvCorrectionFactorAuto, new attr optimizeSolCastAPIreqInterval, change createReadingsFromArray ",
"0.68.1 "=> "17.09.2022 new readings Today_MaxPVforecast, Today_MaxPVforecastTime ", "0.68.1 "=> "17.09.2022 new readings Today_MaxPVforecast, Today_MaxPVforecastTime ",
@ -1843,6 +1844,7 @@ sub __solCast_ApiResponse {
my $allstrings = $paref->{allstrings}; my $allstrings = $paref->{allstrings};
my $type = $hash->{TYPE}; my $type = $hash->{TYPE};
my $t = time;
my ($msg,$starttmstr); my ($msg,$starttmstr);
@ -1887,6 +1889,8 @@ sub __solCast_ApiResponse {
Log3 ($name, 3, "$name - $msg"); Log3 ($name, 3, "$name - $msg");
___setLastAPIcallKeyData ($hash, $t);
$data{$type}{$name}{solcastapi}{'?All'}{'?All'}{response_message} = $jdata->{'response_status'}{'message'}; $data{$type}{$name}{solcastapi}{'?All'}{'?All'}{response_message} = $jdata->{'response_status'}{'message'};
readingsSingleUpdate($hash, "state", $msg, 1); readingsSingleUpdate($hash, "state", $msg, 1);
return; return;
@ -1952,7 +1956,6 @@ sub __solCast_ApiResponse {
} }
} }
my $t = time;
___setLastAPIcallKeyData ($hash, $t); ___setLastAPIcallKeyData ($hash, $t);
$data{$type}{$name}{solcastapi}{'?All'}{'?All'}{response_message} = 'success'; $data{$type}{$name}{solcastapi}{'?All'}{'?All'}{response_message} = 'success';
@ -2062,6 +2065,7 @@ sub ___setLastAPIcallKeyData {
my $lang = AttrVal ('global', 'language', 'EN'); my $lang = AttrVal ('global', 'language', 'EN');
my $apiitv = SolCastAPIVal ($hash, '?All', '?All', 'currentAPIinterval', $apirepetdef); my $apiitv = SolCastAPIVal ($hash, '?All', '?All', 'currentAPIinterval', $apirepetdef);
readingsSingleUpdate($hash, 'nextSolCastCall', $hqtxt{after}{$lang}.' '.(timestampToTimestring ($t + $apiitv))[0], 1); readingsSingleUpdate($hash, 'nextSolCastCall', $hqtxt{after}{$lang}.' '.(timestampToTimestring ($t + $apiitv))[0], 1);
return; return;
@ -3582,20 +3586,29 @@ sub _calcMaxEstimateToday {
return if (!keys %{$data{$type}{$name}{nexthours}}); return if (!keys %{$data{$type}{$name}{nexthours}});
my $maxest = ReadingsNum($name, 'Today_MaxPVforecast', 0); my $maxest = ReadingsNum($name, 'Today_MaxPVforecast', 0);
my $maxtim = ReadingsVal($name, 'Today_MaxPVforecastTime', '-');
my $doold = 1;
for my $idx (sort keys %{$data{$type}{$name}{nexthours}}) { for my $idx (sort keys %{$data{$type}{$name}{nexthours}}) {
next if(!NexthoursVal ($hash, $idx, 'today', 0)); next if(!NexthoursVal ($hash, $idx, 'today', 0));
my $pvfc = NexthoursVal ($hash, $idx, 'pvforecast', 0); my $pvfc = NexthoursVal ($hash, $idx, 'pvforecast', 0);
next if($pvfc <= $maxest); next if($pvfc < $maxest);
my $stt = NexthoursVal ($hash, $idx, 'starttime', ''); my $stt = NexthoursVal ($hash, $idx, 'starttime', '');
next if(!$stt); next if(!$stt);
$doold = 0;
push @$daref, "Today_MaxPVforecast<>". $pvfc." Wh"; push @$daref, "Today_MaxPVforecast<>". $pvfc." Wh";
push @$daref, "Today_MaxPVforecastTime<>". $stt; push @$daref, "Today_MaxPVforecastTime<>". $stt;
} }
if ($doold) {
push @$daref, "Today_MaxPVforecast<>". $maxest." Wh";
push @$daref, "Today_MaxPVforecastTime<>". $maxtim;
}
return; return;
} }