diff --git a/FHEM/59_OPENWEATHER.pm b/FHEM/59_OPENWEATHER.pm index de8f681ec..e816f98a8 100644 --- a/FHEM/59_OPENWEATHER.pm +++ b/FHEM/59_OPENWEATHER.pm @@ -38,8 +38,8 @@ package MyOPENWEATHERParser; use base qw(HTML::Parser); our %fcReadings = (); my $curTag = ""; -my $day = -2; -my $time = ""; +our $day = -2; +our $time = ""; # here HTML::text/start/end are overridden %knownTags = ( tn => "tempMin" diff --git a/FHEM/59_PROPLANTA.pm b/FHEM/59_PROPLANTA.pm index 419bdb5cc..c2e9de701 100644 --- a/FHEM/59_PROPLANTA.pm +++ b/FHEM/59_PROPLANTA.pm @@ -75,6 +75,7 @@ my $curReadingType = 0; ,["SD", "sun", 2] ,["UV", "uv", 2] ,["GS", "rad", 3] + ,["WETTER_ID", "weather", 7] ,["WETTER_ID_MORGENS", "weatherMorning", 7] ,["WETTER_ID_TAGSUEBER", "weatherDay", 7] ,["WETTER_ID_ABENDS", "weatherEvening", 7] @@ -456,7 +457,7 @@ sub PROPLANTA_HtmlAcquire($$) my $name = $hash->{NAME}; return unless (defined($hash->{NAME})); - PROPLANTA_Log $hash, 5, "Start capturing of $URL"; + PROPLANTA_Log $hash, 4, "Start capturing of $URL"; my $err_log = ""; my $agent = LWP::UserAgent->new( env_proxy => 1, keep_alive => 1, protocols_allowed => ['http'], timeout => 10 ); @@ -472,7 +473,7 @@ sub PROPLANTA_HtmlAcquire($$) return "Error|Error " . $response->status_line; } - PROPLANTA_Log $hash, 5, length($response->content)." characters captured"; + PROPLANTA_Log $hash, 4, length($response->content)." characters captured"; return $response->content; } @@ -530,9 +531,6 @@ sub PROPLANTA_Run($) { $URL = $attrURL; } - # abbrechen, wenn wichtige parameter nicht definiert sind - # return "" if ( !defined($URL) ); - # return "" if ( $URL eq "" ); # acquire the html-page my $response = PROPLANTA_HtmlAcquire($hash,$URL); @@ -541,11 +539,10 @@ sub PROPLANTA_Run($) { $ptext .= "|".$response; } - elsif ($response ne "") + else { - PROPLANTA_Log $hash, 5, "Start HTML parsing"; - -# Can't locate object method "new" via package " + PROPLANTA_Log $hash, 4, "Start HTML parsing of captured page"; + my $parser = MyProplantaParser->new; $parser->report_tags(qw(tr td span b img)); @MyProplantaParser::texte = (); @@ -562,7 +559,11 @@ sub PROPLANTA_Run($) { $response = PROPLANTA_HtmlAcquire($hash,$URL . $_); $MyProplantaParser::startDay = $_; - $parser->parse($response); + if ($response !~ /^Error\|/) + { + PROPLANTA_Log $hash, 4, "Start HTML parsing of captured page"; + $parser->parse($response); + } } } @@ -575,10 +576,6 @@ sub PROPLANTA_Run($) } PROPLANTA_Log $hash, 4, "Parsed string: " . $ptext; } - else - { - PROPLANTA_Log $hash, 1, "Error. No response string."; - } return $ptext; } ##################################### @@ -688,6 +685,8 @@ PROPLANTA_Html($)