diff --git a/fhem/FHEM/98_rssFeed.pm b/fhem/FHEM/98_rssFeed.pm index dd0e56893..d05a1e65e 100644 --- a/fhem/FHEM/98_rssFeed.pm +++ b/fhem/FHEM/98_rssFeed.pm @@ -8,6 +8,9 @@ use POSIX; use Encode qw(encode); +use IO::Uncompress::Gunzip qw(gunzip $GunzipError ); + + use XML::Simple; my $modulename='rssFeed'; #Module-Name = TYPE @@ -408,17 +411,40 @@ rssFeed_update(@) #If verbose is set to 5 then log complete response rssFeed_Log3 $name,5,$response; + + #Trying to unzip received response + my $runzipped=undef; + gunzip \$response => \$runzipped; + rssFeed_Log3 $name,5,"unzipError: $GunzipError"; + + #If the response was not zipped, the unzip-result is the original response data + my $zipped=0; + $zipped=1 if($runzipped ne $response); + readingsSingleUpdate($dhash,"gzippedFeed",$zipped,0); + #If rfDebug attribute is set then store complete response in reading if ($rfDebug) { readingsSingleUpdate($dhash,$debug_prefix."LastResponse",$response,0); - #readingsSingleUpdate($dhash,$debug_prefix."LastResponse",$response,0) if (!$enc); - #readingsSingleUpdate($dhash,$debug_prefix."LastResponse",encode($enc,$response),0) if ($enc); + readingsSingleUpdate($dhash,$debug_prefix."UnzippedResponse",$runzipped,0) if ($zipped); } + #using unzipped responsedata if it was originally zipped + $response=$runzipped if($zipped); + #Convert xml data from reponse to an array (hash?) $xml = new XML::Simple; - $nachrichten = $xml->XMLin($response, ForceArray => ['item']); + + rssFeed_Log3 $name,5,'Trying to convert xml to array...'; + eval {$xml->XMLin($response, ForceArray => ['item']);}; + rssFeed_Log3 $name,5,"evalXMLerror: $@"; + + #rssFeed_Log3 $name,4,"evalXMLresult: $evResult"; + + if(!$@) { + $nachrichten = $xml->XMLin($response, ForceArray => ['item']); + } + # -> ToDo: Add a title line to the ticker data e.g. to describe what's @@ -712,6 +738,11 @@ return; This readings contains the number of new items that were extracted in the last update of the feed data. +
gzippedFeed
state
gzippedFeed
state