From 0c16ca6ec5324d6eefa37ce1f258d775c08e9b51 Mon Sep 17 00:00:00 2001 From: markusbloch <> Date: Tue, 20 Jan 2015 22:29:55 +0000 Subject: [PATCH] FB_CALLMONITOR: read phonebooks after all attributes are set from fhem.cfg. (Forum: #30244) git-svn-id: https://svn.fhem.de/fhem/trunk/fhem@7647 2b470e98-0d58-463d-a4d8-8e2adae1ed80 --- CHANGED | 2 ++ FHEM/72_FB_CALLMONITOR.pm | 33 +++++++++++++++++++++++---------- 2 files changed, 25 insertions(+), 10 deletions(-) diff --git a/CHANGED b/CHANGED index a304d2e8a..3a9f68126 100644 --- a/CHANGED +++ b/CHANGED @@ -1,5 +1,7 @@ # 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. + - bugfix: FB_CALLMONITOR: read phonebooks after all attributes are set + from fhem.cfg. - feature: 70_XBMC.pm: clear readings when stopping media - feature: 70_XBMC.pm: new reading is3DFile for 3D files - bugfix: 70_XBMC.pm: improved JSON separator diff --git a/FHEM/72_FB_CALLMONITOR.pm b/FHEM/72_FB_CALLMONITOR.pm index e738b6dbb..d6faf068f 100755 --- a/FHEM/72_FB_CALLMONITOR.pm +++ b/FHEM/72_FB_CALLMONITOR.pm @@ -81,14 +81,16 @@ FB_CALLMONITOR_Initialize($) my ($hash) = @_; # Provider - $hash->{ReadFn} = "FB_CALLMONITOR_Read"; - $hash->{ReadyFn} = "FB_CALLMONITOR_Ready"; - $hash->{GetFn} = "FB_CALLMONITOR_Get"; - $hash->{SetFn} = "FB_CALLMONITOR_Set"; - $hash->{DefFn} = "FB_CALLMONITOR_Define"; - $hash->{UndefFn} = "FB_CALLMONITOR_Undef"; - $hash->{AttrFn} = "FB_CALLMONITOR_Attr"; - $hash->{AttrList}= "do_not_notify:0,1 disable:0,1 unique-call-ids:0,1 local-area-code remove-leading-zero:0,1 reverse-search-cache-file reverse-search:multiple-strict,phonebook,klicktel.de,dasoertliche.de,search.ch,dasschnelle.at reverse-search-cache:0,1 reverse-search-phonebook-file fritzbox-remote-phonebook:0,1 fritzbox-user ". + $hash->{ReadFn} = "FB_CALLMONITOR_Read"; + $hash->{ReadyFn} = "FB_CALLMONITOR_Ready"; + $hash->{GetFn} = "FB_CALLMONITOR_Get"; + $hash->{SetFn} = "FB_CALLMONITOR_Set"; + $hash->{DefFn} = "FB_CALLMONITOR_Define"; + $hash->{UndefFn} = "FB_CALLMONITOR_Undef"; + $hash->{AttrFn} = "FB_CALLMONITOR_Attr"; + $hash->{NotifyFn} = "FB_CALLMONITOR_Notify"; + $hash->{NOTIFYDEV} = "global"; + $hash->{AttrList} = "do_not_notify:0,1 disable:0,1 unique-call-ids:0,1 local-area-code remove-leading-zero:0,1 reverse-search-cache-file reverse-search:multiple-strict,phonebook,klicktel.de,dasoertliche.de,search.ch,dasschnelle.at reverse-search-cache:0,1 reverse-search-phonebook-file fritzbox-remote-phonebook:0,1 fritzbox-user ". $readingFnAttributes; } @@ -334,7 +336,8 @@ FB_CALLMONITOR_Attr($@) if($cmd eq "set") { - if(($attrib eq "reverse-search" and $value =~ /(all|internal|phonebook)/) or $attrib eq "reverse-search-phonebook-file" or $attrib eq "fritzbox-remote-phonebook") + + if((($attrib eq "reverse-search" and $value =~ /(all|internal|phonebook)/) or $attrib eq "reverse-search-phonebook-file" or $attrib eq "fritzbox-remote-phonebook") and $init_done == 1) { $attr{$name}{$attrib} = $value; return FB_CALLMONITOR_readPhonebook($hash); @@ -380,6 +383,17 @@ FB_CALLMONITOR_Attr($@) return undef; } + +sub +FB_CALLMONITOR_Notify($$) +{ + my ($hash,$dev) = @_; + + return if($dev->{NAME} ne "global"); + return if(!grep(m/^INITIALIZED|REREADCFG$/, @{$dev->{CHANGED}})); + + FB_CALLMONITOR_readPhonebook($hash); +} ############################################################################################################ # # Begin of helper functions @@ -640,7 +654,6 @@ sub FB_CALLMONITOR_readPhonebook($;$$) if(AttrVal($name, "fritzbox-remote-phonebook", "0") eq "1") { - ($err, $phonebook) = FB_CALLMONITOR_readRemotePhonebook($hash); if(defined($err))