From c677303aa6ed8ea7e8d53fd044ca286a2fe0a5b3 Mon Sep 17 00:00:00 2001 From: moises <> Date: Mon, 29 May 2017 09:33:00 +0000 Subject: [PATCH] 38_netatmo: fixed blocking connection check on dns error git-svn-id: https://svn.fhem.de/fhem/trunk@14411 2b470e98-0d58-463d-a4d8-8e2adae1ed80 --- fhem/CHANGED | 1 + fhem/FHEM/38_netatmo.pm | 36 +++++++++++++++++++++++++++--------- 2 files changed, 28 insertions(+), 9 deletions(-) diff --git a/fhem/CHANGED b/fhem/CHANGED index 806d44f51..904607680 100644 --- a/fhem/CHANGED +++ b/fhem/CHANGED @@ -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: 38_netatmo: fixed blocking connection check on dns error - change: 02_RSS: height/width for rect layout directive - change: 34_ESPEasy: performance tuning, some fixes - feature: 74_Unifi.pm: added get poeMode and set poeState commands diff --git a/fhem/FHEM/38_netatmo.pm b/fhem/FHEM/38_netatmo.pm index 049a9f476..37b9c8e4e 100644 --- a/fhem/FHEM/38_netatmo.pm +++ b/fhem/FHEM/38_netatmo.pm @@ -10,7 +10,7 @@ # # ############################################################################## -# Release 11 / 2017-04-14 +# Release 12 / 2017-05-29 package main; @@ -850,6 +850,25 @@ netatmo_parseConnection($$$) if( $err ) { Log3 $name, 1, "$name: connection check failed: $err"; + + if($err =~ /refused/ ){ + RemoveInternalTimer($hash); + $hash->{status} = "banned"; + $hash->{network} = "banned"; + } + elsif($err =~ /Bad hostname/ || $err =~ /gethostbyname/){ + $hash->{status} = "timeout"; + $hash->{network} = "dns"; + } + elsif($err =~ /timed out/){ + $hash->{status} = "timeout"; + $hash->{network} = "timeout"; + } + elsif($err =~ /Can't connect/){ + $hash->{status} = "timeout"; + $hash->{network} = "disconnected"; + } + return undef; } elsif( $data ) { $data =~ s/\n//g; @@ -2226,14 +2245,14 @@ netatmo_poll($) if( $hash->{SUBTYPE} eq "ACCOUNT" && defined($hash->{network}) && $hash->{network} eq "timeout" ) { RemoveInternalTimer($hash); - InternalTimer(gettimeofday()+120, "netatmo_poll", $hash); + InternalTimer(gettimeofday()+300, "netatmo_poll", $hash); $hash->{status} = "recovering timeout"; netatmo_checkConnection($hash); readingsSingleUpdate( $hash, "active", $hash->{status}, 1 ) if($hash->{status} ne "no data"); return undef; } elsif( $hash->{SUBTYPE} eq "ACCOUNT" && defined($hash->{network}) && $hash->{network} ne "ok" ) { RemoveInternalTimer($hash); - InternalTimer(gettimeofday()+120, "netatmo_poll", $hash); + InternalTimer(gettimeofday()+600, "netatmo_poll", $hash); $hash->{status} = "recovering network"; netatmo_checkConnection($hash); readingsSingleUpdate( $hash, "active", $hash->{status}, 1 ) if($hash->{status} ne "no data"); @@ -2241,9 +2260,9 @@ netatmo_poll($) return undef; } elsif( $hash->{SUBTYPE} ne "ACCOUNT" && defined($hash->{IODev}->{network}) && $hash->{IODev}->{network} ne "ok" ) { RemoveInternalTimer($hash); - InternalTimer(gettimeofday()+120, "netatmo_poll", $hash); + InternalTimer(gettimeofday()+150, "netatmo_poll", $hash); $hash->{status} = "delayed update"; - netatmo_checkConnection($hash->{IODev}); + #netatmo_checkConnection($hash->{IODev}); readingsSingleUpdate( $hash, "active", $hash->{status}, 1 ) if($hash->{status} ne "no data"); Log3 $name, 5, "$name: DEVICE network error: ".$hash->{IODev}->{network}; return undef; @@ -2323,9 +2342,9 @@ netatmo_dispatch($$$) $hash->{expires_at} = int(gettimeofday()) if($hash->{SUBTYPE} eq "ACCOUNT"); $hash->{IODev}->{expires_at} = int(gettimeofday()) if($hash->{SUBTYPE} ne "ACCOUNT"); } - elsif($err =~ /Bad hostname/){ + elsif($err =~ /Bad hostname/ || $err =~ /gethostbyname/){ RemoveInternalTimer($hash); - InternalTimer(gettimeofday()+300, "netatmo_poll", $hash); + InternalTimer(gettimeofday()+600, "netatmo_poll", $hash); $hash->{status} = "timeout"; $hash->{network} = "dns" if($hash->{SUBTYPE} eq "ACCOUNT"); } @@ -3093,10 +3112,9 @@ netatmo_parseReadings($$;$) Log3 $name, 3, "$name: next extended dynamic update ($requested) at ".FmtDateTime($nextdata); } else { Log3 $name, 2, "$name: invalid time for dynamic update ($requested): ".FmtDateTime($nextdata); + } } } - } - } } else