From 0b4f783dad7c2f0a2e3bf70baf147a47ea8d7177 Mon Sep 17 00:00:00 2001 From: jowiemann <> Date: Fri, 17 Mar 2023 15:03:29 +0000 Subject: [PATCH] =?UTF-8?q?72=5FFRITZBOX.pm:=20get=20=20tr064Command?= =?UTF-8?q?=20geh=C3=A4rtet?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit git-svn-id: https://svn.fhem.de/fhem/trunk@27336 2b470e98-0d58-463d-a4d8-8e2adae1ed80 --- fhem/FHEM/72_FRITZBOX.pm | 58 +++++++++++++++++++++++----------------- 1 file changed, 34 insertions(+), 24 deletions(-) diff --git a/fhem/FHEM/72_FRITZBOX.pm b/fhem/FHEM/72_FRITZBOX.pm index f134be412..e3c33a017 100644 --- a/fhem/FHEM/72_FRITZBOX.pm +++ b/fhem/FHEM/72_FRITZBOX.pm @@ -41,7 +41,7 @@ use warnings; use Blocking; use HttpUtils; -my $ModulVersion = "07.50.9b"; +my $ModulVersion = "07.50.9c"; my $missingModul = ""; my $missingModulWeb = ""; my $missingModulTR064 = ""; @@ -246,7 +246,7 @@ sub FRITZBOX_Define($$) $hash->{NAME} = $name; $hash->{VERSION} = $ModulVersion; - $hash->{HOST} = "undefined"; + $hash->{HOST} = "fritz.box"; $hash->{HOST} = $args[2] if defined $args[2] && $args[2] =~ m=$URL_MATCH=i; $hash->{fhem}{definedHost} = $hash->{HOST}; # to cope with old attribute definitions @@ -4501,33 +4501,43 @@ sub FRITZBOX_TR064_Cmd($$$) -> uri( "urn:dslforum-org:service:".$service ) -> proxy('https://'.$host.":".$port."/upnp/control/".$control, ssl_opts => [ SSL_verify_mode => 0 ], timeout => 10 ) -> readable(1); - my $res = $soap -> call( $action => @soapParams ); - unless( $res ) { # Transport-Error - FRITZBOX_Log $hash, 5, "DEBUG: TR064-Transport-Error: ".$soap->transport->status; - my %errorMsg = ( "Error" => $soap->transport->status ); - push @retArray, \%errorMsg; - $FRITZBOX_TR064pwd = undef; - } - elsif( $res->fault ) { # SOAP Error - will be defined if Fault element is in the message - # my $fcode = $s->faultcode; # - # my $fstring = $s->faultstring; # also available - # my $factor = $s->faultactor; + my $res = eval { $soap -> call( $action => @soapParams )}; - my $ecode = $res->faultdetail->{'UPnPError'}->{'errorCode'}; - my $edesc = $res->faultdetail->{'UPnPError'}->{'errorDescription'}; + if ($@) { + FRITZBOX_Log $hash, 2, "INFO: TR064-PARAM-Error: " . $@; + my %errorMsg = ( "Error" => $@ ); + push @retArray, \%errorMsg; + $FRITZBOX_TR064pwd = undef; - FRITZBOX_Log $hash, 5, "DEBUG: TR064 error $ecode:$edesc ($logMsg)"; + } else { - @{$cmdArray} = (); - # my $fdetail = Dumper($res->faultdetail); # returns value of 'detail' element as string or object - # return "Error\n".$fdetail; + unless( $res ) { # Transport-Error + FRITZBOX_Log $hash, 5, "DEBUG: TR064-Transport-Error: ".$soap->transport->status; + my %errorMsg = ( "Error" => $soap->transport->status ); + push @retArray, \%errorMsg; + $FRITZBOX_TR064pwd = undef; + } + elsif( $res->fault ) { # SOAP Error - will be defined if Fault element is in the message + # my $fcode = $s->faultcode; # + # my $fstring = $s->faultstring; # also available + # my $factor = $s->faultactor; - push @retArray, $res->faultdetail; - $FRITZBOX_TR064pwd = undef; - } - else { # normal result - push @retArray, $res->body; + my $ecode = $res->faultdetail->{'UPnPError'}->{'errorCode'}; + my $edesc = $res->faultdetail->{'UPnPError'}->{'errorDescription'}; + + FRITZBOX_Log $hash, 5, "DEBUG: TR064 error $ecode:$edesc ($logMsg)"; + + @{$cmdArray} = (); + # my $fdetail = Dumper($res->faultdetail); # returns value of 'detail' element as string or object + # return "Error\n".$fdetail; + + push @retArray, $res->faultdetail; + $FRITZBOX_TR064pwd = undef; + } + else { # normal result + push @retArray, $res->body; + } } }