2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-04-16 04:36:02 +00:00

FRITZBOX: improved error handeling

git-svn-id: https://svn.fhem.de/fhem/trunk@8825 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
tpoitzsch 2015-06-25 12:17:55 +00:00
parent b747f25843
commit 8d7c3a3d8d

View File

@ -230,11 +230,23 @@ sub FRITZBOX_Initilize_TR064 ($)
FRITZBOX_Log $hash, 2, "Cannot use TR-064. Perl modul ".$missingModulTR064."is missing on this system. Please install.";
return;
}
if ($missingModulWeb) {
FRITZBOX_Log $hash, 2, "Cannot test TR-064 access. Perl modul ".$missingModulWeb."is missing on this system. Please install.";
return undef;
}
FRITZBOX_Log $hash, 4, "Open TR-064 connection";
my $host = AttrVal( $name, "fritzBoxIP", "fritz.box" );
FRITZBOX_Log $hash, 4, "Check if TR-064 description 'http://".$host.":49000/tr64desc.xml' exists.";
my $agent = LWP::UserAgent->new( env_proxy => 1, keep_alive => 1, protocols_allowed => ['http'], timeout => 10 );
my $response = $agent->get( "http://".$host.":49000/tr64desc.xml" );
if ( $response->is_error() ) {
FRITZBOX_Log $hash, 2, "Box $host doesn't have a TR-064-API.";
return undef;
}
# Security Port anfordern
my $host = AttrVal( $name, "fritzBoxIP", "fritz.box" );
FRITZBOX_Log $hash, 4, "Open TR-064 connection";
my $s = SOAP::Lite
-> uri('urn:dslforum-org:service:DeviceInfo:1')
-> proxy('http://'.$host.':49000/upnp/control/deviceinfo')
@ -506,6 +518,8 @@ sub FRITZBOX_Get($@)
my $returnStr;
if( lc $cmd eq "luaquery" && AttrVal( $name, "allowTR064Command", 0 ) ) {
# get Fritzbox luaQuery inetstat:status/Today/BytesReceivedLow
# get Fritzbox luaQuery telcfg:settings/AlarmClock/list(Name,Active,Time,Number,Weekdays)
Log3 $name, 3, "FRITZBOX: get $name $cmd ".join(" ", @val);
return "Wrong number of arguments, usage: get $name luaQuery <query>" if int @val !=1;
@ -514,9 +528,11 @@ sub FRITZBOX_Get($@)
$returnStr .= "----------------------------------------------------------------------\n";
my $queryStr = "&result=".$val[0];
my $result = FRITZBOX_Web_Query( $hash, $queryStr) ;
my $tmp = Dumper ($result->{result});
$returnStr .= $tmp;
return $returnStr;
my $tmp;
if (ref $result->{result} eq "") { $tmp = $result->{result}; }
else { $tmp = Dumper ($result->{result}); }
return $returnStr . $tmp;
}
elsif( lc $cmd eq "ringtones" ) {
Log3 $name, 3, "FRITZBOX: get $name $cmd ".join(" ", @val);