diff --git a/fhem/CHANGED b/fhem/CHANGED index 492238d7f..2d1729dbe 100644 --- a/fhem/CHANGED +++ b/fhem/CHANGED @@ -1,5 +1,11 @@ # Add changes at the top of the list. Keep it in ASCII, and 80-char wide. # Do not insert empty lines here, update check depends on it. + - change: FB_CALLMONITOR: new attribute "country-code" to import + phonebook entries with your local country code preceded as + a national phonenumber in a correct way. + Per default "0049" is used as country code. (by prodigy7) + - feature: FB_CALLMONITOR: new get commands showPhonebookEntries + and showCacheEntries to get all related entries - changed: enabled authentication with the logitech myharmony server for hub firmware version 4.x, version 3.x still works without. - feature: YAMAHA_BD: support 95_remotecontrol.pm module features diff --git a/fhem/FHEM/72_FB_CALLMONITOR.pm b/fhem/FHEM/72_FB_CALLMONITOR.pm index bf1489e8c..543f22fb0 100755 --- a/fhem/FHEM/72_FB_CALLMONITOR.pm +++ b/fhem/FHEM/72_FB_CALLMONITOR.pm @@ -35,6 +35,7 @@ use Digest::MD5; use HttpUtils; use DevIo; use FritzBoxUtils; +use utf8; my %connection_type = ( 0 => "0", @@ -95,6 +96,7 @@ FB_CALLMONITOR_Initialize($) "disable:0,1 ". "unique-call-ids:0,1 ". "local-area-code ". + "country-code ". "remove-leading-zero:0,1 ". "reverse-search-cache-file ". "reverse-search:multiple-strict,phonebook,klicktel.de,dasoertliche.de,search.ch,dasschnelle.at ". @@ -175,9 +177,53 @@ FB_CALLMONITOR_Get($@) return $head."\n".("-" x $width)."\n".$table; } + elsif($arguments[1] eq "showPhonebookEntries" and exists($hash->{helper}{PHONEBOOK})) + { + my $table = ""; + + my $number_width = 0; + my $name_width = 0; + + foreach my $number (keys %{$hash->{helper}{PHONEBOOK}}) + { + $number_width = length($number) if($number_width < length($number)); + $name_width = length($hash->{helper}{PHONEBOOK}{$number}) if($name_width < length($hash->{helper}{PHONEBOOK}{$number})); + } + my $head = sprintf("%-".$number_width."s %s" ,"Number", "Name"); + foreach my $number (sort { lc($hash->{helper}{PHONEBOOK}{$a}) cmp lc($hash->{helper}{PHONEBOOK}{$b}) } keys %{$hash->{helper}{PHONEBOOK}}) + { + + my $string = sprintf("%-".$number_width."s - %s" , $number,$hash->{helper}{PHONEBOOK}{$number}); + $table .= $string."\n"; + } + + return $head."\n".("-" x ($number_width + $name_width + 3))."\n".$table; + } + elsif($arguments[1] eq "showCacheEntries" and exists($hash->{helper}{CACHE})) + { + my $table = ""; + + my $number_width = 0; + my $name_width = 0; + + foreach my $number (keys %{$hash->{helper}{CACHE}}) + { + $number_width = length($number) if($number_width < length($number)); + $name_width = length($hash->{helper}{CACHE}{$number}) if($name_width < length($hash->{helper}{CACHE}{$number})); + } + my $head = sprintf("%-".$number_width."s %s" ,"Number", "Name"); + foreach my $number (sort { lc($hash->{helper}{CACHE}{$a}) cmp lc($hash->{helper}{CACHE}{$b}) } keys %{$hash->{helper}{CACHE}}) + { + + my $string = sprintf("%-".$number_width."s - %s" , $number,$hash->{helper}{CACHE}{$number}); + $table .= $string."\n"; + } + + return $head."\n".("-" x ($number_width + $name_width + 3))."\n".$table; + } else { - return "unknown argument ".$arguments[1].", choose one of search".(exists($hash->{helper}{PHONEBOOK_NAMES}) ? " showPhonebookIds" : ""); + return "unknown argument ".$arguments[1].", choose one of search".(exists($hash->{helper}{PHONEBOOK_NAMES}) ? " showPhonebookIds" : "").(exists($hash->{helper}{PHONEBOOK}) ? " showPhonebookEntries" : "").(exists($hash->{helper}{CACHE}) ? " showCacheEntries" : ""); } } @@ -801,7 +847,7 @@ sub FB_CALLMONITOR_parsePhonebook($$) my $count_contacts = 0; my $area_code = AttrVal($name, "local-area-code", ""); - + my $country_code = AttrVal($name, "country-code", "0049"); if($phonebook =~ // and $phonebook =~ //) { @@ -818,16 +864,17 @@ sub FB_CALLMONITOR_parsePhonebook($$) if($1 ne "intern" and $1 ne "memo") { $number = $2; - $number =~ s/\s//g; - $number =~ s/^\+\d\d/0/g; # quick'n'dirty fix in case of international number format. - - - if(not $number =~ /^0/ and not $number =~ /@/ and $area_code ne "") + $number =~ s/\s//g; # Remove spaces + $number =~ s/^\+/00/g; # Convert leading + to 00 country extension + $number =~ s/^$country_code/0/g; # Replace own country code with leading 0 + $number =~ s/^(\#[0-9]{1,10}\#)//g; # Remove phone control codes + $number =~ s/\D//g if(not $number =~ /@/); # Remove anything else isn't a number if it is no VoIP number + + if(not $number =~ /^0/ and not $number =~ /@/ and $area_code =~ /^0[1-9]\d+$/) { - if($area_code =~ /^0[1-9]\d+$/) { $number = $area_code.$number; - } - } + } + $count_contacts++; Log3 $name, 4, "FB_CALLMONITOR ($name) - found $contact_name with number $number"; $hash->{helper}{PHONEBOOK}{$number} = FB_CALLMONITOR_html2txt($contact_name) if(not defined($hash->{helper}{PHONEBOOK}{$number})); @@ -1287,6 +1334,8 @@ sub FB_CALLMONITOR_readPassword($;$)
@@ -1327,6 +1376,9 @@ sub FB_CALLMONITOR_readPassword($;$) Default Value is 0 (off)

  • local-area-code
  • Use the given local area code for reverse search in case of a local call (e.g. 0228 for Bonn, Germany)

    +
  • country-code
  • + Your local country code. This is needed to identify phonenumbers in your phonebook with your local country code as a national phone number instead of an international one (e.g. 0049 for Germany, 0043 for Austria or 001 for USA)

    + Default Value is 0049 (Germany)

  • fritzbox-remote-phonebook
  • If this attribute is activated, the phonebook should be obtained direct from the FritzBox via remote network connection (in case FHEM is not running on a FritzBox). This is only possible if a password (and depending on configuration a username as well) is configured.

    Possible values: 0 => off , 1 => on (use remote telnet connection to obtain FritzBox phonebook)
    @@ -1407,6 +1459,8 @@ sub FB_CALLMONITOR_readPassword($;$)
    @@ -1451,14 +1505,17 @@ sub FB_CALLMONITOR_readPassword($;$) Standardwert ist 0 (deaktiviert)

  • local-area-code
  • Verwendet die gesetze Vorwahlnummer bei Rückwärtssuchen von Ortsgesprächen (z.B. 0228 für Bonn)

    +
  • country-code
  • + Die Landesvorwahl wird benötigt um Telefonbucheinträge mit lokaler Landesvorwahl als Inlands-Rufnummern zu erkennen (z.B. 0049 für Deutschland, 0043 für Österreich oder 001 für USA).

    + Standardwert ist 0049 (Deutschland)

  • fritzbox-remote-phonebook
  • Wenn dieses Attribut aktiviert ist, wird das FritzBox Telefonbuch direkt von der FritzBox gelesen. Dazu ist das FritzBox Passwort und je nach FritzBox Konfiguration auch ein Username notwendig, der in den entsprechenden Attributen konfiguriert sein muss.

    Mögliche Werte: 0 => deaktiviert , 1 => aktiviert
    Standardwert ist 0 (deaktiviert)

  • fritzbox-remote-phonebook-via
  • - Setzt die Methode mit der das Telefonbuch von der FritzBox abgefragt werden soll. Bei der Methode "web", werden alle verfügbaren Telefonbücher (lokales sowie alle konfigurierten Online-Telefonbücher) über die Web-Oberfläche eingelesen. Bei der Methode "telnet" wird eine Telnet-Verbindung zur FritzBox aufgebaut um das lokale Telefonbuch abzufragen (keine Online-Telefonbücher). Dazu muss die Telnet-Funktion aktiviert sein (Telefon Kurzwahl: #96*7*)

    + Setzt die Methode mit der das Telefonbuch von der FritzBox abgefragt werden soll. Bei der Methode "web", werden alle verfügbaren Telefonbücher (lokales sowie alle konfigurierten Online-Telefonbücher) über die Web-Oberfläche eingelesen. Bei der Methode "telnet" wird eine Telnet-Verbindung zur FritzBox aufgebaut um das lokale Telefonbuch abzufragen (keine Online-Telefonbücher). Dazu muss die Telnet-Funktion aktiviert sein (Telefon Kurzwahl: #96*7*)

    Mögliche Werte: web,telnet
    - Standardwert ist "web" (retrieve phonebooks via web interface)

    + Standardwert ist "web" (Abfrage aller verfügbaren Telefonbücher über die Web-Oberfläche)

  • fritzbox-remote-phonebook-exclude
  • Eine komma-separierte Liste von Telefonbuch-ID's welche beim einlesen übersprungen werden sollen. Dieses Attribut greift nur beim einlesen der Telefonbücher via "web"-Methode (siehe Attribut fritzbox-remote-phonebook-via). Eine Liste aller möglichen Werte kann über das Get-Kommando showPhonebookIds angezeigt werden.

    Standardmäßig ist diese Funktion deaktiviert (alle Telefonbücher werden eingelesen)