2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-03-03 16:56:54 +00:00

OpenWeatherMapAPI: fix no visibility is available

git-svn-id: https://svn.fhem.de/fhem/trunk@21777 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
LeonGaultier 2020-04-25 23:53:13 +00:00
parent f758136372
commit 9c04ac3eb8
2 changed files with 28 additions and 27 deletions

View File

@ -1,5 +1,6 @@
# 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.
- bugfix: OpenWeatherMapAPI: fix no visibility is available
- feature: 57_SSCal: set compatibility to Calendar package 2.3.4-0631,
some changes according to PBP
- change: 73_GardenaSmartBridge: change state value to Connected

View File

@ -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 {
@ -207,7 +208,8 @@ sub new {
$self->{cachemaxage} = (
defined( $apioptions->{cachemaxage} )
? $apioptions->{cachemaxage}
: 900 );
: 900
);
$self->{cached} = _CreateForecastRef($self);
bless $self, $class;
@ -246,7 +248,7 @@ sub setRetrieveData {
}
sub setLocation {
my ($self,$lat,$long) = @_;
my ( $self, $lat, $long ) = @_;
$self->{lat} = $lat;
$self->{long} = $long;
@ -272,8 +274,7 @@ sub _RetrieveDataFromOpenWeatherMap {
# retrieve data from cache
if ( ( time() - $self->{fetchTime} ) < $self->{cachemaxage}
and $self->{cached}->{lat} == $self->{lat}
and $self->{cached}->{long} == $self->{long}
)
and $self->{cached}->{long} == $self->{long} )
{
return _CallWeatherCallbackFn($self);
}
@ -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,13 @@ 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' ) {
@ -617,7 +617,8 @@ sub _CreateForecastRef {
long => $self->{long},
apiMaintainer =>
'Leon Gaultier (<a href=https://forum.fhem.de/index.php?action=profile;u=13684>CoolTux</a>)',
apiVersion => version->parse(OpenWeatherMapAPI->VERSION())->normal,
apiVersion =>
version->parse( OpenWeatherMapAPI->VERSION() )->normal,
}
);
@ -647,7 +648,6 @@ sub strftimeWrapper {
1;
=pod
=encoding utf8
@ -660,7 +660,7 @@ sub strftimeWrapper {
"abstract": "Wetter API für OpenWeatherMap"
}
},
"version": "v1.0.1",
"version": "v1.0.2",
"author": [
"Marko Oldenburg <leongaultier@gmail.com>"
],