From 5e35b220a5b7329a66c52d014eb4e8b9dde28811 Mon Sep 17 00:00:00 2001 From: nasseeder1 Date: Sat, 28 Jan 2023 19:18:44 +0000 Subject: [PATCH] 93_DbLog: contrib 5.8.0 git-svn-id: https://svn.fhem.de/fhem/trunk@27140 2b470e98-0d58-463d-a4d8-8e2adae1ed80 --- fhem/contrib/DS_Starter/93_DbLog.pm | 596 +++++++++++++++++++--------- 1 file changed, 398 insertions(+), 198 deletions(-) diff --git a/fhem/contrib/DS_Starter/93_DbLog.pm b/fhem/contrib/DS_Starter/93_DbLog.pm index 2568f3439..39bf17671 100644 --- a/fhem/contrib/DS_Starter/93_DbLog.pm +++ b/fhem/contrib/DS_Starter/93_DbLog.pm @@ -132,6 +132,7 @@ my %DbLog_hget = ( ReadingsAvgVal => { fn => \&_DbLog_dbReadings }, webchart => { fn => \&_DbLog_chartQuery }, plotdata => { fn => \&_DbLog_plotData }, + dataRetrieval => { fn => \&_DbLog_chartQuery }, ); my %DbLog_columns = ("DEVICE" => 64, @@ -4888,7 +4889,7 @@ return ($err, @res); } ################################################################# -# einfaches Query prepare, Rückgabe Statement Handle +# einfaches Query prepare, Rückgabe Statement Handle ################################################################# sub __DbLog_SBP_prepareOnly { my $name = shift; @@ -4898,7 +4899,7 @@ sub __DbLog_SBP_prepareOnly { my $err = q{}; my $sth; - + eval{ $sth = $dbh->prepare ($query); 1; } @@ -4916,7 +4917,7 @@ return ($err, $sth); } ################################################################# -# einfaches Query execute +# einfaches Query execute ################################################################# sub __DbLog_SBP_executeOnly { my $name = shift; @@ -4925,7 +4926,7 @@ sub __DbLog_SBP_executeOnly { my $err = q{}; my $result; - + eval{ $result = $sth->execute(); 1; } @@ -5026,7 +5027,7 @@ sub _DbLog_SBP_Log3Parent { my $verbose = AttrVal ($name, 'verbose', $attr{global}{verbose}); return if($level > $verbose); - + my $msg = $paref->{msg}; my $subprocess = $paref->{subprocess}; @@ -5806,14 +5807,14 @@ return $sth; ################################################################ sub DbLog_Get { my ($hash, @a) = @_; - + return qq{"get X" needs at least an argument} if(@a < 2); - + my $name = $hash->{NAME}; @a = (map { my $p = $_; $p =~ s/\s//xg; $p; } @a); - + shift @a; # Device Name wird entfernt - + my $opt = $a[0]; # Kommando spezifizieren / ableiten $opt = 'plotdata' if(lc($a[0]) =~ /^(-|current|history)$/ixs); $opt = 'webchart' if($a[1] && lc($a[1]) eq 'webchart'); @@ -5826,9 +5827,9 @@ sub DbLog_Get { }; if($DbLog_hget{$opt} && defined &{$DbLog_hget{$opt}{fn}}) { - return &{$DbLog_hget{$opt}{fn}} ($params); - } - + return &{$DbLog_hget{$opt}{fn}} ($params); + } + my $getlist = "Unknown argument $opt, choose one of ". "ReadingsVal: ". "ReadingsTimestamp ". @@ -5837,9 +5838,10 @@ sub DbLog_Get { "ReadingsMaxValTimestamp ". "ReadingsMinVal ". "ReadingsMinValTimestamp ". - "ReadingsAvgVal " + "ReadingsAvgVal ". + "dataRetrieval: " ; - + return $getlist; } @@ -5853,7 +5855,7 @@ return $getlist; ######################################################################################## sub _DbLog_dbReadings { my $paref = shift; - + my $hash = $paref->{hash}; my @args = @{$paref->{aref}}; my $history = $hash->{HELPER}{TH}; @@ -5911,21 +5913,24 @@ return; ################################################################ sub _DbLog_chartQuery { my $paref = shift; - + my $hash = $paref->{hash}; my $name = $paref->{name}; my @a = @{$paref->{aref}}; - - return "Usage: \n". - "get $name <in> <out> <from> <to> <column_spec>...\n". - "where column_spec is <device>:<reading>:<default>:<fn>\n". - "(see the #DbLog entries in the .gplot files)\n". - "\n". - "Notes:\n". - "<in> is not used, only for compatibility for FileLog, please use '-' for <in> \n". - "<out> is a prefix, '-' means stdout\n" - if(int(@a) < 4); - + my $opt = $paref->{opt}; + + if ($opt eq 'webchart') { + return "Usage: \n". + "get $name <in> <out> <from> <to> <column_spec>...\n". + "where column_spec is <device>:<reading>:<default>:<fn>\n". + "(see the #DbLog entries in the .gplot files)\n". + "\n". + "Notes:\n". + "<in> is not used, only for compatibility for FileLog, please use '-' for <in> \n". + "<out> is a prefix, '-' means stdout\n" + if(int(@a) < 4); + } + my ($sql, $countsql) = _DbLog_createQuerySql ($paref); if ($sql eq "error") { @@ -5955,14 +5960,14 @@ sub _DbLog_chartQuery { ($err, my $query_handle) = __DbLog_SBP_prepareOnly ($name, $dbh, $sql); return DbLog_jsonError("Could not prepare statement: " .$err. ", SQL was: " .$sql) if($err); - + ($err, $query_handle) = __DbLog_SBP_executeOnly ($name, $query_handle); return DbLog_jsonError("Could not execute statement: " . $err) if($err); - + my $columns = $query_handle->{'NAME'}; my $columncnt; - if($columns) { # When columns are empty but execution was successful, we have done a successful INSERT, UPDATE or DELETE + if($columns) { # When columns are empty but execution was successful, we have done a successful INSERT, UPDATE or DELETE $columncnt = scalar @$columns; } else { @@ -5970,7 +5975,9 @@ sub _DbLog_chartQuery { } my $i = 0; - my $jsonstring = '{"data":['; + my $jsonstring = q({); + $jsonstring .= q("success": "true", ) if($opt eq 'dataRetrieval'); + $jsonstring .= q("data":[); while ( my @data = $query_handle->fetchrow_array()) { if($i == 0) { @@ -5981,12 +5988,12 @@ sub _DbLog_chartQuery { } for ($i = 0; $i < $columncnt; $i++) { - $jsonstring .= '"'; + $jsonstring .= q("); $jsonstring .= uc($query_handle->{NAME}->[$i]); - $jsonstring .= '":'; + $jsonstring .= q(":); if (defined $data[$i]) { - my $fragment = substr($data[$i],0,1); + my $fragment = substr $data[$i], 0, 1; if ($fragment eq "{") { $jsonstring .= $data[$i]; @@ -6000,20 +6007,20 @@ sub _DbLog_chartQuery { } if($i != ($columncnt -1)) { - $jsonstring .= ','; + $jsonstring .= q(,); } } - $jsonstring .= '}'; + $jsonstring .= q(}); } - $jsonstring .= ']'; + $jsonstring .= q(]); if (defined $totalcount && $totalcount ne "") { $jsonstring .= ',"totalCount": '.$totalcount.'}'; } else { - $jsonstring .= '}'; + $jsonstring .= q(}); } return $jsonstring; @@ -6024,27 +6031,44 @@ return $jsonstring; ################################################################ sub _DbLog_createQuerySql { my $paref = shift; - + + my $opt = $paref->{opt}; my $hash = $paref->{hash}; my @a = @{$paref->{aref}}; - my $starttime = $a[2]; - $starttime =~ s/_/ /; - my $endtime = $a[3]; - $endtime =~ s/_/ /; - my $device = $a[4]; - my $userquery = $a[5]; + my $starttime = $a[2]; # + my $endtime = $a[3]; # + my $device = $a[4]; # + my $querytype = $a[5]; # my $xaxis = $a[6]; # ein Datenbankfeld wie TIMESTAMP, READING, DEVICE, UNIT, EVENT - my $yaxis = $a[7]; # ein Reading Name - my $savename = $a[8]; - my $jsonChartConfig = $a[9]; - my $pagingstart = $a[10]; - my $paginglimit = $a[11]; - + my $reading = $a[7]; # ein Reading Name () + my $savename = $a[8]; # + my $jsonChartConfig = $a[9]; # + my $offset = $a[10]; # + my $limit = $a[11]; # + my $dbmodel = $hash->{MODEL}; my $history = $hash->{HELPER}{TH}; my $current = $hash->{HELPER}{TC}; + if ($opt eq 'dataRetrieval') { + $querytype = $a[1]; + $device = $a[2]; + $reading = $a[3]; + $starttime = $a[4]; + $endtime = $a[5]; + $offset = $a[6]; + $limit = $a[7]; + $xaxis = 'TIMESTAMP'; + + if ($querytype eq 'last') { + $limit = '10' if(!$limit); + } + } + + $starttime =~ s/_/ /; + $endtime =~ s/_/ /; + my ($sql, $jsonstring, $countsql, $hourstats, $daystats, $weekstats, $monthstats, $yearstats); if ($dbmodel eq "POSTGRESQL") { @@ -6052,31 +6076,31 @@ sub _DbLog_createQuerySql { ### hour: $hourstats = "SELECT to_char(timestamp, 'YYYY-MM-DD HH24:00:00') AS TIMESTAMP, SUM(VALUE::float) AS SUM, "; $hourstats .= "AVG(VALUE::float) AS AVG, MIN(VALUE::float) AS MIN, MAX(VALUE::float) AS MAX, "; - $hourstats .= "COUNT(VALUE) AS COUNT FROM $history WHERE READING = '$yaxis' AND DEVICE = '$device' "; + $hourstats .= "COUNT(VALUE) AS COUNT FROM $history WHERE READING = '$reading' AND DEVICE = '$device' "; $hourstats .= "AND TIMESTAMP Between '$starttime' AND '$endtime' GROUP BY 1 ORDER BY 1;"; ### day: $daystats = "SELECT to_char(timestamp, 'YYYY-MM-DD 00:00:00') AS TIMESTAMP, SUM(VALUE::float) AS SUM, "; $daystats .= "AVG(VALUE::float) AS AVG, MIN(VALUE::float) AS MIN, MAX(VALUE::float) AS MAX, "; - $daystats .= "COUNT(VALUE) AS COUNT FROM $history WHERE READING = '$yaxis' AND DEVICE = '$device' "; + $daystats .= "COUNT(VALUE) AS COUNT FROM $history WHERE READING = '$reading' AND DEVICE = '$device' "; $daystats .= "AND TIMESTAMP Between '$starttime' AND '$endtime' GROUP BY 1 ORDER BY 1;"; ### week: $weekstats = "SELECT date_trunc('week',timestamp) AS TIMESTAMP, SUM(VALUE::float) AS SUM, "; $weekstats .= "AVG(VALUE::float) AS AVG, MIN(VALUE::float) AS MIN, MAX(VALUE::float) AS MAX, "; - $weekstats .= "COUNT(VALUE) AS COUNT FROM $history WHERE READING = '$yaxis' AND DEVICE = '$device' "; + $weekstats .= "COUNT(VALUE) AS COUNT FROM $history WHERE READING = '$reading' AND DEVICE = '$device' "; $weekstats .= "AND TIMESTAMP Between '$starttime' AND '$endtime' GROUP BY 1 ORDER BY 1;"; ### month: $monthstats = "SELECT to_char(timestamp, 'YYYY-MM-01 00:00:00') AS TIMESTAMP, SUM(VALUE::float) AS SUM, "; $monthstats .= "AVG(VALUE::float) AS AVG, MIN(VALUE::float) AS MIN, MAX(VALUE::float) AS MAX, "; - $monthstats .= "COUNT(VALUE) AS COUNT FROM $history WHERE READING = '$yaxis' AND DEVICE = '$device' "; + $monthstats .= "COUNT(VALUE) AS COUNT FROM $history WHERE READING = '$reading' AND DEVICE = '$device' "; $monthstats .= "AND TIMESTAMP Between '$starttime' AND '$endtime' GROUP BY 1 ORDER BY 1;"; ### year: $yearstats = "SELECT to_char(timestamp, 'YYYY-01-01 00:00:00') AS TIMESTAMP, SUM(VALUE::float) AS SUM, "; $yearstats .= "AVG(VALUE::float) AS AVG, MIN(VALUE::float) AS MIN, MAX(VALUE::float) AS MAX, "; - $yearstats .= "COUNT(VALUE) AS COUNT FROM $history WHERE READING = '$yaxis' AND DEVICE = '$device' "; + $yearstats .= "COUNT(VALUE) AS COUNT FROM $history WHERE READING = '$reading' AND DEVICE = '$device' "; $yearstats .= "AND TIMESTAMP Between '$starttime' AND '$endtime' GROUP BY 1 ORDER BY 1;"; } elsif ($dbmodel eq "MYSQL") { @@ -6084,32 +6108,32 @@ sub _DbLog_createQuerySql { ### hour: $hourstats = "SELECT date_format(timestamp, '%Y-%m-%d %H:00:00') AS TIMESTAMP, SUM(CAST(VALUE AS DECIMAL(12,4))) AS SUM, "; $hourstats .= "AVG(CAST(VALUE AS DECIMAL(12,4))) AS AVG, MIN(CAST(VALUE AS DECIMAL(12,4))) AS MIN, "; - $hourstats .= "MAX(CAST(VALUE AS DECIMAL(12,4))) AS MAX, COUNT(VALUE) AS COUNT FROM $history WHERE READING = '$yaxis' "; + $hourstats .= "MAX(CAST(VALUE AS DECIMAL(12,4))) AS MAX, COUNT(VALUE) AS COUNT FROM $history WHERE READING = '$reading' "; $hourstats .= "AND DEVICE = '$device' AND TIMESTAMP Between '$starttime' AND '$endtime' GROUP BY 1 ORDER BY 1;"; ### day: $daystats = "SELECT date_format(timestamp, '%Y-%m-%d 00:00:00') AS TIMESTAMP, SUM(CAST(VALUE AS DECIMAL(12,4))) AS SUM, "; $daystats .= "AVG(CAST(VALUE AS DECIMAL(12,4))) AS AVG, MIN(CAST(VALUE AS DECIMAL(12,4))) AS MIN, "; - $daystats .= "MAX(CAST(VALUE AS DECIMAL(12,4))) AS MAX, COUNT(VALUE) AS COUNT FROM $history WHERE READING = '$yaxis' "; + $daystats .= "MAX(CAST(VALUE AS DECIMAL(12,4))) AS MAX, COUNT(VALUE) AS COUNT FROM $history WHERE READING = '$reading' "; $daystats .= "AND DEVICE = '$device' AND TIMESTAMP Between '$starttime' AND '$endtime' GROUP BY 1 ORDER BY 1;"; ### week: $weekstats = "SELECT date_format(timestamp, '%Y-%m-%d 00:00:00') AS TIMESTAMP, SUM(CAST(VALUE AS DECIMAL(12,4))) AS SUM, "; $weekstats .= "AVG(CAST(VALUE AS DECIMAL(12,4))) AS AVG, MIN(CAST(VALUE AS DECIMAL(12,4))) AS MIN, "; - $weekstats .= "MAX(CAST(VALUE AS DECIMAL(12,4))) AS MAX, COUNT(VALUE) AS COUNT FROM $history WHERE READING = '$yaxis' "; + $weekstats .= "MAX(CAST(VALUE AS DECIMAL(12,4))) AS MAX, COUNT(VALUE) AS COUNT FROM $history WHERE READING = '$reading' "; $weekstats .= "AND DEVICE = '$device' AND TIMESTAMP Between '$starttime' AND '$endtime' "; $weekstats .= "GROUP BY date_format(timestamp, '%Y-%u 00:00:00') ORDER BY 1;"; ### month: $monthstats = "SELECT date_format(timestamp, '%Y-%m-01 00:00:00') AS TIMESTAMP, SUM(CAST(VALUE AS DECIMAL(12,4))) AS SUM, "; $monthstats .= "AVG(CAST(VALUE AS DECIMAL(12,4))) AS AVG, MIN(CAST(VALUE AS DECIMAL(12,4))) AS MIN, "; - $monthstats .= "MAX(CAST(VALUE AS DECIMAL(12,4))) AS MAX, COUNT(VALUE) AS COUNT FROM $history WHERE READING = '$yaxis' "; + $monthstats .= "MAX(CAST(VALUE AS DECIMAL(12,4))) AS MAX, COUNT(VALUE) AS COUNT FROM $history WHERE READING = '$reading' "; $monthstats .= "AND DEVICE = '$device' AND TIMESTAMP Between '$starttime' AND '$endtime' GROUP BY 1 ORDER BY 1;"; ### year: $yearstats = "SELECT date_format(timestamp, '%Y-01-01 00:00:00') AS TIMESTAMP, SUM(CAST(VALUE AS DECIMAL(12,4))) AS SUM, "; $yearstats .= "AVG(CAST(VALUE AS DECIMAL(12,4))) AS AVG, MIN(CAST(VALUE AS DECIMAL(12,4))) AS MIN, "; - $yearstats .= "MAX(CAST(VALUE AS DECIMAL(12,4))) AS MAX, COUNT(VALUE) AS COUNT FROM $history WHERE READING = '$yaxis' "; + $yearstats .= "MAX(CAST(VALUE AS DECIMAL(12,4))) AS MAX, COUNT(VALUE) AS COUNT FROM $history WHERE READING = '$reading' "; $yearstats .= "AND DEVICE = '$device' AND TIMESTAMP Between '$starttime' AND '$endtime' GROUP BY 1 ORDER BY 1;"; } elsif ($dbmodel eq "SQLITE") { @@ -6117,31 +6141,31 @@ sub _DbLog_createQuerySql { ### hour: $hourstats = "SELECT TIMESTAMP, SUM(CAST(VALUE AS FLOAT)) AS SUM, AVG(CAST(VALUE AS FLOAT)) AS AVG, "; $hourstats .= "MIN(CAST(VALUE AS FLOAT)) AS MIN, MAX(CAST(VALUE AS FLOAT)) AS MAX, COUNT(VALUE) AS COUNT "; - $hourstats .= "FROM $history WHERE READING = '$yaxis' AND DEVICE = '$device' "; + $hourstats .= "FROM $history WHERE READING = '$reading' AND DEVICE = '$device' "; $hourstats .= "AND TIMESTAMP Between '$starttime' AND '$endtime' GROUP BY strftime('%Y-%m-%d %H:00:00', TIMESTAMP);"; ### day: $daystats = "SELECT TIMESTAMP, SUM(CAST(VALUE AS FLOAT)) AS SUM, AVG(CAST(VALUE AS FLOAT)) AS AVG, "; $daystats .= "MIN(CAST(VALUE AS FLOAT)) AS MIN, MAX(CAST(VALUE AS FLOAT)) AS MAX, COUNT(VALUE) AS COUNT "; - $daystats .= "FROM $history WHERE READING = '$yaxis' AND DEVICE = '$device' "; + $daystats .= "FROM $history WHERE READING = '$reading' AND DEVICE = '$device' "; $daystats .= "AND TIMESTAMP Between '$starttime' AND '$endtime' GROUP BY strftime('%Y-%m-%d 00:00:00', TIMESTAMP);"; ### week: $weekstats = "SELECT TIMESTAMP, SUM(CAST(VALUE AS FLOAT)) AS SUM, AVG(CAST(VALUE AS FLOAT)) AS AVG, "; $weekstats .= "MIN(CAST(VALUE AS FLOAT)) AS MIN, MAX(CAST(VALUE AS FLOAT)) AS MAX, COUNT(VALUE) AS COUNT "; - $weekstats .= "FROM $history WHERE READING = '$yaxis' AND DEVICE = '$device' "; + $weekstats .= "FROM $history WHERE READING = '$reading' AND DEVICE = '$device' "; $weekstats .= "AND TIMESTAMP Between '$starttime' AND '$endtime' GROUP BY strftime('%Y-%W 00:00:00', TIMESTAMP);"; ### month: $monthstats = "SELECT TIMESTAMP, SUM(CAST(VALUE AS FLOAT)) AS SUM, AVG(CAST(VALUE AS FLOAT)) AS AVG, "; $monthstats .= "MIN(CAST(VALUE AS FLOAT)) AS MIN, MAX(CAST(VALUE AS FLOAT)) AS MAX, COUNT(VALUE) AS COUNT "; - $monthstats .= "FROM $history WHERE READING = '$yaxis' AND DEVICE = '$device' "; + $monthstats .= "FROM $history WHERE READING = '$reading' AND DEVICE = '$device' "; $monthstats .= "AND TIMESTAMP Between '$starttime' AND '$endtime' GROUP BY strftime('%Y-%m 00:00:00', TIMESTAMP);"; ### year: $yearstats = "SELECT TIMESTAMP, SUM(CAST(VALUE AS FLOAT)) AS SUM, AVG(CAST(VALUE AS FLOAT)) AS AVG, "; $yearstats .= "MIN(CAST(VALUE AS FLOAT)) AS MIN, MAX(CAST(VALUE AS FLOAT)) AS MAX, COUNT(VALUE) AS COUNT "; - $yearstats .= "FROM $history WHERE READING = '$yaxis' AND DEVICE = '$device' "; + $yearstats .= "FROM $history WHERE READING = '$reading' AND DEVICE = '$device' "; $yearstats .= "AND TIMESTAMP Between '$starttime' AND '$endtime' GROUP BY strftime('%Y 00:00:00', TIMESTAMP);"; } @@ -6149,66 +6173,77 @@ sub _DbLog_createQuerySql { $sql = "errordb"; } - if($userquery eq "getreadings") { - $sql = "SELECT distinct(reading) FROM $history WHERE device = '".$device."'"; + if($querytype eq 'getreadings') { + $sql = "SELECT distinct(reading) FROM $history WHERE device = '$device'"; } - elsif ($userquery eq "getdevices") { + elsif ($querytype eq 'getdevices') { $sql = "SELECT distinct(device) FROM $history"; } - elsif ($userquery eq "timerange") { - $sql = "SELECT ".$xaxis.", VALUE FROM $history WHERE READING = '$yaxis' AND DEVICE = '$device' AND TIMESTAMP Between '$starttime' AND '$endtime' ORDER BY TIMESTAMP;"; + elsif ($querytype eq 'last') { + $sql = "SELECT TIMESTAMP, DEVICE, TYPE, EVENT, READING, VALUE, UNIT from $history ORDER BY TIMESTAMP DESC LIMIT $limit"; } - elsif ($userquery eq "hourstats") { + elsif ($querytype eq 'timerange') { + $sql = "SELECT ".$xaxis.", VALUE FROM $history WHERE READING = '$reading' AND DEVICE = '$device' AND TIMESTAMP Between '$starttime' AND '$endtime' ORDER BY TIMESTAMP;"; + } + elsif ($querytype eq 'hourstats') { $sql = $hourstats; } - elsif ($userquery eq "daystats") { + elsif ($querytype eq 'daystats') { $sql = $daystats; } - elsif ($userquery eq "weekstats") { + elsif ($querytype eq 'weekstats') { $sql = $weekstats; } - elsif ($userquery eq "monthstats") { + elsif ($querytype eq 'monthstats') { $sql = $monthstats; } - elsif ($userquery eq "yearstats") { + elsif ($querytype eq 'yearstats') { $sql = $yearstats; } - elsif ($userquery eq "savechart") { + elsif ($querytype eq 'savechart') { $sql = "INSERT INTO frontend (TYPE, NAME, VALUE) VALUES ('savedchart', '$savename', '$jsonChartConfig')"; } - elsif ($userquery eq "renamechart") { + elsif ($querytype eq 'renamechart') { $sql = "UPDATE frontend SET NAME = '$savename' WHERE ID = '$jsonChartConfig'"; } - elsif ($userquery eq "deletechart") { + elsif ($querytype eq 'deletechart') { $sql = "DELETE FROM frontend WHERE TYPE = 'savedchart' AND ID = '".$savename."'"; } - elsif ($userquery eq "updatechart") { + elsif ($querytype eq 'updatechart') { $sql = "UPDATE frontend SET VALUE = '$jsonChartConfig' WHERE ID = '".$savename."'"; } - elsif ($userquery eq "getcharts") { + elsif ($querytype eq 'getcharts') { $sql = "SELECT * FROM frontend WHERE TYPE = 'savedchart'"; } - elsif ($userquery eq "getTableData") { - if ($device ne '""' && $yaxis ne '""') { - $sql = "SELECT * FROM $history WHERE READING = '$yaxis' AND DEVICE = '$device' "; + elsif ($querytype eq 'getTableData') { + if ($device ne '""' && $reading ne '""') { + $sql = "SELECT * FROM $history WHERE READING = '$reading' AND DEVICE = '$device' "; $sql .= "AND TIMESTAMP Between '$starttime' AND '$endtime'"; - $sql .= " LIMIT '$paginglimit' OFFSET '$pagingstart'"; + $sql .= " LIMIT '$limit' OFFSET '$offset'"; - $countsql = "SELECT count(*) FROM $history WHERE READING = '$yaxis' AND DEVICE = '$device' "; + $countsql = "SELECT count(*) FROM $history WHERE READING = '$reading' AND DEVICE = '$device' "; $countsql .= "AND TIMESTAMP Between '$starttime' AND '$endtime'"; } - elsif ($device ne '""' && $yaxis eq '""') { + elsif ($device ne '""' && $reading eq '""') { $sql = "SELECT * FROM $history WHERE DEVICE = '$device' "; $sql .= "AND TIMESTAMP Between '$starttime' AND '$endtime'"; - $sql .= " LIMIT '$paginglimit' OFFSET '$pagingstart'"; + $sql .= " LIMIT '$limit' OFFSET '$offset'"; $countsql = "SELECT count(*) FROM $history WHERE DEVICE = '$device' "; $countsql .= "AND TIMESTAMP Between '$starttime' AND '$endtime'"; } + elsif ($device eq '""' && $reading ne '""') { + $sql = "SELECT * FROM $history WHERE READING = '$reading' "; + $sql .= "AND TIMESTAMP Between '$starttime' AND '$endtime'"; + $sql .= " LIMIT '$limit' OFFSET '$offset'"; + + $countsql = "SELECT count(*) FROM $history WHERE READING = '$reading' "; + $countsql .= "AND TIMESTAMP Between '$starttime' AND '$endtime'"; + } else { $sql = "SELECT * FROM $history"; $sql .= " WHERE TIMESTAMP Between '$starttime' AND '$endtime'"; - $sql .= " LIMIT '$paginglimit' OFFSET '$pagingstart'"; + $sql .= " LIMIT '$limit' OFFSET '$offset'"; $countsql = "SELECT count(*) FROM $history"; $countsql .= " WHERE TIMESTAMP Between '$starttime' AND '$endtime'"; @@ -6228,11 +6263,11 @@ return $sql; ################################################################ sub _DbLog_plotData { my $paref = shift; - + my $hash = $paref->{hash}; my $name = $paref->{name}; my @a = @{$paref->{aref}}; - + return "Usage: \n". "get $name <in> <out> <from> <to> <column_spec>...\n". "where column_spec is <device>:<reading>:<default>:<fn>\n". @@ -6242,10 +6277,10 @@ sub _DbLog_plotData { "<in> is not used, only for compatibility for FileLog, please use '-' for <in> \n". "<out> is a prefix, '-' means stdout\n" if(int(@a) < 4); - + my ($dbh,$err); my ($internal, @fld); - + my $utf8 = defined($hash->{UTF8}) ? $hash->{UTF8} : 0; my $history = $hash->{HELPER}{TH}; my $current = $hash->{HELPER}{TC}; @@ -6274,7 +6309,7 @@ sub _DbLog_plotData { } my (%sqlspec, %from_datetime, %to_datetime); - + my @readings = (); my $verbose = AttrVal ($name, 'verbose', $attr{global}{verbose}); @@ -6415,7 +6450,7 @@ sub _DbLog_plotData { if($readings[$i]->[3] && ($readings[$i]->[3] eq "delta-h" || $readings[$i]->[3] eq "delta-d")) { $deltacalc = 1; - + if ($verbose > 3) { Log3 ($name, 4, "DbLog $name - deltacalc: hour") if($readings[$i]->[3] eq "delta-h"); # geändert V4.8.0 / 14.10.2019 Log3 ($name, 4, "DbLog $name - deltacalc: day") if($readings[$i]->[3] eq "delta-d"); # geändert V4.8.0 / 14.10.2019 @@ -6549,11 +6584,11 @@ sub _DbLog_plotData { #evaluate my $val = $sql_value; my $ts = $sql_timestamp; - + eval("$readings[$i]->[4]"); $sql_value = $val; $sql_timestamp = $ts; - + if($@) { Log3 ($name, 3, "DbLog: Error in inline function: <".$readings[$i]->[4].">, Error: $@"); } @@ -8745,21 +8780,21 @@ return; <devspec>:<Reading> The device can be specified as device specification. The specification of "Reading" is evaluated as a regular expression. - If the reading does not exist and the value "Value" is specified, the reading - will be inserted into the DB if it is not a regular expression and a valid reading name. - - - Value Optionally, "Value" can be specified for the reading value. - If Value is not specified, the current value of the reading is inserted into the DB. - - - CN=<caller name> With the key "CN=" (Caller Name) a string, e.g. the name of the calling device, - can be added to the addLog call. - With the help of the function stored in the attribute valueFn - this key can be evaluated via the variable $CN. - - !useExcludes addLog by default takes into account the readings excluded with the "DbLogExclude" attribute. - With the keyword "!useExcludes" the set attribute "DbLogExclude" is ignored. + If the reading does not exist and the value "Value" is specified, the reading + will be inserted into the DB if it is not a regular expression and a valid reading name. + + + Value Optionally, "Value" can be specified for the reading value. + If Value is not specified, the current value of the reading is inserted into the DB. + + + CN=<caller name> With the key "CN=" (Caller Name) a string, e.g. the name of the calling device, + can be added to the addLog call. + With the help of the function stored in the attribute valueFn + this key can be evaluated via the variable $CN. + + !useExcludes addLog by default takes into account the readings excluded with the "DbLogExclude" attribute. + With the keyword "!useExcludes" the set attribute "DbLogExclude" is ignored.
@@ -9010,7 +9045,8 @@ return;
    -
  • get <name> ReadingsMaxVal[Timestamp] <Device> <Reading> <default>

    +
  • get <name> ReadingsMaxVal[Timestamp] <Device> <Reading> <default> +
      Determines the record with the largest value of the specified Device / Reading combination from the history table.
      Only the value or the combination of value and timestamp is returned as string @@ -9030,7 +9066,8 @@ return;
        -
      • get <name> ReadingsMinVal[Timestamp] <Device> <Reading> <default>

        +
      • get <name> ReadingsMinVal[Timestamp] <Device> <Reading> <default> +
          Determines the record with the smallest value of the specified device / reading combination from the history table.
          Only the value or the combination of value and timestamp is returned as string @@ -9049,7 +9086,8 @@ return;
            -
          • get <name> ReadingsAvgVal <Device> <Reading> <default>

            +
          • get <name> ReadingsAvgVal <Device> <Reading> <default> +
              Determines the average value of the specified Device / Reading combination from the history table.
              The simple arithmetic average value is returned.
              @@ -9067,7 +9105,8 @@ return;
                -
              • get <name> ReadingsVal[Timestamp] <Device> <Reading> <default>

                +
              • get <name> ReadingsVal[Timestamp] <Device> <Reading> <default> +
                  Reads the last (newest) record stored in the history table of the specified Device / Reading combination.
                  @@ -9087,7 +9126,8 @@ return;
                    -
                  • get <name> ReadingsTimestamp <Device> <Reading> <default>

                    +
                  • get <name> ReadingsTimestamp <Device> <Reading> <default> +
                      Reads the timestamp of the last (newest) record stored in the history table of the specified Device/Reading combination and returns this value.
                      @@ -9102,8 +9142,82 @@ return;

                  • + +
                      + +
                    • get <name> dataRetrieval <querytype> <device> <reading> <from> <to> <offset> <limit> +
                      + +
                        + Reads data from the database table history and returns the results formatted as JSON.
                        + The query method or the desired query result is determined by the specified <querytype>.
                        + Each <querytype> may require additional parameters according to the following table. Parameters not entered + must always be entered as "" if another parameter is entered afterwards. +
                        +
                        + +
                          + + + + + + + + + + + + + + + + + + + + + + +
                          getdevices Determines all devices stored in the database.
                          getreadings Determines all readings stored in the database for a specific device.
                          required parameters: <device>
                          timerange Determines the stored data sets of the specified Device / Reading combination.
                          required parameters: <device>, <reading>, <from>, <to>
                          getTableData Determines the stored records of a certain period.
                          The number of selected records is returned as the key "totalcount".
                          required parameters: <from>, <to>, <offset>, <limit>
                          last Lists the last 10 saved events.
                          possible parameters: <limit> (overwrites the default 10)
                          hourstats Calculates the statistics SUM, AVG, MIN, MAX, COUNT for one hour.
                          required parameters: <device>, <reading>, <from>, <to>
                          daystats Calculates the statistics SUM, AVG, MIN, MAX, COUNT for one day.
                          required parameters: <device>, <reading>, <from>, <to>
                          weekstats Calculates the statistics SUM, AVG, MIN, MAX, COUNT for one week.
                          required parameters: <device>, <reading>, <from>, <to>
                          monthstats Calculates the statistics SUM, AVG, MIN, MAX, COUNT for one month.
                          required parameters: <device>, <reading>, <from>, <to>
                          yearstats Calculates the statistics SUM, AVG, MIN, MAX, COUNT for one year.
                          required parameters: <device>, <reading>, <from>, <to>
                          +
                        +
                        + + Note:
                        + This database retrieval works blocking and influences FHEM if the database does not respond or not responds + sufficiently fast. For non-blocking database queries is referred to the module DbRep. +
                        +
                        + + Examples: +
                          +
                        • get LogSQLITE3 dataRetrieval getdevices +
                        • + +
                        • get LogSQLITE3 dataRetrieval getreadings MySTP_5000 +
                        • + +
                        • get LogSQLITE3 dataRetrieval last "" "" "" "" "" 50 +
                        • + +
                        • get LogSQLITE3 dataRetrieval timerange MySTP_5000 etotal 2023-01-01_00:00:00 2023-01-25_00:00:00 +
                        • + +
                        • get LogSQLITE3 dataRetrieval getTableData MySTP_5000 "" 2023-01-01_00:00:00 2023-01-25_00:00:00 0 100 +
                        • + +
                        • get LogSQLITE3 dataRetrieval getTableData "" etotal 2023-01-01_00:00:00 2023-01-25_00:00:00 0 100 +
                        • + +
                        • get LogSQLITE3 dataRetrieval hourstats MySTP_5000 etotal 2023-01-01_00:00:00 2023-01-25_00:00:00 +
                        • +
                        +
                      +
                    +
                    - +
                    + Get for the use of SVG plots

                    @@ -9278,7 +9392,7 @@ return; Get when used for webcharts

                    - +
                    • get <name> <in> <out> <from> <to> <device> <querytype> <xaxis> <yaxis> <savename> <chartconfig> <pagingstart> <paginglimit>

                      @@ -9286,7 +9400,7 @@ return; Query the Database to retrieve JSON-Formatted Data, which is used by the charting frontend.

                      - +
                      • <name>
                        The name of the defined DbLog, like it is given in fhem.cfg.
                      • @@ -9328,13 +9442,12 @@ return;
                      • <xaxis>
                        - A string which represents the xaxis. It must be a valid field name of the history table, like e.g. - TIMESTAMP. + A string which represents the xaxis. It must be a valid field name, typically 'TIMESTAMP', of the history table.

                      • <yaxis>
                        - A string representing the Y-axis to be set to the name of the reading to be evaluated. + A string representing the Y-axis to be set to the name of the reading to be evaluated.

                      • @@ -9416,32 +9529,32 @@ return;

                        This attribute sets the processing procedure according to which the DbLog device writes the data to the database.
                        - DbLog uses a sub-process to write the log data into the database and processes the data + DbLog uses a sub-process to write the log data into the database and processes the data generally not blocking for FHEM.
                        Thus, the writing process to the database is generally not blocking and FHEM is not affected in the case the database is not performing or is not available (maintenance, error condition).
                        (default: 0) -

                        +

                        -
                          +
                            - - - - - - - - - - - - - + + + + + + + + + + + + +
                            0 - Synchronous log mode. The data to be logged is only briefly cached and immediately
                            written to the database.
                            Advantages:
                            In principle, the data is immediately available in the database.
                            Very little to no data is lost when FHEM crashes.
                            Disadvantages:
                            An alternative storage in the file system (in case of database problems) is not supported.
                            1 - Asynchroner Log-Modus. The data to be logged is first cached in a memory cache and written to the database
                            depending on a time interval or fill level of the cache.
                            Advantages:
                            The data is cached and will not be lost if the database is unavailable or malfunctions.
                            The alternative storage of data in the file system is supported.
                            Disadvantages:
                            The data is available in the database with a time delay.
                            If FHEM crashes, all data cached in the memory will be lost.
                            In principle, the data is immediately available in the database.
                            Very little to no data is lost when FHEM crashes.
                            Disadvantages:
                            An alternative storage in the file system (in case of database problems) is not supported.
                            1 - Asynchroner Log-Modus. The data to be logged is first cached in a memory cache and written to the database
                            depending on a time interval or fill level of the cache.
                            Advantages:
                            The data is cached and will not be lost if the database is unavailable or malfunctions.
                            The alternative storage of data in the file system is supported.
                            Disadvantages:
                            The data is available in the database with a time delay.
                            If FHEM crashes, all data cached in the memory will be lost.
                          @@ -9704,7 +9817,7 @@ return; The DbLogSelectionMode attribute must be set accordingly to enable DbLogInclude.
                          With the defaultMinInterval attribute a default for - <MinInterval> can be specified. + <MinInterval> can be specified.

                          Example
                          @@ -9730,7 +9843,7 @@ return; regular expression are excluded from logging to the database.
                          Readings that have not been excluded via the regex are logged in the database. The behavior of the - storage is controlled with the following optional specifications.
                          + storage is controlled with the following optional specifications.
                          The optional <MinInterval> addition specifies that a value is saved when at least <MinInterval> seconds have passed since the last storage.
                          @@ -9755,7 +9868,7 @@ return; The DbLogSelectionMode attribute can be set appropriately to disable DbLogExclude.
                          With the defaultMinInterval attribute a default for - <MinInterval> can be specified. + <MinInterval> can be specified.

                          Example
                          @@ -10530,22 +10643,22 @@ attr SMA_Energymeter DbLogValueFn <devspec>:<Reading> Das Device kann als Geräte-Spezifikation angegeben werden. Die Angabe von "Reading" wird als regulärer Ausdruck ausgewertet. - Ist das Reading nicht vorhanden und der Wert "Value" angegeben, wird das Reading - in die DB eingefügt wenn es kein regulärer Ausdruck und ein valider Readingname ist. - - - Value Optional kann "Value" für den Readingwert angegeben werden. - Ist Value nicht angegeben, wird der aktuelle Wert des Readings in die DB eingefügt. - - - CN=<caller name> Mit dem Schlüssel "CN=" (Caller Name) kann dem addLog-Aufruf ein String, - z.B. der Name des aufrufenden Devices, mitgegeben werden. - Mit Hilfe der im Attribut valueFn hinterlegten Funktion kann - dieser Schlüssel über die Variable $CN ausgewertet werden. - - - !useExcludes addLog berücksichtigt per default die mit dem Attribut "DbLogExclude" ausgeschlossenen Readings. - Mit dem Schüsselwort "!useExcludes" wird das gesetzte Attribut "DbLogExclude" ignoriert. + Ist das Reading nicht vorhanden und der Wert "Value" angegeben, wird das Reading + in die DB eingefügt wenn es kein regulärer Ausdruck und ein valider Readingname ist. + + + Value Optional kann "Value" für den Readingwert angegeben werden. + Ist Value nicht angegeben, wird der aktuelle Wert des Readings in die DB eingefügt. + + + CN=<caller name> Mit dem Schlüssel "CN=" (Caller Name) kann dem addLog-Aufruf ein String, + z.B. der Name des aufrufenden Devices, mitgegeben werden. + Mit Hilfe der im Attribut valueFn hinterlegten Funktion kann + dieser Schlüssel über die Variable $CN ausgewertet werden. + + + !useExcludes addLog berücksichtigt per default die mit dem Attribut "DbLogExclude" ausgeschlossenen Readings. + Mit dem Schüsselwort "!useExcludes" wird das gesetzte Attribut "DbLogExclude" ignoriert.
                          @@ -10803,7 +10916,9 @@ attr SMA_Energymeter DbLogValueFn
                            -
                          • get <name> ReadingsMaxVal[Timestamp] <Device> <Reading> <default>

                            +
                          • get <name> ReadingsMaxVal[Timestamp] <Device> <Reading> <default> +
                            +
                              Ermittelt den Datensatz mit dem größten Wert der angegebenen Device / Reading Kombination aus der history Tabelle.
                              Zurück gegeben wird nur der Wert oder die Kombination aus Wert und Timestamp als String @@ -10814,7 +10929,7 @@ attr SMA_Energymeter DbLogValueFn Hinweis:
                              Dieser Datenbankabruf arbeitet blockierend und beeinflusst FHEM wenn die Datenbank nicht oder nicht - hinreichend schnell antwortet. Für nicht-blockierende Datenbankabfragen wird auf das Modul DbRep + hinreichend schnell antwortet. Für nicht-blockierende Datenbankabfragen wird auf das Modul DbRep verwiesen.
                          @@ -10823,7 +10938,9 @@ attr SMA_Energymeter DbLogValueFn
                            -
                          • get <name> ReadingsMinVal[Timestamp] <Device> <Reading> <default>

                            +
                          • get <name> ReadingsMinVal[Timestamp] <Device> <Reading> <default> +
                            +
                              Ermittelt den Datensatz mit dem kleinsten Wert der angegebenen Device / Reading Kombination aus der history Tabelle.
                              Zurück gegeben wird nur der Wert oder die Kombination aus Wert und Timestamp als String @@ -10834,7 +10951,7 @@ attr SMA_Energymeter DbLogValueFn Hinweis:
                              Dieser Datenbankabruf arbeitet blockierend und beeinflusst FHEM wenn die Datenbank nicht oder nicht - hinreichend schnell antwortet. Für nicht-blockierende Datenbankabfragen wird auf das Modul DbRep + hinreichend schnell antwortet. Für nicht-blockierende Datenbankabfragen wird auf das Modul DbRep verwiesen.
                          @@ -10843,7 +10960,9 @@ attr SMA_Energymeter DbLogValueFn
                            -
                          • get <name> ReadingsAvgVal <Device> <Reading> <default>

                            +
                          • get <name> ReadingsAvgVal <Device> <Reading> <default> +
                            +
                              Ermittelt den Durchschnittswert der angegebenen Device / Reading Kombination aus der history Tabelle.
                              Zurück gegeben wird der einfache arithmetische Durchschnittswert.
                              @@ -10853,7 +10972,7 @@ attr SMA_Energymeter DbLogValueFn Hinweis:
                              Dieser Datenbankabruf arbeitet blockierend und beeinflusst FHEM wenn die Datenbank nicht oder nicht - hinreichend schnell antwortet. Für nicht-blockierende Datenbankabfragen wird auf das Modul DbRep + hinreichend schnell antwortet. Für nicht-blockierende Datenbankabfragen wird auf das Modul DbRep verwiesen.
                          @@ -10862,7 +10981,9 @@ attr SMA_Energymeter DbLogValueFn
                            -
                          • get <name> ReadingsVal[Timestamp] <Device> <Reading> <default>

                            +
                          • get <name> ReadingsVal[Timestamp] <Device> <Reading> <default> +
                            +
                              Liest den letzten (neuesten) in der history Tabelle gespeicherten Datensatz der angegebenen Device / Reading Kombination.
                              @@ -10874,7 +10995,7 @@ attr SMA_Energymeter DbLogValueFn Hinweis:
                              Dieser Datenbankabruf arbeitet blockierend und beeinflusst FHEM wenn die Datenbank nicht oder nicht - hinreichend schnell antwortet. Für nicht-blockierende Datenbankabfragen wird auf das Modul DbRep + hinreichend schnell antwortet. Für nicht-blockierende Datenbankabfragen wird auf das Modul DbRep verwiesen.
                          @@ -10883,7 +11004,9 @@ attr SMA_Energymeter DbLogValueFn
                            -
                          • get <name> ReadingsTimestamp <Device> <Reading> <default>

                            +
                          • get <name> ReadingsTimestamp <Device> <Reading> <default> +
                            +
                              Liest den Zeitstempel des letzten (neuesten) in der history Tabelle gespeicherten Datensatzes der angegebenen Device/Reading Kombination und gibt diesen Wert zurück.
                              @@ -10893,14 +11016,89 @@ attr SMA_Energymeter DbLogValueFn Hinweis:
                              Dieser Datenbankabruf arbeitet blockierend und beeinflusst FHEM wenn die Datenbank nicht oder nicht - hinreichend schnell antwortet. Für nicht-blockierende Datenbankabfragen wird auf das Modul DbRep + hinreichend schnell antwortet. Für nicht-blockierende Datenbankabfragen wird auf das Modul DbRep verwiesen.

                          + +
                            + +
                          • get <name> dataRetrieval <querytype> <device> <reading> <from> <to> <offset> <limit> +
                            + +
                              + Liest Daten aus der Datenbank Tabelle history und gibt die Ergebnisse als JSON formatiert zurück.
                              + Die Abfragemethode bzw. das gewünschte Abfrageergebnis wird durch den angegebenen <querytype> bestimmt.
                              + Jeder <querytype> verlangt evtl. weitere Parameter gemäß der folgenden Tabelle. Nicht eingegebene Parameter sind + immer als "" anzugeben sofern danach noch ein weiterer Parameter eingegeben wird. +
                              +
                              + +
                                + + + + + + + + + + + + + + + + + + + + + + +
                                getdevices Ermittelt alle in der Datenbank gespeicherten Devices.
                                getreadings Ermittelt alle in der Datenbank gespeicherten Readings für ein bestimmtes Device.
                                benötigte Parameter: <device>
                                timerange Ermittelt die gespeicherten Datensätze der angegebenen Device / Reading Kombination.
                                benötigte Parameter: <device>, <reading>, <from>, <to>
                                getTableData Ermittelt die gespeicherten Datensätze eines bestimmten Zeitraumes.
                                Die Anzahl der selektierten Datensätze wird als Schlüssel "totalcount" zurückgegeben.
                                benötigte Parameter: <from>, <to>, <offset>, <limit>
                                last Listet die letzten 10 gespeicherten Events auf.
                                mögliche Parameter: <limit> (überschreibt den Standard 10)
                                hourstats Errechnet die Statistiken SUM, AVG, MIN, MAX, COUNT für eine Stunde.
                                benötigte Parameter: <device>, <reading>, <from>, <to>
                                daystats Errechnet die Statistiken SUM, AVG, MIN, MAX, COUNT für einen Tag.
                                benötigte Parameter: <device>, <reading>, <from>, <to>
                                weekstats Errechnet die Statistiken SUM, AVG, MIN, MAX, COUNT für eine Woche.
                                benötigte Parameter: <device>, <reading>, <from>, <to>
                                monthstats Errechnet die Statistiken SUM, AVG, MIN, MAX, COUNT für einen Monat.
                                benötigte Parameter: <device>, <reading>, <from>, <to>
                                yearstats Errechnet die Statistiken SUM, AVG, MIN, MAX, COUNT für ein Jahr.
                                benötigte Parameter: <device>, <reading>, <from>, <to>
                                +
                              +
                              + + Hinweis:
                              + Dieser Datenbankabruf arbeitet blockierend und beeinflusst FHEM wenn die Datenbank nicht oder nicht + hinreichend schnell antwortet. Für nicht-blockierende Datenbankabfragen wird auf das Modul DbRep + verwiesen. +
                              +
                              + + Beispiele: +
                                +
                              • get LogSQLITE3 dataRetrieval getdevices +
                              • + +
                              • get LogSQLITE3 dataRetrieval getreadings MySTP_5000 +
                              • + +
                              • get LogSQLITE3 dataRetrieval last "" "" "" "" "" 50 +
                              • + +
                              • get LogSQLITE3 dataRetrieval timerange MySTP_5000 etotal 2023-01-01_00:00:00 2023-01-25_00:00:00 +
                              • + +
                              • get LogSQLITE3 dataRetrieval getTableData MySTP_5000 "" 2023-01-01_00:00:00 2023-01-25_00:00:00 0 100 +
                              • + +
                              • get LogSQLITE3 dataRetrieval getTableData "" etotal 2023-01-01_00:00:00 2023-01-25_00:00:00 0 100 +
                              • + +
                              • get LogSQLITE3 dataRetrieval hourstats MySTP_5000 etotal 2023-01-01_00:00:00 2023-01-25_00:00:00 +
                              • +
                              +
                            +
                          +
                          - +
                          + Get für die Nutzung von SVG-Plots

                          @@ -10999,8 +11197,8 @@ attr SMA_Energymeter DbLogValueFn in Sekunden und ersetzt damit den originalen Wert.
                        - -
                        + +
                      • <regexp>
                        Diese Zeichenkette wird als Perl Befehl ausgewertet. @@ -11074,10 +11272,11 @@ attr SMA_Energymeter DbLogValueFn Get für die Nutzung von webcharts

                        - +
                          -
                        • get <name> <in> <out> <from> - <to> <device> <querytype> <xaxis> <yaxis> <savename> <chartconfig> <pagingstart> <paginglimit>
                          +
                        • get <name> <in> <out> <from> + <to> <device> <querytype> <xaxis> <yaxis> <savename> <chartconfig> <pagingstart> <paginglimit> +

                          Liest Daten aus der Datenbank aus und gibt diese in JSON formatiert aus. Wird für das Charting Frontend genutzt. @@ -11086,7 +11285,7 @@ attr SMA_Energymeter DbLogValueFn
                          • <name>
                            - Der Name des definierten DbLogs, so wie er in der fhem.cfg angegeben wurde. + Der Name des definierten DbLog Devices, so wie er in der fhem.cfg angegeben wurde.

                          • @@ -11133,8 +11332,7 @@ attr SMA_Energymeter DbLogValueFn
                          • <xaxis>
                            - Ein String, der die X-Achse repräsentiert. Es muß ein gültiger Feldname der history-Tabelle sein, wie z.B. - TIMESTAMP. + Ein String, der die X-Achse repräsentiert. Es muß ein gültiger Feldname, typisch 'TIMESTAMP', der history-Tabelle sein.

                          • @@ -11186,8 +11384,10 @@ attr SMA_Energymeter DbLogValueFn
                          • get logdb - webchart "" "" "" deletechart "" "" 7
                            Löscht einen zuvor gespeicherten Chart unter Angabe einer id
                          -

                          +
                          +
                        +
                      • @@ -11224,34 +11424,34 @@ attr SMA_Energymeter DbLogValueFn Dieses Attribut stellt den Verarbeitungsprozess ein nach dessen Verfahren das DbLog Device die Daten in die Datenbank schreibt.
                        - DbLog verwendet zum Schreiben der Log-Daten in die Datenbank einen SubProzess und verarbeitet die Daten + DbLog verwendet zum Schreiben der Log-Daten in die Datenbank einen SubProzess und verarbeitet die Daten generell nicht blockierend für FHEM.
                        Dadurch erfolgt der Schreibprozess in die Datenbank generell nicht blockierend und FHEM wird in dem Fall, dass die Datenbank nicht performant arbeitet oder nicht verfügbar ist (Wartung, Fehlerzustand, etc.), nicht beeinträchtigt.
                        (default: 0) -

                        +

                        -
                          +
                            - - - - - - - - - - - - - - + + + + + + + + + + + + + +
                            0 - Synchroner Log-Modus. Die zu loggenden Daten werden nur kurz im Cache zwischengespeichert und sofort
                            in die Datenbank geschrieben.
                            Vorteile:
                            Die Daten stehen im Prinzip sofort in der Datenbank zur Verfügung.
                            Bei einem Absturz von FHEM gehen sehr wenige bis keine Daten verloren.
                            Nachteile:
                            Eine alternative Speicherung im Filesystem (bei Datenbankproblemen) wird nicht unterstützt.
                            1 - Asynchroner Log-Modus. Die zu loggenden Daten werden zunächst in einem Memory Cache zwischengespeichert
                            und abhängig von einem Zeitintervall bzw. Füllgrad des Caches in die Datenbank geschrieben.
                            Vorteile:
                            Die Daten werden zwischengespeichert und gehen nicht verloren wenn die Datenbank nicht verfügbar ist
                            oder fehlerhaft arbeitet. Die alternative Speicherung im Filesystem wird unterstützt.
                            Nachteile:
                            Die Daten stehen zeitlich verzögert in der Datenbank zur Verfügung.
                            Bei einem Absturz von FHEM gehen alle im Memory Cache zwischengespeicherten Daten verloren.
                            Die Daten stehen im Prinzip sofort in der Datenbank zur Verfügung.
                            Bei einem Absturz von FHEM gehen sehr wenige bis keine Daten verloren.
                            Nachteile:
                            Eine alternative Speicherung im Filesystem (bei Datenbankproblemen) wird nicht unterstützt.
                            1 - Asynchroner Log-Modus. Die zu loggenden Daten werden zunächst in einem Memory Cache zwischengespeichert
                            und abhängig von einem Zeitintervall bzw. Füllgrad des Caches in die Datenbank geschrieben.
                            Vorteile:
                            Die Daten werden zwischengespeichert und gehen nicht verloren wenn die Datenbank nicht verfügbar ist
                            oder fehlerhaft arbeitet. Die alternative Speicherung im Filesystem wird unterstützt.
                            Nachteile:
                            Die Daten stehen zeitlich verzögert in der Datenbank zur Verfügung.
                            Bei einem Absturz von FHEM gehen alle im Memory Cache zwischengespeicherten Daten verloren.
                          @@ -11555,12 +11755,12 @@ attr SMA_Energymeter DbLogValueFn

                          Mit dem Attribut DbLogExclude werden die Readings definiert, die nicht in der Datenbank gespeichert werden - sollen.
                          + sollen.
                          Die Definition der auszuschließenden Readings erfolgt über einen regulären Ausdruck und alle Readings, die mit dem regulären Ausdruck matchen, werden vom Logging in die Datenbank ausgeschlossen.
                          Readings, die nicht über den Regex ausgeschlossen wurden, werden in der Datenbank geloggt. Das Verhalten der - Speicherung wird mit den nachfolgenden optionalen Angaben gesteuert.
                          + Speicherung wird mit den nachfolgenden optionalen Angaben gesteuert.
                          Der optionale Zusatz <MinInterval> gibt an, dass ein Wert dann gespeichert wird wenn mindestens <MinInterval> Sekunden seit der letzten Speicherung vergangen sind.
                          @@ -11585,7 +11785,7 @@ attr SMA_Energymeter DbLogValueFn Das Attribut DbLogSelectionMode kann entsprechend gesetzt werden um DbLogExclude zu deaktivieren.
                          Mit dem Attribut defaultMinInterval kann ein Default für - <MinInterval> vorgegeben werden. + <MinInterval> vorgegeben werden.

                          Beispiel