diff --git a/fhem/FHEM/72_FB_CALLLIST.pm b/fhem/FHEM/72_FB_CALLLIST.pm
index 436c5600a..96b417353 100755
--- a/fhem/FHEM/72_FB_CALLLIST.pm
+++ b/fhem/FHEM/72_FB_CALLLIST.pm
@@ -45,6 +45,7 @@ FB_CALLLIST_Initialize($)
$hash->{AttrList} = "number-of-calls:1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20 ".
"internal-number-filter ".
"connection-mapping ".
+ "create-readings:0,1 ".
"visible-columns:sortable-strict,row,state,timestamp,name,number,internal,connection,duration ".
"show-icons:0,1 ".
"list-type:all,incoming,outgoing,missed-calls,completed,active " .
@@ -52,7 +53,9 @@ FB_CALLLIST_Initialize($)
"list-order:ascending,descending ".
"language:de,en ".
"disable:0,1 ".
- "disabledForIntervals";
+ "disabledForIntervals ".
+ "do_not_notify:0,1 ".
+ $readingFnAttributes;
$hash->{FW_detailFn} = "FB_CALLLIST_makeTable";
$hash->{FW_summaryFn} = "FB_CALLLIST_makeTable";
@@ -90,7 +93,7 @@ sub FB_CALLLIST_Define($$)
$hash->{FB} = $a[2];
$hash->{NOTIFYDEV} = $a[2];
$hash->{STATE} = 'Initialized';
-
+ $hash->{helper}{DEFAULT_COLUMN_ORDER} = "row,state,timestamp,name,number,internal,connection,duration";
FB_CALLLIST_loadList($hash);
return undef;
@@ -403,6 +406,8 @@ sub FB_CALLLIST_cleanupList($)
Log3 $name, 5, "FB_CALLLIST ($name) - deleting old call $index";
delete($hash->{helper}{DATA}{$index}) if(exists($hash->{helper}{DATA}{$index}));
}
+
+
}
else
{
@@ -412,16 +417,17 @@ sub FB_CALLLIST_cleanupList($)
#####################################
# returns the call state of a specific call as icon or text
-sub FB_CALLLIST_returnCallState($$)
+sub FB_CALLLIST_returnCallState($$;$)
{
- my ($hash, $index) = @_;
+ my ($hash, $index, $icons) = @_;
return undef unless(exists($hash->{helper}{DATA}{$index}));
my $data = \%{$hash->{helper}{DATA}{$index}};
- my $icons = AttrVal($hash->{NAME}, "show-icons", 1);
my $state;
+ $icons = AttrVal($hash->{NAME}, "show-icons", 1) unless(defined($icons));
+
if($data->{running_call})
{
if($data->{direction} eq "incoming" and $data->{last_event} eq "connect" )
@@ -493,7 +499,9 @@ sub FB_CALLLIST_list2html($;$)
my $name = $hash->{NAME};
my $alias = AttrVal($hash->{NAME}, "alias", $hash->{NAME});
-
+
+ my $create_readings = AttrVal($hash->{NAME}, "create-readings",0);
+
my $ret = "";
my $td_style = "style=\"padding-left:6px;padding-right:6px;\"";
my @json_output = ();
@@ -526,6 +534,7 @@ sub FB_CALLLIST_list2html($;$)
{
@list = grep { !$hash->{helper}{DATA}{$_}{running_call} } @list;
}
+
foreach my $index (@list)
{
@@ -540,6 +549,7 @@ sub FB_CALLLIST_list2html($;$)
my $duration = FB_CALLLIST_formatDuration($hash, $index);
$line = {
+ index => $index,
line => $count,
row => $count,
state => $state,
@@ -550,12 +560,15 @@ sub FB_CALLLIST_list2html($;$)
connection => $connection,
duration => $duration
};
+
push @json_output, FB_CALLLIST_returnOrderedJSONOutput($hash, $line);
-
+ FB_CALLLIST_updateReadings($hash, $line) if($to_json and $create_readings);
$ret .= FB_CALLLIST_returnOrderedHTMLOutput($hash, $line, "number=\"$count\" class=\"fbcalllist ".($count % 2 == 1 ? "odd" : "even")."\"", "class=\"fbcalllist\" $td_style");
$count++;
}
+
+
}
else
{
@@ -570,7 +583,7 @@ sub FB_CALLLIST_list2html($;$)
$string = "empty";
}
- my @columns = split(",",AttrVal($name, "visible-columns", "row,state,timestamp,name,number,internal,connection,duration"));
+ my @columns = split(",",AttrVal($name, "visible-columns", $hash->{helper}{DEFAULT_COLUMN_ORDER}));
my $additional_columns = scalar(@columns);
$ret .= "
$string |
";
@@ -722,7 +735,7 @@ sub FB_CALLLIST_returnOrderedHTMLOutput($$$$)
my $name = $hash->{NAME};
- my @order = split(",", AttrVal($name, "visible-columns", "row,state,timestamp,name,number,internal,connection,duration"));
+ my @order = split(",", AttrVal($name, "visible-columns",$hash->{helper}{DEFAULT_COLUMN_ORDER}));
my @ret = ();
@@ -745,7 +758,7 @@ sub FB_CALLLIST_returnOrderedJSONOutput($$)
my $name = $hash->{NAME};
- my @order = split(",", AttrVal($name, "visible-columns", "row,state,timestamp,name,number,internal,connection,duration"));
+ my @order = split(",", AttrVal($name, "visible-columns",$hash->{helper}{DEFAULT_COLUMN_ORDER}));
my @ret = ();
@@ -761,6 +774,32 @@ sub FB_CALLLIST_returnOrderedJSONOutput($$)
return "{".join(",",@ret)."}";
}
+
+sub FB_CALLLIST_updateReadings($$)
+{
+ my ($hash,$line) = @_;
+
+ my $name = $hash->{NAME};
+
+ my %line_tmp = %{$line};
+
+ my @order = split(",", AttrVal($name, "visible-columns",$hash->{helper}{DEFAULT_COLUMN_ORDER}));
+
+ $line_tmp{state} = FB_CALLLIST_returnCallState($hash, $line->{index}, 0);
+
+ readingsBeginUpdate($hash);
+
+ foreach my $col (@order)
+ {
+ readingsBulkUpdate($hash, $line_tmp{line}."-$col", $line_tmp{$col});
+ }
+
+ readingsEndUpdate($hash, 1);
+
+
+}
+
+
#####################################
# Check, if a given internal number matches the configured internal-number-filter (if set). returns true if number matches
sub FB_CALLLIST_checkForInternalNumberFilter($$)
@@ -798,20 +837,22 @@ sub FB_CALLLIST_updateFhemWebClients($)
Log3 $name, 5, "FB_CALLLIST ($name) - inform all FHEMWEB clients";
# inform all FHEMWEB clients about changes
+ my $count = 0;
foreach my $line (FB_CALLLIST_list2html($hash, 1))
{
FW_directNotify($name, $line, 1);
+ $count++;
}
# send the current row count to ensure all other rows are deleted via JS
- FW_directNotify($name,"max-lines,".(scalar keys %{$hash->{helper}{DATA}}), 1);
+ FW_directNotify($name,"max-lines,$count", 1);
}
else
{
Log3 $name, 5, "FB_CALLLIST ($name) - list is empty, sending a clear command to all FHEMWEB clients";
# inform all FHEMWEB clients about empty list
- my @columns = split(",",AttrVal($name, "visible-columns", "row,state,timestamp,name,number,internal,connection,duration"));
+ my @columns = split(",",AttrVal($name, "visible-columns", $hash->{helper}{DEFAULT_COLUMN_ORDER}));
my $additional_columns = scalar(@columns);
my $string;
@@ -930,7 +971,8 @@ sub FB_CALLLIST_returnTableHeader($)
Attributes
-
+ - do_not_notify
+ - readingFnAttributes
- disable 0,1
Optional attribute to disable the call list update. When disabled, call events will be processed and the list wouldn't be updated accordingly.
@@ -943,6 +985,10 @@ sub FB_CALLLIST_returnTableHeader($)
To specify an interval spawning midnight, you have to specify two intervals, e.g.:
23:00-24:00 00:00-01:00
Default Value is empty (no intervals defined, calllist is always active)
+ create-readings 0,1
+ If enabled, for all visible calls in the list, readings and events will be created. It is recommended to set the attribute event-on-change-reading to .*
(all readings), to reduce the amount of generated readings for certain call events.
+ Possible values: 0 => no readings will be created, 1 => readings and events will be created.
+ Default Value is 0 (no readings will be created)
number-of-calls 1..20
Defines the maximum number of displayed call entries in the list.
Default Value is 5 calls
@@ -1084,6 +1130,8 @@ sub FB_CALLLIST_returnTableHeader($)
Attributes
+ - do_not_notify
+ - readingFnAttributes
- disable
Optionales Attribut zur Deaktivierung der Anrufliste. Es werden dann keine Anruf-Events mehr verarbeitet und die Liste nicht weiter aktualisiert.
@@ -1097,6 +1145,11 @@ sub FB_CALLLIST_returnTableHeader($)
Um einen Intervall um Mitternacht zu spezifizieren, muss man zwei einzelne Intervalle angeben, z.Bsp.:
23:00-24:00 00:00-01:00
Standardwert ist nicht gesetzt (aktiv)
+ create-readings 0,1
+ Sofern aktiviert, werden für alle sichtbaren Anrufe in der Liste entsprechende Readings und Events erzeugt.
+ Es wird empfohlen das Attribut event-on-change-reading auf den Wert .*
zu stellen um die hohe Anzahl an Events in bestimmten Fällen zu minimieren.
+ Possible values: 0 => no readings will be created, 1 => readings and events will be created.
+ Default Value is 0 (no readings will be created)
number-of-calls 1..20
Setzt die maximale Anzahl an Einträgen in der Anrufliste. Sollte die Anrufliste voll sein, wird das älteste Gespräch gelöscht.
Standardwert sind 5 Einträge