patch-specials #10
| @@ -1,4 +1,4 @@ | |||||||
| UPD 2022-12-28_09:21:01 54815 FHEM/59_Weather.pm | UPD 2022-12-28_09:21:01 54815 FHEM/59_Weather.pm | ||||||
| UPD 2022-12-28_09:20:44 49883 lib/FHEM/APIs/Weather/DarkSkyAPI.pm | UPD 2022-12-28_09:20:44 49883 lib/FHEM/APIs/Weather/DarkSkyAPI.pm | ||||||
| UPD 2022-12-28_09:20:52 32101 lib/FHEM/APIs/Weather/OpenWeatherMapAPI.pm | UPD 2022-12-28_09:20:52 32101 lib/FHEM/APIs/Weather/OpenWeatherMapAPI.pm | ||||||
| UPD 2022-12-29_04:40:05 35600 lib/FHEM/APIs/Weather/wundergroundAPI.pm | UPD 2022-12-30_12:10:48 36045 lib/FHEM/APIs/Weather/wundergroundAPI.pm | ||||||
|   | |||||||
| @@ -366,14 +366,13 @@ sub _RetrieveDataFinished { | |||||||
| sub _ProcessingRetrieveData { | sub _ProcessingRetrieveData { | ||||||
|     return 0 unless ( __PACKAGE__ eq caller(0) ); |     return 0 unless ( __PACKAGE__ eq caller(0) ); | ||||||
|  |  | ||||||
|     my $self     = shift; |     my ( $self, $response ) = @_; | ||||||
|     my $response = shift; |  | ||||||
|  |  | ||||||
|     if (    $self->{cached}{status} eq 'ok' |     if (    $self->{cached}{status} eq 'ok' | ||||||
|         and defined($response) |         and defined($response) | ||||||
|         and $response ) |         and $response ) | ||||||
|     { |     { | ||||||
|         if ( $response =~ m/^\{.*\}$/x ) { |         if ( $response =~ m/^\{.*\}$/ ) { | ||||||
|             my $data = eval { decode_json( encode_utf8($response) ) }; |             my $data = eval { decode_json( encode_utf8($response) ) }; | ||||||
|             if ($@) { |             if ($@) { | ||||||
|                 _ErrorHandling( $self, |                 _ErrorHandling( $self, | ||||||
| @@ -393,7 +392,7 @@ sub _ProcessingRetrieveData { | |||||||
|                 # print Dumper $data;    ## für Debugging |                 # print Dumper $data;    ## für Debugging | ||||||
|  |  | ||||||
|                 $self->{cached}{current_date_time} = |                 $self->{cached}{current_date_time} = | ||||||
|                   _strftimeWrapper( "%a, %e %b %Y %H:%M", |                   strftimeWrapper( "%a, %e %b %Y %H:%M", | ||||||
|                     localtime( $self->{fetchTime} ) ); |                     localtime( $self->{fetchTime} ) ); | ||||||
|  |  | ||||||
|                 # $self->{cached}{timezone} = $data->{timezone}; |                 # $self->{cached}{timezone} = $data->{timezone}; | ||||||
| @@ -423,17 +422,22 @@ sub _ProcessingRetrieveData { | |||||||
|                     ); |                     ); | ||||||
|  |  | ||||||
|                     $self->{cached}{current} = { |                     $self->{cached}{current} = { | ||||||
|                         'dewPoint'  => sprintf( "%.1f", $data->{$unit}{dewpt} ), |                         'dewPoint' => | ||||||
|                         'heatIndex' => $data->{$unit}{heatIndex}, |                           int( sprintf( "%.1f", $data->{$unit}{dewpt} ) + 0.5 ), | ||||||
|  |                         'heatIndex'   => $data->{$unit}{heatIndex}, | ||||||
|                         'precipRate'  => $data->{$unit}{precipRate}, |                         'precipRate'  => $data->{$unit}{precipRate}, | ||||||
|                         'precipTotal' => $data->{$unit}{precipTotal}, |                         'precipTotal' => $data->{$unit}{precipTotal}, | ||||||
|                         'pressure'    => |                         'pressure'    => int( | ||||||
|                           sprintf( "%.1f", $data->{$unit}{pressure} ), |                             sprintf( "%.1f", $data->{$unit}{pressure} ) + 0.5 | ||||||
|  |                         ), | ||||||
|                         'temperature' => |                         'temperature' => | ||||||
|                           sprintf( "%.1f", $data->{$unit}{temp} ), |                           int( sprintf( "%.1f", $data->{$unit}{temp} ) + 0.5 ), | ||||||
|                         'temp_c'     => sprintf( "%.1f", $data->{$unit}{temp} ), |                         'temp_c' => | ||||||
|                         'wind_chill' => |                           int( sprintf( "%.1f", $data->{$unit}{temp} ) + 0.5 ), | ||||||
|                           sprintf( "%.1f", ( $data->{$unit}{windChill} ) ), |                         'wind_chill' => int( | ||||||
|  |                             sprintf( "%.1f", ( $data->{$unit}{windChill} ) ) + | ||||||
|  |                               0.5 | ||||||
|  |                         ), | ||||||
|                         'windGust' => int( |                         'windGust' => int( | ||||||
|                             sprintf( "%.1f", ( $data->{$unit}{windGust} ) ) + |                             sprintf( "%.1f", ( $data->{$unit}{windGust} ) ) + | ||||||
|                               0.5 |                               0.5 | ||||||
| @@ -450,7 +454,7 @@ sub _ProcessingRetrieveData { | |||||||
|                         'solarRadiation' => $data->{solarRadiation}, |                         'solarRadiation' => $data->{solarRadiation}, | ||||||
|                         'uvIndex'        => $data->{uv}, |                         'uvIndex'        => $data->{uv}, | ||||||
|                         'humidity'       => $data->{humidity}, |                         'humidity'       => $data->{humidity}, | ||||||
|                         'pubDate'        => _strftimeWrapper( |                         'pubDate'        => strftimeWrapper( | ||||||
|                             "%a, %e %b %Y %H:%M", |                             "%a, %e %b %Y %H:%M", | ||||||
|                             localtime( |                             localtime( | ||||||
|                                 main::time_str2num( $data->{obsTimeLocal} ) |                                 main::time_str2num( $data->{obsTimeLocal} ) | ||||||
| @@ -479,23 +483,21 @@ sub _ProcessingRetrieveData { | |||||||
|                 { |                 { | ||||||
|                     ### löschen des alten Datensatzes |                     ### löschen des alten Datensatzes | ||||||
|                     delete $self->{cached}{forecast}; |                     delete $self->{cached}{forecast}; | ||||||
|                     my $data; |  | ||||||
|                     $data = |                     my $data = | ||||||
|                       exists( $data->{daily} ) ? $data->{daily} : $data; |                       exists( $data->{daily} ) ? $data->{daily} : $data; | ||||||
|                     my $days = scalar @{ $data->{temperatureMin} }; |                     my $days = scalar @{ $data->{temperatureMin} }; | ||||||
|  |  | ||||||
|                     my $i; |                     my $i = 0; | ||||||
|                     $i = 0; |  | ||||||
|  |  | ||||||
|                     while ( $i < $days ) { |                     while ( $i < $days ) { | ||||||
|                         $data->{moonriseTimeLocal}[$i] =~ |                         $data->{moonriseTimeLocal}[$i] =~ | ||||||
|                           s/^(....-..-..T..:..).*/$1/x; |                           s/^(....-..-..T..:..).*/$1/; | ||||||
|                         $data->{moonsetTimeLocal}[$i] =~ |                         $data->{moonsetTimeLocal}[$i] =~ | ||||||
|                           s/^(....-..-..T..:..).*/$1/x; |                           s/^(....-..-..T..:..).*/$1/; | ||||||
|                         $data->{sunriseTimeLocal}[$i] =~ |                         $data->{sunriseTimeLocal}[$i] =~ | ||||||
|                           s/^(....-..-..T..:..).*/$1/x; |                           s/^(....-..-..T..:..).*/$1/; | ||||||
|                         $data->{sunsetTimeLocal}[$i] =~ |                         $data->{sunsetTimeLocal}[$i] =~ | ||||||
|                           s/^(....-..-..T..:..).*/$1/x; |                           s/^(....-..-..T..:..).*/$1/; | ||||||
|  |  | ||||||
|                         push( |                         push( | ||||||
|                             @{ $self->{cached}{forecast}{daily} }, |                             @{ $self->{cached}{forecast}{daily} }, | ||||||
| @@ -504,7 +506,7 @@ sub _ProcessingRetrieveData { | |||||||
|                                 'moonPhase'     => $data->{moonPhase}[$i], |                                 'moonPhase'     => $data->{moonPhase}[$i], | ||||||
|                                 'moonPhaseCode' => $data->{moonPhaseCode}[$i], |                                 'moonPhaseCode' => $data->{moonPhaseCode}[$i], | ||||||
|                                 'moonPhaseDay'  => $data->{moonPhaseDay}[$i], |                                 'moonPhaseDay'  => $data->{moonPhaseDay}[$i], | ||||||
|                                 'moonriseTime'  => _strftimeWrapper( |                                 'moonriseTime'  => strftimeWrapper( | ||||||
|                                     "%a, %e %b %Y %H:%M", |                                     "%a, %e %b %Y %H:%M", | ||||||
|                                     localtime( |                                     localtime( | ||||||
|                                         main::time_str2num( |                                         main::time_str2num( | ||||||
| @@ -512,7 +514,7 @@ sub _ProcessingRetrieveData { | |||||||
|                                         ) |                                         ) | ||||||
|                                     ) |                                     ) | ||||||
|                                 ), |                                 ), | ||||||
|                                 'moonsetTime' => _strftimeWrapper( |                                 'moonsetTime' => strftimeWrapper( | ||||||
|                                     "%a, %e %b %Y %H:%M", |                                     "%a, %e %b %Y %H:%M", | ||||||
|                                     localtime( |                                     localtime( | ||||||
|                                         main::time_str2num( |                                         main::time_str2num( | ||||||
| @@ -523,7 +525,7 @@ sub _ProcessingRetrieveData { | |||||||
|                                 'narrative'         => $data->{narrative}[$i], |                                 'narrative'         => $data->{narrative}[$i], | ||||||
|                                 'precipProbability' => $data->{qpf}[$i], |                                 'precipProbability' => $data->{qpf}[$i], | ||||||
|                                 'precipProbabilitySnow' => $data->{qpfSnow}[$i], |                                 'precipProbabilitySnow' => $data->{qpfSnow}[$i], | ||||||
|                                 'sunriseTime'           => _strftimeWrapper( |                                 'sunriseTime'           => strftimeWrapper( | ||||||
|                                     "%a, %e %b %Y %H:%M", |                                     "%a, %e %b %Y %H:%M", | ||||||
|                                     localtime( |                                     localtime( | ||||||
|                                         main::time_str2num( |                                         main::time_str2num( | ||||||
| @@ -531,7 +533,7 @@ sub _ProcessingRetrieveData { | |||||||
|                                         ) |                                         ) | ||||||
|                                     ) |                                     ) | ||||||
|                                 ), |                                 ), | ||||||
|                                 'sunsetTime' => _strftimeWrapper( |                                 'sunsetTime' => strftimeWrapper( | ||||||
|                                     "%a, %e %b %Y %H:%M", |                                     "%a, %e %b %Y %H:%M", | ||||||
|                                     localtime( |                                     localtime( | ||||||
|                                         main::time_str2num( |                                         main::time_str2num( | ||||||
| @@ -539,27 +541,33 @@ sub _ProcessingRetrieveData { | |||||||
|                                         ) |                                         ) | ||||||
|                                     ) |                                     ) | ||||||
|                                 ), |                                 ), | ||||||
|                                 'low_c' => sprintf( |                                 'low_c' => int( | ||||||
|                                     "%.1f", $data->{temperatureMin}[$i] |                                     sprintf( "%.1f", | ||||||
|  |                                         $data->{temperatureMin}[$i] ) + 0.5 | ||||||
|                                 ), |                                 ), | ||||||
|                                 'high_c' => sprintf( |                                 'high_c' => int( | ||||||
|                                     "%.1f", |                                     sprintf( | ||||||
|                                     ( |                                         "%.1f", | ||||||
|                                           $data->{temperatureMax}[$i] |                                         ( | ||||||
|                                         ? $data->{temperatureMax}[$i] |                                               $data->{temperatureMax}[$i] | ||||||
|                                         : 0 |                                             ? $data->{temperatureMax}[$i] | ||||||
|                                     ) |                                             : 0 | ||||||
|  |                                         ) | ||||||
|  |                                     ) + 0.5 | ||||||
|                                 ), |                                 ), | ||||||
|                                 'tempLow' => sprintf( |                                 'tempLow' => int( | ||||||
|                                     "%.1f", $data->{temperatureMin}[$i] |                                     sprintf( "%.1f", | ||||||
|  |                                         $data->{temperatureMin}[$i] ) + 0.5 | ||||||
|                                 ), |                                 ), | ||||||
|                                 'tempHigh' => sprintf( |                                 'tempHigh' => int( | ||||||
|                                     "%.1f", |                                     sprintf( | ||||||
|                                     ( |                                         "%.1f", | ||||||
|                                           $data->{temperatureMax}[$i] |                                         ( | ||||||
|                                         ? $data->{temperatureMax}[$i] |                                               $data->{temperatureMax}[$i] | ||||||
|                                         : 0 |                                             ? $data->{temperatureMax}[$i] | ||||||
|                                     ) |                                             : 0 | ||||||
|  |                                         ) | ||||||
|  |                                     ) + 0.5 | ||||||
|                                 ), |                                 ), | ||||||
|                             } |                             } | ||||||
|                         ); |                         ); | ||||||
| @@ -574,10 +582,10 @@ sub _ProcessingRetrieveData { | |||||||
|                         and ref( $data->{daypart}[0]{daypartName} ) eq "ARRAY" |                         and ref( $data->{daypart}[0]{daypartName} ) eq "ARRAY" | ||||||
|                         and scalar @{ $data->{daypart}[0]{daypartName} } > 0 ) |                         and scalar @{ $data->{daypart}[0]{daypartName} } > 0 ) | ||||||
|                     { |                     { | ||||||
|                         $data = $data->{daypart}[0]; |                         my $data     = $data->{daypart}[0]; | ||||||
|                         my $dayparts = scalar @{ $data->{daypartName} }; |                         my $dayparts = scalar @{ $data->{daypartName} }; | ||||||
|  |  | ||||||
|                         $i = 0; |                         my $i   = 0; | ||||||
|                         my $day = 0; |                         my $day = 0; | ||||||
|                         while ( $i < $dayparts ) { |                         while ( $i < $dayparts ) { | ||||||
|  |  | ||||||
| @@ -715,7 +723,7 @@ sub _ProcessingRetrieveData { | |||||||
|     } |     } | ||||||
|  |  | ||||||
|     ## Aufruf der callbackFn |     ## Aufruf der callbackFn | ||||||
|     return _CallWeatherCallbackFn($self); |     _CallWeatherCallbackFn($self); | ||||||
| } | } | ||||||
|  |  | ||||||
| sub _CallWeatherCallbackFn { | sub _CallWeatherCallbackFn { | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user