2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-03-03 16:56:54 +00:00

FB_CALLLIST: delete also corresponding readings if a call gets deleted (Forum: #52158)

git-svn-id: https://svn.fhem.de/fhem/trunk@11300 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
markusbloch 2016-04-23 15:16:10 +00:00
parent 68af103947
commit 3ae0174d47
2 changed files with 22 additions and 7 deletions

View File

@ -1,5 +1,7 @@
# Add changes at the top of the list. Keep it in ASCII, and 80-char wide. # 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. # Do not insert empty lines here, update check depends on it.
- change: FB_CALLLIST: delete also corresponding readings if a call gets
deleted
- feature: 49_SSCam: Attribute "disable" to deactivate the module added - feature: 49_SSCam: Attribute "disable" to deactivate the module added
- bugfix: 14_CUL_TCM97001: Fix battery bits. - bugfix: 14_CUL_TCM97001: Fix battery bits.
Fix Auriol receive Fix Auriol receive

View File

@ -316,7 +316,7 @@ sub FB_CALLLIST_Notify($$)
FB_CALLLIST_cleanupList($hash); FB_CALLLIST_cleanupList($hash);
# Inform all FHEMWEB clients # Inform all FHEMWEB clients
FB_CALLLIST_updateFhemWebClients($hash) if(grep(m/^(?:ATTR|DELETEATTR)$/, @{$d->{CHANGED}})); FB_CALLLIST_updateFhemWebClients($hash) if(grep(m/^(?:ATTR|DELETEATTR)/, @{$d->{CHANGED}}));
# save current list state to file/configDB # save current list state to file/configDB
FB_CALLLIST_saveList($hash); FB_CALLLIST_saveList($hash);
@ -741,7 +741,6 @@ sub FB_CALLLIST_list2html($;$)
$ret .= '<div class="fhemWidget" informId="'.$name.'" cmd="" arg="fbcalllist" dev="'.$name.'">'; # div tag to support inform updates $ret .= '<div class="fhemWidget" informId="'.$name.'" cmd="" arg="fbcalllist" dev="'.$name.'">'; # div tag to support inform updates
$ret .= '<table class="block fbcalllist">'; $ret .= '<table class="block fbcalllist">';
$ret .= FB_CALLLIST_returnOrderedHTMLOutput($hash, FB_CALLLIST_returnTableHeader($hash), 'class="fbcalllist header"','') if(AttrVal($name, "no-table-header", "0") eq "0"); $ret .= FB_CALLLIST_returnOrderedHTMLOutput($hash, FB_CALLLIST_returnTableHeader($hash), 'class="fbcalllist header"','') if(AttrVal($name, "no-table-header", "0") eq "0");
if(exists($hash->{helper}{DATA}) and (scalar keys %{$hash->{helper}{DATA}}) > 0) if(exists($hash->{helper}{DATA}) and (scalar keys %{$hash->{helper}{DATA}}) > 0)
@ -761,7 +760,9 @@ sub FB_CALLLIST_list2html($;$)
{ {
@list = grep { !$hash->{helper}{DATA}{$_}{running_call} } @list; @list = grep { !$hash->{helper}{DATA}{$_}{running_call} } @list;
} }
readingsBeginUpdate($hash) if($to_json and $create_readings eq "1");
foreach my $index (@list) foreach my $index (@list)
{ {
$count++; $count++;
@ -797,7 +798,22 @@ sub FB_CALLLIST_list2html($;$)
$ret .= FB_CALLLIST_returnOrderedHTMLOutput($hash, $line, 'number="'.$count.'" class="fbcalllist '.($count % 2 == 1 ? "odd" : "even").'"', 'class="fbcalllist" '.$td_style); $ret .= FB_CALLLIST_returnOrderedHTMLOutput($hash, $line, 'number="'.$count.'" class="fbcalllist '.($count % 2 == 1 ? "odd" : "even").'"', 'class="fbcalllist" '.$td_style);
} }
readingsSingleUpdate($hash, "numberOfCalls", $count, 1) if($to_json and $create_readings eq "1"); if($to_json and $create_readings eq "1")
{
readingsBulkUpdate($hash, "numberOfCalls", $count, 1);
my @delete_readings;
for my $reading (grep { /^(\d+)-/ and ($1 > $count) } keys %{$hash->{READINGS}})
{
readingsBulkUpdate($hash, $reading, "");
push @delete_readings, $reading;
}
readingsEndUpdate($hash, 1) if($to_json and $create_readings eq "1");
map { delete($hash->{READINGS}{$_}) } @delete_readings;
}
} }
else else
{ {
@ -1017,14 +1033,11 @@ sub FB_CALLLIST_updateReadings($$)
$line_tmp{state} = FB_CALLLIST_returnCallState($hash, $line->{index}, 0); $line_tmp{state} = FB_CALLLIST_returnCallState($hash, $line->{index}, 0);
readingsBeginUpdate($hash);
foreach my $col (@order) foreach my $col (@order)
{ {
readingsBulkUpdate($hash, $line_tmp{line}."-$col", $line_tmp{$col}); readingsBulkUpdate($hash, $line_tmp{line}."-$col", $line_tmp{$col});
} }
readingsEndUpdate($hash, 1);
} }
##################################### #####################################