60_allergy.pm: fixed error handling for server replies

git-svn-id: https://svn.fhem.de/fhem/trunk@13588 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
moises
2017-03-03 15:45:05 +00:00
parent abd3af15dd
commit af834dad22
2 changed files with 19 additions and 15 deletions

View File

@@ -1,5 +1,6 @@
# Add changes at the top of the list. Keep it in ASCII, and 80-char wide. # 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. # Do not insert empty lines here, update check depends on it.
- bugfix: 60_allergy.pm: fixed error handling for server replies
- update: 38_netatmo.pm: 3 stations minimum for PUBLIC statistics - update: 38_netatmo.pm: 3 stations minimum for PUBLIC statistics
- update: 74_AMAD: new Version 2.6.11, add startDaydream and more media - update: 74_AMAD: new Version 2.6.11, add startDaydream and more media
commands commands

View File

@@ -3,7 +3,7 @@
# #
# 60_allergy.pm # 60_allergy.pm
# #
# 2016 Markus Moises < vorname at nachname . de > # 2017 Markus Moises < vorname at nachname . de >
# #
# This module provides allergy forecast data # This module provides allergy forecast data
# #
@@ -36,18 +36,16 @@ sub allergy_Initialize($) {
my ($hash) = @_; my ($hash) = @_;
my $name = $hash->{NAME}; my $name = $hash->{NAME};
$hash->{DefFn} = "allergy_Define"; $hash->{DefFn} = "allergy_Define";
$hash->{UndefFn} = "allergy_Undefine"; $hash->{UndefFn} = "allergy_Undefine";
$hash->{GetFn} = "allergy_Get"; $hash->{GetFn} = "allergy_Get";
$hash->{AttrList} = "disable:0,1 ". $hash->{AttrList} = "disable:0,1 ".
"ignoreList ". "ignoreList ".
"updateIgnored:1 ". "updateIgnored:1 ".
"updateEmpty:1 ". "updateEmpty:1 ".
"levelsFormat ". "levelsFormat ".
"weekdaysFormat ". "weekdaysFormat ".
$readingFnAttributes; $readingFnAttributes;
} }
sub allergy_Define($$$) { sub allergy_Define($$$) {
@@ -60,6 +58,7 @@ sub allergy_Define($$$) {
$hash->{helper}{ZIPCODE} = $a[2]; $hash->{helper}{ZIPCODE} = $a[2];
$hash->{helper}{INTERVAL} = 10800; $hash->{helper}{INTERVAL} = 10800;
$hash->{ERROR} = 0;
my $req = eval my $req = eval
{ {
@@ -163,10 +162,14 @@ sub allergy_Parse($$$)
if( $err ) if( $err )
{ {
Log3 $name, 1, "$name: URL error: ".$err; Log3 $name, 1, "$name: URL error: ".$err;
$hash->{STATE} = "error"; my $nextupdate = gettimeofday()+( (900*$hash->{ERROR}) + 90 );
InternalTimer($nextupdate, "allergy_GetUpdate", $hash, 1);
$hash->{STATE} = "error" if($hash->{ERROR} > 1);
$hash->{ERROR} = $hash->{ERROR}+1;
return undef; return undef;
} }
$hash->{ERROR} = 0;
Log3 $name, 5, "Received XML data ".$data; Log3 $name, 5, "Received XML data ".$data;
my $xml = new XML::Simple(); my $xml = new XML::Simple();