fix "PERL WARNING: Use of uninitialized value"

no {wind}->{gust} field in $data
This commit is contained in:
Marko Oldenburg 2022-12-25 09:20:58 +01:00
parent 745fea37e2
commit df08ffb7c4

View File

@ -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;
}