FRITZBOX: bugfix landevice0

git-svn-id: https://svn.fhem.de/fhem/trunk@11878 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
grompo 2016-08-02 16:15:25 +00:00
parent 509d8b7f7f
commit 97bc02e64d

View File

@ -733,11 +733,11 @@ sub FRITZBOX_API_Check_Run($)
if ($response->is_success) { if ($response->is_success) {
FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "->WEBCM", 1; FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "->WEBCM", 1;
FRITZBOX_Log $hash, 4, "API webcm found."; FRITZBOX_Log $hash, 4, "API webcm found (".$response->code.").";
} }
else { else {
FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "->WEBCM", 0; FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "->WEBCM", 0;
FRITZBOX_Log $hash, 4, "API webcm does not exist: ".$response->status_line; FRITZBOX_Log $hash, 4, "API webcm does not exist (".$response->status_line.")";
} }
# Check if query.lua exists # Check if query.lua exists
@ -745,11 +745,15 @@ sub FRITZBOX_API_Check_Run($)
if ($response->is_success) { if ($response->is_success) {
FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "->LUAQUERY", 1; FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "->LUAQUERY", 1;
FRITZBOX_Log $hash, 4, "API luaQuery found."; FRITZBOX_Log $hash, 4, "API luaQuery found (".$response->code.").";
}
elsif ($response->code eq "500") {
FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "->LUAQUERY", 1;
FRITZBOX_Log $hash, 4, "API luaQuery found but responded with: ".$response->status_line;
} }
else { else {
FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "->LUAQUERY", 0; FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "->LUAQUERY", 0;
FRITZBOX_Log $hash, 4, "API luaQuery does not exist: ".$response->status_line; FRITZBOX_Log $hash, 4, "API luaQuery does not exist (".$response->status_line.")";
} }
# Check if tr064 specification exists and determine TR064-Port # Check if tr064 specification exists and determine TR064-Port
@ -1061,8 +1065,7 @@ sub FRITZBOX_Readout_Run_Shell($)
} }
# Assign data of DECT handset to DECT numbers # Assign data of DECT handset to DECT numbers
for (0..$handsetCount) for (0..$handsetCount) {
{
# 0 Handset FonUser # 0 Handset FonUser
push @readoutCmdArray, [ "", "ctlmgr_ctl r dect settings/Handset".$_."/User", "" ]; push @readoutCmdArray, [ "", "ctlmgr_ctl r dect settings/Handset".$_."/User", "" ];
# 1 Handset manufacturer # 1 Handset manufacturer
@ -1412,37 +1415,39 @@ sub FRITZBOX_Readout_Run_Web($)
%landevice = (); %landevice = ();
my $wlanCount = 0; my $wlanCount = 0;
my $gWlanCount = 0; my $gWlanCount = 0;
foreach ( @{ $result->{lanDevice} } ) { if ( ref $result->{lanDevice} eq 'ARRAY' ) {
my $dIp = $_->{ip}; foreach ( @{ $result->{lanDevice} } ) {
my $dName = $_->{name}; my $dIp = $_->{ip};
FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "fhem->landevice->$dIp", $dName; my $dName = $_->{name};
$landevice{$dIp}=$dName; FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "fhem->landevice->$dIp", $dName;
# Create a reading if a landevice is connected $landevice{$dIp}=$dName;
if ($_->{active} == 1) { # Create a reading if a landevice is connected
my $mac = $_->{mac}; if ($_->{active} == 1) {
$mac =~ s/:/_/g; my $mac = $_->{mac};
if ($_->{ethernet} == 0 && $_->{wlan} == 1) { $mac =~ s/:/_/g;
$dName .= " ("; if ($_->{ethernet} == 0 && $_->{wlan} == 1) {
$dName .= "g" if $_->{guest}; $dName .= " (";
$dName .= "WLAN"; $dName .= "g" if $_->{guest};
$dName .= ", " . $wlanList{$mac}{speed} . " / " . $wlanList{$mac}{speed_rx} . " Mbit/s, ". $wlanList{$mac}{rssi} $dName .= "WLAN";
if defined $wlanList{$mac}; $dName .= ", " . $wlanList{$mac}{speed} . " / " . $wlanList{$mac}{speed_rx} . " Mbit/s, ". $wlanList{$mac}{rssi}
$dName .= ")"; if defined $wlanList{$mac};
$dName .= ")";
}
if ( $_->{ethernet} == 1 ) {
$dName .= " (";
$dName .= "g" if $_->{guest};
$dName .= "LAN" . $_->{ethernet_port};
$dName .= ", 1 Gbit/s" if $_->{speed} == 1000;
$dName .= ", " . $_->{speed} . " Mbit/s" if $_->{speed} != 1000 && $_->{speed} != 0;
$dName .= ")";
}
my $rName = "mac_".$mac;
FRITZBOX_Readout_Add_Reading $hash, \@roReadings, $rName, $dName;
$wlanCount++ if $_->{wlan} == 1;
$gWlanCount++ if $_->{wlan} == 1 && $_->{guest} == 1;
# Remove mac address from oldLanDevice-List
delete $oldLanDevice{$rName} if exists $oldLanDevice{$rName};
} }
if ( $_->{ethernet} == 1 ) {
$dName .= " (";
$dName .= "g" if $_->{guest};
$dName .= "LAN" . $_->{ethernet_port};
$dName .= ", 1 Gbit/s" if $_->{speed} == 1000;
$dName .= ", " . $_->{speed} . " Mbit/s" if $_->{speed} != 1000 && $_->{speed} != 0;
$dName .= ")";
}
my $rName = "mac_".$mac;
FRITZBOX_Readout_Add_Reading $hash, \@roReadings, $rName, $dName;
$wlanCount++ if $_->{wlan} == 1;
$gWlanCount++ if $_->{wlan} == 1 && $_->{guest} == 1;
# Remove mac address from oldLanDevice-List
delete $oldLanDevice{$rName} if exists $oldLanDevice{$rName};
} }
} }
FRITZBOX_Readout_Add_Reading ($hash, \@roReadings, "box_wlanCount", $wlanCount); FRITZBOX_Readout_Add_Reading ($hash, \@roReadings, "box_wlanCount", $wlanCount);