From c61c8ecfc104fb0a94eaa48ba84fa0c15caca3a2 Mon Sep 17 00:00:00 2001 From: markusbloch <> Date: Wed, 24 Jun 2015 19:14:24 +0000 Subject: [PATCH] FB_CALLLIST: new attribute create-readings to optionally enable the generation of readings/events for each listed call (Forum: #38322) git-svn-id: https://svn.fhem.de/fhem/trunk@8817 2b470e98-0d58-463d-a4d8-8e2adae1ed80 --- fhem/FHEM/72_FB_CALLLIST.pm | 79 +++++++++++++++++++++++++++++++------ 1 file changed, 66 insertions(+), 13 deletions(-) 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 .= "
23:00-24:00 00:00-01:00Default Value is empty (no intervals defined, calllist is always active)
.*
(all readings), to reduce the amount of generated readings for certain call events.23:00-24:00 00:00-01:00Standardwert ist nicht gesetzt (aktiv)
.*
zu stellen um die hohe Anzahl an Events in bestimmten Fällen zu minimieren.