From cb3f5c1ecb3c67e783af4b32be20101170a673b7 Mon Sep 17 00:00:00 2001 From: Marko Oldenburg Date: Sat, 25 Apr 2020 08:49:56 +0200 Subject: [PATCH] fix no visibility is available --- OpenWeatherMapAPI.pm | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/OpenWeatherMapAPI.pm b/OpenWeatherMapAPI.pm index b4381db..f9d30e0 100644 --- a/OpenWeatherMapAPI.pm +++ b/OpenWeatherMapAPI.pm @@ -36,7 +36,6 @@ package OpenWeatherMapAPI; use strict; use warnings; use FHEM::Meta; -use Data::Dumper; FHEM::Meta::Load(__PACKAGE__); use version 0.50; our $VERSION = $main::packages{OpenWeatherMapAPI}{META}{version}; @@ -48,6 +47,8 @@ use warnings; use POSIX; use HttpUtils; +# use Data::Dumper; + # try to use JSON::MaybeXS wrapper # for chance of better performance + open code eval { @@ -424,8 +425,6 @@ sub _ProcessingRetrieveData { ), 'wind_direction' => $data->{wind}->{deg}, 'cloudCover' => $data->{clouds}->{all}, - 'visibility' => - int( sprintf( "%.1f", $data->{visibility} ) + 0.5 ), 'code' => $codes{ $data->{weather}->[0]->{id} }, 'iconAPI' => $data->{weather}->[0]->{icon}, 'sunsetTime' => strftimeWrapper( @@ -438,12 +437,12 @@ sub _ProcessingRetrieveData { ), 'pubDate' => strftimeWrapper( "%a, %e %b %Y %H:%M", - ( exists $data->{dt} - ? localtime( $data->{dt} ) - : localtime( time ) - ) + localtime( $data->{dt} ) ), }; + + $self->{cached}->{current}->{'visibility'} = int(sprintf( "%.1f", $data->{visibility} ) + 0.5) + if ( exists $data->{visibility} ); } if ( $self->{endpoint} eq 'forecast' ) { @@ -660,7 +659,7 @@ sub strftimeWrapper { "abstract": "Wetter API für OpenWeatherMap" } }, - "version": "v1.0.1", + "version": "v1.0.2", "author": [ "Marko Oldenburg " ],