From 89b6a0ba2bbd4c0c71ab8945b4aaf6414e0b21da Mon Sep 17 00:00:00 2001 From: nasseeder1 Date: Thu, 2 Aug 2018 19:26:57 +0000 Subject: [PATCH] 93_DbRep: fix in fetchrow function (forum:#89886),fix highlighting git-svn-id: https://svn.fhem.de/fhem/trunk@17080 2b470e98-0d58-463d-a4d8-8e2adae1ed80 --- fhem/CHANGED | 1 + fhem/FHEM/93_DbRep.pm | 55 ++++++++++++++++++++++++++----------------- 2 files changed, 35 insertions(+), 21 deletions(-) diff --git a/fhem/CHANGED b/fhem/CHANGED index a85b74afe..15376997c 100644 --- a/fhem/CHANGED +++ b/fhem/CHANGED @@ -1,5 +1,6 @@ # 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. + - bugfix: 93_DbRep: fix in fetchrow function (forum:#89886),fix highlighting - bugfix: 82_LGTV_WebOS: fix set cmd for AmazonLovefilm - feature: 51_MOBILEALERTS: added feature to adjust values in define - changed: 09_CUL_FHTTK: adapted battery reading to new common reading diff --git a/fhem/FHEM/93_DbRep.pm b/fhem/FHEM/93_DbRep.pm index af749558b..8dff5ef8c 100644 --- a/fhem/FHEM/93_DbRep.pm +++ b/fhem/FHEM/93_DbRep.pm @@ -37,6 +37,7 @@ ########################################################################################################################### # Versions History: # +# 7.18.2 02.08.2018 fix in fetchrow function (forum:#89886), fix highlighting # 7.18.1 03.06.2018 commandref revised # 7.18.0 02.06.2018 possible use of y:(\d) for timeDiffToNow, timeOlderThan , minor fixes of timeOlderThan # delEntries considers executeBeforeDump,executeAfterDump @@ -342,7 +343,7 @@ no if $] >= 5.017011, warnings => 'experimental::smartmatch'; sub DbRep_Main($$;$); sub DbLog_cutCol($$$$$$$); # DbLog-Funktion nutzen um Daten auf maximale Länge beschneiden -my $DbRepVersion = "7.18.1"; +my $DbRepVersion = "7.18.2"; my %dbrep_col = ("DEVICE" => 64, "TYPE" => 64, @@ -4548,9 +4549,9 @@ sub fetchrows_ParseDone($) { my $name = $hash->{NAME}; my $reading = AttrVal($name, "reading", undef); my $limit = AttrVal($name, "limit", 1000); - my $color = ""; # Highlighting doppelter DB-Einträge + my $color = ""; # Highlighting doppelter DB-Einträge $color =~ s/#// if($color =~ /red|blue|brown|green|orange/); - my $ecolor = ""; # Ende Highlighting + my $ecolor = ""; # Ende Highlighting my @i; my @row; my $reading_runtime_string; @@ -4569,22 +4570,11 @@ sub fetchrows_ParseDone($) { # Readingaufbereitung readingsBeginUpdate($hash); - my $orow; + my ($orow,$nrow,$oval,$nval); my $dz = 1; # Index des Vorkommens im Selektionsarray + my $zs = ""; # Zusatz wenn device + Reading + Timestamp von folgenden DS gleich ist UND Value unterschiedlich + my $zsz = 1; # Zusatzzähler foreach my $row (@row_array) { - if($orow) { - if($orow eq $row) { - $dz++; - - } else { - $dz = 1; - } - } - $orow = $row; - if($dz > 1) { - # Hervorhebung von multiplen Datensätzen - # $dz = "".$dz.""; - } my @a = split("_ESC_", $row, 6); my $dev = $a[0]; my $rea = $a[1]; @@ -4593,18 +4583,41 @@ sub fetchrows_ParseDone($) { my $val = $a[4]; my $unt = $a[5]; $val = $unt?$val." ".$unt:$val; + + $nrow = $ts.$dev.$rea; + $nval = $val; + if($orow) { + if($orow.$oval eq $nrow.$val) { + $dz++; + $zs = ""; + $zsz = 1; + } else { + # wenn device + Reading + Timestamp gleich ist UND Value unterschiedlich -> dann Zusatz an Reading hängen + if(($orow eq $nrow) && ($oval ne $val)) { + $zs = "_".$zsz; + $zsz++; + } else { + $zs = ""; + $zsz = 1; + } + $dz = 1; + + } + } + $orow = $nrow; + $oval = $val; if ($reading && AttrVal($hash->{NAME}, "readingNameMap", "")) { if($dz > 1 && AttrVal($name, "fetchMarkDuplicates", undef)) { - $reading_runtime_string = $ts."__".$color.$dz."__".AttrVal($hash->{NAME}, "readingNameMap", "").$ecolor; + $reading_runtime_string = $ts."__".$color.$dz."__".AttrVal($hash->{NAME}, "readingNameMap", "").$zs.$ecolor; } else { - $reading_runtime_string = $ts."__".$dz."__".AttrVal($hash->{NAME}, "readingNameMap", ""); + $reading_runtime_string = $ts."__".$dz."__".AttrVal($hash->{NAME}, "readingNameMap", "").$zs; } } else { if($dz > 1 && AttrVal($name, "fetchMarkDuplicates", undef)) { - $reading_runtime_string = $ts."__".$color.$dz."__".$dev."__".$rea.$ecolor; + $reading_runtime_string = $ts."__".$color.$dz."__".$dev."__".$rea.$zs.$ecolor; } else { - $reading_runtime_string = $ts."__".$dz."__".$dev."__".$rea; + $reading_runtime_string = $ts."__".$dz."__".$dev."__".$rea.$zs; } }