2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-04-20 13:26:02 +00:00

76_SolarForecast: contrib 0.82.4

git-svn-id: https://svn.fhem.de/fhem/trunk@27971 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
nasseeder1 2023-09-16 07:25:06 +00:00
parent 4b57c712eb
commit 4e75f22a46

View File

@ -139,6 +139,7 @@ BEGIN {
# Versions History intern # Versions History intern
my %vNotesIntern = ( my %vNotesIntern = (
"0.82.4" => "16.09.2023 generate DWD API graphis header information and extend plant check for DWD API errors ",
"0.82.3" => "14.09.2023 more mouse over information in graphic header, ai support in autocorrection selectable ". "0.82.3" => "14.09.2023 more mouse over information in graphic header, ai support in autocorrection selectable ".
"substitute use of Test2::Suite ", "substitute use of Test2::Suite ",
"0.82.2" => "11.09.2023 activate implementation of DWD AI support, add runTimeTrainAI ", "0.82.2" => "11.09.2023 activate implementation of DWD AI support, add runTimeTrainAI ",
@ -3252,9 +3253,11 @@ sub __getDWDSolarData {
my $stime = $date.' 00:00:00'; # Startzeit Soll Übernahmedaten my $stime = $date.' 00:00:00'; # Startzeit Soll Übernahmedaten
my $sts = timestringToTimestamp ($stime); my $sts = timestringToTimestamp ($stime);
my @strings = sort keys %{$data{$type}{$name}{strings}}; my @strings = sort keys %{$data{$type}{$name}{strings}};
my $ret = q{};
$data{$type}{$name}{solcastapi}{'?All'}{'?All'}{lastretrieval_time} = (timestampToTimestring ($t, $lang))[3]; # letzte Abrufzeit $data{$type}{$name}{solcastapi}{'?All'}{'?All'}{lastretrieval_time} = (timestampToTimestring ($t, $lang))[3]; # letzte Abrufzeit
$data{$type}{$name}{solcastapi}{'?All'}{'?All'}{lastretrieval_timestamp} = $t; $data{$type}{$name}{solcastapi}{'?All'}{'?All'}{lastretrieval_timestamp} = $t;
$data{$type}{$name}{solcastapi}{'?All'}{'?All'}{todayDoneAPIrequests} += 1;
debugLog ($paref, "apiCall", "DWD API - collect DWD Radiation data with start >$stime<- device: $raname =>"); debugLog ($paref, "apiCall", "DWD API - collect DWD Radiation data with start >$stime<- device: $raname =>");
@ -3269,15 +3272,16 @@ sub __getDWDSolarData {
my $rad = ReadingsVal ($raname, "fc${fd}_${runh}_Rad1h", undef); my $rad = ReadingsVal ($raname, "fc${fd}_${runh}_Rad1h", undef);
if (!defined $rad) { if (!defined $rad) {
my $ret = "The reading >fc${fd}_${runh}_Rad1h< doesn't exist. Check the device $raname !"; $ret = "The reading 'fc${fd}_${runh}_Rad1h' doesn't exist. Check the device $raname!";
debugLog ($paref, "apiCall", "DWD API - ERROR - got no data of starttime: $dateTime. The reading >fc${fd}_${runh}_Rad1h< doesn't exist. Check the device $raname !"); $data{$type}{$name}{solcastapi}{'?All'}{'?All'}{response_message} = $ret;
$data{$type}{$name}{solcastapi}{'?All'}{'?All'}{response_message} = 'reading fc${fd}_${runh}_Rad1h and/or device >$raname< problem'; debugLog ($paref, "apiCall", "DWD API - ERROR - got no data of starttime: $dateTime. ".$ret);
return $ret; $rad = 0;
} }
else {
debugLog ($paref, "apiCall", "DWD API - got data -> starttime: $dateTime, reading: fc${fd}_${runh}_Rad1h, rad: $rad"); debugLog ($paref, "apiCall", "DWD API - got data -> starttime: $dateTime, reading: fc${fd}_${runh}_Rad1h, rad: $rad");
}
$data{$type}{$name}{solcastapi}{'?All'}{$dateTime}{Rad1h} = $rad; $data{$type}{$name}{solcastapi}{'?All'}{$dateTime}{Rad1h} = $rad;
@ -3294,10 +3298,9 @@ sub __getDWDSolarData {
$data{$type}{$name}{solcastapi}{$string}{$dateTime}{pv_estimate50} = $pv; $data{$type}{$name}{solcastapi}{$string}{$dateTime}{pv_estimate50} = $pv;
} }
} }
$data{$type}{$name}{solcastapi}{'?All'}{'?All'}{response_message} = 'success'; $data{$type}{$name}{solcastapi}{'?All'}{'?All'}{response_message} = 'success' if(!$ret);
return; return;
} }
@ -8571,6 +8574,7 @@ sub _graphicHeader {
my $api = isSolCastUsed ($hash) ? 'SolCast:' : my $api = isSolCastUsed ($hash) ? 'SolCast:' :
isForecastSolarUsed ($hash) ? 'Forecast.Solar:' : isForecastSolarUsed ($hash) ? 'Forecast.Solar:' :
isVictronKiUsed ($hash) ? 'VictronVRM:' : isVictronKiUsed ($hash) ? 'VictronVRM:' :
isDWDUsed ($hash) ? 'DWD:' :
q{}; q{};
my $nscc = ReadingsVal ($name, 'nextSolCastCall', '?'); my $nscc = ReadingsVal ($name, 'nextSolCastCall', '?');
@ -8659,6 +8663,26 @@ sub _graphicHeader {
$api .= ')'; $api .= ')';
$api .= '</span>'; $api .= '</span>';
} }
elsif ($api eq 'DWD:') {
$nscc = ReadingsVal ($name, 'nextCycletime', '?');
$api .= '&nbsp;'.$lrt;
if ($scrm eq 'success') {
$img = FW_makeImage('10px-kreis-gruen.png', $htitles{scaresps}{$lang}.'&#10;'.$htitles{natc}{$lang}.' '.$nscc);
}
else {
$img = FW_makeImage('10px-kreis-rot.png', $htitles{scarespf}{$lang}.': '. $scrm);
}
$scicon = "<a>$img</a>";
$api .= '&nbsp;&nbsp;'.$scicon;
$api .= '<span title="'.$htitles{dapic}{$lang}.'">';
$api .= '&nbsp;&nbsp;(';
$api .= SolCastAPIVal ($hash, '?All', '?All', 'todayDoneAPIrequests', 0);
$api .= ')';
$api .= '</span>';
}
## Qualitäts-Icon ## Qualitäts-Icon
###################### ######################
@ -11589,6 +11613,7 @@ sub checkPlantConfig {
my $lang = AttrVal ($name, 'ctrlLanguage', AttrVal ('global', 'language', $deflang)); my $lang = AttrVal ($name, 'ctrlLanguage', AttrVal ('global', 'language', $deflang));
my $pcf = ReadingsVal ($name, 'pvCorrectionFactor_Auto', ''); my $pcf = ReadingsVal ($name, 'pvCorrectionFactor_Auto', '');
my $raname = ReadingsVal ($name, 'currentRadiationDev', '');
my $acu = isAutoCorrUsed ($name); my $acu = isAutoCorrUsed ($name);
my $cf = 0; # config fault: 1 -> Konfig fehlerhaft, 0 -> Konfig ok my $cf = 0; # config fault: 1 -> Konfig fehlerhaft, 0 -> Konfig ok
@ -11693,8 +11718,6 @@ sub checkPlantConfig {
$result->{'DWD Radiation Attributes'}{note} = ''; $result->{'DWD Radiation Attributes'}{note} = '';
$result->{'DWD Radiation Attributes'}{fault} = 0; $result->{'DWD Radiation Attributes'}{fault} = 0;
my $raname = ReadingsVal($name, 'currentRadiationDev', '');
if (!$raname || !$defs{$raname}) { if (!$raname || !$defs{$raname}) {
$result->{'DWD Radiation Attributes'}{state} = $nok; $result->{'DWD Radiation Attributes'}{state} = $nok;
$result->{'DWD Radiation Attributes'}{result} .= qq{The DWD device "$raname" doesn't exist <br>}; $result->{'DWD Radiation Attributes'}{result} .= qq{The DWD device "$raname" doesn't exist <br>};
@ -11882,6 +11905,8 @@ sub checkPlantConfig {
## allg. Settings bei Nutzung DWD API ## allg. Settings bei Nutzung DWD API
####################################### #######################################
if (isDWDUsed ($hash)) { if (isDWDUsed ($hash)) {
my $lam = SolCastAPIVal ($hash, '?All', '?All', 'response_message', 'success');
if ($aidtabs) { if ($aidtabs) {
$result->{'Common Settings'}{state} = $info; $result->{'Common Settings'}{state} = $info;
$result->{'Common Settings'}{result} .= qq{The Perl module AI::DecisionTree is missing. <br>}; $result->{'Common Settings'}{result} .= qq{The Perl module AI::DecisionTree is missing. <br>};
@ -11895,6 +11920,15 @@ sub checkPlantConfig {
$result->{'Common Settings'}{note} .= qq{Set pvCorrectionFactor_Auto to "on*" if an automatic adjustment of the prescaler data should be done.<br>}; $result->{'Common Settings'}{note} .= qq{Set pvCorrectionFactor_Auto to "on*" if an automatic adjustment of the prescaler data should be done.<br>};
} }
if ($lam ne 'success') {
$result->{'API Access'}{state} = $nok;
$result->{'API Access'}{result} .= qq{DWD last message:<br>"$lam"<br>};
$result->{'API Access'}{note} .= qq{Check the setup of the device "$raname". <br>};
$result->{'API Access'}{note} .= qq{It is possible that not all readings are transmitted when "$raname" is newly set up. <br>};
$result->{'API Access'}{note} .= qq{In this case, wait until tomorrow and check again.<br>};
$result->{'API Access'}{fault} = 1;
}
if (!$result->{'Common Settings'}{fault} && !$result->{'Common Settings'}{warn} && !$result->{'Common Settings'}{info}) { if (!$result->{'Common Settings'}{fault} && !$result->{'Common Settings'}{warn} && !$result->{'Common Settings'}{info}) {
$result->{'Common Settings'}{result} = $hqtxt{fulfd}{$lang}; $result->{'Common Settings'}{result} = $hqtxt{fulfd}{$lang};
$result->{'Common Settings'}{note} .= qq{checked parameters: <br>}; $result->{'Common Settings'}{note} .= qq{checked parameters: <br>};
@ -14188,7 +14222,7 @@ die ordnungsgemäße Anlagenkonfiguration geprüft werden.
Eine zusätzliche Autokorrektur wird nicht empfohlen, d.h. die empfohlene Autokorrekturmethode ist <b>off</b>. <br><br> Eine zusätzliche Autokorrektur wird nicht empfohlen, d.h. die empfohlene Autokorrekturmethode ist <b>off</b>. <br><br>
<b>Model DWD:</b> <br> <b>Model DWD:</b> <br>
Die empfohlene Autokorrekturmethode ist <b>on_complex</b>. <br><br> Die empfohlene Autokorrekturmethode ist <b>on_complex</b> bzw. <b>on_complex_ai</b>. <br><br>
<b>Model ForecastSolarAPI:</b> <br> <b>Model ForecastSolarAPI:</b> <br>
Die empfohlene Autokorrekturmethode ist <b>on_simple</b>. Die empfohlene Autokorrekturmethode ist <b>on_simple</b>.