diff --git a/fhem/CHANGED b/fhem/CHANGED index 83be4f4c6..e28bf9e4c 100644 --- a/fhem/CHANGED +++ b/fhem/CHANGED @@ -1,5 +1,8 @@ # 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: 72_FB_CALLLIST: enhanced possibilities to disable a FB_CALLLIST + definition (via attribute "disable") + new attribute processEventsWhileDisabled - feature: 73_PRESENCE: new presenced deb package (ping command, systemd) - feature: 93_DbRep: V7.6.1, data with "|" in value are possible to process, attr "sqlCmdHistoryLength" to use sqlCmdHistory list, diff --git a/fhem/FHEM/72_FB_CALLLIST.pm b/fhem/FHEM/72_FB_CALLLIST.pm index de6213e40..f8aa23d6b 100755 --- a/fhem/FHEM/72_FB_CALLLIST.pm +++ b/fhem/FHEM/72_FB_CALLLIST.pm @@ -58,7 +58,8 @@ FB_CALLLIST_Initialize($) "list-order:ascending,descending ". "answMachine-is-missed-call:0,1 ". "language:de,en ". - "disable:0,1 ". + "disable:0,1,2,3 ". + "processEventsWhileDisabled:0,1 ". "number-cmd ". "disabledForIntervals ". "do_not_notify:0,1 ". @@ -232,7 +233,7 @@ sub FB_CALLLIST_Set($@) if(AttrVal($name, "create-readings", "0") eq "1") { readingsBeginUpdate($hash); - + readingsBulkUpdate($hash, "numberOfCalls", 0, 1); for my $reading (grep { /^\d+-/ } keys %{$hash->{READINGS}}) @@ -389,7 +390,7 @@ sub FB_CALLLIST_Notify($$) my $fb = $dev->{NAME}; - return undef if(IsDisabled($name)); + return undef if(IsDisabled($name) and AttrVal($name, "processEventsWhileDisabled", "0") eq "0"); return undef if($fb ne $hash->{FB}); return undef if(!grep(m/^event:/,@{$events})); @@ -498,14 +499,18 @@ sub FB_CALLLIST_Notify($$) # clean up the list FB_CALLLIST_cleanupList($hash); + # save current list state to file/configDB + FB_CALLLIST_saveList($hash); + + return undef if(IsDisabled($name)); + # inform about changes of current call index FB_CALLLIST_updateOneItemInFHEMWEB($hash,$data->{internal_index}); # Update readings FB_CALLLIST_createReadings($hash); - # save current list state to file/configDB - FB_CALLLIST_saveList($hash); + } ############################################################################################################ @@ -904,9 +909,7 @@ sub FB_CALLLIST_list2html($) my $td_style = 'style="padding-left:6px;padding-right:6px;"'; my $line; - - - my $ret .= ""; + my $ret .= '
'; if(AttrVal($name, "no-heading", "0") eq "0" and defined($FW_ME) and defined($FW_subdir)) { @@ -915,42 +918,59 @@ sub FB_CALLLIST_list2html($) $ret .= ""; } - $ret .= "
"; - $ret .= '
'; # div tag to support inform updates - $ret .= ''; - - $ret .= FB_CALLLIST_returnOrderedHTMLOutput($hash, FB_CALLLIST_returnTableHeader($hash), 'class="fbcalllist header"','') if(AttrVal($name, "no-table-header", "0") eq "0"); - - my @item_list = FB_CALLLIST_getAllItemLines($hash); - - if(@item_list > 0) + if(AttrVal($name, "disable", "0") ne "3") { - foreach $line (@item_list) - { - $ret .= FB_CALLLIST_returnOrderedHTMLOutput($hash, $line, 'number="'.$line->{line}.'" index="'.$line->{index}.'" class="fbcalllist item '.($line->{line} % 2 == 1 ? "odd" : "even").'"', 'class="fbcalllist cell" '.$td_style); - } - } - else - { - my $string; + $ret .= ""; } - $ret .= "
"; + $ret .= '
'; # div tag to support inform updates + $ret .= ''; - if(AttrVal($name, "language", "en") eq "de") + $ret .= FB_CALLLIST_returnOrderedHTMLOutput($hash, FB_CALLLIST_returnTableHeader($hash), 'class="fbcalllist header"'.((AttrVal($name, "no-table-header", "0") eq "1") ? ' style="display:none;"' : ''),''); + + if(AttrVal($name,'disable',"0") eq "2") { - $string = "leer"; + my $string = '
'.((AttrVal($name, "language", "en") eq "de") ? "deaktiviert" : "disabled").'
'; + + my @columns = split(",",AttrVal($name, "visible-columns", $hash->{helper}{DEFAULT_COLUMN_ORDER})); + my $additional_columns = scalar(@columns); + + $ret .= ''; } else { - $string = "empty"; + my @item_list = FB_CALLLIST_getAllItemLines($hash); + + if(@item_list > 0) + { + foreach $line (@item_list) + { + $ret .= FB_CALLLIST_returnOrderedHTMLOutput($hash, $line, 'number="'.$line->{line}.'" index="'.$line->{index}.'" class="fbcalllist item '.($line->{line} % 2 == 1 ? "odd" : "even").'"', 'class="fbcalllist cell" '.$td_style); + } + } + else + { + my $string; + + if(AttrVal($name, "language", "en") eq "de") + { + $string = "leer"; + } + else + { + $string = "empty"; + } + + my @columns = split(",",AttrVal($name, "visible-columns", $hash->{helper}{DEFAULT_COLUMN_ORDER})); + my $additional_columns = scalar(@columns); + + $ret .= ''; + } } - my @columns = split(",",AttrVal($name, "visible-columns", $hash->{helper}{DEFAULT_COLUMN_ORDER})); - my $additional_columns = scalar(@columns); - - $ret .= ''; + $ret .= "
'.$string.'
'.$string.'
'.$string.'
"; + $ret .= "
"; - $ret .= "
"; + $ret .= ""; return $ret; } @@ -1124,7 +1144,7 @@ sub FB_CALLLIST_loadList($) } else { - Log3 $name, 5, "FB_CALLLIST ($name) - no list found for restoring"; + Log3 $name, 5, "FB_CALLLIST ($name) - no list found for restoring"; } } @@ -1250,7 +1270,7 @@ sub FB_CALLLIST_deleteItem($;$) if(FB_CALLLIST_createOrderedIndexList($hash)) { - FW_directNotify($name, "{\"action\":\"delete\",\"index\":\"$index\"}", 1) if(defined($FW_ME) and $index); + FW_directNotify($name, '{"action":"delete","index":"'.$index.'"}', 1) if(defined($FW_ME) and $index); } else { @@ -1270,7 +1290,7 @@ sub FB_CALLLIST_deleteItem($;$) $string = "empty"; } - FW_directNotify($name, "{\"action\":\"clear\",\"content\":\"$string\"}", 1); + FW_directNotify($name, '{"action":"clear","content":"'.$string.'"}', 1); } } @@ -1284,20 +1304,38 @@ sub FB_CALLLIST_updateFhemWebClients($) return undef unless($init_done); - if(my @list = FB_CALLLIST_getAllItemLines($hash)) + if(IsDisabled($name)) { - Log3 $name, 5, "FB_CALLLIST ($name) - inform all FHEMWEB clients"; + my $string = "
".((AttrVal($name, "language", "en") eq "de") ? "deaktiviert" : "disabled").'
'; - # inform all FHEMWEB clients about changes - foreach my $line (@list) + if(AttrVal($name,"disable","0") eq "2") { - my $json = FB_CALLLIST_returnOrderedJSONOutput($hash, $line); - FW_directNotify($name, "{\"action\":\"update\",\"index\":\"".$line->{index}."\",\"order\":\"".AttrVal($name, "list-order","descending")."\",\"item\":$json}", 1); + FW_directNotify($name, '{"action":"clear","content":"'.$string.'"}', 1); + } + elsif(AttrVal($name,"disable","0") eq "3") + { + FW_directNotify($name, '{"action":"hide"}', 1); } } else { - FB_CALLLIST_deleteItem($hash); + if(my @list = FB_CALLLIST_getAllItemLines($hash)) + { + Log3 $name, 5, "FB_CALLLIST ($name) - inform all FHEMWEB clients"; + + # inform all FHEMWEB clients about changes + foreach my $line (@list) + { + my $json = FB_CALLLIST_returnOrderedJSONOutput($hash, $line); + FW_directNotify($name, '{"action":"update","index":"'.$line->{index}.'","order":"'.AttrVal($name, "list-order","descending").'","item":'.$json.'}', 1); + } + } + else + { + FB_CALLLIST_deleteItem($hash); + } + + FW_directNotify($name, '{"action":"show"}', 1); } } @@ -1314,7 +1352,7 @@ sub FB_CALLLIST_updateOneItemInFHEMWEB($$) my $json = FB_CALLLIST_returnOrderedJSONOutput($hash, $line); - FW_directNotify($name, "{\"action\":\"update\",\"index\":\"$index\",\"order\":\"".AttrVal($name, "list-order","descending")."\",\"item\":$json}", 1); + FW_directNotify($name, '{"action":"update","index":"'.$index.'","order":"'.AttrVal($name, "list-order","descending").'","item":'.$json.'}', 1); return undef; } @@ -1455,20 +1493,31 @@ sub FB_CALLLIST_returnTableHeader($) Possible values: 0 => no readings will be created, 1 => readings and events will be created.
Default Value is 0 (no readings will be created)

-
  • 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. +
  • disable 0,1,2,3
  • + Optional attribute to disable the call list. When disabled, call events will not be processed and the list wouldn't be updated accordingly. Depending on the value, the call list can

    - Possible values: 0 => FB_CALLLIST is activated, 1 => FB_CALLLIST is deactivated.
    + Possible values:
    Default Value is 0 (activated)

    -
  • disabledForIntervals HH:MM-HH:MM HH:MM-HH-MM...
  • - Optional attribute to disable the call list update during a specific time interval. The attribute contains a space separated list of HH:MM tupels. +
  • disabledForIntervals HH:MM-HH:MM HH:MM-HH:MM...
  • + Optional attribute to disable event processing and updates of the call list during a specific time interval. The attribute contains a space separated list of HH:MM tupels. If the current time is between any of these time specifications, the callist will be disabled and no longer updated. Instead of HH:MM you can also specify HH or HH:MM:SS.

    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)

    +
  • processEventsWhileDisabled 0,1
  • + If enabled, events where still be processed, even FB_CALLLIST is disabled (see disable and disabledForIntervals). So after re-enabling FB_CALLLIST, all calls during disabled state are completely available. +

    + Possible values: 0 => no event processing when FB_CALLIST is disabled, 1 => events are still processed, even FB_CALLLIST is disabled
    + Default Value is 0 (no event processing when disabled)

    +
  • expire-calls-after <time frame>
  • Optional attribute to automatically delete finished calls which are older than a given time frame. If a finished call is older than this time frame, it will be deleted from the list.

    A time frame can be specified as follows: @@ -1708,21 +1757,33 @@ sub FB_CALLLIST_returnTableHeader($) Standardwert ist nicht gesetzt (Keine Zuordnung, es werden die Originalwerte verwendet)

    -
  • disable 0,1
  • - Optionales Attribut zur Deaktivierung der Anrufliste. Es werden dann keine Anruf-Events mehr verarbeitet und die Liste nicht weiter aktualisiert. +
  • disable 0,1,2,3
  • + Optionales Attribut zur Deaktivierung der Anrufliste. Sofern aktiviert, werden keine Anruf-Events mehr verarbeitet und die Liste nicht weiter aktualisiert. Je nach gesetztem Wert verhält sich FB_CALLLIST unterschiedlich.

    - Mögliche Werte: 0 => Anrufliste ist aktiv, 1 => Anrufliste ist deaktiviert.
    + Mögliche Werte:
    Standardwert ist 0 (aktiv)

    -
  • disabledForIntervals HH:MM-HH:MM HH:MM-HH-MM...
  • +
  • disabledForIntervals HH:MM-HH:MM HH:MM-HH:MM...
  • Optionales Attribut zur Deaktivierung der Anrufliste innerhalb von bestimmten Zeitintervallen. Das Argument ist eine Leerzeichen-getrennte Liste von Minuszeichen-getrennten HH:MM Paaren (Stunde : Minute). - Falls die aktuelle Uhrzeit zwischen diese Werte fällt, dann wird die Ausführung, wie bei disable, ausgesetzt. + Falls die aktuelle Uhrzeit zwischen diese Werte fällt, dann wird die Ausführung, wie bei disable gleich 1, ausgesetzt. Statt HH:MM kann man auch HH oder HH:MM:SS angeben.

    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 (dauerhaft aktiv)

    +
  • processEventsWhileDisabled 0,1
  • + Sofern gesetzt, werden Events weiterhin verarbeitet, selbst wenn FB_CALLLIST deaktiviert ist (siehe disabled und disabledForIntervals). + Sobald FB_CALLLIST wieder aktiviert wurde, stehen sämtliche Anrufe, während FB_CALLLIST deaktiviert war, zur Verfügung. +

    + Mögliche Werte: 0 => keine Eventverabeitung wenn FB_CALLLIST deaktiviert ist, 1 => Events werden trotz deaktiviert FB_CALLLIST intern weiterhin verarbeitet.
    + Standardwert ist 0 (keine Eventverabeitung wenn deaktiviert)

    +
  • expire-calls-after <Zeitfenster>
  • Optionales Attribut um beendete Anrufe nach einem angegeben Zeitfenster automatisch aus der Anrufliste zu löschen. Sobald ein beendetes Gespräch älter ist als das angegebene Zeitfenster, wird es automatisch aus der Liste entfernt. diff --git a/fhem/www/pgm2/fhemweb_fbcalllist.js b/fhem/www/pgm2/fhemweb_fbcalllist.js index 910111f8f..76bf23731 100755 --- a/fhem/www/pgm2/fhemweb_fbcalllist.js +++ b/fhem/www/pgm2/fhemweb_fbcalllist.js @@ -23,7 +23,7 @@ function FW_processCallListUpdate(data) if(!table.find("tr[name=empty]").length) { table.find("tr[number]").remove(); - table.append(""+json_data.content+""); + table.append(""+json_data.content+""); } return; } @@ -36,6 +36,20 @@ function FW_processCallListUpdate(data) return; } + // hide the complete table + if(json_data.action == "hide") + { + table.hide(); + return; + } + + // show the complete table + if(json_data.action == "show") + { + table.show(); + return; + } + // update a item with new data if(json_data.action == "update") { @@ -77,6 +91,7 @@ function FW_processCallListUpdate(data) } FW_FbCalllistUpdateRowNumbers(table); } + return; } }