Merge pull request #7 from fhem/patch-wu

add support for set weather newLocation, temorary location change
This commit is contained in:
Leon Gaultier 2019-09-13 10:35:39 +02:00 committed by GitHub
commit 7885ec01bd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -172,6 +172,15 @@ sub setRetrieveData {
return 0; return 0;
} }
sub setLocation {
my ($self,$lat,$long) = @_;
$self->{lat} = $lat;
$self->{long} = $long;
return 0;
}
sub getFetchTime { sub getFetchTime {
my $self = shift; my $self = shift;
@ -188,10 +197,19 @@ sub _RetrieveDataFromWU($) {
my $self = shift; my $self = shift;
# retrieve data from cache # retrieve data from cache
if ( ( time() - $self->{fetchTime} ) < $self->{cachemaxage} ) { if ( ( time() - $self->{fetchTime} ) < $self->{cachemaxage}
and $self->{cached}->{lat} == $self->{lat}
and $self->{cached}->{long} == $self->{long}
)
{
return _CallWeatherCallbackFn($self); return _CallWeatherCallbackFn($self);
} }
$self->{cached}->{lat} = $self->{lat}
unless ( $self->{cached}->{lat} == $self->{lat} );
$self->{cached}->{long} = $self->{long}
unless ( $self->{cached}->{long} == $self->{long} );
my $paramRef = { my $paramRef = {
timeout => 15, timeout => 15,
self => $self, self => $self,