diff --git a/fhem/contrib/DS_Starter/76_SolarForecast.pm b/fhem/contrib/DS_Starter/76_SolarForecast.pm index 8021766ca..e93b5f24a 100644 --- a/fhem/contrib/DS_Starter/76_SolarForecast.pm +++ b/fhem/contrib/DS_Starter/76_SolarForecast.pm @@ -115,8 +115,9 @@ BEGIN { # Versions History intern my %vNotesIntern = ( - "0.3.0" => "21.12.2021 add cloud correction, add rain correction, add reset pvHistory, setter writeHistory ", - "0.2.0" => "20.12.2021 use SMUtils, JSON, implement getter data,html,pvHistory, correct the 'disable' problem ", + "0.4.0" => "24.01.2021 setter moduleDirection, add Area factor to calcPVforecast, add reset pvCorrection ", + "0.3.0" => "21.01.2021 add cloud correction, add rain correction, add reset pvHistory, setter writeHistory ", + "0.2.0" => "20.01.2021 use SMUtils, JSON, implement getter data,html,pvHistory, correct the 'disable' problem ", "0.1.0" => "09.12.2020 initial Version " ); @@ -149,6 +150,7 @@ my %hset = ( # Ha pvCorrectionFactor_Auto => { fn => \&_setpvCorrectionFactorAuto }, reset => { fn => \&_setreset }, moduleTiltAngle => { fn => \&_setmoduleTiltAngle }, + moduleDirection => { fn => \&_setmoduleDirection }, writeHistory => { fn => \&_setwriteHistory }, ); @@ -159,18 +161,18 @@ my %hget = ( # Ha pvHistory => { fn => \&_getlistPVHistory, needcred => 0 }, ); -my %htilt = ( # Faktor für Neigungswinkel der Solarmodule (Südausrichtung) - "0" => 1.00, # https://www.labri.fr/perso/billaud/travaux/Helios/Helios2/resources/de04/Chapter_4_DE.pdf - "10" => 1.06, - "20" => 1.15, - "30" => 1.35, - "40" => 1.43, - "45" => 1.44, - "50" => 1.47, - "60" => 1.50, - "70" => 1.44, - "80" => 1.35, - "90" => 1.26 +my %hff = ( # Flächenfaktoren + "0" => { N => 100, NE => 100, E => 100, SE => 100, S => 100, SW => 100, W => 100, NW => 100 }, # http://www.ing-büro-junge.de/html/photovoltaik.html + "10" => { N => 90, NE => 93, E => 100, SE => 105, S => 107, SW => 105, W => 100, NW => 93 }, + "20" => { N => 80, NE => 84, E => 97, SE => 109, S => 114, SW => 109, W => 97, NW => 84 }, + "30" => { N => 69, NE => 76, E => 94, SE => 110, S => 116, SW => 110, W => 94, NW => 76 }, + "40" => { N => 59, NE => 68, E => 90, SE => 109, S => 117, SW => 109, W => 90, NW => 68 }, + "45" => { N => 55, NE => 65, E => 87, SE => 108, S => 115, SW => 108, W => 87, NW => 65 }, + "50" => { N => 49, NE => 62, E => 85, SE => 107, S => 113, SW => 107, W => 85, NW => 62 }, + "60" => { N => 42, NE => 55, E => 80, SE => 102, S => 111, SW => 102, W => 80, NW => 55 }, + "70" => { N => 37, NE => 50, E => 74, SE => 95, S => 104, SW => 95, W => 74, NW => 50 }, + "80" => { N => 35, NE => 46, E => 67, SE => 86, S => 95, SW => 86, W => 67, NW => 46 }, + "90" => { N => 33, NE => 43, E => 62, SE => 78, S => 85, SW => 78, W => 62, NW => 43 }, ); my %weather_ids = ( @@ -440,7 +442,7 @@ sub Set { } $cf = join " ", @cfs if(@cfs); - my $tilt = join ",", sort keys %htilt; + my $tilt = join ",", sort keys %hff; $setlist = "Unknown argument $opt, choose one of ". "currentForecastDev:$fcd ". @@ -450,8 +452,9 @@ sub Set { "moduleArea ". "moduleEfficiency ". "moduleTiltAngle:$tilt ". + "moduleDirection:N,NE,E,SE,S,SW,W,NW ". "pvCorrectionFactor_Auto:on,off ". - "reset:currentForecastDev,currentInverterDev,currentMeterDev,pvHistory ". + "reset:currentForecastDev,currentInverterDev,currentMeterDev,pvCorrection,pvHistory ". "writeHistory:noArg ". $cf ; @@ -589,6 +592,11 @@ sub _setreset { ## no critic "not used" delete $data{$type}{$name}{pvhist}; return; } + + if($prop eq "pvCorrection") { + deleteReadingspec ($hash, "pvCorrectionFactor_.*"); + return; + } readingsDelete($hash, $prop); @@ -644,6 +652,24 @@ sub _setmoduleTiltAngle { ## no critic "not used" return; } +################################################################ +# Setter moduleDirection +################################################################ +sub _setmoduleDirection { ## no critic "not used" + my $paref = shift; + my $hash = $paref->{hash}; + my $name = $paref->{name}; + my $prop = $paref->{prop} // return qq{no module direction was provided}; + + if($prop !~ /N|NE|E|SE|S|SW|W|NW/x) { + return qq{No valid value for module direction: $prop}; + } + + readingsSingleUpdate($hash, "moduleDirection", $prop, 1); + +return; +} + ################################################################ # Setter inverterEfficiency ################################################################ @@ -1411,16 +1437,17 @@ sub forecastGraphic { $hash->{HELPER}{SPGROOM} = $FW_room ? $FW_room : ""; # Raum aus dem das SMAPortalSPG-Device die Funktion aufrief $hash->{HELPER}{SPGDETAIL} = $FW_detail ? $FW_detail : ""; # Name des SMAPortalSPG-Devices (wenn Detailansicht) - my $fcdev = ReadingsVal($name, "currentForecastDev", ""); # aktuelles Forecast Device - my $indev = ReadingsVal($name, "currentInverterDev", ""); # aktuelles Inverter Device + my $fcdev = ReadingsVal ($name, "currentForecastDev", ""); # aktuelles Forecast Device + my $indev = ReadingsVal ($name, "currentInverterDev", ""); # aktuelles Inverter Device my ($a,$h) = parseParams ($indev); $indev = $a->[0] // ""; my $cclv = "L05"; - my $pv0 = ReadingsNum ($name, "ThisHour_PVforecast", undef); - my $ma = ReadingsNum ($name, "moduleArea", 0); # Solar Modulfläche (qm) + my $pv0 = ReadingsNum ($name, "ThisHour_PVforecast", undef); + my $ma = ReadingsNum ($name, "moduleArea", 0); # Solar Modulfläche (qm) + my $moddir = ReadingsVal ($name, "moduleDirection", ""); # aktuelles Inverter Device - if(!$fcdev || !$ma || !defined $pv0) { + if(!$fcdev || !$ma || !defined $pv0 || !$moddir) { $height = AttrNum($name, 'beamHeight', 200); $ret .= "