From 3734a05a15b1565e763354af75321f9f33359d27 Mon Sep 17 00:00:00 2001 From: DS_Starter Date: Sat, 14 Oct 2017 18:41:41 +0000 Subject: [PATCH] 93_DbLog: V2.22.11, Attribute DbLogType expanded by SampleFill 93_DbRep: V5.7.1, commands tableCurrentPurge, tableCurrentFillup git-svn-id: https://svn.fhem.de/fhem/trunk@15257 2b470e98-0d58-463d-a4d8-8e2adae1ed80 --- fhem/CHANGED | 2 + fhem/FHEM/93_DbLog.pm | 108 +++++++++---- fhem/FHEM/93_DbRep.pm | 362 +++++++++++++++++++++++++++++++++++++----- 3 files changed, 397 insertions(+), 75 deletions(-) diff --git a/fhem/CHANGED b/fhem/CHANGED index c4599bfd3..030c73944 100644 --- a/fhem/CHANGED +++ b/fhem/CHANGED @@ -1,5 +1,7 @@ # 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: 93_DbLog: V2.22.11, Attribute DbLogType expanded by SampleFill + - feature: 93_DbRep: V5.7.1, commands tableCurrentPurge, tableCurrentFillup - feature: 98_DOIFtools: add getter modelColorGradient, returns a table of value, colornumber, RGB values and color bar using Color::pahColor - new: 98_Siro.pm: New module for Siro shutters diff --git a/fhem/FHEM/93_DbLog.pm b/fhem/FHEM/93_DbLog.pm index 2ab213525..387193208 100644 --- a/fhem/FHEM/93_DbLog.pm +++ b/fhem/FHEM/93_DbLog.pm @@ -16,6 +16,7 @@ ############################################################################################################################################ # Versions History done by DS_Starter & DeeSPe: # +# 2.22.11 13.10.2017 DbLogType expanded by SampleFill, DbLog_sampleDataFn adapted to sort case insensitive, commandref revised # 2.22.10 04.10.2017 Encode::encode_utf8 of $error, DbLog_PushAsyncAborted adapted to use abortArg (Forum:77472) # 2.22.9 04.10.2017 added hint to SVG/DbRep in commandref # 2.22.8 29.09.2017 avoid multiple entries in Dopdown-list when creating SVG by group Device:Reading in DbLog_sampleDataFn @@ -154,7 +155,7 @@ use Blocking; use Time::HiRes qw(gettimeofday tv_interval); use Encode qw(encode_utf8); -my $DbLogVersion = "2.22.10"; +my $DbLogVersion = "2.22.11"; my %columns = ("DEVICE" => 64, "TYPE" => 64, @@ -184,7 +185,7 @@ sub DbLog_Initialize($) "colReading ". "colValue ". "disable:1,0 ". - "DbLogType:Current,History,Current/History ". + "DbLogType:Current,History,Current/History,SampleFill/History ". "shutdownWait ". "suppressUndef:0,1 ". "verbose4Devs ". @@ -2895,7 +2896,7 @@ sub DbLog_configcheck($) { $rec .= "UNIT: $columns{UNIT}

"; $rec .= "You can change the column width in database by a statement like 'alter table history modify VALUE varchar(128);' (example for changing field 'VALUE'). "; $rec .= "You can do it for example by executing 'sqlCMD' in DbRep or in a SQL-Editor of your choice. (switch $name to asynchron mode for non-blocking).
"; - $rec .= "The field width used by the module can be done by setting attributes 'colEvent', 'colReading', 'colValue',"; + $rec .= "The field width used by the module can be adjusted by attributes 'colEvent', 'colReading', 'colValue',"; } $check .= "Result of table 'history' check

"; @@ -2956,7 +2957,7 @@ sub DbLog_configcheck($) { $rec .= "UNIT: $columns{UNIT}

"; $rec .= "You can change the column width in database by a statement like 'alter table current modify VALUE varchar(128);' (example for changing field 'VALUE'). "; $rec .= "You can do it for example by executing 'sqlCMD' in DbRep or in a SQL-Editor of your choice. (switch $name to asynchron mode for non-blocking).
"; - $rec .= "The field width used by the module can be done by setting attributes 'colEvent', 'colReading', 'colValue',"; + $rec .= "The field width used by the module can be adjusted by attributes 'colEvent', 'colReading', 'colValue',"; } $check .= "Result of table 'current' check

"; @@ -4267,9 +4268,7 @@ return $jsonstring; } ######################### -sub -DbLog_fhemwebFn($$$$) -{ +sub DbLog_fhemwebFn($$$$) { my ($FW_wname, $d, $room, $pageHash) = @_; # pageHash is set for summaryFn. my $ret; @@ -4282,20 +4281,16 @@ DbLog_fhemwebFn($$$$) "set $name copyGplotFile&detail=$name", "
Create SVG plot from DbLog
", 0, "dval", 1); - return $ret; - +return $ret; } -sub -DbLog_sampleDataFn($$$$$) -{ +sub DbLog_sampleDataFn($$$$$) { my ($dlName, $dlog, $max, $conf, $wName) = @_; my $desc = "Device:Reading"; my @htmlArr; my @example; my @colregs; my $counter; - # my $currentPresent = AttrVal($dlName,'DbLogType','Current'); my $currentPresent = AttrVal($dlName,'DbLogType','History'); my $dbhf = DbLog_ConnectNewDBH($defs{$dlName}); @@ -4306,7 +4301,7 @@ DbLog_sampleDataFn($$$$$) my $prescurr = eval {$dbhf->selectrow_array("select count(*) from current");} || 0; Log3($dlName, 5, "DbLog $dlName: Table current present : $prescurr (0 = not present or no content)"); - if($currentPresent =~ m/Current/ && $prescurr) { + if($currentPresent =~ m/Current|SampleFill/ && $prescurr) { # Table Current present, use it for sample data my $query = "select device,reading from current where device <> '' group by device,reading"; my $sth = $dbhf->prepare( $query ); @@ -4317,7 +4312,7 @@ DbLog_sampleDataFn($$$$$) push (@colregs, "$line[0]:$line[1]"); # push all eventTypes to selection list } $dbhf->disconnect(); - my $cols = join(",", sort @colregs); + my $cols = join(",", sort { "\L$a" cmp "\L$b" } @colregs); $max = 8 if($max > 8); for(my $r=0; $r < $max; $r++) { @@ -4349,7 +4344,7 @@ DbLog_sampleDataFn($$$$$) } - return ($desc, \@htmlArr, join("
", @example)); +return ($desc, \@htmlArr, join("
", @example)); } # @@ -4500,13 +4495,13 @@ sub checkUsePK ($$){
@@ -5057,7 +5052,29 @@ sub checkUsePK ($$){
This attribute determines which table or which tables in the database are wanted to use. If the attribute isn't set, - the table history will be used as default.
+ the adjustment history will be used as default.
+ + + The meaning of the adjustments in detail are:

+ + +
+
+ Note:
The current-table has to be used to get a Device:Reading-DropDown list when a SVG-Plot will be created.
@@ -5372,13 +5389,13 @@ sub checkUsePK ($$){
@@ -5983,11 +6000,32 @@ sub checkUsePK ($$){
@@ -6796,7 +7070,7 @@ sub bdump { Das Modul setzt den Einsatz einer oder mehrerer DbLog-Instanzen voraus. Es werden die Zugangsdaten dieser Datenbankdefinition genutzt.
- Es werden nur Inhalte der Tabelle "history" (Ausnahme Kommando "sqlCmd") berücksichtigt.

+ Es werden nur Inhalte der Tabelle "history" berücksichtigt wenn nichts anderes beschrieben ist.

Überblick welche anderen Perl-Module DbRep verwendet:

@@ -7149,12 +7423,20 @@ sub bdump { angegeben sein. Diese Funktion ist sinnvoll wenn fortlaufend Wertedifferenzen eines Readings in die Datenbank geschrieben werden.
+
  • tableCurrentFillup - Die current-Tabelle wird mit einem Extrakt der history-Tabelle aufgefüllt. + Die Attribute zur Zeiteinschränkung bzw. device, reading werden ausgewertet. + Dadurch kann der Inhalt des Extrakts beeinflusst werden. Im zugehörigen DbLog-Device sollte sollte das Attribut + "DbLogType=SampleFill/History" gesetzt sein.

  • + +
  • tableCurrentPurge - löscht den Inhalt der current-Tabelle. Es werden keine Limitierungen, z.B. durch die Attribute "timestamp_begin", + "timestamp_end", device, reading, usw. , ausgewertet.

  • +
  • vacuum - optimiert die Tabellen in der angeschlossenen Datenbank (SQLite, PostgreSQL).