diff --git a/fhem/CHANGED b/fhem/CHANGED
index bdf91c5eb..d4d17f74d 100644
--- a/fhem/CHANGED
+++ b/fhem/CHANGED
@@ -1,5 +1,10 @@
# 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.
+ - feature: FB_CALLMONITOR: new reading "direction" to differentiate
+ between incoming and outgoing call.
+ - feature: FB_CALLMONITOR: all informational readings about a call will be
+ triggered for each call event
+ (call, ring, connect and disconnect)
- feature: mailcheck: allow user and pssword as perl expression
- feature: netatmo: support for public stations
- feature: PRESENCE: new set command "power" to execute a FHEM command
diff --git a/fhem/FHEM/72_FB_CALLMONITOR.pm b/fhem/FHEM/72_FB_CALLMONITOR.pm
index 0ca57ff9e..00154175c 100755
--- a/fhem/FHEM/72_FB_CALLMONITOR.pm
+++ b/fhem/FHEM/72_FB_CALLMONITOR.pm
@@ -233,64 +233,75 @@ FB_CALLMONITOR_Read($)
$reverse_search = FB_CALLMONITOR_reverseSearch($hash, $external_number) if(defined($external_number) and AttrVal($name, "reverse-search", "none") ne "none");
- readingsBeginUpdate($hash);
- readingsBulkUpdate($hash, "event", lc($array[1]));
- readingsBulkUpdate($hash, "external_number", (defined($external_number) ? $external_number : "unknown")) if($array[1] eq "RING" or $array[1] eq "CALL");
- readingsBulkUpdate($hash, "external_name",(defined($reverse_search) ? $reverse_search : "unknown")) if($array[1] eq "RING" or $array[1] eq "CALL");
- readingsBulkUpdate($hash, "internal_number", $array[4]) if($array[1] eq "RING" or $array[1] eq "CALL");
- readingsBulkUpdate($hash, "external_connection", $array[5]) if($array[1] eq "RING");
- readingsBulkUpdate($hash, "external_connection", $array[6]) if($array[1] eq "CALL");
- readingsBulkUpdate($hash, "internal_connection", $connection_type{$array[3]}) if($array[1] eq "CALL" or $array[1] eq "CONNECT" and defined($connection_type{$array[3]}));
- readingsBulkUpdate($hash, "call_duration", $array[3]) if($array[1] eq "DISCONNECT");
+ if($array[1] eq "CALL" or $array[1] eq "RING")
+ {
+ if(AttrVal($name, "unique-call-ids", "0") eq "1")
+ {
+ $hash->{helper}{TEMP}{$array[2]}{call_id}= Digest::MD5::md5_hex($data);
+ }
+ else
+ {
+ $hash->{helper}{TEMP}{$array[2]}{call_id} = $array[2];
+ }
+ }
+ if($array[1] eq "CALL")
+ {
+ delete($hash->{helper}{TEMP}{$array[2]}) if(exists($hash->{helper}{TEMP}{$array[2]}));
+
+ $hash->{helper}{TEMP}{$array[2]}{external_number} = (defined($external_number) ? $external_number : "unknown");
+ $hash->{helper}{TEMP}{$array[2]}{external_name} = (defined($reverse_search) ? $reverse_search : "unknown");
+ $hash->{helper}{TEMP}{$array[2]}{internal_number} = $array[4];
+ $hash->{helper}{TEMP}{$array[2]}{external_connection} = $array[6];
+ $hash->{helper}{TEMP}{$array[2]}{internal_connection} = $connection_type{$array[3]} if(defined($connection_type{$array[3]}));
+ $hash->{helper}{TEMP}{$array[2]}{direction} = "outgoing";
+ }
+
if($array[1] eq "RING")
{
- $hash->{helper}{MISSED_CALL_DETECTION}{$array[2]}{EVENT} = $array[1];
- my $no = "unknown";
- if(defined($external_number))
- {
- $no = $external_number;
- if(defined($reverse_search))
- {
- $no .= " (".$reverse_search.")";
- }
- }
-
- $hash->{helper}{MISSED_CALL_DETECTION}{$array[2]}{NUMBER} = $no;
- $hash->{helper}{MISSED_CALL_DETECTION}{$array[2]}{LINE} = $array[4];
+ delete($hash->{helper}{TEMP}{$array[2]}) if(exists($hash->{helper}{TEMP}{$array[2]}));
+ $hash->{helper}{TEMP}{$array[2]}{external_number} = (defined($external_number) ? $external_number : "unknown");
+ $hash->{helper}{TEMP}{$array[2]}{external_name} = (defined($reverse_search) ? $reverse_search : "unknown");
+ $hash->{helper}{TEMP}{$array[2]}{internal_number} = $array[4];
+ $hash->{helper}{TEMP}{$array[2]}{external_connection} = $array[5];
+ $hash->{helper}{TEMP}{$array[2]}{direction} = "incoming";
}
- elsif ($array[1] eq "DISCONNECT")
+
+ if($array[1] eq "CONNECT" and not exists($hash->{helper}{TEMP}{$array[2]}{internal_connection}))
{
- if (($array[3] eq "0") and (exists($hash->{helper}{MISSED_CALL_DETECTION}{$array[2]}) and $hash->{helper}{MISSED_CALL_DETECTION}{$array[2]}{EVENT} eq "RING"))
+ $hash->{helper}{TEMP}{$array[2]}{internal_connection} = $connection_type{$array[3]} if(defined($connection_type{$array[3]}));
+ }
+
+ if($array[1] eq "DISCONNECT")
+ {
+ $hash->{helper}{TEMP}{$array[2]}{call_duration} = $array[3];
+
+ if($hash->{helper}{TEMP}{$array[2]}{direction} eq "incoming" and $array[3] eq "0")
{
- readingsBulkUpdate($hash, "missed_call", $hash->{helper}{MISSED_CALL_DETECTION}{$array[2]}{NUMBER});
- readingsBulkUpdate($hash, "missed_call_line", $hash->{helper}{MISSED_CALL_DETECTION}{$array[2]}{LINE})
+ $hash->{helper}{TEMP}{$array[2]}{missed_call} = $hash->{helper}{TEMP}{$array[2]}{external_number}.($hash->{helper}{TEMP}{$array[2]}{external_name} ne "unknown" ? " (".$hash->{helper}{TEMP}{$array[2]}{external_name}.")" : "");
+ $hash->{helper}{TEMP}{$array[2]}{missed_call_line} = $hash->{helper}{TEMP}{$array[2]}{internal_number};
}
- delete($hash->{helper}{MISSED_CALL_DETECTION}{$array[2]}) if(exists($hash->{helper}{MISSED_CALL_DETECTION}{$array[2]}));
- }
-
-
- if(AttrVal($name, "unique-call-ids", "0") eq "1")
+ }
+
+ readingsBeginUpdate($hash);
+ readingsBulkUpdate($hash, "event", lc($array[1]));
+
+ foreach my $key (keys $hash->{helper}{TEMP}{$array[2]})
{
- if($array[1] eq "RING" or $array[1] eq "CALL")
- {
- $hash->{helper}{CALLID}{$array[2]} = Digest::MD5::md5_hex($data);
- }
- readingsBulkUpdate($hash, "call_id", $hash->{helper}{CALLID}{$array[2]});
-
- if($array[1] eq "DISCONNECT")
- {
- delete($hash->{helper}{CALLID}{$array[2]});
- }
- }
- else
- {
- readingsBulkUpdate($hash, "call_id", $array[2]);
+ readingsBulkUpdate($hash, $key, $hash->{helper}{TEMP}{$array[2]}{$key});
}
+
+ if($array[1] eq "DISCONNECT")
+ {
+ delete($hash->{helper}{TEMP}{$array[2]}) if(exists($hash->{helper}{TEMP}{$array[2]}));
+ }
+
readingsEndUpdate($hash, 1);
+
+
}
@@ -827,6 +838,7 @@ sub FB_CALLMONITOR_loadCacheFile($)
Generated Events: