mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-03-03 16:56:54 +00:00
New Reading "condition" in Twilight to react directly on weather condition code without Twilight internal mapping
git-svn-id: https://svn.fhem.de/fhem/trunk@1480 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
0ce595af59
commit
03095993ef
@ -182,7 +182,8 @@ sub Twilight_GetUpdate{
|
||||
$sunrise_set[4]{DEGREE}=$hash->{INDOOR_HORIZON};
|
||||
$sunrise_set[5]{SR_NAME}="sr_weather";
|
||||
$sunrise_set[5]{SS_NAME}="ss_weather";
|
||||
$hash->{WEATHER_HORIZON}=Twilight_getWeatherHorizon($hash->{WEATHER})+$hash->{INDOOR_HORIZON};
|
||||
Twilight_getWeatherHorizon($hash);
|
||||
readingsUpdate($hash,"condition",$hash->{CONDITION});
|
||||
if($hash->{WEATHER_HORIZON}>(89-$hash->{LATITUDE}+$declination)){$hash->{WEATHER_HORIZON}=89-$hash->{LATITUDE}+$declination;}
|
||||
$sunrise_set[5]{DEGREE}=$hash->{WEATHER_HORIZON};
|
||||
|
||||
@ -264,13 +265,16 @@ sub twilight_calc {
|
||||
sub Twilight_getWeatherHorizon{
|
||||
my @a_current = (25,25,25,25,20,10,10,10,10,10,10,7,7,7,5,10,10,6,6,6,10,6,6,6,6,6,6,5,5,3,3,0,0,0,0,7,0,15,15,15,9,15,8,5,12,6,8,8);
|
||||
#condition codes are described in FHEM wiki and in the documentation of the yahoo weather API
|
||||
my $location=shift;
|
||||
my $hash=shift;
|
||||
my $location=$hash->{WEATHER};
|
||||
my $xml = GetHttpFile("weather.yahooapis.com:80","/forecastrss?w=".$location."&u=c",4.0);
|
||||
my $current;
|
||||
if($xml=~/code="(.*)"(\ *)temp/){
|
||||
$current=$1;
|
||||
if(($current>=0) && ($current <=47)) {
|
||||
return $a_current[$current];
|
||||
$hash->{WEATHER_HORIZON}=$a_current[$current]+$hash->{INDOOR_HORIZON};
|
||||
$hash->{CONDITION}=$current;
|
||||
return 1;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user