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

76_SolarForecast: attr ctrlInterval: immediate impact when set

git-svn-id: https://svn.fhem.de/fhem/trunk@28841 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
nasseeder1 2024-05-06 19:23:55 +00:00
parent 0ace63c02b
commit b5bd45a36b
2 changed files with 29 additions and 8 deletions

View File

@ -1,5 +1,6 @@
# Add changes at the top of the list. Keep it in ASCII, and 80-char wide. # 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 # 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 - bugfix: 74_GardenaSmartDevice: fix patch code scheduling by hhhdg
- feature: 74_AutomowerConnect.pm: new mower schedule editor - feature: 74_AutomowerConnect.pm: new mower schedule editor
- bugfix: 76_SolarForecast: possible Illegal division by zero if Attr - bugfix: 76_SolarForecast: possible Illegal division by zero if Attr

View File

@ -158,6 +158,7 @@ BEGIN {
# Versions History intern # Versions History intern
my %vNotesIntern = ( 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.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.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 ", "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)) { if (!isSolCastUsed ($hash)) {
return qq{The attribute $aName is only valid for device model "SolCastAPI".}; 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'); ($err) = checkCode ($name, $aVal, 'cc1');
return $err if($err); 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 = { my $params = {
@ -6149,12 +6157,7 @@ sub runTask {
my $nct = CurrentVal ($hash, 'nextCycleTime', 0); # gespeicherte nächste CyleTime my $nct = CurrentVal ($hash, 'nextCycleTime', 0); # gespeicherte nächste CyleTime
if ($t >= $nct) { if ($t >= $nct) {
my $new = $t + $interval; # nächste Wiederholungszeit _newCycTime ($hash, $t, $interval);
$hash->{MODE} = 'Automatic - next Cycletime: '.FmtTime($new);
$data{$hash->{TYPE}}{$name}{current}{nextCycleTime} = $new;
storeReading ('nextCycletime', FmtTime($new));
centralTask ($hash, 1); centralTask ($hash, 1);
} }
@ -6193,6 +6196,23 @@ sub runTask {
return; 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 # neue Attribute zur Laufzeit hinzufügen
# Device spezifische ".AttrList" überschreibt Modul AttrList ! # Device spezifische ".AttrList" überschreibt Modul AttrList !