From db1fb378d277f3339fb788a652d9ce2e8edb345c Mon Sep 17 00:00:00 2001 From: markusbloch <> Date: Mon, 16 May 2016 12:15:57 +0000 Subject: [PATCH] FB_CALLLIST: fix not working calllist when renaming the configured FB_CALLMONITOR definition. git-svn-id: https://svn.fhem.de/fhem/trunk@11466 2b470e98-0d58-463d-a4d8-8e2adae1ed80 --- fhem/CHANGED | 2 ++ fhem/FHEM/72_FB_CALLLIST.pm | 34 +++++++++++++++++++++++++--------- 2 files changed, 27 insertions(+), 9 deletions(-) diff --git a/fhem/CHANGED b/fhem/CHANGED index ded8364da..896d62a53 100644 --- a/fhem/CHANGED +++ b/fhem/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_CALLLIST: fix not working calllist when renaming the + configured FB_CALLMONITOR definition. - feature: 10_SOMFY : Added readingFnAttributes - bugfix: FB_CALLLIST: no reading update when list becomes empty - feature: added new module 37_plex.pm diff --git a/fhem/FHEM/72_FB_CALLLIST.pm b/fhem/FHEM/72_FB_CALLLIST.pm index 426165f23..09b8819f2 100755 --- a/fhem/FHEM/72_FB_CALLLIST.pm +++ b/fhem/FHEM/72_FB_CALLLIST.pm @@ -297,18 +297,19 @@ sub FB_CALLLIST_Undef($$) # NotifyFn is trigger upon changes on FB_CALLMONITOR device. Imports the call data into call list sub FB_CALLLIST_Notify($$) { - my ($hash,$d) = @_; + my ($hash,$dev) = @_; - return undef if(!defined($hash) or !defined($d)); + return undef if(!defined($hash) or !defined($dev)); my $name = $hash->{NAME}; + my $events = deviceEvents($dev,0); - if($d->{NAME} eq "global") + if($dev->{NAME} eq "global") { - if(grep(m/^(?:ATTR $name .*|DELETEATTR $name .*|INITIALIZED|REREADCFG)$/, @{$d->{CHANGED}})) + my $callmonitor = $hash->{FB}; + + if(grep(m/^(?:ATTR $name .*|DELETEATTR $name .*|INITIALIZED|REREADCFG)$/, @{$events})) { - my $callmonitor = $hash->{FB}; - Log3 $name, 3, "FB_CALLLIST ($name) - WARNING - the selected device $callmonitor does not exist" unless(defined($defs{$callmonitor})); Log3 $name, 3, "FB_CALLLIST ($name) - WARNING - selected device $callmonitor ist not of type FB_CALLMONITOR" if(defined($defs{$callmonitor}) and $defs{$callmonitor}->{TYPE} ne "FB_CALLMONITOR"); @@ -316,19 +317,34 @@ sub FB_CALLLIST_Notify($$) FB_CALLLIST_cleanupList($hash); # Inform all FHEMWEB clients - FB_CALLLIST_updateFhemWebClients($hash) if(grep(m/^(?:ATTR|DELETEATTR)/, @{$d->{CHANGED}})); + FB_CALLLIST_updateFhemWebClients($hash) if(grep(m/^(?:ATTR|DELETEATTR)/, @{$events})); # save current list state to file/configDB FB_CALLLIST_saveList($hash); } + + # detect renaming of attached FB_CALLMONITOR + if(defined($callmonitor) and grep(/^RENAMED $callmonitor \S+$/, @{$events})) + { + my ($new) = map((/^RENAMED $callmonitor (\S+)$/ ? $1 : () ), @{$events}); + + if(defined($new)) + { + Log3 $name, 3, "FB_CALLLIST ($name) - configured callmonitor definition $callmonitor was renamed to $new"; + $hash->{DEF} = $new; + $hash->{NOTIFYDEV} = "global,".$new; + $hash->{FB} = $new; + } + } + return undef; } - my $fb = $d->{NAME}; + my $fb = $dev->{NAME}; return undef if(IsDisabled($name)); return undef if($fb ne $hash->{FB}); - return undef if(!grep(m/^event:/, @{$d->{CHANGED}})); + return undef if(!grep(m/^event:/,@{$events})); my $event = ReadingsVal($fb, "event", undef); my $call_id = ReadingsVal($fb, "call_id", undef);