diff --git a/fhem/FHEM/72_FRITZBOX.pm b/fhem/FHEM/72_FRITZBOX.pm index 9faf87cfe..37a8db7ac 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.9"; +my $ModulVersion = "07.50.9a"; my $missingModul = ""; my $missingModulWeb = ""; my $missingModulTR064 = ""; @@ -237,13 +237,15 @@ sub FRITZBOX_Define($$) return "Usage: define FRITZBOX [IP address]" if(@args <2 || @args >3); + return "Error: no valid IPv4 Address: $args[2]" if defined $args[2] && $args[2] !~ m/^(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})$/; + my $name = $args[0]; $hash->{NAME} = $name; $hash->{VERSION} = $ModulVersion; $hash->{HOST} = "undefined"; - $hash->{HOST} = $args[2] if defined $args[2]; + $hash->{HOST} = $args[2] if defined $args[2] && $args[2] =~ m/^(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})$/; $hash->{fhem}{definedHost} = $hash->{HOST}; # to cope with old attribute definitions my $msg; @@ -285,13 +287,22 @@ sub FRITZBOX_Define($$) my $msg = "The support for telnet and operation on a Fritz!Box has been discontinued. The functions are disabled."; FRITZBOX_Log $hash, 2, $msg; $hash->{INFO} = $msg; - $msg = "The following attributes are not longer supperted:\n" - . "useGuiHack, ringWithIntern, defaultCallerName, allowTR064Command\n" + $msg = "The following attributes are not longer supported:\n" + . "useGuiHack, ringWithIntern, defaultCallerName, allowTR064Command,\n" + . "forceTelnetConnection, telnetUser, telnetTimeOut\n" . "Use deleteattr to delete from Attributes."; FRITZBOX_Log $hash, 2, $msg; $hash->{INFO2} = $msg; } + CommandDeleteAttr(undef,"$hash useGuiHack -silent"); + CommandDeleteAttr(undef,"$hash ringWithIntern -silent"); + CommandDeleteAttr(undef,"$hash defaultCallerName -silent"); + CommandDeleteAttr(undef,"$hash allowTR064Command -silent"); + CommandDeleteAttr(undef,"$hash forceTelnetConnection -silent"); + CommandDeleteAttr(undef,"$hash telnetUser -silent"); + CommandDeleteAttr(undef,"$hash telnetTimeOut -silent"); + return undef; } #end FRITZBOX_Define @@ -349,6 +360,7 @@ sub FRITZBOX_Attr($@) if ($aName eq "fritzBoxIP") { if ($cmd eq "set") { + return "plain IPv4 recommended" if $aVal !~ m/^(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})$/; $hash->{HOST} = $aVal; } else { @@ -363,8 +375,8 @@ sub FRITZBOX_Attr($@) return "character | not possible in _default_" if $aVal =~ m/\|/; - $aVal =~ s/\,/\,\n/g; - $_[3] = $aVal; +# $aVal =~ s/\,/\,\n/g; +# $_[3] = $aVal; } } @@ -374,8 +386,8 @@ sub FRITZBOX_Attr($@) foreach ( @reading_list ) { readingsDelete($hash, $_) if exists $hash->{READINGS}{$_}; } - $aVal =~ s/\,/\,\n/g; - $_[3] = $aVal; +# $aVal =~ s/\,/\,\n/g; +# $_[3] = $aVal; } } @@ -1386,12 +1398,16 @@ sub FRITZBOX_API_Check_Run($) my $host = $hash->{HOST}; my $boxUser = AttrVal( $name, "boxUser", "" ); - if ( $host =~ /undefined/ ) { - my $tmp = "fritzBoxIP"; - $tmp .= ", boxUser" if $boxUser eq ""; - $tmp .= " nicht definiert"; + if ( $host =~ /undefined/ || $boxUser eq "") { + my $tmp = ""; + $tmp = "fritzBoxIP" if $host =~ /undefined/; + $tmp .= ", " if $host =~ /undefined/ && $boxUser eq ""; + $tmp .= " boxUser (bei Repeatern nicht unbedingt notwendig)" if $boxUser eq ""; + $tmp .= " nicht definiert. Bitte auch das Passwort mit setzen."; - FRITZBOX_Log $hash, 2, "INFO: " . $hash->{HINWEIS}; + FRITZBOX_Readout_Add_Reading ($hash, \@roReadings, "->HINWEIS", $tmp); + + FRITZBOX_Log $hash, 2, "ERROR: " . $tmp; } # change host name if necessary @@ -2735,6 +2751,8 @@ sub FRITZBOX_Readout_Run_Web($) } # statistics + FRITZBOX_Readout_Add_Reading ($hash, \@roReadings, "->HINWEIS", ""); + push @roReadings, "readoutTime", sprintf( "%.2f", time()-$startTime); my $returnStr = join('|', @roReadings ); @@ -2844,6 +2862,7 @@ sub FRITZBOX_Readout_Process($$) else { $hash->{$rName1}{$rName2} = $rValue; } + delete ($hash->{HINWEIS}) if $rName2 eq "HINWEIS" && $rValue eq ""; } elsif ($rName eq "box_fwVersion" && defined $values{box_fwUpdate}) { $rValue .= " (old)" if $values{box_fwUpdate} eq "1"; @@ -2888,6 +2907,7 @@ sub FRITZBOX_Readout_Process($$) } $rValue .= " [".$values{box_oem}."]" if $values{box_oem}; } + if ($rName !~ /->|box_fwUpdate|box_oem|readoutTime/) { if ($rValue ne "") { readingsBulkUpdate( $hash, $rName, $rValue ); @@ -4635,9 +4655,8 @@ sub FRITZBOX_Web_OpenCon ($) return undef; } my $user = AttrVal( $name, "boxUser", "" ); - $user = AttrVal( $name, "telnetUser", "" ) if $user eq ""; - FRITZBOX_Log $hash, 4, "INFO: Open Web connection to $host"; + FRITZBOX_Log $hash, 4, "INFO: Open Web connection to $host : $user"; FRITZBOX_Log $hash, 4, "INFO: getting new SID"; $sid = (FB_doCheckPW($host, $user, $pwd)); @@ -5876,7 +5895,7 @@ sub FRITZBOX_fritztris($)
Check also the other FRITZ!BOX moduls: SYSMON and FB_CALLMONITOR.
- The modul uses the Perl modul 'Net::Telnet', 'JSON::XS', 'LWP', 'SOAP::Lite' for remote access. + The modul uses the Perl modul 'JSON::XS', 'LWP', 'SOAP::Lite' for remote access.

@@ -5925,14 +5944,14 @@ sub FRITZBOX_fritztris($)
Switches the DECT base of the box on or off.
- Requires the API: Telnet, webcm or FRITZ!OS 7.21 or higher. + Requires FRITZ!OS 7.21 or higher.
  • set <name> diversity <number> <on|off>

    Switches the call diversity number (1, 2 ...) on or off. - A call diversity for an incoming number has to be created with the FRITZ!BOX web interface. Requires the API: Telnet, webcm or TR064 (>=6.50). + A call diversity for an incoming number has to be created with the FRITZ!BOX web interface. Requires TR064 (>=6.50).
    Note! Only a diversity for a concret home number and without filter for the calling number can be set. Hence, an approbriate diversity-reading must exist.

  • @@ -6004,7 +6023,7 @@ sub FRITZBOX_fritztris($)
  • -
    set <name> ring <intNumbers> [duration [ringTone]] [show:Text] [say:Text | play:MP3URL]
    +
    set <name> ring <intNumbers> [duration] [show:Text] [say:Text | play:MP3URL]
    Example:
    set <name> ring 611,612 5 Budapest show:It is raining @@ -6020,8 +6039,6 @@ sub FRITZBOX_fritztris($) Ring tone will be ignored for collected calls (9 or 50).
    If the call is taken the callee hears the "music on hold" which can also be used to transmit messages. -
    - The parameter ringtone, show:, say: and play: require the API Telnet or webcm.

    If the attribute 'ringWithIntern' is specified, the text behind 'show:' will be shown as the callers name. Maximal 30 characters are allowed. @@ -6389,7 +6406,7 @@ sub FRITZBOX_fritztris($)
    Bitte auch die anderen FRITZ!BOX-Module beachten: SYSMON und FB_CALLMONITOR.
    - Das Modul nutzt das Perlmodule 'Net::Telnet', 'JSON::XS', 'LWP', 'SOAP::Lite' für den Fernzugriff. + Das Modul nutzt das Perlmodule 'JSON::XS', 'LWP', 'SOAP::Lite' für den Fernzugriff.

    Define @@ -6437,7 +6454,7 @@ sub FRITZBOX_fritztris($)
    Schaltet die DECT-Basis der Box an oder aus.
    - Benötigt Telnet, webcm oder mindestens FRITZ!OS 7.21 + Benötigt mindestens FRITZ!OS 7.21

  • @@ -6445,12 +6462,10 @@ sub FRITZBOX_fritztris($)
    Schaltet die Rufumleitung (Nummer 1, 2 ...) für einzelne Rufnummern an oder aus.
    - Die Rufumleitung muss zuvor auf der FRITZ!BOX eingerichtet werden. Benötigt die API: Telnet oder webcm. -
    Achtung! Es lassen sich nur Rufumleitungen für einzelne angerufene Telefonnummern (also nicht "alle") und ohne Abhängigkeit von der anrufenden Nummer schalten. Es muss also ein diversity-Geräwert geben.
    - Benötigt die API: Telnet, webcm oder TR064 (>=6.50). + Benötigt die API: TR064 (>=6.50).

  • @@ -6510,7 +6525,7 @@ sub FRITZBOX_fritztris($)
  • set <name> password <password>

    - Speichert das Passwort für den Fernzugriff über Telnet. + Speichert das Passwort für den Fernzugriff.

  • @@ -6521,7 +6536,7 @@ sub FRITZBOX_fritztris($)

  • -
    set <name> ring <intNumbers> [duration [ringTone]] [show:Text] [say:Text | play:MP3URL]
    +
    set <name> ring <intNumbers> [duration] [show:Text] [say:Text | play:MP3URL]

    Beispiel:
    @@ -6540,8 +6555,6 @@ sub FRITZBOX_fritztris($)
    Wenn der Anruf angenommen wird, hört der Angerufene die Wartemusik (music on hold), welche ebenfalls zur Nachrichtenübermittlung genutzt werden kann.
    - Die Parameter Klingelton, show:, say: und play: benötigen die API Telnet oder webcm. -

    Wenn das Attribut 'ringWithIntern' existiert, wird der Text hinter 'show:' als Name des Anrufers angezeigt. Er darf maximal 30 Zeichen lang sein.