diff --git a/FHEM/59_Twilight.pm b/FHEM/59_Twilight.pm index ceb68b5d4..7fd17637f 100644 --- a/FHEM/59_Twilight.pm +++ b/FHEM/59_Twilight.pm @@ -74,7 +74,7 @@ sub Twilight_Initialize($) $hash->{DefFn} = "Twilight_Define"; $hash->{UndefFn} = "Twilight_Undef"; $hash->{GetFn} = "Twilight_Get"; - $hash->{AttrList}= $readingFnAttributes; + $hash->{AttrList}= "$readingFnAttributes " ."useExtWeather"; } # # @@ -540,12 +540,29 @@ sub Twilight_sunpos($) my $twilight = int(($dElevation+12.0)/18.0 * 1000)/10; $twilight = 100 if ($twilight>100); $twilight = 0 if ($twilight< 0); + + my $twilight_weather ; - my $twilight_weather = int(($dElevation-$hash->{WEATHER_HORIZON}+12.0)/18.0 * 1000)/10; - $twilight_weather = 100 if ($twilight_weather>100); - $twilight_weather = 0 if ($twilight_weather< 0); + if( (my $ExtWeather = AttrVal($hashName, "useExtWeather", "")) eq "") { + $twilight_weather = int(($dElevation-$hash->{WEATHER_HORIZON}+12.0)/18.0 * 1000)/10; + Log3 $hash, 5, "[$hash->{NAME}] " . "Original weather readings"; + } else { + my($extDev,$extReading) = split(":",$ExtWeather); + my $extWeatherHorizont = ReadingsVal($extDev,$extReading,-1); + if ($extWeatherHorizont >= 0){ + $extWeatherHorizont = 100 if ($extWeatherHorizont > 100); + Log3 $hash, 5, "[$hash->{NAME}] " . "New weather readings from: ".$extDev.":".$extReading.":".$extWeatherHorizont; + $twilight_weather = $twilight - int(0.007 * ($extWeatherHorizont ** 2)); ## SCM: 100% clouds => 30% light (rough estimation) + } else { + $twilight_weather = int(($dElevation-$hash->{WEATHER_HORIZON}+12.0)/18.0 * 1000)/10; + Log3 $hash, 3, "[$hash->{NAME}] " . "Error with external readings from: ".$extDev.":".$extReading." , taking original weather readings"; + } + } + + $twilight_weather = 100 if ($twilight_weather>100); + $twilight_weather = 0 if ($twilight_weather< 0); - # set readings + # set readings $dAzimuth = int(100*$dAzimuth )/100; $dElevation = int(100*$dElevation)/100; @@ -729,6 +746,10 @@ sub twilight($$$$) { Attributes
@@ -856,6 +877,10 @@ Wissenswert dazu ist, dass die Sonne, abhägnig vom Breitengrad, bestimmte E Attributes
diff --git a/FHEM/98_RandomTimer.pm b/FHEM/98_RandomTimer.pm index d2bf0f5b3..417dc07fa 100644 --- a/FHEM/98_RandomTimer.pm +++ b/FHEM/98_RandomTimer.pm @@ -138,7 +138,7 @@ sub RandomTimer_SetTimer($) myInternalTimer ("Exec", $setExecTime, "RandomTimer_Exec", $hash, 0); if ($hash->{REP} gt "") { - my $setTimerTime = max($now+$secToMidnight, $hash->{stopTime}) + 60; + my $setTimerTime = max($now+$secToMidnight, $hash->{stopTime}) + $hash->{TIMETOSWITCH}+15; myRemoveInternalTimer("SetTimer", $hash); myInternalTimer ("SetTimer", $setTimerTime, "RandomTimer_SetTimer", $hash, 0); }