add support for set weather newLocation, temorary location change

This commit is contained in:
Marko Oldenburg 2019-09-11 08:19:31 +02:00
parent 7a3fbb960b
commit 3d8ababbfe
1 changed files with 19 additions and 1 deletions

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,