diff --git a/fhem/CHANGED b/fhem/CHANGED index 26587bf1a..6e43796ee 100644 --- a/fhem/CHANGED +++ b/fhem/CHANGED @@ -1,5 +1,6 @@ # Add changes at the top of the list. Keep it in ASCII, and 80-char wide. # Do not insert empty lines here, update check depends on it + - change: 76_SolarForecast: attr ctrlInterval: immediate impact when set - bugfix: 74_GardenaSmartDevice: fix patch code scheduling by hhhdg - feature: 74_AutomowerConnect.pm: new mower schedule editor - bugfix: 76_SolarForecast: possible Illegal division by zero if Attr diff --git a/fhem/FHEM/76_SolarForecast.pm b/fhem/FHEM/76_SolarForecast.pm index eff8a68a5..aa9671192 100644 --- a/fhem/FHEM/76_SolarForecast.pm +++ b/fhem/FHEM/76_SolarForecast.pm @@ -158,6 +158,7 @@ BEGIN { # Versions History intern my %vNotesIntern = ( + "1.17.12"=> "06.05.2024 attr ctrlInterval: immediate impact when set ", "1.17.11"=> "04.05.2024 correction in commandref, delete attr affectMaxDayVariance ", "1.17.10"=> "19.04.2024 calcTodayPVdeviation: avoid Illegal division by zero, Forum: https://forum.fhem.de/index.php?msg=1311121 ", "1.17.9" => "17.04.2024 _batSocTarget: fix Illegal division by zero, Forum: https://forum.fhem.de/index.php?msg=1310930 ", @@ -5379,16 +5380,23 @@ sub Attr { } } - if ($init_done == 1 && $aName eq "ctrlSolCastAPIoptimizeReq") { + if ($init_done && $aName eq 'ctrlSolCastAPIoptimizeReq') { if (!isSolCastUsed ($hash)) { return qq{The attribute $aName is only valid for device model "SolCastAPI".}; } } - if ($aName eq 'ctrlUserExitFn' && $init_done) { + if ($init_done && $aName eq 'ctrlUserExitFn') { ($err) = checkCode ($name, $aVal, 'cc1'); return $err if($err); } + + if ($init_done && $aName eq 'ctrlInterval') { + _newCycTime ($hash, time, $aVal); + my $nct = CurrentVal ($hash, 'nextCycleTime', 0); # gespeicherte nächste CyleTime + readingsSingleUpdate ($hash, 'nextCycletime', FmtTime($nct), 0); + return; + } } my $params = { @@ -6149,12 +6157,7 @@ sub runTask { my $nct = CurrentVal ($hash, 'nextCycleTime', 0); # gespeicherte nächste CyleTime if ($t >= $nct) { - my $new = $t + $interval; # nächste Wiederholungszeit - $hash->{MODE} = 'Automatic - next Cycletime: '.FmtTime($new); - - $data{$hash->{TYPE}}{$name}{current}{nextCycleTime} = $new; - - storeReading ('nextCycletime', FmtTime($new)); + _newCycTime ($hash, $t, $interval); centralTask ($hash, 1); } @@ -6193,6 +6196,23 @@ sub runTask { return; } +################################################################ +# neue Zykluszeit bestimmen +################################################################ +sub _newCycTime { + my $hash = shift; + my $t = shift; + my $interval = shift; + + my $new = $t + $interval; # nächste Wiederholungszeit + $hash->{MODE} = 'Automatic - next Cycletime: '.FmtTime($new); + + $data{$hash->{TYPE}}{$hash->{NAME}}{current}{nextCycleTime} = $new; + storeReading ('nextCycletime', FmtTime($new)); + +return; +} + ################################################################ # neue Attribute zur Laufzeit hinzufügen # Device spezifische ".AttrList" überschreibt Modul AttrList !