mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-05-01 20:20:10 +00:00
FB_CALLMONITOR: add support for wildcard phonebook entries (Forum: #85761)
git-svn-id: https://svn.fhem.de/fhem/trunk@16709 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
e6918e6938
commit
c8430b5d98
@ -1,5 +1,7 @@
|
|||||||
# Add changes at the top of the list. Keep it in ASCII, and 80-char wide.
|
# 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.
|
# Do not insert empty lines here, update check depends on it.
|
||||||
|
- feature: 72_FB_CALLMONITOR: support for wildcard phonebook entries (numbers
|
||||||
|
with trailing star sign)
|
||||||
- bugfix: 74_XiaomiBTLSens: bugfix
|
- bugfix: 74_XiaomiBTLSens: bugfix
|
||||||
- new: 98_feels_like.pm: New module to compute a "feels like" temperature
|
- new: 98_feels_like.pm: New module to compute a "feels like" temperature
|
||||||
and the cloud coverage from a WH2600 like
|
and the cloud coverage from a WH2600 like
|
||||||
|
@ -687,10 +687,18 @@ FB_CALLMONITOR_reverseSearch($$)
|
|||||||
# Using internal phonebook if available and enabled
|
# Using internal phonebook if available and enabled
|
||||||
if($method eq "phonebook")
|
if($method eq "phonebook")
|
||||||
{
|
{
|
||||||
if(exists($hash->{helper}{PHONEBOOK}) and defined($hash->{helper}{PHONEBOOK}{$number}))
|
if(exists($hash->{helper}{PHONEBOOK}))
|
||||||
{
|
{
|
||||||
Log3 $name, 4, "FB_CALLMONITOR ($name) - using internal phonebook for reverse search of $number";
|
if(defined($hash->{helper}{PHONEBOOK}{$number}))
|
||||||
return $hash->{helper}{PHONEBOOK}{$number};
|
{
|
||||||
|
Log3 $name, 4, "FB_CALLMONITOR ($name) - using internal phonebook for reverse search of $number";
|
||||||
|
return $hash->{helper}{PHONEBOOK}{$number};
|
||||||
|
}
|
||||||
|
elsif(my $result = FB_CALLMONITOR_searchPhonebookWildcards($hash->{helper}{PHONEBOOK}, $number))
|
||||||
|
{
|
||||||
|
Log3 $name, 4, "FB_CALLMONITOR ($name) - using internal phonebook for reverse search of $number";
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(exists($hash->{helper}{PHONEBOOKS}))
|
if(exists($hash->{helper}{PHONEBOOKS}))
|
||||||
@ -702,6 +710,11 @@ FB_CALLMONITOR_reverseSearch($$)
|
|||||||
Log3 $name, 4, "FB_CALLMONITOR ($name) - using internal phonebook for reverse search of $number";
|
Log3 $name, 4, "FB_CALLMONITOR ($name) - using internal phonebook for reverse search of $number";
|
||||||
return $hash->{helper}{PHONEBOOKS}{$pb_id}{$number};
|
return $hash->{helper}{PHONEBOOKS}{$pb_id}{$number};
|
||||||
}
|
}
|
||||||
|
elsif(my $result = FB_CALLMONITOR_searchPhonebookWildcards($hash->{helper}{PHONEBOOKS}{$pb_id}, $number))
|
||||||
|
{
|
||||||
|
Log3 $name, 4, "FB_CALLMONITOR ($name) - using internal phonebook for reverse search of $number";
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1030,6 +1043,31 @@ FB_CALLMONITOR_reverseSearch($$)
|
|||||||
return undef;
|
return undef;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#####################################
|
||||||
|
# check a number against wildcard entries in a given phonebook list
|
||||||
|
sub FB_CALLMONITOR_searchPhonebookWildcards($$)
|
||||||
|
{
|
||||||
|
my ($list, $number) = @_;
|
||||||
|
|
||||||
|
foreach my $key (keys %{$list})
|
||||||
|
{
|
||||||
|
next if($key !~ /^\+?\d+\*$/);
|
||||||
|
|
||||||
|
if(defined($list->{$key}))
|
||||||
|
{
|
||||||
|
my $test = $key;
|
||||||
|
$test =~ s/\*$//;
|
||||||
|
|
||||||
|
if(index($number,$test) == 0)
|
||||||
|
{
|
||||||
|
return $list->{$key}.substr($number,length($test));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return undef;
|
||||||
|
}
|
||||||
|
|
||||||
#####################################
|
#####################################
|
||||||
# replaces all HTML entities to their utf-8 counter parts.
|
# replaces all HTML entities to their utf-8 counter parts.
|
||||||
sub FB_CALLMONITOR_html2txt($)
|
sub FB_CALLMONITOR_html2txt($)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user