From 66b8a2a30bc08f3be013dfc410121c93c4ea6b4d Mon Sep 17 00:00:00 2001 From: nasseeder1 Date: Mon, 14 Apr 2025 21:21:13 +0000 Subject: [PATCH] 76_SolarForecast: Version 1.50.4 git-svn-id: https://svn.fhem.de/fhem/trunk@29859 2b470e98-0d58-463d-a4d8-8e2adae1ed80 --- fhem/contrib/DS_Starter/76_SolarForecast.pm | 98 ++++++++++++++++++--- 1 file changed, 84 insertions(+), 14 deletions(-) diff --git a/fhem/contrib/DS_Starter/76_SolarForecast.pm b/fhem/contrib/DS_Starter/76_SolarForecast.pm index a2e558ce3..7b26929e6 100644 --- a/fhem/contrib/DS_Starter/76_SolarForecast.pm +++ b/fhem/contrib/DS_Starter/76_SolarForecast.pm @@ -160,8 +160,8 @@ BEGIN { # Versions History intern my %vNotesIntern = ( - "1.50.4" => "13.04.2025 Consumer Strokes: fix __dynColor, new key flowGraphicControl->strokeCmrRedColLimit ". - "__getopenMeteoData: fix get calclated call interval ", + "1.50.4" => "14.04.2025 Consumer Strokes: fix __dynColor, new key flowGraphicControl->strokeCmrRedColLimit ". + "__getopenMeteoData: fix get calclated call interval, new Setter cycleInterval ", "1.50.3" => "12.04.2025 __calcPVestimates: Fix missing limitation for strings if more than one string is assigned to an inverter ". "code change in _attrInverterStrings, _attrStringPeak, checkPlantConfig: improved string check ", "1.50.2" => "11.04.2025 take inverter cap into account if no strings key is set, ctrlSpecialReadings: new option tomorrowConsumptionForecast ". @@ -637,6 +637,7 @@ my %hset = ( # Ha consumerImmediatePlanning => { fn => \&_setconsumerImmediatePlanning }, consumerNewPlanning => { fn => \&_setconsumerNewPlanning }, clientAction => { fn => \&_setclientAction }, + cycleInterval => { fn => \&_setcycleInterval }, energyH4Trigger => { fn => \&_setTrigger }, plantConfiguration => { fn => \&_setplantConfiguration }, batteryTrigger => { fn => \&_setTrigger }, @@ -1717,6 +1718,7 @@ sub Set { $setlist = "Unknown argument $opt, choose one of ". "consumerImmediatePlanning:$coms ". "consumerNewPlanning:$coms ". + "cycleInterval ". "energyH4Trigger:textField-long ". "operatingMemory:backup,save".$rf." ". "operationMode:active,inactive ". @@ -1786,8 +1788,6 @@ return "$setlist"; sub _setconsumerImmediatePlanning { ## no critic "not used" my $paref = shift; my $name = $paref->{name}; - my $type = $paref->{type}; - my $opt = $paref->{opt}; my $c = $paref->{prop}; my $evt = $paref->{prop1} // 0; # geändert V 1.1.0 - 1 -> 0 my $hash = $defs{$name}; @@ -1867,6 +1867,42 @@ sub _setconsumerNewPlanning { ## no critic "not used" return; } +################################################################ +# Setter cycleInterval +################################################################ +sub _setcycleInterval { ## no critic "not used" + my $paref = shift; + my $name = $paref->{name}; + my $opt = $paref->{opt}; + my $prop = $paref->{prop} // return; + + return if(!$init_done); + + if ($prop !~ /^\d+$/xs) { + return "The $opt must be specified by an Integer."; + } + + my $pc = AttrVal ($name, 'plantControl', undef); + my $new; + + if (!defined $pc) { + $new = "$name plantControl cycleInterval=$prop"; + } + elsif ($pc =~ /cycleInterval=\d+/xs) { + $pc =~ s/cycleInterval=\d+/cycleInterval=$prop/gs; + $new = "$name plantControl $pc"; + } + else { + my $npc = $pc." cycleInterval=$prop"; + $new = "$name plantControl $npc"; + } + + my $ret = CommandAttr (undef, "$new"); + ::CommandSave (1, undef) if(!$ret); + +return; +} + ################################################################ # Setter roofIdentPair ################################################################ @@ -4239,11 +4275,11 @@ sub __getopenMeteoData { my $reqm = $paref->{reqm}; if (!$force) { # regulärer API Abruf - my $lrt = StatusAPIVal ($name, 'OpenMeteo', '?All', 'lastretrieval_timestamp', 0); - my $cival = StatusAPIVal ($name, 'OpenMeteo', '?All', 'currentAPIinterval', OMETEOREPDEF); + my $lrt = StatusAPIVal ($name, 'OpenMeteo', '?All', 'lastretrieval_timestamp', 0); + my $apiitv = StatusAPIVal ($name, 'OpenMeteo', '?All', 'currentAPIinterval', OMETEOREPDEF); - if ($lrt && $t < $lrt + $cival) { - my $rt = $lrt + $cival - $t; + if ($lrt && $t < $lrt + $apiitv) { + my $rt = $lrt + $apiitv - $t; return qq{The waiting time to the next Open-Meteo API call has not expired yet. The remaining waiting time is $rt seconds}; } } @@ -23364,6 +23400,23 @@ to ensure that the system configuration is correct.
+ + +

+ + +