From df08ffb7c4d608ad13bf884f5747a59e3ae2aad3 Mon Sep 17 00:00:00 2001 From: Marko Oldenburg Date: Sun, 25 Dec 2022 09:20:58 +0100 Subject: [PATCH] fix "PERL WARNING: Use of uninitialized value" no {wind}->{gust} field in $data --- lib/FHEM/APIs/Weather/OpenWeatherMapAPI.pm | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/FHEM/APIs/Weather/OpenWeatherMapAPI.pm b/lib/FHEM/APIs/Weather/OpenWeatherMapAPI.pm index 0a71f45..5187b7f 100644 --- a/lib/FHEM/APIs/Weather/OpenWeatherMapAPI.pm +++ b/lib/FHEM/APIs/Weather/OpenWeatherMapAPI.pm @@ -585,8 +585,6 @@ sub _FillSelfHashWithWeatherResponseForWeatherCurrent { int( sprintf( "%.1f", ( $data->{wind}->{speed} * 3.6 ) ) + 0.5 ), 'wind_speed' => int( sprintf( "%.1f", ( $data->{wind}->{speed} * 3.6 ) ) + 0.5 ), - 'wind_gust' => - int( sprintf( "%.1f", ( $data->{wind}->{gust} * 3.6 ) ) + 0.5 ), 'wind_direction' => $data->{wind}->{deg}, 'cloudCover' => $data->{clouds}->{all}, 'code' => $codes{ $data->{weather}->[0]->{id} }, @@ -606,6 +604,9 @@ sub _FillSelfHashWithWeatherResponseForWeatherCurrent { $self->{cached}->{current}->{'visibility'} = int( sprintf( "%.1f", $data->{visibility} ) + 0.5 ) if ( exists $data->{visibility} ); + $self->{cached}->{current}->{'wind_gust'} = + int( sprintf( "%.1f", ( $data->{wind}->{gust} * 3.6 ) ) + 0.5 ) + if ( exists $data->{wind}->{gust} ); return $self; }