From 339b29e05396bbadde55df46c045499ff5bd10c8 Mon Sep 17 00:00:00 2001 From: DS_Starter Date: Mon, 7 Jul 2025 21:11:14 +0000 Subject: [PATCH] 76_SolarForecast: contrib V 1.54.1 git-svn-id: https://svn.fhem.de/fhem/trunk@30113 2b470e98-0d58-463d-a4d8-8e2adae1ed80 --- fhem/contrib/DS_Starter/76_SolarForecast.pm | 74 ++++++++++++--------- 1 file changed, 42 insertions(+), 32 deletions(-) diff --git a/fhem/contrib/DS_Starter/76_SolarForecast.pm b/fhem/contrib/DS_Starter/76_SolarForecast.pm index 65a5afec5..cf4310705 100644 --- a/fhem/contrib/DS_Starter/76_SolarForecast.pm +++ b/fhem/contrib/DS_Starter/76_SolarForecast.pm @@ -160,8 +160,9 @@ BEGIN { # Versions History intern my %vNotesIntern = ( - "1.54.1" => "06.07.2025 change utf8 to UTF-8, userExit: new coding, __createReduceIcon: fix Wide character in syswrite - https://forum.fhem.de/index.php?msg=1344368 ". - "_setattrKeyVal: optimize function between execute from FHEMWEB and Commandline ", + "1.54.1" => "07.07.2025 change utf8 to UTF-8, userExit: new coding, __createReduceIcon: fix Wide character in syswrite - https://forum.fhem.de/index.php?msg=1344368 ". + "_setattrKeyVal: optimize function between execute from FHEMWEB and Commandline ". + "_beamGraphicFirstHour, _beamGraphicRemainingHours: decimal places according to the setting of the energy unit", "1.54.0" => "05.07.2025 edit commandref, ___areaFactorTrack: important bugfix in calc of direct area factor for DWD use ", "1.53.3" => "04.07.2025 Change of the correction factor calculation to the ratio of real production and the API raw forecast ", "1.53.2" => "03.07.2025 graphicControl->showDiff can be set separately for each level ". @@ -1132,7 +1133,7 @@ my %htitles = ( DE => qq{API Abfrage erfolgreich aber die Strahlungswerte sind veraltet.\nPrüfen sie die Anlage mit 'set plantConfiguration check'.} }, aswfc2o => { EN => qq{The weather data is outdated.\nCheck the plant with 'set plantConfiguration check'.}, DE => qq{Die Wetterdaten sind veraltet.\nPrüfen sie die Anlage mit 'set plantConfiguration check'.} }, - rdcstat => { EN => qq{no reduction status available\nPlease set the key ‘reductionState’ with 'attr plantControl'}, + rdcstat => { EN => qq{no reduction status available\nPlease set the key 'reductionState' with 'attr plantControl'}, DE => qq{kein Abregelungsstatus verfügbar\nSetzen sie bitte den Schlüssel 'reductionState' mit 'attr plantControl'} }, ); @@ -1465,6 +1466,7 @@ my %hfspvh = ( feedprice => { fn => \&_storeVal, storname => 'feedprice', validkey => undef, fpar => undef }, # Einspeisevergütung pro kWh der Stunde socwhsum => { fn => \&_storeVal, storname => 'socwhsum', validkey => undef, fpar => undef }, # real eerichter SoC (Wh) zusammengefasst über alle Batterien socprogwhsum => { fn => \&_storeVal, storname => 'socprogwhsum', validkey => undef, fpar => undef }, # prognostizierter SoC (Wh) zusammengefasst über alle Batterien + pvapifcraw => { fn => \&_storeVal, storname => 'pvapifcraw', validkey => undef, fpar => undef }, # prognostizierter Energieertrag Raw pvfc => { fn => \&_storeVal, storname => 'pvfc', validkey => undef, fpar => 'comp99' }, # prognostizierter Energieertrag confc => { fn => \&_storeVal, storname => 'confc', validkey => undef, fpar => 'comp99' }, # prognostizierter Hausverbrauch gcons => { fn => \&_storeVal, storname => 'gcons', validkey => undef, fpar => 'comp99' }, # bezogene Energie @@ -8822,6 +8824,8 @@ sub centralTask { # delete $data{$name}{circular}{$hodc}; #} + delete $data{$name}{circular}{'00'}; + #my $gbw = AttrVal ($name, 'graphicBeamWidth', undef); # 27.04. #my $gco = AttrVal ($name, 'graphicControl', ''); @@ -8879,7 +8883,7 @@ sub centralTask { } if (CurrentVal ($hash, 'ctrunning', 0)) { - Log3 ($name, 3, "$name - INFO - central task was called when it was already running ... end this call"); + Log3 ($name, 4, "$name - INFO - central task was called when it was already running ... end this call"); return; } @@ -9293,7 +9297,7 @@ sub _collectAllRegConsumers { $data{$name}{current}{consumerCollected} = 1; - Log3 ($name, 3, "$name - all registered consumers collected"); + Log3 ($name, 4, "$name - INFO - all registered consumers collected"); return; } @@ -10384,8 +10388,9 @@ sub _transferAPIRadiationValues { } if ($fd == 0 && $fh1) { - writeToHistory ( { paref => $paref, key => 'pvfc', val => $pvfc, hour => $fh1 } ); - writeToHistory ( { paref => $paref, key => 'radiation', val => $rad1h, hour => $fh1 } ); + writeToHistory ( { paref => $paref, key => 'pvapifcraw', val => $pvapifcraw, hour => $fh1 } ); + writeToHistory ( { paref => $paref, key => 'pvfc', val => $pvfc, hour => $fh1 } ); + writeToHistory ( { paref => $paref, key => 'radiation', val => $rad1h, hour => $fh1 } ); } } @@ -16034,7 +16039,7 @@ sub __createReduceIcon { my $img; if (!defined $rps) { - $title = encode ('UTF-8', $htitles{rdcstat}{$lang}); + $title = encode ('UTF-8', $htitles{rdcstat}{$lang}); $title =~ s//$name/xs; $img = '-'; } @@ -16814,7 +16819,7 @@ sub _beamGraphicFirstHour { $hfcg->{0}{beam1} //= 0; $hfcg->{0}{beam2} //= 0; $hfcg->{0}{diff} = sprintf "%.1f", ($hfcg->{0}{beam1} - $hfcg->{0}{beam2}); - $hfcg->{0}{diff} = sprintf "%.0f", $hfcg->{0}{diff} if(($hfcg->{0}{beam1} - $hfcg->{0}{beam2}) * 1 == 0); + $hfcg->{0}{diff} = sprintf "%.0f", $hfcg->{0}{diff} if($kw eq 'Wh' && ($beam1cont eq 'pvForecast' || $beam1cont eq 'pvReal')); my $epc = CurrentVal ($hash, 'ePurchasePriceCcy', 0); my $efc = CurrentVal ($hash, 'eFeedInTariffCcy', 0); @@ -16865,6 +16870,7 @@ sub _beamGraphicRemainingHours { my $hourstyle = $paref->{hourstyle}; my $beam1cont = $paref->{beam1cont}; my $beam2cont = $paref->{beam2cont}; + my $kw = $paref->{kw}; my ($val1, $val2, $val3, $val4, $val5, $val6, $val7, $val8, $val9, $val10); my $hbsocs; @@ -17024,7 +17030,7 @@ sub _beamGraphicRemainingHours { $hfcg->{$i}{beam1} //= 0; $hfcg->{$i}{beam2} //= 0; $hfcg->{$i}{diff} = sprintf "%.1f", ($hfcg->{$i}{beam1} - $hfcg->{$i}{beam2}); - $hfcg->{$i}{diff} = sprintf "%.0f", $hfcg->{$i}{diff} if(($hfcg->{$i}{beam1} - $hfcg->{$i}{beam2}) * 1 == 0); + $hfcg->{$i}{diff} = sprintf "%.0f", $hfcg->{$i}{diff} if($kw eq 'Wh' && ($beam1cont eq 'pvForecast' || $beam1cont eq 'pvReal')); $maxVal = $hfcg->{$i}{beam1} if($hfcg->{$i}{beam1} > $maxVal); $maxVal = $hfcg->{$i}{beam2} if($hfcg->{$i}{beam2} > $maxVal); @@ -20346,6 +20352,7 @@ sub _listDataPoolPvHist { my $pvrl = HistoryVal ($name, $day, $key, 'pvrl', '-'); my $pvrlvd = HistoryVal ($name, $day, $key, 'pvrlvd', '-'); my $pvfc = HistoryVal ($name, $day, $key, 'pvfc', '-'); + my $pvapifcraw = HistoryVal ($name, $day, $key, 'pvapifcraw', '-'); my $gcons = HistoryVal ($name, $day, $key, 'gcons', '-'); my $con = HistoryVal ($name, $day, $key, 'con', '-'); my $confc = HistoryVal ($name, $day, $key, 'confc', '-'); @@ -20370,6 +20377,7 @@ sub _listDataPoolPvHist { $hexp->{$day}{$key}{PVreal} = $pvrl; $hexp->{$day}{$key}{PVrealValid} = $pvrlvd; $hexp->{$day}{$key}{PVforecast} = $pvfc; + $hexp->{$day}{$key}{PVapiForecastRaw} = $pvapifcraw; $hexp->{$day}{$key}{GridConsumption} = $gcons; $hexp->{$day}{$key}{Consumption} = $con; $hexp->{$day}{$key}{confc} = $confc; @@ -20473,7 +20481,7 @@ sub _listDataPoolPvHist { $ret .= "\n " if($ret); $ret .= $key." => "; - $ret .= "pvfc: $pvfc, pvrl: $pvrl, pvrlvd: $pvrlvd, plantderated: $pd, rad1h: $rad1h"; + $ret .= "pvapifcraw: $pvapifcraw, pvfc: $pvfc, pvrl: $pvrl, pvrlvd: $pvrlvd, plantderated: $pd, rad1h: $rad1h"; $ret .= "\n "; $ret .= $inve if($inve && $key ne '99'); $ret .= "\n " if($inve && $key ne '99'); @@ -21831,7 +21839,7 @@ sub checkPlantConfig { if (!$fipl && isBatteryUsed ($name)) { $result->{'Plant Control'}{state} = $info; $result->{'Plant Control'}{result} .= qq{It may be useful setting 'plantControl->feedinPowerLimit' if Batteries are installed.
}; - $result->{'Plant Control'}{note} .= qq{The 'feedinPowerLimit' parameter is helpful in conjunction with the ‘ctrlBatSocManagementXX’ attribute to prevent a possible curtailment of the PV system and to make optimum use of the yield if battery(ies) are used.
}; + $result->{'Plant Control'}{note} .= qq{The 'feedinPowerLimit' parameter is helpful in conjunction with the 'ctrlBatSocManagementXX' attribute to prevent a possible curtailment of the PV system and to make optimum use of the yield if battery(ies) are used.
}; $result->{'Plant Control'}{note} .= qq{(see this section in the german Wiki)
}; $result->{'Plant Control'}{info} = 1; } @@ -25151,7 +25159,7 @@ to ensure that the system configuration is correct. addRawData Relevant PV, radiation and environmental data are extracted and stored for later use. rawDataGHIreplace Historical GHI (Global Horizontal Irradiance) values are retrieved from the Open-Meteo service and the values in aiRawData - (see get ... valDecTree aiRawData) replaces existing values ‘rad1h’ + (see get ... valDecTree aiRawData) replaces existing values 'rad1h' or adds them if they are not available. @@ -25224,8 +25232,8 @@ to ensure that the system configuration is correct.
  • cycleInterval <Integer>

    Repetition interval of the data collection in seconds.
    - The command is suitable for dynamically changing the ‘cycleInterval’ key in the ‘plantControl’ attribute. - The conditions of the ‘plantControl’ attribute apply to the entry. + The command is suitable for dynamically changing the 'cycleInterval' key in the 'plantControl' attribute. + The conditions of the 'plantControl' attribute apply to the entry.

      @@ -25774,6 +25782,7 @@ to ensure that the system configuration is correct. minutescsmXX total active minutes in the hour of ConsumerXX plantderated Timestamp of the first curtailment event of the system in this hour, otherwise '0' pprlXX Energy generation of producer XX (see attribute setupOtherProducerXX) in the hour (Wh) + pvapifcraw expected PV generation (Wh) of the API used (raw) pvfc the predicted PV yield (Wh) pvrlXX real PV generation (Wh) of inverter XX pvrl Sum real PV generation (Wh) of all inverters @@ -26116,7 +26125,7 @@ to ensure that the system configuration is correct. dummyIcon Icon and, if applicable, its color for displaying the dummy consumer in the flow chart (optional). Syntax: [<Icon>][@<Color>] - If only the color of the standard dummy icon is to be changed, only ‘@<color>’ can be specified. + If only the color of the standard dummy icon is to be changed, only '@<color>' can be specified. The color can be specified as a hex value (e.g. #cc3300) or designation (e.g. red, blue). showLegend Defines the position or display method of the consumer legend if consumers are registered. @@ -26774,8 +26783,8 @@ to ensure that the system configuration is correct. <Level>:lin - linear scaling (default) <Level>:log - logarithmic scaling - showDiff Additional numerical display of the difference ‘<primary bar content> - <secondary bar content>’. - The specification for each level consists of the level number (1..X), a ‘:’ followed by the position ‘top’ or ‘bottom’. + showDiff Additional numerical display of the difference '<primary bar content> - <secondary bar content>'. + The specification for each level consists of the level number (1..X), a ':' followed by the position 'top' or 'bottom'. The strings for each level are separated by commas (see example). <Level>:top - display above the bars <Level>:bottom - display below the bars @@ -26952,7 +26961,7 @@ to ensure that the system configuration is correct. 0 no display of night hours if no value is to be displayed (default) If the selected content contains a value, these bars are still displayed. - 01 Like ‘0’, but time synchronisation takes place between the level 1 + 01 Like '0', but time synchronisation takes place between the level 1 and the subsequent bar chart level. 1 the night hours are always displayed @@ -27010,16 +27019,16 @@ to ensure that the system configuration is correct. consForecastLastDays The specified number of historical days is included in the calculation of the consumption forecast. For example, with the attribute value “1” only the previous day is taken into account, with the value “14” the previous 14 days. The days taken into account may be fewer if there are not enough values in the internal memory. - If the key ‘consForecastIdentWeekdays’ is also set, the specified number of past weekdays + If the key 'consForecastIdentWeekdays' is also set, the specified number of past weekdays of the same day (Mon .. Sun) is taken into account. - For example, if the value is set to ‘8’, the same weekdays of the past 8 weeks are taken into account. + For example, if the value is set to '8', the same weekdays of the past 8 weeks are taken into account. Value: Integer 0..180, default: 60 cycleInterval Repetition interval of the data collection in seconds. - If cycleInterval is explicitly set to ‘0’, there is no regular data collection and must be started externally - with ‘get <name> data’. + If cycleInterval is explicitly set to '0', there is no regular data collection and must be started externally + with 'get <name> data'. Value: Integer, default: 70 - Note: Regardless of the interval set (even with ‘0’), data is collected automatically a few seconds before the end + Note: Regardless of the interval set (even with '0'), data is collected automatically a few seconds before the end and after the start of a full hour. Data is also collected automatically when an event from a device defined as “asynchronous” (consumer, meter, etc.) is received and processed. @@ -27033,7 +27042,7 @@ to ensure that the system configuration is correct. daily - Calculation and creation of Today_PVdeviation takes place after sunset (default) continuously - Calculation and creation of Today_PVdeviation is continuous - genPVforecastsToEvent The module generates daily ‘AllPVforecastsToEvent’ events to visualize the PV forecast. + genPVforecastsToEvent The module generates daily 'AllPVforecastsToEvent' events to visualize the PV forecast. Further explanations can be found in the german Wiki. Note: When using the attribute, the attribute event-on-update-reading=AllPVforecastsToEvent must also be set. Event generation can be optimized for specific uses: @@ -27045,7 +27054,7 @@ to ensure that the system configuration is correct. Reading - Reading that provides the reduction status The check of the supplied value can be formulated as a regular expression or as Perl code enclosed in {..}: Regex - Regular expression that must be fulfilled for a reduction status (true) - {Perl-Code} - the Perl code enclosed in {..} must return ‘true’ for a reduction status. It must not contain spaces. + {Perl-Code} - the Perl code enclosed in {..} must return 'true' for a reduction status. It must not contain spaces. The value of Device:Reading is transferred to the code with the variable $VALUE. showLink Display of a link to the detailed view of the device above the graphics area @@ -27086,11 +27095,11 @@ to ensure that the system configuration is correct. intotal Reading which provides the total battery charge as a continuous counter (optional) If the reading violates the specification of a continuously rising counter, SolarForecast handles - this error and reports the situation that has occurred with a log entry with verbose 2. + this error and reports the situation that has occurred with a log entry with verbose 3. outtotal Reading which provides the total battery discharge as a continuous counter (optional) If the reading violates the specification of a continuously rising counter, SolarForecast handles - this error and reports the situation that has occurred with a log entry with verbose 2. + this error and reports the situation that has occurred with a log entry with verbose 3. cap installed battery capacity. Option can be: Integer - direct specification of the battery capacity in Wh without specifying the unit! @@ -27101,8 +27110,8 @@ to ensure that the system configuration is correct. Unit the respective unit (W,Wh,kW,kWh) icon Icon and/or (only) color of the battery in the bar graph according to the status (optional). - The identifier (e.g. blue), HEX value (e.g. #d9d9d9) or ‘dyn’ can be specified as the color. - If ‘dyn’ is used, the icon is colored depending on the SoC value. + The identifier (e.g. blue), HEX value (e.g. #d9d9d9) or 'dyn' can be specified as the color. + If 'dyn' is used, the icon is colored depending on the SoC value. <recomm> - Icon if charging is recommended but inactive (no charging / discharging) <charge> - Icon is used when the battery is currently being charged <discharge> - Icon is used when the battery is currently being discharged @@ -28431,6 +28440,7 @@ die ordnungsgemäße Anlagenkonfiguration geprüft werden. minutescsmXX Summe Aktivminuten in der Stunde von ConsumerXX plantderated Zeitstempel des ersten Abregelungsvorfalls der Anlage in dieser Stunde, sonst '0' pprlXX Energieerzeugung des Produzenten XX (siehe Attribut setupOtherProducerXX) in der Stunde (Wh) + pvapifcraw erwartete PV Erzeugung (Wh) der verwendeten API (raw) pvfc der prognostizierte PV Ertrag (Wh) pvrlXX reale PV Erzeugung (Wh) von Inverter XX pvrl Summe reale PV Erzeugung (Wh) aller Inverter @@ -29742,11 +29752,11 @@ die ordnungsgemäße Anlagenkonfiguration geprüft werden. intotal Reading welches die totale Batterieladung als fortlaufenden Zähler liefert (optional) Sollte des Reading die Vorgabe eines stetig aufsteigenden Zählers verletzen, behandelt - SolarForecast diesen Fehler und meldet die aufgetretene Situation durch einen Logeintrag mit verbose 2. + SolarForecast diesen Fehler und meldet die aufgetretene Situation durch einen Logeintrag mit verbose 3. outtotal Reading welches die totale Batterieentladung als fortlaufenden Zähler liefert (optional) Sollte des Reading die Vorgabe eines stetig aufsteigenden Zählers verletzen, behandelt - SolarForecast diesen Fehler und meldet die aufgetretene Situation durch einen Logeintrag mit verbose 2. + SolarForecast diesen Fehler und meldet die aufgetretene Situation durch einen Logeintrag mit verbose 3. cap installierte Batteriekapazität. Option kann sein: Ganzzahl - direkte Angabe der Batteriekapazität in Wh ohne die Einheit anzugeben!