2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-04-04 17:08:43 +00:00

76_SolarForecast: contrib 1.49.5

git-svn-id: https://svn.fhem.de/fhem/trunk@29810 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
nasseeder1 2025-03-30 21:13:03 +00:00
parent 5b6e2e20e7
commit c8ab9192fa

View File

@ -6281,28 +6281,22 @@ sub _attraiControl { ## no critic "not used"
my $name = $paref->{name};
my $aVal = $paref->{aVal};
my $cmd = $paref->{cmd};
my $valid = {
aiStorageDuration => { comp => '\d+', act => 0 },
aiTrainStart => { comp => '(1?[1-9]|10|2[0-3])', act => 0 },
aiTreesPV => { comp => '(1?[1-9]|10|[2-4][0-9]|50)', act => 0 },
};
my $hash = $defs{$name};
for my $av ( qw( aiStorageDuration
aiTrainStart
aiTreesPV
) ) {
for my $av (keys %{$valid}) {
delete $data{$name}{current}{$av};
}
my ($a, $h) = parseParams ($aVal);
if ($cmd eq 'set') {
my $valid = {
aiStorageDuration => '\d+',
aiTrainStart => '(1?[1-9]|10|2[0-3])',
aiTreesPV => '(1?[1-9]|10|[2-4][0-9]|50)',
};
my ($a, $h) = parseParams ($aVal);
for my $key (keys %{$h}) {
my $comp = $valid->{$key};
my $comp = $valid->{$key}{comp};
next if(!$comp);
if ($h->{$key} =~ /^$comp$/xs) {
@ -6313,6 +6307,18 @@ sub _attraiControl { ## no critic "not used"
}
}
}
for my $akey (keys %{$h}) { # von bestimmten Schlüsseln abhängige Aktionen ausführen
next if(!$valid->{$akey}{act});
$paref->{akey} = $akey;
$paref->{keyval} = $h->{$akey};
__attrKeyAction ($paref);
delete $paref->{keyval};
delete $paref->{akey};
}
return;
}
@ -6325,36 +6331,27 @@ sub _attrplantControl { ## no critic "not used"
my $name = $paref->{name};
my $aVal = $paref->{aVal};
my $cmd = $paref->{cmd};
my $hash = $defs{$name};
for my $av ( qw( backupFilesKeep
batteryPreferredCharge
consForecastIdentWeekdays
consForecastLastDays
consForecastInPlanning
feedinPowerLimit
showLink
) ) {
my $valid = {
backupFilesKeep => { comp => '\d+', act => 0 },
batteryPreferredCharge => { comp => '([0-9]|[1-9][0-9]|100)', act => 0 },
consForecastIdentWeekdays => { comp => '(0|1)', act => 0 },
consForecastLastDays => { comp => '([1-9]|[1-9][0-9]|1[0-7][0-9]|180)', act => 0 },
consForecastInPlanning => { comp => '(0|1)', act => 0 },
feedinPowerLimit => { comp => '\d+', act => 0 },
interval => { comp => '\d+', act => 1 },
showLink => { comp => '(0|1)', act => 0 },
};
for my $av (keys %{$valid}) {
delete $data{$name}{current}{$av};
}
my ($a, $h) = parseParams ($aVal);
if ($cmd eq 'set') {
my $valid = {
backupFilesKeep => '\d+',
batteryPreferredCharge => '([0-9]|[1-9][0-9]|100)',
consForecastIdentWeekdays => '(0|1)',
consForecastLastDays => '([1-9]|[1-9][0-9]|1[0-7][0-9]|180)',
consForecastInPlanning => '(0|1)',
feedinPowerLimit => '\d+',
showLink => '(0|1)',
};
my ($a, $h) = parseParams ($aVal);
for my $key (keys %{$h}) {
my $comp = $valid->{$key};
my $comp = $valid->{$key}{comp};
next if(!$comp);
if ($h->{$key} =~ /^$comp$/xs) {
@ -6365,6 +6362,18 @@ sub _attrplantControl { ## no critic "not used"
}
}
}
for my $akey (keys %{$h}) { # von bestimmten Schlüsseln abhängige Aktionen ausführen
next if(!$valid->{$akey}{act});
$paref->{akey} = $akey;
$paref->{keyval} = $h->{$akey};
__attrKeyAction ($paref);
delete $paref->{keyval};
delete $paref->{akey};
}
return;
}
@ -6816,7 +6825,7 @@ sub _attrRadiationAPI { ## no critic "not used"
return if(!$init_done);
my $hash = $defs{$name};
my $hash = $defs{$name};
if ($paref->{cmd} eq 'set') {
if ($aVal !~ /-API$/x && (!$defs{$aVal} || $defs{$aVal}{TYPE} ne "DWD_OpenData")) {
@ -6883,6 +6892,29 @@ sub _attrgraphicBeamXContent { ## no critic "not used"
return;
}
################################################################
# von bestimmten Schlüsseln abhängige Aktionen ausführen
################################################################
sub __attrKeyAction {
my $paref = shift;
my $name = $paref->{name};
my $akey = $paref->{akey};
my $keyval = $paref->{keyval};
my $cmd = $paref->{cmd};
my $hash = $defs{$name};
if ($cmd eq 'set') {
if ($init_done && $akey eq 'interval') {
_newCycTime ($hash, time, $keyval);
my $nct = CurrentVal ($name, 'nextCycleTime', 0); # gespeicherte nächste CyleTime
readingsSingleUpdate ($hash, 'nextCycletime', (!$nct ? 'Manual / Event-controlled' : FmtTime($nct)), 0);
}
}
return;
}
################################################################
# Attr setupRadiationAPI und setupWeatherDev1
# harmonisieren wenn erforderlich