From 3844d3c12910186c39492b20e97a695be6bf1098 Mon Sep 17 00:00:00 2001 From: nasseeder1 Date: Sun, 30 Oct 2022 12:13:52 +0000 Subject: [PATCH] 76_SolarForecast.pm: contrib 0.72.1 git-svn-id: https://svn.fhem.de/fhem/trunk@26623 2b470e98-0d58-463d-a4d8-8e2adae1ed80 --- fhem/contrib/DS_Starter/76_SolarForecast.pm | 36 +++++++++++++++++---- 1 file changed, 29 insertions(+), 7 deletions(-) diff --git a/fhem/contrib/DS_Starter/76_SolarForecast.pm b/fhem/contrib/DS_Starter/76_SolarForecast.pm index 6a0931d96..9cc755fd4 100644 --- a/fhem/contrib/DS_Starter/76_SolarForecast.pm +++ b/fhem/contrib/DS_Starter/76_SolarForecast.pm @@ -130,6 +130,7 @@ BEGIN { # Versions History intern my %vNotesIntern = ( + "0.72.1" => "30.10.2022 fix 'connection lost ...' issue again ", "0.72.0" => "30.10.2022 rename some graphic attributes ", "0.71.4" => "29.10.2022 flowgraphic some changes (https://forum.fhem.de/index.php/topic,117864.msg1241836.html#msg1241836) ", "0.71.3" => "28.10.2022 new circular keys tdayDvtn, ydayDvtn for calculation PV forecast/generation in header ", @@ -2993,6 +2994,7 @@ sub centralTask { my $cst = [gettimeofday]; # Zyklus-Startzeit RemoveInternalTimer($hash, "FHEM::SolarForecast::centralTask"); + RemoveInternalTimer($hash, "FHEM::SolarForecast::_writeState"); ### nicht mehr benötigte Readings/Daten löschen - kann später wieder raus !! #for my $i (keys %{$data{$type}{$name}{pvhist}}) { @@ -3021,9 +3023,11 @@ sub centralTask { setModel ($hash); # Model setzen if($init_done == 1) { + my @da; + if(!$interval) { $hash->{MODE} = "Manual"; - readingsSingleUpdate($hash, 'nextCycletime', 'Manual', 1); + push @da, "nextCycletime<>Manual"; } else { my $new = gettimeofday()+$interval; @@ -3031,7 +3035,7 @@ sub centralTask { if(!IsDisabled($name)) { $hash->{MODE} = "Automatic - next Cycletime: ".FmtTime($new); - readingsSingleUpdate($hash, 'nextCycletime', FmtTime($new), 1); + push @da, "nextCycletime<>".FmtTime($new); } } @@ -3045,7 +3049,6 @@ sub centralTask { return; } - my @da; my $t = time; # aktuelle Unix-Zeit my $date = strftime "%Y-%m-%d", localtime($t); # aktuelles Datum my $chour = strftime "%H", localtime($t); # aktuelle Stunde @@ -3105,12 +3108,18 @@ sub centralTask { saveEnergyConsumption ($centpars); # Energie Hausverbrauch speichern - readingsSingleUpdate ($hash, 'state', $centpars->{state}, 1); # Abschluß state setTimeTracking ($hash, $cst, 'runTimeCentralTask'); # Zyklus-Laufzeit ermitteln genStatisticReadings ($centpars); # optionale Statistikreadings erstellen createReadingsFromArray ($hash, \@da, $evt); # Readings erzeugen + + if ($evt) { + InternalTimer(gettimeofday()+1, "FHEM::SolarForecast::_writeState", $centpars, 0); + } + else { + _writeState ($centpars); + } } else { InternalTimer(gettimeofday()+5, "FHEM::SolarForecast::centralTask", $hash, 0); @@ -3119,6 +3128,18 @@ sub centralTask { return; } +################################################################ +# "state" updaten +################################################################ +sub _writeState { + my $paref = shift; + my $hash = $paref->{hash}; + + readingsSingleUpdate ($hash, 'state', $paref->{state}, 1); # Abschluß state + +return; +} + ################################################################ # Erstellen der Stringkonfiguration # Stringhash: $data{$type}{$name}{strings} @@ -6168,7 +6189,9 @@ sub FwFn { RemoveInternalTimer($hash, \&pageRefresh); $hash->{HELPER}{FW} = $FW_wname; - my $ret = entryGraphic ($name); + my $ret = ""; + $ret .= entryGraphic ($name); + $ret .= ""; # Autorefresh nur des aufrufenden FHEMWEB-Devices my $al = AttrVal($name, "autoRefresh", 0); @@ -6296,7 +6319,6 @@ sub entryGraphic { $ret .= "$dlink
" if(AttrVal($name,"showLink",0)); - $ret .= ""; $ret .= $html_start if (defined($html_start)); $ret .= ""; $ret .= ""; @@ -6391,7 +6413,6 @@ sub entryGraphic { $ret .= ""; $ret .= "
"; $ret .= $html_end if (defined($html_end)); - $ret .= ""; return $ret; } @@ -6629,6 +6650,7 @@ sub _graphicHeader { my $naup = ReadingsVal ($name, 'nextCycletime', ''); if ($upstate =~ /updated|successfully|switched/ix) { $img = FW_makeImage('10px-kreis-gruen.png', $htitles{upd}{$lang}.' ('.$htitles{natc}{$lang}.' '.$naup.')'); + #$img = FW_makeImage('10px-kreis-gruen.png', $htitles{upd}{$lang}); $upicon = "$img"; } elsif ($upstate =~ /running/ix) {