mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-03-10 03:06:37 +00:00
OpenWeatherMapAPI: fix Use of uninitialized value in sprintf
git-svn-id: https://svn.fhem.de/fhem/trunk@21745 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
5228d9fc66
commit
6d181dc672
@ -1,5 +1,6 @@
|
|||||||
# Add changes at the top of the list. Keep it in ASCII, and 80-char wide.
|
# Add changes at the top of the list. Keep it in ASCII, and 80-char wide.
|
||||||
# Do not insert empty lines here, update check depends on it.
|
# Do not insert empty lines here, update check depends on it.
|
||||||
|
- bugfix: OpenWeatherMapAPI: fix Use of uninitialized value in sprintf
|
||||||
- change: 58_HVAC_DaikinAC.pm: initial checkin for new module.
|
- change: 58_HVAC_DaikinAC.pm: initial checkin for new module.
|
||||||
Forum topic #109562
|
Forum topic #109562
|
||||||
- change: 76_SMAPortal: update time in portalgraphics changed to last
|
- change: 76_SMAPortal: update time in portalgraphics changed to last
|
||||||
|
@ -214,7 +214,7 @@ sub new {
|
|||||||
return $self;
|
return $self;
|
||||||
}
|
}
|
||||||
|
|
||||||
sub parseApiOptions($) {
|
sub parseApiOptions {
|
||||||
my $apioptions = shift;
|
my $apioptions = shift;
|
||||||
|
|
||||||
my @params;
|
my @params;
|
||||||
@ -266,7 +266,7 @@ sub getWeather {
|
|||||||
return $self->{cached};
|
return $self->{cached};
|
||||||
}
|
}
|
||||||
|
|
||||||
sub _RetrieveDataFromOpenWeatherMap($) {
|
sub _RetrieveDataFromOpenWeatherMap {
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
|
|
||||||
# retrieve data from cache
|
# retrieve data from cache
|
||||||
@ -326,8 +326,10 @@ sub _RetrieveDataFromOpenWeatherMap($) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
sub _RetrieveDataFinished($$$) {
|
sub _RetrieveDataFinished {
|
||||||
my ( $paramRef, $err, $response ) = @_;
|
my $paramRef = shift;
|
||||||
|
my $err = shift;
|
||||||
|
my $response = shift;
|
||||||
my $self = $paramRef->{self};
|
my $self = $paramRef->{self};
|
||||||
|
|
||||||
if ( !$err ) {
|
if ( !$err ) {
|
||||||
@ -342,8 +344,9 @@ sub _RetrieveDataFinished($$$) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
sub _ProcessingRetrieveData($$) {
|
sub _ProcessingRetrieveData {
|
||||||
my ( $self, $response ) = @_;
|
my $self = shift;
|
||||||
|
my $response = shift;
|
||||||
|
|
||||||
if ( $self->{cached}->{status} eq 'ok'
|
if ( $self->{cached}->{status} eq 'ok'
|
||||||
and defined($response)
|
and defined($response)
|
||||||
@ -401,6 +404,10 @@ sub _ProcessingRetrieveData($$) {
|
|||||||
sprintf( "%.1f",
|
sprintf( "%.1f",
|
||||||
( $data->{main}->{temp_max} - 273.15 ) ) + 0.5
|
( $data->{main}->{temp_max} - 273.15 ) ) + 0.5
|
||||||
),
|
),
|
||||||
|
'tempFeelsLike_c' => int(
|
||||||
|
sprintf( "%.1f",
|
||||||
|
( $data->{main}->{feels_like} - 273.15 ) ) + 0.5
|
||||||
|
),
|
||||||
'humidity' => $data->{main}->{humidity},
|
'humidity' => $data->{main}->{humidity},
|
||||||
'condition' =>
|
'condition' =>
|
||||||
encode_utf8( $data->{weather}->[0]->{description} ),
|
encode_utf8( $data->{weather}->[0]->{description} ),
|
||||||
@ -431,7 +438,10 @@ sub _ProcessingRetrieveData($$) {
|
|||||||
),
|
),
|
||||||
'pubDate' => strftimeWrapper(
|
'pubDate' => strftimeWrapper(
|
||||||
"%a, %e %b %Y %H:%M",
|
"%a, %e %b %Y %H:%M",
|
||||||
localtime( $data->{dt} )
|
( exists $data->{dt}
|
||||||
|
? localtime( $data->{dt} )
|
||||||
|
: localtime( time )
|
||||||
|
)
|
||||||
),
|
),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@ -444,7 +454,7 @@ sub _ProcessingRetrieveData($$) {
|
|||||||
delete $self->{cached}->{forecast};
|
delete $self->{cached}->{forecast};
|
||||||
|
|
||||||
my $i = 0;
|
my $i = 0;
|
||||||
foreach ( @{ $data->{list} } ) {
|
for ( @{ $data->{list} } ) {
|
||||||
push(
|
push(
|
||||||
@{ $self->{cached}->{forecast}->{hourly} },
|
@{ $self->{cached}->{forecast}->{hourly} },
|
||||||
{
|
{
|
||||||
@ -580,7 +590,7 @@ sub _ProcessingRetrieveData($$) {
|
|||||||
_CallWeatherCallbackFn($self) if ( $self->{endpoint} eq 'none' );
|
_CallWeatherCallbackFn($self) if ( $self->{endpoint} eq 'none' );
|
||||||
}
|
}
|
||||||
|
|
||||||
sub _CallWeatherCallbackFn($) {
|
sub _CallWeatherCallbackFn {
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
|
|
||||||
# print 'Dumperausgabe: ' . Dumper $self;
|
# print 'Dumperausgabe: ' . Dumper $self;
|
||||||
@ -588,8 +598,9 @@ sub _CallWeatherCallbackFn($) {
|
|||||||
main::Weather_RetrieveCallbackFn( $self->{devName} );
|
main::Weather_RetrieveCallbackFn( $self->{devName} );
|
||||||
}
|
}
|
||||||
|
|
||||||
sub _ErrorHandling($$) {
|
sub _ErrorHandling {
|
||||||
my ( $self, $err ) = @_;
|
my $self = shift;
|
||||||
|
my $err = shift;
|
||||||
|
|
||||||
$self->{cached}->{current_date_time} =
|
$self->{cached}->{current_date_time} =
|
||||||
strftimeWrapper( "%a, %e %b %Y %H:%M", localtime( $self->{fetchTime} ) ),
|
strftimeWrapper( "%a, %e %b %Y %H:%M", localtime( $self->{fetchTime} ) ),
|
||||||
@ -597,7 +608,7 @@ sub _ErrorHandling($$) {
|
|||||||
$self->{cached}->{validity} = 'stale';
|
$self->{cached}->{validity} = 'stale';
|
||||||
}
|
}
|
||||||
|
|
||||||
sub _CreateForecastRef($) {
|
sub _CreateForecastRef {
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
|
|
||||||
my $forecastRef = (
|
my $forecastRef = (
|
||||||
@ -613,7 +624,7 @@ sub _CreateForecastRef($) {
|
|||||||
return $forecastRef;
|
return $forecastRef;
|
||||||
}
|
}
|
||||||
|
|
||||||
sub strftimeWrapper(@) {
|
sub strftimeWrapper {
|
||||||
my $string = POSIX::strftime(@_);
|
my $string = POSIX::strftime(@_);
|
||||||
|
|
||||||
$string =~ s/\xe4/ä/g;
|
$string =~ s/\xe4/ä/g;
|
||||||
@ -649,7 +660,7 @@ sub strftimeWrapper(@) {
|
|||||||
"abstract": "Wetter API für OpenWeatherMap"
|
"abstract": "Wetter API für OpenWeatherMap"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"version": "v1.0.0",
|
"version": "v1.0.1",
|
||||||
"author": [
|
"author": [
|
||||||
"Marko Oldenburg <leongaultier@gmail.com>"
|
"Marko Oldenburg <leongaultier@gmail.com>"
|
||||||
],
|
],
|
||||||
|
Loading…
x
Reference in New Issue
Block a user