diff --git a/fhem/contrib/DS_Starter/76_SolarForecast.pm b/fhem/contrib/DS_Starter/76_SolarForecast.pm index a2e029893..695cf7519 100644 --- a/fhem/contrib/DS_Starter/76_SolarForecast.pm +++ b/fhem/contrib/DS_Starter/76_SolarForecast.pm @@ -200,7 +200,8 @@ sub Initialize { "showWeather:1,0 ". "spaceSize ". "Wh/kWh:Wh,kWh ". - "weatherColor:colorpicker,RGB ". + "weatherColor:colorpicker,RGB ". + "weatherColor_night:colorpicker,RGB ". $readingFnAttributes; $hash->{FW_hideDisplayName} = 1; # Forum 88667 @@ -782,16 +783,15 @@ sub _transWeatherValues { $epoche = $t + (3600*$num); } - my $wid = ReadingsVal($fcname, "fc${fd}_${fh}_ww", 0); - $wid = sprintf "%02d", $wid; # führende 0 einfügen wenn nötig + my $wid = ReadingsNum($fcname, "fc${fd}_${fh}_ww", 99); # 55_DWD -> 0 .. 98 definiert , 99 ist nicht vorhanden # führende 0 einfügen wenn nötig my $fhstr = sprintf "%02d", $fh; if($fd == 0 && ($fhstr lt $fc0_SunRise_round || $fhstr gt $fc0_SunSet_round)) { # Zeit vor Sonnenaufgang oder nach Sonnenuntergang heute - $wid = "1".$wid; # "1" der WeatherID voranstellen wenn Nacht + $wid += 100; # "1" der WeatherID voranstellen wenn Nacht } elsif ($fd == 1 && ($fhstr lt $fc0_SunRise_round || $fhstr gt $fc0_SunSet_round)) { # Zeit vor Sonnenaufgang oder nach Sonnenuntergang morgen - $wid = "1".$wid; # "1" der WeatherID voranstellen wenn Nacht + $wid += 100; # "1" der WeatherID voranstellen wenn Nacht } my $txt = ReadingsVal($fcname, "fc${fd}_${fh}_wwd", ''); @@ -1152,7 +1152,8 @@ sub forecastGraphic { my $show_night = AttrNum ($name, 'showNight', 0 ); # alle Balken (Spalten) anzeigen ? my $show_diff = AttrVal ($name, 'showDiff', 'no' ); # zusätzliche Anzeige $di{} in allen Typen my $weather = AttrNum ($name, 'showWeather', 1 ); - my $colorw = AttrVal ($name, 'weatherColor', undef ); + my $colorw = AttrVal ($name, 'weatherColor', undef ); # Wetter Icon Farbe + my $colorwn = AttrVal ($name, 'weatherColor_night', $colorw ); # Wetter Icon Farbe Nacht my $wlalias = AttrVal ($name, 'alias', $name ); my $header = AttrNum ($name, 'showHeader', 1 ); @@ -1314,12 +1315,12 @@ sub forecastGraphic { ########################## # Werte aktuelle Stunde ########################## - $pv{0} = ReadingsNum($name, "ThisHour_PVforecast", 0); - $co{0} = ReadingsNum($name, "ThisHour_Consumption", 0); - $di{0} = $pv{0} - $co{0}; - $is{0} = (ReadingsVal($name,"ThisHour_IsConsumptionRecommended",'no') eq 'yes' ) ? $icon : undef; - $we{0} = $hash->{HELPER}{"ThisHour_WeatherId"} if($weather); # für Wettericons - $we{0} //= 999; + $pv{0} = ReadingsNum($name, "ThisHour_PVforecast", 0); + $co{0} = ReadingsNum($name, "ThisHour_Consumption", 0); + $di{0} = $pv{0} - $co{0}; + $is{0} = (ReadingsVal($name,"ThisHour_IsConsumptionRecommended",'no') eq 'yes' ) ? $icon : undef; + $we{0} = $hash->{HELPER}{"ThisHour_WeatherId"} if($weather); # für Wettericons + $we{0} //= 99; if(AttrVal("global","language","EN") eq "DE") { (undef,undef,undef,$t{0}) = ReadingsVal($name, "ThisHour_Time", '00.00.0000 24') =~ m/(\d{2}).(\d{2}).(\d{4})\s(\d{2})/x; @@ -1390,19 +1391,18 @@ sub forecastGraphic { my $minDif = $di{0}; # für Typ diff for my $i (1..$maxhours-1) { - $pv{$i} = ReadingsNum($name, "NextHour".sprintf("%02d",$i)."_PVforecast", 0); # Erzeugung - $co{$i} = ReadingsNum($name, "NextHour".sprintf("%02d",$i)."_Consumption", 0); # Verbrauch - $di{$i} = $pv{$i} - $co{$i}; + $pv{$i} = ReadingsNum($name, "NextHour".sprintf("%02d",$i)."_PVforecast", 0); # Erzeugung + $co{$i} = ReadingsNum($name, "NextHour".sprintf("%02d",$i)."_Consumption", 0); # Verbrauch + $di{$i} = $pv{$i} - $co{$i}; - $maxVal = $pv{$i} if ($pv{$i} > $maxVal); - $maxCon = $co{$i} if ($co{$i} > $maxCon); - $maxDif = $di{$i} if ($di{$i} > $maxDif); - $minDif = $di{$i} if ($di{$i} < $minDif); + $maxVal = $pv{$i} if ($pv{$i} > $maxVal); + $maxCon = $co{$i} if ($co{$i} > $maxCon); + $maxDif = $di{$i} if ($di{$i} > $maxDif); + $minDif = $di{$i} if ($di{$i} < $minDif); - $is{$i} = (ReadingsVal($name,"NextHour".sprintf("%02d",$i)."_IsConsumptionRecommended",'no') eq 'yes') ? $icon : undef; - $we{$i} = $hash->{HELPER}{"NextHour". sprintf("%02d",$i)."_WeatherId"} if($weather); # für Wettericons - - $we{$i} //= 999; + $is{$i} = (ReadingsVal($name,"NextHour".sprintf("%02d",$i)."_IsConsumptionRecommended",'no') eq 'yes') ? $icon : undef; + $we{$i} = $hash->{HELPER}{"NextHour". sprintf("%02d",$i)."_WeatherId"} if($weather); # für Wettericons + $we{$i} //= 99; if(AttrVal("global","language","EN") eq "DE") { (undef,undef,undef,$t{$i}) = ReadingsVal($name,"NextHour".sprintf("%02d",$i)."_Time", '00.00.0000 24') =~ m/(\d{2}).(\d{2}).(\d{4})\s(\d{2})/x; @@ -1447,15 +1447,18 @@ sub forecastGraphic { for my $i (0..$maxhours-1) { # keine Anzeige bei Null Ertrag bzw. in der Nacht , Typ pcvo & diff haben aber immer Daten in der Nacht if ($pv{$i} || $show_night || ($type eq 'pvco') || ($type eq 'diff')) { # FHEM Wetter Icons (weather_xxx) , Skalierung und Farbe durch FHEM Bordmittel + my $night = ($we{$i} > 99) ? 1 : 0; + $we{$i} -= 100 if ($night); my $icon_name = weather_icon($we{$i}); # unknown -> FHEM Icon Fragezeichen im Kreis wird als Ersatz Icon ausgegeben - Log3($name, 4, "$name - unknown weather id: ".$we{$i}.", please inform the maintainer") if($icon_name eq 'unknown'); + Log3($name, 3, "$name - unknown weather id: ".$we{$i}.", please inform the maintainer") if($icon_name eq 'unknown'); - $icon_name .='@'.$colorw if (defined($colorw)); + $icon_name .='@'.$colorw if (defined($colorw) && !$night); + $icon_name .='@'.$colorwn if (defined($colorwn) && $night); $val = FW_makeImage($icon_name); if ($val eq $icon_name) { # passendes Icon beim User nicht vorhanden ! ( attr web iconPath falsch/prüfen/update ? ) $val ='???'; - Log3($name, 4, qq{$name - the icon $we{$i} not found. Please check attribute "iconPath" of your FHEMWEB instance and/or update your FHEM software}); + Log3($name, 3, qq{$name - the icon $we{$i} not found. Please check attribute "iconPath" of your FHEMWEB instance and/or update your FHEM software}); } $ret .= "