mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-03-04 17:36:39 +00:00
FRITZBOX: bugfix
git-svn-id: https://svn.fhem.de/fhem/trunk@8929 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
f838e32648
commit
cb108c9d4e
@ -244,14 +244,9 @@ sub FRITZBOX_Attr($@)
|
|||||||
# aName and aVal are Attribute name and value
|
# aName and aVal are Attribute name and value
|
||||||
my $hash = $defs{$name};
|
my $hash = $defs{$name};
|
||||||
|
|
||||||
if ($cmd eq "set") {
|
if ($aName eq "fritzBoxIP" && $hash->{APICHECKED} == 1) {
|
||||||
if ($aName eq "fritzBoxIP" && $aVal ne "") {
|
$hash->{APICHECKED} = 0;
|
||||||
$hash->{fhem}{lastHour} = 0; # Refresh all readings during next update
|
FRITZBOX_Readout_Start($hash->{helper}{TimerReadout});
|
||||||
if ($hash->{REMOTE} == 0) {
|
|
||||||
$hash->{REMOTE} = 1;
|
|
||||||
FRITZBOX_Log $hash, 3, "Changed to remote access because attribute 'fritzBoxIP' is defined.";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return undef;
|
return undef;
|
||||||
@ -316,7 +311,7 @@ sub FRITZBOX_Set($$@)
|
|||||||
# }
|
# }
|
||||||
}
|
}
|
||||||
elsif ( lc $cmd eq 'checkapis') {
|
elsif ( lc $cmd eq 'checkapis') {
|
||||||
Log3 $name, 3, "FRITZBOX: get $name $cmd ".join(" ", @val);
|
Log3 $name, 3, "FRITZBOX: get $name $cmd ".join(" ", @val);
|
||||||
$hash->{APICHECKED} = 0;
|
$hash->{APICHECKED} = 0;
|
||||||
FRITZBOX_Readout_Start($hash->{helper}{TimerReadout});
|
FRITZBOX_Readout_Start($hash->{helper}{TimerReadout});
|
||||||
return undef;
|
return undef;
|
||||||
@ -548,9 +543,8 @@ sub FRITZBOX_Readout_Start($)
|
|||||||
my $func = substr $timerpara, $index + 1, length($timerpara); # function extrahieren
|
my $func = substr $timerpara, $index + 1, length($timerpara); # function extrahieren
|
||||||
my $name = substr $timerpara, 0, $index; # name extrahieren
|
my $name = substr $timerpara, 0, $index; # name extrahieren
|
||||||
my $hash = $defs{$name};
|
my $hash = $defs{$name};
|
||||||
|
|
||||||
my $runFn = "FRITZBOX_Readout_Run_Web";
|
my $runFn;
|
||||||
$runFn = "FRITZBOX_Readout_Run_Shell" if AttrVal( $name, "forceTelnetConnection", 0 ) == 1 || $hash->{REMOTE} == 0;
|
|
||||||
|
|
||||||
# First run is an API check
|
# First run is an API check
|
||||||
unless ( $hash->{APICHECKED} ) {
|
unless ( $hash->{APICHECKED} ) {
|
||||||
@ -558,10 +552,16 @@ sub FRITZBOX_Readout_Start($)
|
|||||||
$hash->{STATE} = "Check APIs";
|
$hash->{STATE} = "Check APIs";
|
||||||
$runFn = "FRITZBOX_API_Check_Run";
|
$runFn = "FRITZBOX_API_Check_Run";
|
||||||
}
|
}
|
||||||
# Set timer value
|
# Run shell or web api, restrict interval
|
||||||
elsif ($hash->{INTERVAL} < 60 && $hash->{INTERVAL} != 0 ) {
|
else {
|
||||||
$hash->{INTERVAL} = 60;
|
$runFn = "FRITZBOX_Readout_Run_Web";
|
||||||
$hash->{INTERVAL} = AttrVal( $name, "INTERVAL", $hash->{INTERVAL} );
|
$runFn = "FRITZBOX_Readout_Run_Shell" if AttrVal( $name, "forceTelnetConnection", 0 ) == 1 || $hash->{REMOTE} == 0;
|
||||||
|
|
||||||
|
# Set timer value
|
||||||
|
if ($hash->{INTERVAL} < 60 && $hash->{INTERVAL} != 0 ) {
|
||||||
|
$hash->{INTERVAL} = 60;
|
||||||
|
$hash->{INTERVAL} = AttrVal( $name, "INTERVAL", $hash->{INTERVAL} );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if($hash->{INTERVAL} != 0) {
|
if($hash->{INTERVAL} != 0) {
|
||||||
@ -597,19 +597,21 @@ sub FRITZBOX_API_Check_Run($)
|
|||||||
my $response;
|
my $response;
|
||||||
my $startTime = time();
|
my $startTime = time();
|
||||||
|
|
||||||
# Check if FHEM runs on a FritzBox under root user
|
# if no FritzBoxIP is set, check if FHEM runs on a FritzBox under root user
|
||||||
# unless (qx ( [ -f /usr/bin/ctlmgr_ctl ] && echo 1 || echo 0 ))
|
# unless (qx ( [ -f /usr/bin/ctlmgr_ctl ] && echo 1 || echo 0 ))
|
||||||
if ( -X "/usr/bin/ctlmgr_ctl" ) {
|
if ( AttrVal( $name, "fritzBoxIP", "" ) eq "" ) {
|
||||||
if ( $< != 0 ) {
|
if ( -X "/usr/bin/ctlmgr_ctl" ) {
|
||||||
FRITZBOX_Log $hash, 3, "FHEM is running on a Fritz!Box but not as 'root' user (currently " .
|
if ( $< != 0 ) {
|
||||||
( getpwuid( $< ) )[ 0 ] . "). Cannot run in local mode.";
|
FRITZBOX_Log $hash, 3, "FHEM is running on a Fritz!Box but not as 'root' user (currently " .
|
||||||
}
|
( getpwuid( $< ) )[ 0 ] . "). Cannot run in local mode.";
|
||||||
else {
|
}
|
||||||
$fritzShell = 1;
|
else {
|
||||||
FRITZBOX_Log $hash, 5, "FHEM is running on a Fritz!Box as 'root' user.";
|
$fritzShell = 1;
|
||||||
|
FRITZBOX_Log $hash, 5, "FHEM is running on a Fritz!Box as 'root' user.";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
# Determine local or remote mode
|
# Determine local or remote mode
|
||||||
if ($fritzShell) {
|
if ($fritzShell) {
|
||||||
FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "->REMOTE", 0;
|
FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "->REMOTE", 0;
|
||||||
@ -1240,7 +1242,7 @@ sub FRITZBOX_Readout_Run_Web($)
|
|||||||
# Power Rate
|
# Power Rate
|
||||||
FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "box_powerRate", $result->{box_powerRate};
|
FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "box_powerRate", $result->{box_powerRate};
|
||||||
# Box Features
|
# Box Features
|
||||||
FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "fhem->is_double_wlan", $result->{is_double_wlan};
|
FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "fhem->is_double_wlan", $result->{is_double_wlan}, "01";
|
||||||
# Box model and firmware
|
# Box model and firmware
|
||||||
FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "box_fwVersion", $result->{box_fwVersion};
|
FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "box_fwVersion", $result->{box_fwVersion};
|
||||||
FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "box_fwUpdate", $result->{box_fwUpdate};
|
FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "box_fwUpdate", $result->{box_fwUpdate};
|
||||||
@ -1489,7 +1491,10 @@ sub FRITZBOX_Readout_Format($$$)
|
|||||||
return $readout unless defined $format;
|
return $readout unless defined $format;
|
||||||
return $readout unless $readout ne "" && $format ne "" ;
|
return $readout unless $readout ne "" && $format ne "" ;
|
||||||
|
|
||||||
if ($format eq "aldays") {
|
if ($format eq "01") {
|
||||||
|
$readout = 0 if $readout ne "1";
|
||||||
|
}
|
||||||
|
elsif ($format eq "aldays") {
|
||||||
if ($readout eq "0") {
|
if ($readout eq "0") {
|
||||||
$readout = "once";
|
$readout = "once";
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user