From 38d823c13fee55d7e6046f3d90157aceb80087c1 Mon Sep 17 00:00:00 2001 From: nasseeder1 Date: Tue, 20 Aug 2024 19:14:29 +0000 Subject: [PATCH] 76_SolarForecast: attr ctrlWeatherDevX to setupWeatherDevX git-svn-id: https://svn.fhem.de/fhem/trunk@29089 2b470e98-0d58-463d-a4d8-8e2adae1ed80 --- fhem/CHANGED | 1 + fhem/FHEM/76_SolarForecast.pm | 150 ++- fhem/contrib/DS_Starter/76_SolarForecast.pm | 972 ++++++++++---------- 3 files changed, 551 insertions(+), 572 deletions(-) diff --git a/fhem/CHANGED b/fhem/CHANGED index 6b3dddbc5..3c0d349c9 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 ctrlWeatherDevX to setupWeatherDevX, - bufgix: 76_SMAInverter: fix PW Lengs Bug - bugfix: 10_KNX: prevent set/get-cmd during fhem start add sub dpts for dpt14, enfoce gadname rules diff --git a/fhem/FHEM/76_SolarForecast.pm b/fhem/FHEM/76_SolarForecast.pm index 2b406c62c..af5711cdb 100644 --- a/fhem/FHEM/76_SolarForecast.pm +++ b/fhem/FHEM/76_SolarForecast.pm @@ -155,6 +155,7 @@ BEGIN { # Versions History intern my %vNotesIntern = ( + "1.31.0" => "20.08.2024 rename attributes ctrlWeatherDevX to setupWeatherDevX ", "1.30.0" => "18.08.2024 new attribute flowGraphicShift, Forum:https://forum.fhem.de/index.php?msg=1318597 ", "1.29.4" => "03.08.2024 delete writeCacheToFile from _getRoofTopData, _specialActivities: avoid loop caused by \@widgetreadings ", "1.29.3" => "20.07.2024 eleminate hand over \$hash in _getRoofTopData routines, fix label 'gcon' to 'gcons' ", @@ -388,7 +389,7 @@ my $WhtokJ = 3.6; my $defmaxvar = 0.5; # max. Varianz pro Tagesberechnung Autokorrekturfaktor my $definterval = 70; # Standard Abfrageintervall my $slidenumdef = 3; # max. Anzahl der Arrayelemente in Schieberegistern -my $weatherDevMax = 3; # max. Anzahl Wetter Devices (Attr ctrlWeatherDevX) +my $weatherDevMax = 3; # max. Anzahl Wetter Devices (Attr setupWeatherDevX) my $maxSoCdef = 95; # default Wert (%) auf den die Batterie maximal aufgeladen werden soll bzw. als aufgeladen gilt my $carecycledef = 20; # max. Anzahl Tage die zwischen der Batterieladung auf maxSoC liegen dürfen my $batSocChgDay = 5; # prozentuale SoC Änderung pro Tag @@ -522,7 +523,7 @@ my @aconfigs = qw( affect70percentRule affectBatteryPreferredCharge affectConsFo ctrlBatSocManagement ctrlConsRecommendReadings ctrlGenPVdeviation ctrlInterval ctrlLanguage ctrlNextDayForecastReadings ctrlShowLink ctrlSolCastAPImaxReq ctrlSolCastAPIoptimizeReq ctrlStatisticReadings ctrlUserExitFn - ctrlWeatherDev1 ctrlWeatherDev2 ctrlWeatherDev3 + setupWeatherDev1 setupWeatherDev2 setupWeatherDev3 disable flowGraphicSize flowGraphicAnimate flowGraphicConsumerDistance flowGraphicShowConsumer flowGraphicShowConsumerDummy flowGraphicShowConsumerPower flowGraphicShowConsumerRemainTime @@ -609,9 +610,9 @@ my %hattr = ( # H ctrlConsRecommendReadings => { fn => \&_attrcreateConsRecRdgs }, ctrlStatisticReadings => { fn => \&_attrcreateStatisticRdgs }, ctrlDebug => { fn => \&_attrctrlDebug }, - ctrlWeatherDev1 => { fn => \&_attrWeatherDev }, - ctrlWeatherDev2 => { fn => \&_attrWeatherDev }, - ctrlWeatherDev3 => { fn => \&_attrWeatherDev }, + setupWeatherDev1 => { fn => \&_attrWeatherDev }, + setupWeatherDev2 => { fn => \&_attrWeatherDev }, + setupWeatherDev3 => { fn => \&_attrWeatherDev }, setupMeterDev => { fn => \&_attrMeterDev }, setupBatteryDev => { fn => \&_attrBatteryDev }, setupInverterDev => { fn => \&_attrInverterDev }, @@ -661,8 +662,8 @@ my %hqtxt = ( "set LINK plantConfiguration check" oder mit Druck auf das angebotene Icon.
Korrigieren sie bitte eventuelle Fehler und beachten sie mögliche Hinweise.
(Die Anzeigesprache kann mit dem Attribut "ctrlLanguage" umgestellt werden.)

} }, - cfd => { EN => qq{Please enter at least one weather forecast device with "attr LINK ctrlWeatherDev1"}, - DE => qq{Bitte geben sie mindestens ein Wettervorhersage Device mit "attr LINK ctrlWeatherDev1" an} }, + cfd => { EN => qq{Please enter at least one weather forecast device with "attr LINK setupWeatherDev1"}, + DE => qq{Bitte geben sie mindestens ein Wettervorhersage Device mit "attr LINK setupWeatherDev1" an} }, crd => { EN => qq{Please select the radiation forecast service with "attr LINK setupRadiationAPI"}, DE => qq{Bitte geben sie den Strahlungsvorhersage Dienst mit "attr LINK setupRadiationAPI" an} }, cid => { EN => qq{Please specify the Inverter device with "attr LINK setupInverterDev"}, @@ -1182,9 +1183,6 @@ sub Initialize { "ctrlSolCastAPIoptimizeReq:1,0 ". "ctrlStatisticReadings:multiple-strict,$srd ". "ctrlUserExitFn:textField-long ". - "ctrlWeatherDev1 ". - "ctrlWeatherDev2 ". - "ctrlWeatherDev3 ". "disable:1,0 ". "flowGraphicSize ". "flowGraphicAnimate:1,0 ". @@ -1232,6 +1230,9 @@ sub Initialize { "setupInverterDev:textField-long ". "setupInverterStrings ". "setupMeterDev:textField-long ". + "setupWeatherDev1 ". + "setupWeatherDev2 ". + "setupWeatherDev3 ". "setupRoofTops ". "setupBatteryDev:textField-long ". "setupRadiationAPI ". @@ -1245,6 +1246,9 @@ sub Initialize { # $hash->{FW_atPageEnd} = 1; # wenn 1 -> kein Longpoll ohne informid in HTML-Tag $hash->{AttrRenameMap} = { "graphicBeamHeight" => "graphicBeamHeightLevel1", # 07.05.24 + "ctrlWeatherDev1" => "setupWeatherDev1", # 20.08.24 + "ctrlWeatherDev2" => "setupWeatherDev2", + "ctrlWeatherDev3" => "setupWeatherDev3", }; eval { FHEM::Meta::InitMod( __FILE__, $hash ) }; ## no critic 'eval' @@ -5669,7 +5673,7 @@ return; } ################################################################ -# Attr ctrlWeatherDevX +# Attr setupWeatherDevX ################################################################ sub _attrWeatherDev { ## no critic "not used" my $paref = shift; @@ -5687,11 +5691,11 @@ sub _attrWeatherDev { ## no critic "not used" } if ($aVal =~ /^OpenMeteo/xs) { - if ($aName ne 'ctrlWeatherDev1') { - return qq{Only the leading attribute 'ctrlWeatherDev1' can set to '$aVal'}; + if ($aName ne 'setupWeatherDev1') { + return qq{Only the leading attribute 'setupWeatherDev1' can set to '$aVal'}; } - InternalTimer (gettimeofday()+1, 'FHEM::SolarForecast::__setRadAPIdelayed', $hash, 0); # automatisch setupRadiationAPI setzen wenn ctrlWeatherDev1 + InternalTimer (gettimeofday()+1, 'FHEM::SolarForecast::__setRadAPIdelayed', $hash, 0); # automatisch setupRadiationAPI setzen wenn setupWeatherDev1 return; } @@ -5723,12 +5727,12 @@ sub _attrRadiationAPI { ## no critic "not used" return qq{The device "$aVal" doesn't exist or has no TYPE "DWD_OpenData"}; } - my $awdev1 = AttrVal ($name, 'ctrlWeatherDev1', ''); + my $awdev1 = AttrVal ($name, 'setupWeatherDev1', ''); if (($awdev1 eq 'OpenMeteoDWD-API' && $aVal ne 'OpenMeteoDWD-API') || ($awdev1 eq 'OpenMeteoDWDEnsemble-API' && $aVal ne 'OpenMeteoDWDEnsemble-API') || ($awdev1 eq 'OpenMeteoWorld-API' && $aVal ne 'OpenMeteoWorld-API')) { - return "The attribute 'ctrlWeatherDev1' is set to '$awdev1'. \n". + return "The attribute 'setupWeatherDev1' is set to '$awdev1'. \n". "Change that attribute to another weather device first if you want use an other API."; } @@ -5798,7 +5802,7 @@ sub __setRadAPIdelayed { my $hash = shift; my $name = $hash->{NAME}; - my $awdev1 = AttrVal ($name, 'ctrlWeatherDev1', ''); + my $awdev1 = AttrVal ($name, 'setupWeatherDev1', ''); CommandAttr (undef, "$name setupRadiationAPI $awdev1"); # automatisch setupRadiationAPI setzen @@ -6428,7 +6432,7 @@ sub _addDynAttr { my $hash = shift; my $type = $hash->{TYPE}; - ## Attr ctrlWeatherDevX zur Laufzeit hinzufügen + ## Attr setupWeatherDevX zur Laufzeit hinzufügen ################################################# my $adwds = ''; my @alldwd = devspec2array ("TYPE=DWD_OpenData"); @@ -6445,16 +6449,17 @@ sub _addDynAttr { my @deva = split " ", $modules{$type}{AttrList}; - my $atd = 'ctrlWeatherDev|setupRadiationAPI'; + my $atd = 'setupWeatherDev|setupRadiationAPI'; @deva = grep {!/$atd/} @deva; for my $step (1..$weatherDevMax) { if ($step == 1) { - push @deva, ($adwds ? "ctrlWeatherDev1:OpenMeteoDWD-API,OpenMeteoDWDEnsemble-API,OpenMeteoWorld-API,$adwds" : "ctrlWeatherDev1:OpenMeteoDWD-API,OpenMeteoDWDEnsemble-API,OpenMeteoWorld-API"); + push @deva, ($adwds ? "setupWeatherDev1:OpenMeteoDWD-API,OpenMeteoDWDEnsemble-API,OpenMeteoWorld-API,$adwds" : + "setupWeatherDev1:OpenMeteoDWD-API,OpenMeteoDWDEnsemble-API,OpenMeteoWorld-API"); next; } - push @deva, ($adwds ? "ctrlWeatherDev".$step.":$adwds" : ""); + push @deva, ($adwds ? "setupWeatherDev".$step.":$adwds" : ""); } push @deva, "setupRadiationAPI:$rdd "; @@ -6495,19 +6500,7 @@ sub centralTask { return if(!$init_done); ### nicht mehr benötigte Daten verarbeiten - Bereich kann später wieder raus !! - ########################################################################################################################## - my $val4 = ReadingsVal ($name, 'currentRadiationAPI', ''); # 10.06.2024 - if ($val4) { - CommandAttr (undef, "$name setupRadiationAPI $val4"); - readingsDelete ($hash, 'currentRadiationAPI'); - } - - my $val5 = ReadingsVal ($name, 'modulePeakString', ''); # 12.06.2024 - if ($val5) { - CommandAttr (undef, "$name setupStringPeak $val5"); - readingsDelete ($hash, 'modulePeakString'); - } - + ########################################################################################################################## my $dir = ReadingsVal ($name, 'moduleAzimuth', ''); # 16.06.2024 if ($dir) { readingsSingleUpdate ($hash, 'setupStringAzimuth', $dir, 0); @@ -7362,7 +7355,7 @@ sub _transferWeatherValues { my $chour = $paref->{chour}; my $hash = $defs{$name}; - my ($valid, $fcname, $apiu) = isWeatherDevValid ($hash, 'ctrlWeatherDev1'); # Standard Weather Forecast Device + my ($valid, $fcname, $apiu) = isWeatherDevValid ($hash, 'setupWeatherDev1'); # Standard Weather Forecast Device return if(!$valid); my $type = $paref->{type}; @@ -7443,7 +7436,7 @@ return; } ################################################################ -# lese Wetterdaten aus Device im Attribut ctrlWeatherDevX +# lese Wetterdaten aus Device im Attribut setupWeatherDevX # X = laufende Schleifenvariable $step ################################################################ sub __readDataWeather { @@ -7454,7 +7447,7 @@ sub __readDataWeather { my $step = $paref->{step}; my $hash = $defs{$name}; - my ($valid, $fcname, $apiu) = isWeatherDevValid ($hash, 'ctrlWeatherDev'.$step); # Weather Forecast Device + my ($valid, $fcname, $apiu) = isWeatherDevValid ($hash, 'setupWeatherDev'.$step); # Weather Forecast Device return if(!$valid); if ($apiu) { # eine API wird verwendet @@ -7562,7 +7555,7 @@ sub __mergeDataWeather { my $ds = 0; for my $wd (1..$weatherDevMax) { - my ($valid, $fcname, $apiu) = isWeatherDevValid ($hash, 'ctrlWeatherDev'.$wd); # Weather Forecast Device + my ($valid, $fcname, $apiu) = isWeatherDevValid ($hash, 'setupWeatherDev'.$wd); # Weather Forecast Device $ds++ if($valid); } @@ -11689,7 +11682,7 @@ sub _checkSetupNotComplete { ########################################################################################## my $is = AttrVal ($name, 'setupInverterStrings', undef); # String Konfig - my $wedev = AttrVal ($name, 'ctrlWeatherDev1', undef); # Device Vorhersage Wetterdaten (Bewölkung etc.) + my $wedev = AttrVal ($name, 'setupWeatherDev1', undef); # Device Vorhersage Wetterdaten (Bewölkung etc.) my $radev = AttrVal ($name, 'setupRadiationAPI', undef); # Device Strahlungsdaten Vorhersage my $indev = AttrVal ($name, 'setupInverterDev', undef); # Inverter Device my $medev = AttrVal ($name, 'setupMeterDev', undef); # Meter Device @@ -13638,18 +13631,14 @@ sub _flowGraphic { my $csc_style = $csc && $cpv ? 'flowg active_out' : 'flowg inactive_out'; my $cgfi_style = $cgfi ? 'flowg active_out' : 'flowg inactive_out'; - my $vbminx = -10 * $flowgshift; # min-x and min-y represent the smallest X and Y coordinates that the viewBox may have - my $vbminy = -25; - my $vbwidth = 800; # width and height specify the viewBox size - my $vbhight = !$flowgcons ? 480 : - $flowgconTime ? 700 : - 680; + my $vbminx = -10 * $flowgshift; # min-x and min-y represent the smallest X and Y coordinates that the viewBox may have + my $vbminy = -25; + my $vbwidth = 800; # width and height specify the viewBox size + my $vbhight = !$flowgcons ? 480 : + $flowgconTime ? 700 : + 680; my $vbox = "$vbminx $vbminy $vbwidth $vbhight"; - - #my $vbox = !$flowgcons ? "$vbminx -25 800 480" : - # $flowgconTime ? "$vbminx -25 800 700" : - # "$vbminx -25 800 680"; my $ret = << "END0"; - + @@ -13794,7 +13766,7 @@ END3 $consumer_style = 'flowg active_in' if($cc_dummy > 1); my $chain_color = ""; # Farbe der Laufkette Consumer-Dummy - if($cc_dummy > 0.5) { + if ($cc_dummy > 0.5) { $chain_color = 'style="stroke: #'.substr(Color::pahColor(0,500,1000,$cc_dummy,[0,255,0, 127,255,0, 255,255,0, 255,127,0, 255,0,0]),0,6).';"'; #$chain_color = 'style="stroke: #DF0101;"'; } @@ -13832,7 +13804,7 @@ END3 $consumer_style = 'flowg active_out' if($p > $defpopercent); my $chain_color = ""; # Farbe der Laufkette des Consumers - if($p > 0.5) { + if ($p > 0.5) { $chain_color = 'style="stroke: #'.substr(Color::pahColor(0,50,100,$p,[0,255,0, 127,255,0, 255,255,0, 255,127,0, 255,0,0]),0,6).';"'; #$chain_color = 'style="stroke: #DF0101;"'; } @@ -13968,7 +13940,7 @@ sub consinject { if ($_) { my ($cons,$im,$start,$end) = split (':', $_); - if($debug =~ /graphic/x) { + if ($debug =~ /graphic/x) { Log3 ($name, 1, qq{$name DEBUG> Consumer to show -> $cons, relative to current time -> start: $start, end: $end}) if($i<1); } @@ -14057,7 +14029,7 @@ sub weather_icon { $id = int $id; my $txt = $lang eq "DE" ? "txtd" : "txte"; - if(defined $weather_ids{$id}) { + if (defined $weather_ids{$id}) { return $weather_ids{$id}{icon}, encode("utf8", $weather_ids{$id}{$txt}); } @@ -14086,7 +14058,7 @@ sub checkdwdattr { $err = qq{ERROR - device "$dwddev" -> attribute "forecastProperties" must contain: }.join ",",@aneeded; } - if($fcr != 1) { + if ($fcr != 1) { $err .= ", " if($err); $err .= qq{ERROR - device "$dwddev" -> attribute "forecastResolution" must be set to "1"}; } @@ -14101,13 +14073,13 @@ return $err; ################################################################ sub _addHourAiRawdata { my $paref = shift; - my $hash = $paref->{hash}; my $name = $paref->{name}; my $aln = $paref->{aln}; # Autolearning my $h = $paref->{h}; - my $rho = sprintf "%02d", $h; - my $sr = ReadingsVal ($name, ".signaldone_".$rho, ""); + my $hash = $defs{$name}; + my $rho = sprintf "%02d", $h; + my $sr = ReadingsVal ($name, ".signaldone_".$rho, ""); return if($sr eq "done"); @@ -14158,8 +14130,9 @@ return $hdv; ############################################################### sub manageTrain { my $paref = shift; - my $hash = $paref->{hash}; my $name = $paref->{name}; + + my $hash = $defs{$name}; if (CircularVal ($hash, 99, 'runTimeTrainAI', 0) < $aibcthhld) { BlockingKill ($hash->{HELPER}{AIBLOCKRUNNING}) if(defined $hash->{HELPER}{AIBLOCKRUNNING}); @@ -14220,8 +14193,7 @@ sub finishTrain { $data{$type}{$name}{circular}{99}{aitrainLastFinishTs} = $aitrainFinishTs if(defined $aitrainFinishTs); if ($aitrainstate eq 'ok') { - _readCacheFile ({ hash => $hash, - name => $name, + _readCacheFile ({ name => $name, type => $type, file => $aitrained.$name, cachename => 'aitrained', @@ -14268,11 +14240,12 @@ return; ################################################################ sub aiAddInstance { ## no critic "not used" my $paref = shift; - my $hash = $paref->{hash}; my $name = $paref->{name}; my $type = $paref->{type}; my $taa = $paref->{taa}; # do train after add - + + my $hash = $defs{$name}; + return if(!isPrepared4AI ($hash)); my $err = aiInit ($paref); @@ -14336,11 +14309,11 @@ return; ################################################################ sub aiTrain { ## no critic "not used" my $paref = shift; - my $hash = $paref->{hash}; my $name = $paref->{name}; my $type = $paref->{type}; my $block = $paref->{block} // 0; + my $hash = $defs{$name}; my ($serial, $err); if (!isPrepared4AI ($hash)) { @@ -14414,12 +14387,13 @@ return; ################################################################ sub aiGetResult { my $paref = shift; - my $hash = $paref->{hash}; my $name = $paref->{name}; my $type = $paref->{type}; my $hod = $paref->{hod}; my $nhtstr = $paref->{nhtstr}; + my $hash = $defs{$name}; + return 'AI usage is not prepared' if(!isPrepared4AI ($hash, 'full')); my $dtree = AiDetreeVal ($hash, 'aitrained', undef); @@ -14466,8 +14440,7 @@ sub aiGetResult { return ('accurate', $pvaifc); } - (my $msg, $pvaifc) = _aiGetSpread ( { hash => $hash, - name => $name, + (my $msg, $pvaifc) = _aiGetSpread ( { name => $name, type => $type, rad1h => $rad1h, temp => $tbin, @@ -14574,9 +14547,10 @@ return 'No AI decition delivered'; ################################################################ sub aiInit { ## no critic "not used" my $paref = shift; - my $hash = $paref->{hash}; my $name = $paref->{name}; my $type = $paref->{type}; + + my $hash = $defs{$name}; if (!isPrepared4AI ($hash)) { my $err = CurrentVal ($hash, 'aicanuse', ''); @@ -14602,13 +14576,14 @@ return; ################################################################ sub aiAddRawData { my $paref = shift; - my $hash = $paref->{hash}; my $name = $paref->{name}; my $type = $paref->{type}; my $day = $paref->{day} // strftime "%d", localtime(time); # aktueller Tag (range 01 to 31) my $ood = $paref->{ood} // 0; # only one (current) day my $rho = $paref->{rho}; # only this hour of day - + + my $hash = $defs{$name}; + delete $data{$type}{$name}{current}{aitrawstate}; my $err; @@ -14686,10 +14661,11 @@ return; ################################################################ sub aiDelRawData { my $paref = shift; - my $hash = $paref->{hash}; my $name = $paref->{name}; my $type = $paref->{type}; + my $hash = $defs{$name}; + if (!keys %{$data{$type}{$name}{aidectree}{airaw}}) { return; } @@ -14747,7 +14723,6 @@ return $ridx; ################################################################ sub writeToHistory { my $ph = shift; - my $paref = $ph->{paref}; my $key = $ph->{key}; my $val = $ph->{val}; @@ -14777,7 +14752,6 @@ return; ################################################################ sub setPVhistory { my $paref = shift; - my $hash = $paref->{hash}; my $name = $paref->{name}; my $type = $paref->{type}; my $day = $paref->{day}; @@ -14788,6 +14762,8 @@ sub setPVhistory { my $reorg = $paref->{reorg} // 0; # Neuberechnung von Werten in Stunde "99" nach Löschen von Stunden eines Tages my $reorgday = $paref->{reorgday} // q{}; # Tag der reorganisiert werden soll + my $hash = $defs{$name}; + $data{$type}{$name}{pvhist}{$day}{99}{dayname} = $dayname if($day); if ($hfspvh{$histname} && defined &{$hfspvh{$histname}{fn}}) { @@ -14883,7 +14859,6 @@ return; ################################################################ sub _storeVal { ## no critic "not used" my $paref = shift; - my $hash = $paref->{hash}; my $name = $paref->{name}; my $type = $paref->{type}; my $day = $paref->{day}; @@ -14891,6 +14866,7 @@ sub _storeVal { ## no critic "not used" my $histname = $paref->{histname}; my $val = $paref->{val}; + my $hash = $defs{$name}; my $store = $hfspvh{$histname}{storname}; my ($validkey, $validval); @@ -15014,7 +14990,7 @@ sub listDataPool { $ret .= $key." => "; $ret .= "etotal: $etotal, pvfc: $pvfc, pvrl: $pvrl, pvrlvd: $pvrlvd, rad1h: $rad1h"; $ret .= "\n "; - $ret .= "confc: $confc, con: $con, gcon: $gcons, conprice: $conprc"; + $ret .= "confc: $confc, con: $con, gcons: $gcons, conprice: $conprc"; $ret .= "\n "; $ret .= "gfeedin: $gfeedin, feedprice: $feedprc"; $ret .= "\n "; @@ -15628,14 +15604,14 @@ sub checkPlantConfig { my $resh; for my $step (1..$weatherDevMax) { - my ($valid, $fcname, $apiu) = isWeatherDevValid ($hash, 'ctrlWeatherDev'.$step); + my ($valid, $fcname, $apiu) = isWeatherDevValid ($hash, 'setupWeatherDev'.$step); next if(!$fcname && $step ne 1); if (!$valid) { $result->{'DWD Weather Properties'}{state} = $nok; if (!$fcname) { - $result->{'DWD Weather Properties'}{result} .= qq{No DWD device is defined in attribute "ctrlWeatherDev$step".
}; + $result->{'DWD Weather Properties'}{result} .= qq{No DWD device is defined in attribute "setupWeatherDev$step".
}; } else { $result->{'DWD Weather Properties'}{result} .= qq{The DWD device "$fcname" doesn't exist.
}; @@ -15661,7 +15637,7 @@ sub checkPlantConfig { $result->{'DWD Weather Properties'}{info} = 1; } - $result->{'DWD Weather Properties'}{result} .= $hqtxt{fulfd}{$lang}." ($hqtxt{attrib}{$lang}: ctrlWeatherDev$step)
"; + $result->{'DWD Weather Properties'}{result} .= $hqtxt{fulfd}{$lang}." ($hqtxt{attrib}{$lang}: setupWeatherDev$step)
"; } $result->{'DWD Weather Properties'}{note} .= qq{checked parameters and attributes of device "$fcname":
}; @@ -15669,14 +15645,14 @@ sub checkPlantConfig { $result->{'DWD Weather Properties'}{note} .= 'forecastRefresh '.($mosm eq 'MOSMIX_L' ? '-> set attribute to below "6" if possible' : '').'
'; } else { - $result->{'DWD Weather Properties'}{result} .= $hqtxt{fulfd}{$lang}." ($hqtxt{attrib}{$lang}: ctrlWeatherDev$step)
"; + $result->{'DWD Weather Properties'}{result} .= $hqtxt{fulfd}{$lang}." ($hqtxt{attrib}{$lang}: setupWeatherDev$step)
"; } } } ## Alter DWD Wetterdaten ########################## - ($err, $resh) = isWeatherAgeExceeded ( {hash => $hash, name => $name, lang => $lang} ); + ($err, $resh) = isWeatherAgeExceeded ( {name => $name, lang => $lang} ); if (!$err && $resh->{exceed}) { $result->{'DWD Weather Properties'}{state} = $warn; @@ -15725,7 +15701,7 @@ sub checkPlantConfig { ## Alter DWD Radiation ####################### - ($err, $resh) = isRad1hAgeExceeded ( {hash => $hash, name => $name, lang => $lang} ); + ($err, $resh) = isRad1hAgeExceeded ( {name => $name, lang => $lang} ); if (!$err && $resh->{exceed}) { $result->{'DWD Radiation Properties'}{state} = $warn; @@ -16306,7 +16282,7 @@ sub createReadingsFromArray { readingsEndUpdate ($hash, $doevt); - undef @da; + @da = (); # completely empty @ARRAY return; } @@ -16376,15 +16352,15 @@ sub createAssociatedWith { my (@cd, @nd); my ($afc, $ara, $ain, $ame, $aba, $h); - my $fcdev1 = AttrVal ($name, 'ctrlWeatherDev1', ''); # Weather forecast Device 1 + my $fcdev1 = AttrVal ($name, 'setupWeatherDev1', ''); # Weather forecast Device 1 ($afc,$h) = parseParams ($fcdev1); $fcdev1 = $afc->[0] // ""; - my $fcdev2 = AttrVal ($name, 'ctrlWeatherDev2', ''); # Weather forecast Device 2 + my $fcdev2 = AttrVal ($name, 'setupWeatherDev2', ''); # Weather forecast Device 2 ($afc,$h) = parseParams ($fcdev2); $fcdev2 = $afc->[0] // ""; - my $fcdev3 = AttrVal ($name, 'ctrlWeatherDev3', ''); # Weather forecast Device 3 + my $fcdev3 = AttrVal ($name, 'setupWeatherDev3', ''); # Weather forecast Device 3 ($afc,$h) = parseParams ($fcdev3); $fcdev3 = $afc->[0] // ""; @@ -16864,11 +16840,11 @@ return ConsumerVal ($hash, $c, 'isIntimeframe', 0); ################################################################ sub isInLocktime { my $paref = shift; - my $hash = $paref->{hash}; my $name = $paref->{name}; my $c = $paref->{consumer}; my $t = $paref->{t}; + my $hash = $defs{$name}; my $iilt = 0; my $rlt = 0; my $lt = 0; @@ -17155,7 +17131,7 @@ return ($err, $a->[0], $h); } ##################################################################### -# Prüft ob das in ctrlWeatherDevX +# Prüft ob das in setupWeatherDevX # übergebene Weather Device valide ist # return - $valid -> ist die Angabe valide (1) # $apiu -> wird ein Device oder API verwendet @@ -17188,10 +17164,10 @@ return ($valid, $fcname, $apiu); ################################################################### sub isWeatherAgeExceeded { my $paref = shift; - my $hash = $paref->{hash}; my $name = $paref->{name}; my $lang = $paref->{lang}; + my $hash = $defs{$name}; my $currts = int time; my $agets = $currts; @@ -17203,13 +17179,13 @@ sub isWeatherAgeExceeded { my ($newts, $th); for my $step (1..$weatherDevMax) { - my ($valid, $fcname, $apiu) = isWeatherDevValid ($hash, 'ctrlWeatherDev'.$step); + my ($valid, $fcname, $apiu) = isWeatherDevValid ($hash, 'setupWeatherDev'.$step); next if(!$fcname && $step ne 1); if (!$apiu) { if (!$fcname || !$valid) { if (!$fcname) { - return (qq{No DWD device is defined in attribute "ctrlWeatherDev$step"}, $resh); + return (qq{No DWD device is defined in attribute "setupWeatherDev$step"}, $resh); } else { return (qq{The DWD device "$fcname" doesn't exist}, $resh); @@ -17262,10 +17238,10 @@ return ('', $resh); ################################################################### sub isRad1hAgeExceeded { my $paref = shift; - my $hash = $paref->{hash}; my $name = $paref->{name}; my $lang = $paref->{lang}; + my $hash = $defs{$name}; my $currts = int time; my $fcname = CurrentVal ($hash, 'dwdRad1hDev', ''); @@ -17742,8 +17718,8 @@ return $ret; ################################################################ sub userExit { my $paref = shift; - my $hash = $paref->{hash}; my $name = $paref->{name}; + my $hash = $defs{$name}; my $uefn = AttrVal ($name, 'ctrlUserExitFn', ''); return if(!$uefn); @@ -18374,7 +18350,7 @@ to ensure that the system configuration is correct.