2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-01-31 12:49:34 +00:00

93_DbLog: change cache from %defs to %data, improved log infos with verbose 5 of SVG generation, bugfix check TIMESTAMP

in attribute DbLogValueFn or attribute valueFn

git-svn-id: https://svn.fhem.de/fhem/trunk@20304 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
nasseeder1 2019-10-04 08:59:19 +00:00
parent 4b6bd82d6d
commit 4224484ff1
2 changed files with 510 additions and 468 deletions

View File

@ -1,5 +1,8 @@
# 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: 93_DbLog: change cache from %defs to %data, improved log infos
with verbose 5 of SVG generation, bugfix check TIMESTAMP
in attribute DbLogValueFn or attribute valueFn
- bugfix: 73_AutoShuttersControl: fix partyMode and window open condition - bugfix: 73_AutoShuttersControl: fix partyMode and window open condition
- bugfix: 70_BRAVIA: fix state - bugfix: 70_BRAVIA: fix state
- bugfix: 10_MYSENSORS_DEVICE: Prevent FHEM crash in case of ext. OTA update - bugfix: 10_MYSENSORS_DEVICE: Prevent FHEM crash in case of ext. OTA update

View File

@ -30,6 +30,10 @@ no if $] >= 5.017011, warnings => 'experimental::smartmatch';
# Version History intern by DS_Starter: # Version History intern by DS_Starter:
our %DbLog_vNotesIntern = ( our %DbLog_vNotesIntern = (
"4.7.4" => "03.10.2019 bugfix test of TIMESTAMP got from DbLogValueFn or valueFn in DbLog_Log and DbLog_AddLog",
"4.7.3" => "02.10.2019 improved log out entries of DbLog_Get for SVG ",
"4.7.2" => "28.09.2019 change cache from %defs to %data ",
"4.7.1" => "10.09.2019 release the memcache memory: https://www.effectiveperlprogramming.com/2018/09/undef-a-scalar-to-release-its-memory/ in asynchron mode: https://www.effectiveperlprogramming.com/2018/09/undef-a-scalar-to-release-its-memory/ ",
"4.7.0" => "04.09.2019 attribute traceHandles, extract db driver versions in configCheck ", "4.7.0" => "04.09.2019 attribute traceHandles, extract db driver versions in configCheck ",
"4.6.0" => "03.09.2019 add-on parameter \"force\" for MinInterval, Forum: #97148 ", "4.6.0" => "03.09.2019 add-on parameter \"force\" for MinInterval, Forum: #97148 ",
"4.5.0" => "28.08.2019 consider attr global logdir in set exportCache ", "4.5.0" => "28.08.2019 consider attr global logdir in set exportCache ",
@ -224,8 +228,7 @@ sub DbLog_dbReadings($@);
sub DbLog_showChildHandles($$$$); sub DbLog_showChildHandles($$$$);
################################################################ ################################################################
sub DbLog_Initialize($) sub DbLog_Initialize($) {
{
my ($hash) = @_; my ($hash) = @_;
$hash->{DefFn} = "DbLog_Define"; $hash->{DefFn} = "DbLog_Define";
@ -237,36 +240,36 @@ sub DbLog_Initialize($)
$hash->{SVG_regexpFn} = "DbLog_regexpFn"; $hash->{SVG_regexpFn} = "DbLog_regexpFn";
$hash->{DelayedShutdownFn} = "DbLog_DelayedShutdown"; $hash->{DelayedShutdownFn} = "DbLog_DelayedShutdown";
$hash->{AttrList} = "addStateEvent:0,1 ". $hash->{AttrList} = "addStateEvent:0,1 ".
"asyncMode:1,0 ".
"bulkInsert:1,0 ". "bulkInsert:1,0 ".
"commitMode:basic_ta:on,basic_ta:off,ac:on_ta:on,ac:on_ta:off,ac:off_ta:on ". "commitMode:basic_ta:on,basic_ta:off,ac:on_ta:on,ac:on_ta:off,ac:off_ta:on ".
"cacheEvents:2,1,0 ".
"cacheLimit ".
"colEvent ". "colEvent ".
"colReading ". "colReading ".
"colValue ". "colValue ".
"DbLogSelectionMode:Exclude,Include,Exclude/Include ".
"DbLogType:Current,History,Current/History,SampleFill/History ".
"dbSchema ". "dbSchema ".
"disable:1,0 ". "disable:1,0 ".
"DbLogType:Current,History,Current/History,SampleFill/History ".
"suppressUndef:0,1 ".
"verbose4Devs ".
"excludeDevs ". "excludeDevs ".
"expimpdir ". "expimpdir ".
"exportCacheAppend:1,0 ". "exportCacheAppend:1,0 ".
"noSupportPK:1,0 ".
"noNotifyDev:1,0 ". "noNotifyDev:1,0 ".
"showproctime:1,0 ". "showproctime:1,0 ".
"suppressAddLogV3:1,0 ". "suppressAddLogV3:1,0 ".
"traceFlag:SQL,CON,ENC,DBD,TXN,ALL ". "suppressUndef:0,1 ".
"traceLevel:0,1,2,3,4,5,6,7 ".
"traceHandles ".
"asyncMode:1,0 ".
"cacheEvents:2,1,0 ".
"cacheLimit ".
"noSupportPK:1,0 ".
"syncEvents:1,0 ". "syncEvents:1,0 ".
"syncInterval ". "syncInterval ".
"showNotifyTime:1,0 ". "showNotifyTime:1,0 ".
"traceFlag:SQL,CON,ENC,DBD,TXN,ALL ".
"traceLevel:0,1,2,3,4,5,6,7 ".
"traceHandles ".
"timeout ". "timeout ".
"useCharfilter:0,1 ". "useCharfilter:0,1 ".
"valueFn:textField-long ". "valueFn:textField-long ".
"DbLogSelectionMode:Exclude,Include,Exclude/Include ". "verbose4Devs ".
$readingFnAttributes; $readingFnAttributes;
addToAttrList("DbLogInclude"); addToAttrList("DbLogInclude");
@ -282,8 +285,7 @@ return;
} }
############################################################### ###############################################################
sub DbLog_Define($@) sub DbLog_Define($@) {
{
my ($hash, $def) = @_; my ($hash, $def) = @_;
my @a = split("[ \t][ \t]*", $def); my @a = split("[ \t][ \t]*", $def);
@ -293,6 +295,7 @@ sub DbLog_Define($@)
return "wrong syntax: define <name> DbLog configuration regexp" return "wrong syntax: define <name> DbLog configuration regexp"
if(int(@a) != 4); if(int(@a) != 4);
my $name = $hash->{NAME};
$hash->{CONFIGURATION} = $a[2]; $hash->{CONFIGURATION} = $a[2];
my $regexp = $a[3]; my $regexp = $a[3];
@ -316,7 +319,7 @@ sub DbLog_Define($@)
$hash->{PID} = $$; $hash->{PID} = $$;
# CacheIndex für Events zum asynchronen Schreiben in DB # CacheIndex für Events zum asynchronen Schreiben in DB
$hash->{cache}{index} = 0; $data{DbLog}{$name}{cache}{index} = 0;
# read configuration data # read configuration data
my $ret = DbLog_readCfg($hash); my $ret = DbLog_readCfg($hash);
@ -348,6 +351,7 @@ sub DbLog_Undef($$) {
BlockingKill($hash->{HELPER}{DELDAYS_PID}) if($hash->{HELPER}{DELDAYS_PID}); BlockingKill($hash->{HELPER}{DELDAYS_PID}) if($hash->{HELPER}{DELDAYS_PID});
$dbh->disconnect() if(defined($dbh)); $dbh->disconnect() if(defined($dbh));
RemoveInternalTimer($hash); RemoveInternalTimer($hash);
delete $data{DbLog}{$name};
return undef; return undef;
} }
@ -673,7 +677,7 @@ sub DbLog_Set($@) {
$ret = "Rereadcfg executed."; $ret = "Rereadcfg executed.";
} }
elsif ($a[1] eq 'purgeCache') { elsif ($a[1] eq 'purgeCache') {
delete $hash->{cache}; delete $data{DbLog}{$name}{cache};
readingsSingleUpdate($hash, 'CacheUsage', 0, 1); readingsSingleUpdate($hash, 'CacheUsage', 0, 1);
} }
elsif ($a[1] eq 'commitCache') { elsif ($a[1] eq 'commitCache') {
@ -681,8 +685,8 @@ sub DbLog_Set($@) {
} }
elsif ($a[1] eq 'listCache') { elsif ($a[1] eq 'listCache') {
my $cache; my $cache;
foreach my $key (sort{$a <=>$b}keys%{$hash->{cache}{".memcache"}}) { foreach my $key (sort{$a <=>$b}keys %{$data{DbLog}{$name}{cache}{memcache}}) {
$cache .= $key." => ".$hash->{cache}{".memcache"}{$key}."\n"; $cache .= $key." => ".$data{DbLog}{$name}{cache}{memcache}{$key}."\n";
} }
return $cache; return $cache;
} }
@ -744,8 +748,8 @@ sub DbLog_Set($@) {
} }
if(!$error) { if(!$error) {
foreach my $key (sort(keys%{$hash->{cache}{".memcache"}})) { foreach my $key (sort(keys %{$data{DbLog}{$name}{cache}{memcache}})) {
$cln = $hash->{cache}{".memcache"}{$key}."\n"; $cln = $data{DbLog}{$name}{cache}{memcache}{$key}."\n";
print FH $cln ; print FH $cln ;
$crows++; $crows++;
} }
@ -763,7 +767,7 @@ sub DbLog_Set($@) {
Log3($name, 3, "DbLog $name: $crows cache rows exported to $outfile."); Log3($name, 3, "DbLog $name: $crows cache rows exported to $outfile.");
if (lc($a[-1]) =~ m/^purgecache/i) { if (lc($a[-1]) =~ m/^purgecache/i) {
delete $hash->{cache}; delete $data{DbLog}{$name}{cache};
readingsSingleUpdate($hash, 'CacheUsage', 0, 1); readingsSingleUpdate($hash, 'CacheUsage', 0, 1);
Log3($name, 3, "DbLog $name: Cache purged after exporting rows to $outfile."); Log3($name, 3, "DbLog $name: Cache purged after exporting rows to $outfile.");
} }
@ -1444,7 +1448,13 @@ sub DbLog_Log($$) {
next; next;
} }
$timestamp = $TIMESTAMP if($TIMESTAMP =~ /(19[0-9][0-9]|2[0-9][0-9][0-9])-(0[1-9]|1[1-2])-(0[1-9]|1[0-9]|2[0-9]|3[0-1]) (0[0-9]|1[1-9]|2[0-3]):([0-5][0-9]):([0-5][0-9])/); my ($yyyy, $mm, $dd, $hh, $min, $sec) = ($TIMESTAMP =~ /(\d+)-(\d+)-(\d+) (\d+):(\d+):(\d+)/);
eval { my $epoch_seconds_begin = timelocal($sec, $min, $hh, $dd, $mm-1, $yyyy-1900); };
if (!$@) {
$timestamp = $TIMESTAMP;
} else {
Log3 ($name, 2, "DbLog $name -> TIMESTAMP got from DbLogValueFn in $dev_name is invalid: $TIMESTAMP");
}
$reading = $READING if($READING ne ''); $reading = $READING if($READING ne '');
$value = $VALUE if(defined $VALUE); $value = $VALUE if(defined $VALUE);
$unit = $UNIT if(defined $UNIT); $unit = $UNIT if(defined $UNIT);
@ -1471,8 +1481,13 @@ sub DbLog_Log($$) {
if($vb4show && !$hash->{HELPER}{".RUNNING_PID"}); if($vb4show && !$hash->{HELPER}{".RUNNING_PID"});
next; next;
} }
my ($yyyy, $mm, $dd, $hh, $min, $sec) = ($TIMESTAMP =~ /(\d+)-(\d+)-(\d+) (\d+):(\d+):(\d+)/);
$timestamp = $TIMESTAMP if($TIMESTAMP =~ /(19[0-9][0-9]|2[0-9][0-9][0-9])-(0[1-9]|1[1-2])-(0[1-9]|1[0-9]|2[0-9]|3[0-1]) (0[0-9]|1[1-9]|2[0-3]):([0-5][0-9]):([0-5][0-9])/); eval { my $epoch_seconds_begin = timelocal($sec, $min, $hh, $dd, $mm-1, $yyyy-1900); };
if (!$@) {
$timestamp = $TIMESTAMP;
} else {
Log3 ($name, 2, "DbLog $name -> Parameter TIMESTAMP got from valueFn is invalid: $TIMESTAMP");
}
$dev_name = $DEVICE if($DEVICE ne ''); $dev_name = $DEVICE if($DEVICE ne '');
$dev_type = $DEVICETYPE if($DEVICETYPE ne ''); $dev_type = $DEVICETYPE if($DEVICETYPE ne '');
$reading = $READING if($READING ne ''); $reading = $READING if($READING ne '');
@ -1490,11 +1505,11 @@ sub DbLog_Log($$) {
if($async) { if($async) {
# asynchoner non-blocking Mode # asynchoner non-blocking Mode
# Cache & CacheIndex für Events zum asynchronen Schreiben in DB # Cache & CacheIndex für Events zum asynchronen Schreiben in DB
$hash->{cache}{index}++; $data{DbLog}{$name}{cache}{index}++;
my $index = $hash->{cache}{index}; my $index = $data{DbLog}{$name}{cache}{index};
$hash->{cache}{".memcache"}{$index} = $row; $data{DbLog}{$name}{cache}{memcache}{$index} = $row;
my $memcount = $hash->{cache}{".memcache"}?scalar(keys%{$hash->{cache}{".memcache"}}):0; my $memcount = $data{DbLog}{$name}{cache}{memcache}?scalar(keys %{$data{DbLog}{$name}{cache}{memcache}}):0;
if($ce == 1) { if($ce == 1) {
readingsSingleUpdate($hash, "CacheUsage", $memcount, 1); readingsSingleUpdate($hash, "CacheUsage", $memcount, 1);
} else { } else {
@ -2111,7 +2126,7 @@ sub DbLog_execmemcache ($) {
} }
} }
$memcount = $hash->{cache}{".memcache"}?scalar(keys%{$hash->{cache}{".memcache"}}):0; $memcount = $data{DbLog}{$name}{cache}{memcache}?scalar(keys %{$data{DbLog}{$name}{cache}{memcache}}):0;
if($ce == 2) { if($ce == 2) {
readingsSingleUpdate($hash, "CacheUsage", $memcount, 1); readingsSingleUpdate($hash, "CacheUsage", $memcount, 1);
} else { } else {
@ -2125,10 +2140,11 @@ sub DbLog_execmemcache ($) {
Log3 $name, 4, "DbLog $name -> MemCache contains $memcount entries to process"; Log3 $name, 4, "DbLog $name -> MemCache contains $memcount entries to process";
Log3 $name, 4, "DbLog $name -> DbLogType is: $DbLogType"; Log3 $name, 4, "DbLog $name -> DbLogType is: $DbLogType";
foreach my $key (sort(keys%{$hash->{cache}{".memcache"}})) { foreach my $key (sort(keys %{$data{DbLog}{$name}{cache}{memcache}})) {
Log3 $hash->{NAME}, 5, "DbLog $name -> MemCache contains: ".$hash->{cache}{".memcache"}{$key}; Log3 $hash->{NAME}, 5, "DbLog $name -> MemCache contains: ".$data{DbLog}{$name}{cache}{memcache}{$key};
push(@row_array, delete($hash->{cache}{".memcache"}{$key})); push(@row_array, delete($data{DbLog}{$name}{cache}{memcache}{$key}));
} }
undef $data{DbLog}{$name}{cache}{memcache}; # sicherheitshalber Memory freigeben: https://perlmaven.com/undef-on-perl-arrays-and-hashes, bzw. https://www.effectiveperlprogramming.com/2018/09/undef-a-scalar-to-release-its-memory/
my $rowlist = join('§', @row_array); my $rowlist = join('§', @row_array);
$rowlist = encode_base64($rowlist,""); $rowlist = encode_base64($rowlist,"");
@ -2699,15 +2715,15 @@ sub DbLog_PushAsyncDone ($) {
eval { eval {
foreach my $row (@row_array) { foreach my $row (@row_array) {
# Cache & CacheIndex für Events zum asynchronen Schreiben in DB # Cache & CacheIndex für Events zum asynchronen Schreiben in DB
$hash->{cache}{index}++; $data{DbLog}{$name}{cache}{index}++;
my $index = $hash->{cache}{index}; my $index = $data{DbLog}{$name}{cache}{index};
$hash->{cache}{".memcache"}{$index} = $row; $data{DbLog}{$name}{cache}{memcache}{$index} = $row;
} }
$memcount = scalar(keys%{$hash->{cache}{".memcache"}}); $memcount = scalar(keys %{$data{DbLog}{$name}{cache}{memcache}});
}; };
} }
$memcount = $hash->{cache}{".memcache"}?scalar(keys%{$hash->{cache}{".memcache"}}):0; $memcount = $data{DbLog}{$name}{cache}{memcache}?scalar(keys %{$data{DbLog}{$name}{cache}{memcache}}):0;
readingsSingleUpdate($hash, 'CacheUsage', $memcount, 0); readingsSingleUpdate($hash, 'CacheUsage', $memcount, 0);
if(AttrVal($name, "showproctime", undef) && $bt) { if(AttrVal($name, "showproctime", undef) && $bt) {
@ -3034,9 +3050,12 @@ sub DbLog_Get($@) {
" <in> is not used, only for compatibility for FileLog, please use - \n" . " <in> is not used, only for compatibility for FileLog, please use - \n" .
" <out> is a prefix, - means stdout\n" " <out> is a prefix, - means stdout\n"
if(int(@a) < 5); if(int(@a) < 5);
shift @a; shift @a;
my $inf = lc(shift @a); my $inf = lc(shift @a);
my $outf = lc(shift @a); my $outf = lc(shift @a); # Wert ALL: get all colums from table, including a header
# Wert Array: get the columns as array of hashes
# Wert INT: internally used by generating plots
my $from = shift @a; my $from = shift @a;
my $to = shift @a; # Now @a contains the list of column_specs my $to = shift @a; # Now @a contains the list of column_specs
my ($internal, @fld); my ($internal, @fld);
@ -3087,9 +3106,10 @@ sub DbLog_Get($@) {
my @ReturnArray; my @ReturnArray;
my $writeout = 0; my $writeout = 0;
my (@min, @max, @sum, @cnt, @lastv, @lastd, @mind, @maxd); my (@min, @max, @sum, @cnt, @lastv, @lastd, @mind, @maxd);
my (%tstamp, %lasttstamp, $out_tstamp, $out_value, $minval, $maxval, $deltacalc); #fuer delta-h/d Berechnung my (%tstamp, %lasttstamp, $out_tstamp, $out_value, $minval, $maxval, $deltacalc); # fuer delta-h/d Berechnung
#extract the Device:Reading arguments into @readings array # extract the Device:Reading arguments into @readings array
# Ausgangspunkt ist z.B.: KS300:temperature KS300:rain::delta-h KS300:rain::delta-d
for(my $i = 0; $i < int(@a); $i++) { for(my $i = 0; $i < int(@a); $i++) {
@fld = split(":", $a[$i], 5); @fld = split(":", $a[$i], 5);
$readings[$i][0] = $fld[0]; # Device $readings[$i][0] = $fld[0]; # Device
@ -3098,7 +3118,7 @@ sub DbLog_Get($@) {
$readings[$i][3] = $fld[3]; # function $readings[$i][3] = $fld[3]; # function
$readings[$i][4] = $fld[4]; # regexp $readings[$i][4] = $fld[4]; # regexp
$readings[$i][1] = "%" if(!$readings[$i][1] || length($readings[$i][1])==0); #falls Reading nicht gefuellt setze Joker $readings[$i][1] = "%" if(!$readings[$i][1] || length($readings[$i][1])==0); # falls Reading nicht gefuellt setze Joker
} }
Log3 $name, 4, "DbLog $name -> ################################################################"; Log3 $name, 4, "DbLog $name -> ################################################################";
@ -3106,26 +3126,12 @@ sub DbLog_Get($@) {
Log3 $name, 4, "DbLog $name -> ################################################################"; Log3 $name, 4, "DbLog $name -> ################################################################";
Log3($name, 4, "DbLog $name -> main PID: $hash->{PID}, secondary PID: $$"); Log3($name, 4, "DbLog $name -> main PID: $hash->{PID}, secondary PID: $$");
# $dbh = $hash->{DBHP};
# if ( !$dbh || not $dbh->ping ) {
# # DB Session dead, try to reopen now !
# return "Can't connect to database." if(!DbLog_ConnectPush($hash,1));
# $dbh = $hash->{DBHP};
# }
# if( $hash->{PID} != $$ ) {
# #create new connection for plotfork
# $dbh->disconnect();
# return "Can't connect to database." if(!DbLog_ConnectPush($hash,1));
# $dbh = $hash->{DBHP};
# }
my $nh = ($hash->{MODEL} ne 'SQLITE')?1:0; my $nh = ($hash->{MODEL} ne 'SQLITE')?1:0;
# $hash->{PID} != $$ -> create new connection for plotfork # $hash->{PID} != $$ -> create new connection for plotfork
if ($nh || $hash->{PID} != $$) { # 17.04.2019 Forum: https://forum.fhem.de/index.php/topic,99719.0.html if ($nh || $hash->{PID} != $$) { # 17.04.2019 Forum: https://forum.fhem.de/index.php/topic,99719.0.html
$dbh = DbLog_ConnectNewDBH($hash); $dbh = DbLog_ConnectNewDBH($hash);
return "Can't connect to database." if(!$dbh); return "Can't connect to database." if(!$dbh);
} else { } else {
$dbh = $hash->{DBHP}; $dbh = $hash->{DBHP};
eval { eval {
@ -3142,7 +3148,7 @@ sub DbLog_Get($@) {
} }
} }
#vorbereiten der DB-Abfrage, DB-Modell-abhaengig # vorbereiten der DB-Abfrage, DB-Modell-abhaengig
if ($hash->{MODEL} eq "POSTGRESQL") { if ($hash->{MODEL} eq "POSTGRESQL") {
$sqlspec{get_timestamp} = "TO_CHAR(TIMESTAMP, 'YYYY-MM-DD HH24:MI:SS')"; $sqlspec{get_timestamp} = "TO_CHAR(TIMESTAMP, 'YYYY-MM-DD HH24:MI:SS')";
$sqlspec{from_timestamp} = "TO_TIMESTAMP('$from', 'YYYY-MM-DD HH24:MI:SS')"; $sqlspec{from_timestamp} = "TO_TIMESTAMP('$from', 'YYYY-MM-DD HH24:MI:SS')";
@ -3269,17 +3275,14 @@ sub DbLog_Get($@) {
$stm = $stm2; $stm = $stm2;
} }
Log3 $hash->{NAME}, 4, "Processing Statement: $stm"; Log3 ($name, 4, "$name - Processing Statement: $stm");
my $sth= $dbh->prepare($stm) || my $sth = $dbh->prepare($stm) || return "Cannot prepare statement $stm: $DBI::errstr";
return "Cannot prepare statement $stm: $DBI::errstr"; my $rc = $sth->execute() || return "Cannot execute statement $stm: $DBI::errstr";
my $rc= $sth->execute() ||
return "Cannot execute statement $stm: $DBI::errstr";
if($outf =~ m/(all|array)/) { if($outf =~ m/(all|array)/) {
$sth->bind_columns(undef, \$sql_timestamp, \$sql_device, \$sql_reading, \$sql_value, \$type, \$event, \$unit); $sth->bind_columns(undef, \$sql_timestamp, \$sql_device, \$sql_reading, \$sql_value, \$type, \$event, \$unit);
} } else {
else {
$sth->bind_columns(undef, \$sql_timestamp, \$sql_device, \$sql_reading, \$sql_value); $sth->bind_columns(undef, \$sql_timestamp, \$sql_device, \$sql_reading, \$sql_value);
} }
@ -3292,10 +3295,21 @@ sub DbLog_Get($@) {
# Select Auswertung # Select Auswertung
################################ ################################
while($sth->fetch()) { while($sth->fetch()) {
no warnings 'uninitialized';
my $ds = "TS: $sql_timestamp, DEV: $sql_device, RD: $sql_reading, VAL: $sql_value";
Log3 ($name, 5, "$name - SQL-result -> $ds");
use warnings;
############ Auswerten des 5. Parameters: Regexp ################### ############ Auswerten des 5. Parameters: Regexp ###################
# die Regexep wird vor der Function ausgewertet und der Wert im Feld # die Regexep wird vor der Function ausgewertet und der Wert im Feld
# Value angepasst. # Value angepasst.
# z.B.: KS300:temperature KS300:rain::delta-h KS300:rain::delta-d
# 0 1 2 3
# $readings[$i][0] = Device
# $readings[$i][1] = Reading
# $readings[$i][2] = Default
# $readings[$i][3] = function
# $readings[$i][4] = regexp
#################################################################### ####################################################################
if($readings[$i]->[4]) { if($readings[$i]->[4]) {
#evaluate #evaluate
@ -3308,14 +3322,14 @@ sub DbLog_Get($@) {
} }
if($sql_timestamp lt $from && $deltacalc) { if($sql_timestamp lt $from && $deltacalc) {
if(Scalar::Util::looks_like_number($sql_value)){ if(Scalar::Util::looks_like_number($sql_value)) {
#nur setzen wenn nummerisch # nur setzen wenn numerisch
$minval = $sql_value if($sql_value < $minval); $minval = $sql_value if($sql_value < $minval);
$maxval = $sql_value if($sql_value > $maxval); $maxval = $sql_value if($sql_value > $maxval);
$lastv[$i] = $sql_value; $lastv[$i] = $sql_value;
} }
} else {
} else {
$writeout = 0; $writeout = 0;
$out_value = ""; $out_value = "";
$out_tstamp = ""; $out_tstamp = "";
@ -3323,25 +3337,23 @@ sub DbLog_Get($@) {
if($readings[$i]->[4]) { if($readings[$i]->[4]) {
$out_tstamp = $sql_timestamp; $out_tstamp = $sql_timestamp;
$writeout=1 if(!$deltacalc); $writeout = 1 if(!$deltacalc);
} }
############ Auswerten des 4. Parameters: function ################### ############ Auswerten des 4. Parameters: function ###################
if($readings[$i]->[3] && $readings[$i]->[3] eq "int") { if($readings[$i]->[3] && $readings[$i]->[3] eq "int") { # nur den integerwert uebernehmen falls zb value=15°C
#nur den integerwert uebernehmen falls zb value=15°C
$out_value = $1 if($sql_value =~ m/^(\d+).*/o); $out_value = $1 if($sql_value =~ m/^(\d+).*/o);
$out_tstamp = $sql_timestamp; $out_tstamp = $sql_timestamp;
$writeout=1; $writeout = 1;
} elsif ($readings[$i]->[3] && $readings[$i]->[3] =~ m/^int(\d+).*/o) { } elsif ($readings[$i]->[3] && $readings[$i]->[3] =~ m/^int(\d+).*/o) { # Uebernehme den Dezimalwert mit den angegebenen Stellen an Nachkommastellen
#Uebernehme den Dezimalwert mit den angegebenen Stellen an Nachkommastellen
$out_value = $1 if($sql_value =~ m/^([-\.\d]+).*/o); $out_value = $1 if($sql_value =~ m/^([-\.\d]+).*/o);
$out_tstamp = $sql_timestamp; $out_tstamp = $sql_timestamp;
$writeout=1; $writeout = 1;
} elsif ($readings[$i]->[3] && $readings[$i]->[3] eq "delta-ts" && lc($sql_value) !~ m(ignore)) { } elsif ($readings[$i]->[3] && $readings[$i]->[3] eq "delta-ts" && lc($sql_value) !~ m(ignore)) {
#Berechung der vergangen Sekunden seit dem letten Logeintrag # Berechung der vergangen Sekunden seit dem letzten Logeintrag
#zb. die Zeit zwischen on/off # zb. die Zeit zwischen on/off
my @a = split("[- :]", $sql_timestamp); my @a = split("[- :]", $sql_timestamp);
my $akt_ts = mktime($a[5],$a[4],$a[3],$a[2],$a[1]-1,$a[0]-1900,0,0,-1); my $akt_ts = mktime($a[5],$a[4],$a[3],$a[2],$a[1]-1,$a[0]-1900,0,0,-1);
if($lastd[$i] ne "undef") { if($lastd[$i] ne "undef") {
@ -3350,10 +3362,14 @@ sub DbLog_Get($@) {
my $last_ts = mktime($a[5],$a[4],$a[3],$a[2],$a[1]-1,$a[0]-1900,0,0,-1); my $last_ts = mktime($a[5],$a[4],$a[3],$a[2],$a[1]-1,$a[0]-1900,0,0,-1);
$out_tstamp = $sql_timestamp; $out_tstamp = $sql_timestamp;
$out_value = sprintf("%02d", $akt_ts - $last_ts); $out_value = sprintf("%02d", $akt_ts - $last_ts);
if(lc($sql_value) =~ m(hide)){$writeout=0;} else {$writeout=1;}
} elsif ($readings[$i]->[3] && $readings[$i]->[3] eq "delta-h") { if(lc($sql_value) =~ m(hide)) {
#Berechnung eines Stundenwertes $writeout = 0;
} else {
$writeout = 1;
}
} elsif ($readings[$i]->[3] && $readings[$i]->[3] eq "delta-h") { # Berechnung eines Delta-Stundenwertes
%tstamp = DbLog_explode_datetime($sql_timestamp, ()); %tstamp = DbLog_explode_datetime($sql_timestamp, ());
if($lastd[$i] eq "undef") { if($lastd[$i] eq "undef") {
%lasttstamp = DbLog_explode_datetime($sql_timestamp, ()); %lasttstamp = DbLog_explode_datetime($sql_timestamp, ());
@ -3364,9 +3380,10 @@ sub DbLog_Get($@) {
# 04 01 # 04 01
# 06 23 # 06 23
if("$tstamp{hour}" ne "$lasttstamp{hour}") { if("$tstamp{hour}" ne "$lasttstamp{hour}") {
# Aenderung der stunde, Berechne Delta # Aenderung der Stunde, Berechne Delta
#wenn die Stundendifferenz größer 1 ist muss ein Dummyeintrag erstellt werden # wenn die Stundendifferenz größer 1 ist muss ein Dummyeintrag erstellt werden
$retvaldummy = ""; $retvaldummy = "";
if(($tstamp{hour}-$lasttstamp{hour}) > 1) { if(($tstamp{hour}-$lasttstamp{hour}) > 1) {
for (my $j=$lasttstamp{hour}+1; $j < $tstamp{hour}; $j++) { for (my $j=$lasttstamp{hour}+1; $j < $tstamp{hour}; $j++) {
$out_value = "0"; $out_value = "0";
@ -3387,6 +3404,7 @@ sub DbLog_Get($@) {
} }
} }
} }
if(($tstamp{hour}-$lasttstamp{hour}) < 0) { if(($tstamp{hour}-$lasttstamp{hour}) < 0) {
for (my $j=0; $j < $tstamp{hour}; $j++) { for (my $j=0; $j < $tstamp{hour}; $j++) {
$out_value = "0"; $out_value = "0";
@ -3397,48 +3415,54 @@ sub DbLog_Get($@) {
if ($outf =~ m/(all)/) { if ($outf =~ m/(all)/) {
# Timestamp: Device, Type, Event, Reading, Value, Unit # Timestamp: Device, Type, Event, Reading, Value, Unit
$retvaldummy .= sprintf("%s: %s, %s, %s, %s, %s, %s\n", $out_tstamp, $sql_device, $type, $event, $sql_reading, $out_value, $unit); $retvaldummy .= sprintf("%s: %s, %s, %s, %s, %s, %s\n", $out_tstamp, $sql_device, $type, $event, $sql_reading, $out_value, $unit);
} elsif ($outf =~ m/(array)/) { } elsif ($outf =~ m/(array)/) {
push(@ReturnArray, {"tstamp" => $out_tstamp, "device" => $sql_device, "type" => $type, "event" => $event, "reading" => $sql_reading, "value" => $out_value, "unit" => $unit}); push(@ReturnArray, {"tstamp" => $out_tstamp, "device" => $sql_device, "type" => $type, "event" => $event, "reading" => $sql_reading, "value" => $out_value, "unit" => $unit});
} else { } else {
$out_tstamp =~ s/\ /_/g; #needed by generating plots $out_tstamp =~ s/\ /_/g; # needed by generating plots
$retvaldummy .= "$out_tstamp $out_value\n"; $retvaldummy .= "$out_tstamp $out_value\n";
} }
} }
} }
$out_value = sprintf("%g", $maxval - $minval); $out_value = sprintf("%g", $maxval - $minval);
$sum[$i] += $out_value; $sum[$i] += $out_value;
$cnt[$i]++; $cnt[$i]++;
$out_tstamp = DbLog_implode_datetime($lasttstamp{year}, $lasttstamp{month}, $lasttstamp{day}, $lasttstamp{hour}, "30", "00"); $out_tstamp = DbLog_implode_datetime($lasttstamp{year}, $lasttstamp{month}, $lasttstamp{day}, $lasttstamp{hour}, "30", "00");
#$minval = (~0 >> 1); # $minval = (~0 >> 1);
$minval = $maxval; $minval = $maxval;
# $maxval = -(~0 >> 1); # $maxval = -(~0 >> 1);
$writeout=1; $writeout = 1;
Log3 ($name, 5, "$name - Output delta-h -> TS: $tstamp{hour}, LASTTS: $lasttstamp{hour}, OUTTS: $out_tstamp, OUTVAL: $out_value");
} }
} elsif ($readings[$i]->[3] && $readings[$i]->[3] eq "delta-d") {
#Berechnung eines Tageswertes } elsif ($readings[$i]->[3] && $readings[$i]->[3] eq "delta-d") { # Berechnung eines Tageswertes
%tstamp = DbLog_explode_datetime($sql_timestamp, ()); %tstamp = DbLog_explode_datetime($sql_timestamp, ());
if($lastd[$i] eq "undef") { if($lastd[$i] eq "undef") {
%lasttstamp = DbLog_explode_datetime($sql_timestamp, ()); %lasttstamp = DbLog_explode_datetime($sql_timestamp, ());
} else { } else {
%lasttstamp = DbLog_explode_datetime($lastd[$i], ()); %lasttstamp = DbLog_explode_datetime($lastd[$i], ());
} }
if("$tstamp{day}" ne "$lasttstamp{day}") { if("$tstamp{day}" ne "$lasttstamp{day}") {
# Aenderung des Tages, Berechne Delta # Aenderung des Tages, Berechne Delta
$out_value = sprintf("%g", $maxval - $minval); $out_value = sprintf("%g", $maxval - $minval);
$sum[$i] += $out_value; $sum[$i] += $out_value;
$cnt[$i]++; $cnt[$i]++;
$out_tstamp = DbLog_implode_datetime($lasttstamp{year}, $lasttstamp{month}, $lasttstamp{day}, "12", "00", "00"); $out_tstamp = DbLog_implode_datetime($lasttstamp{year}, $lasttstamp{month}, $lasttstamp{day}, "12", "00", "00");
# $minval = (~0 >> 1); # $minval = (~0 >> 1);
$minval = $maxval; $minval = $maxval;
# $maxval = -(~0 >> 1); # $maxval = -(~0 >> 1);
$writeout=1; $writeout = 1;
Log3 ($name, 5, "$name - Output delta-d -> TS: $tstamp{day}, LASTTS: $lasttstamp{day}, OUTTS: $out_tstamp, OUTVAL: $out_value");
} }
} else { } else {
$out_value = $sql_value; $out_value = $sql_value;
$out_tstamp = $sql_timestamp; $out_tstamp = $sql_timestamp;
$writeout=1; $writeout = 1;
} }
# Wenn Attr SuppressUndef gesetzt ist, dann ausfiltern aller undef-Werte # Wenn Attr SuppressUndef gesetzt ist, dann ausfiltern aller undef-Werte
@ -3454,17 +3478,17 @@ sub DbLog_Get($@) {
} elsif ($outf =~ m/(array)/) { } elsif ($outf =~ m/(array)/) {
push(@ReturnArray, {"tstamp" => $out_tstamp, "device" => $sql_device, "type" => $type, "event" => $event, "reading" => $sql_reading, "value" => $out_value, "unit" => $unit}); push(@ReturnArray, {"tstamp" => $out_tstamp, "device" => $sql_device, "type" => $type, "event" => $event, "reading" => $sql_reading, "value" => $out_value, "unit" => $unit});
} else { } else { # generating plots
$out_tstamp =~ s/\ /_/g; #needed by generating plots $out_tstamp =~ s/\ /_/g; # needed by generating plots
$retval .= "$out_tstamp $out_value\n"; $retval .= "$out_tstamp $out_value\n";
$retval .= $retvaldummy; $retval .= $retvaldummy;
} }
} }
if(Scalar::Util::looks_like_number($sql_value)){ if(Scalar::Util::looks_like_number($sql_value)) {
#nur setzen wenn nummerisch # nur setzen wenn numerisch
if($deltacalc) { if($deltacalc) {
if(Scalar::Util::looks_like_number($out_value)){ if(Scalar::Util::looks_like_number($out_value)) {
if($out_value < $min[$i]) { if($out_value < $min[$i]) {
$min[$i] = $out_value; $min[$i] = $out_value;
$mind[$i] = $out_tstamp; $mind[$i] = $out_tstamp;
@ -3475,6 +3499,7 @@ sub DbLog_Get($@) {
} }
} }
$maxval = $sql_value; $maxval = $sql_value;
} else { } else {
if($sql_value < $min[$i]) { if($sql_value < $min[$i]) {
$min[$i] = $sql_value; $min[$i] = $sql_value;
@ -3488,6 +3513,7 @@ sub DbLog_Get($@) {
$minval = $sql_value if($sql_value < $minval); $minval = $sql_value if($sql_value < $minval);
$maxval = $sql_value if($sql_value > $maxval); $maxval = $sql_value if($sql_value > $maxval);
} }
} else { } else {
$min[$i] = 0; $min[$i] = 0;
$max[$i] = 0; $max[$i] = 0;
@ -3495,6 +3521,7 @@ sub DbLog_Get($@) {
$minval = 0; $minval = 0;
$maxval = 0; $maxval = 0;
} }
if(!$deltacalc) { if(!$deltacalc) {
$cnt[$i]++; $cnt[$i]++;
$lastv[$i] = $sql_value; $lastv[$i] = $sql_value;
@ -3503,7 +3530,7 @@ sub DbLog_Get($@) {
} }
$lastd[$i] = $sql_timestamp; $lastd[$i] = $sql_timestamp;
} }
} #while fetchrow } # while fetchrow Ende
######## den letzten Abschlusssatz rausschreiben ########## ######## den letzten Abschlusssatz rausschreiben ##########
if($readings[$i]->[3] && ($readings[$i]->[3] eq "delta-h" || $readings[$i]->[3] eq "delta-d")) { if($readings[$i]->[3] && ($readings[$i]->[3] eq "delta-h" || $readings[$i]->[3] eq "delta-d")) {
@ -3530,7 +3557,8 @@ sub DbLog_Get($@) {
$retval .= "$out_tstamp $out_value\n"; $retval .= "$out_tstamp $out_value\n";
} }
} }
# DatenTrenner setzen
# Datentrenner setzen
$retval .= "#$readings[$i]->[0]"; $retval .= "#$readings[$i]->[0]";
$retval .= ":"; $retval .= ":";
$retval .= "$readings[$i]->[1]" if($readings[$i]->[1]); $retval .= "$readings[$i]->[1]" if($readings[$i]->[1]);
@ -3541,9 +3569,10 @@ sub DbLog_Get($@) {
$retval .= ":"; $retval .= ":";
$retval .= "$readings[$i]->[4]" if($readings[$i]->[4]); $retval .= "$readings[$i]->[4]" if($readings[$i]->[4]);
$retval .= "\n"; $retval .= "\n";
} #for @readings
#Ueberfuehren der gesammelten Werte in die globale Variable %data } # Ende for @readings-Schleife über alle Readinggs im get
# Ueberfuehren der gesammelten Werte in die globale Variable %data
for(my $j=0; $j<int(@readings); $j++) { for(my $j=0; $j<int(@readings); $j++) {
my $k = $j+1; my $k = $j+1;
$data{"min$k"} = $min[$j]; $data{"min$k"} = $min[$j];
@ -3557,7 +3586,7 @@ sub DbLog_Get($@) {
$data{"maxdate$k"} = $maxd[$j]; $data{"maxdate$k"} = $maxd[$j];
} }
#cleanup (plotfork) connection # cleanup (plotfork) connection
# $dbh->disconnect() if( $hash->{PID} != $$ ); # $dbh->disconnect() if( $hash->{PID} != $$ );
$dbh->disconnect() if($nh || $hash->{PID} != $$); $dbh->disconnect() if($nh || $hash->{PID} != $$);
@ -4367,7 +4396,13 @@ sub DbLog_AddLog($$$$$) {
Log3 $name, 2, "DbLog $name -> error valueFn: ".$@ if($@); Log3 $name, 2, "DbLog $name -> error valueFn: ".$@ if($@);
next if($IGNORE); # aktueller Event wird nicht geloggt wenn $IGNORE=1 gesetzt in $value_fn next if($IGNORE); # aktueller Event wird nicht geloggt wenn $IGNORE=1 gesetzt in $value_fn
$ts = $TIMESTAMP if($TIMESTAMP =~ /^(\d{4})-(\d{2})-(\d{2} \d{2}):(\d{2}):(\d{2})$/); my ($yyyy, $mm, $dd, $hh, $min, $sec) = ($TIMESTAMP =~ /(\d+)-(\d+)-(\d+) (\d+):(\d+):(\d+)/);
eval { my $epoch_seconds_begin = timelocal($sec, $min, $hh, $dd, $mm-1, $yyyy-1900); };
if (!$@) {
$ts = $TIMESTAMP;
} else {
Log3 ($name, 2, "DbLog $name -> Parameter TIMESTAMP got from valueFn is invalid: $TIMESTAMP");
}
$dev_name = $DEVICE if($DEVICE ne ''); $dev_name = $DEVICE if($DEVICE ne '');
$dev_type = $DEVICETYPE if($DEVICETYPE ne ''); $dev_type = $DEVICETYPE if($DEVICETYPE ne '');
$dev_reading = $READING if($READING ne ''); $dev_reading = $READING if($READING ne '');
@ -4390,10 +4425,10 @@ sub DbLog_AddLog($$$$$) {
if($async) { if($async) {
# asynchoner non-blocking Mode # asynchoner non-blocking Mode
# Cache & CacheIndex für Events zum asynchronen Schreiben in DB # Cache & CacheIndex für Events zum asynchronen Schreiben in DB
$hash->{cache}{index}++; $data{DbLog}{$name}{cache}{index}++;
my $index = $hash->{cache}{index}; my $index = $data{DbLog}{$name}{cache}{index};
$hash->{cache}{".memcache"}{$index} = $row; $data{DbLog}{$name}{cache}{memcache}{$index} = $row;
my $memcount = $hash->{cache}{".memcache"}?scalar(keys%{$hash->{cache}{".memcache"}}):0; my $memcount = $data{DbLog}{$name}{cache}{memcache}?scalar(keys %{$data{DbLog}{$name}{cache}{memcache}}):0;
if($ce == 1) { if($ce == 1) {
readingsSingleUpdate($hash, "CacheUsage", $memcount, 1); readingsSingleUpdate($hash, "CacheUsage", $memcount, 1);
} else { } else {
@ -4477,11 +4512,11 @@ sub DbLog_addCacheLine($$$$$$$$) {
use warnings; use warnings;
eval { # one transaction eval { # one transaction
$hash->{cache}{index}++; $data{DbLog}{$name}{cache}{index}++;
my $index = $hash->{cache}{index}; my $index = $data{DbLog}{$name}{cache}{index};
$hash->{cache}{".memcache"}{$index} = $row; $data{DbLog}{$name}{cache}{memcache}{$index} = $row;
my $memcount = $hash->{cache}{".memcache"}?scalar(keys%{$hash->{cache}{".memcache"}}):0; my $memcount = $data{DbLog}{$name}{cache}{memcache}?scalar(keys %{$data{DbLog}{$name}{cache}{memcache}}):0;
if($ce == 1) { if($ce == 1) {
readingsSingleUpdate($hash, "CacheUsage", $memcount, 1); readingsSingleUpdate($hash, "CacheUsage", $memcount, 1);
} else { } else {
@ -5890,7 +5925,7 @@ sub DbLog_setVersionInfo($) {
if($modules{$type}{META}{x_prereqs_src} && !$hash->{HELPER}{MODMETAABSENT}) { if($modules{$type}{META}{x_prereqs_src} && !$hash->{HELPER}{MODMETAABSENT}) {
# META-Daten sind vorhanden # META-Daten sind vorhanden
$modules{$type}{META}{version} = "v".$v; # Version aus META.json überschreiben, Anzeige mit {Dumper $modules{SMAPortal}{META}} $modules{$type}{META}{version} = "v".$v; # Version aus META.json überschreiben, Anzeige mit {Dumper $modules{DbLog}{META}}
if($modules{$type}{META}{x_version}) { # {x_version} ( nur gesetzt wenn $Id$ im Kopf komplett! vorhanden ) if($modules{$type}{META}{x_version}) { # {x_version} ( nur gesetzt wenn $Id$ im Kopf komplett! vorhanden )
$modules{$type}{META}{x_version} =~ s/1.1.1/$v/g; $modules{$type}{META}{x_version} =~ s/1.1.1/$v/g;
} else { } else {
@ -5938,7 +5973,7 @@ sub DbLog_showChildHandles ($$$$) {
my $t = $h->{Type}."h"; my $t = $h->{Type}."h";
$t = ($t=~/drh/)?"DriverHandle ":($t=~/dbh/)?"DatabaseHandle ":($t=~/sth/)?"StatementHandle":"Undefined"; $t = ($t=~/drh/)?"DriverHandle ":($t=~/dbh/)?"DatabaseHandle ":($t=~/sth/)?"StatementHandle":"Undefined";
Log3($name, 1, "DbLog - traceHandles (system wide) - Driver: ".$key.", ".$t.": ".("\t" x $level).$h); Log3($name, 1, "DbLog $name - traceHandles (system wide) - Driver: ".$key.", ".$t.": ".("\t" x $level).$h);
DbLog_showChildHandles($name, $_, $level + 1, $key) DbLog_showChildHandles($name, $_, $level + 1, $key)
for (grep { defined } @{$h->{ChildHandles}}); for (grep { defined } @{$h->{ChildHandles}});
} }
@ -6847,6 +6882,7 @@ attr SMA_Energymeter DbLogValueFn
} }
if ($READING =~ /Einspeisung_Wirkleistung_Zaehler/ && $VALUE < 2){ if ($READING =~ /Einspeisung_Wirkleistung_Zaehler/ && $VALUE < 2){
$IGNORE=1; $IGNORE=1;
}
} }
</pre> </pre>
</ul> </ul>
@ -7077,7 +7113,7 @@ attr SMA_Energymeter DbLogValueFn
<li><b>timeout</b> <li><b>timeout</b>
<ul> <ul>
<code> <code>
attr &lt;device&gt; timeout <n> attr &lt;device&gt; timeout &lt;n&gt;
</code><br> </code><br>
setup timeout of the write cycle into database in asynchronous mode (default 86400s) <br> setup timeout of the write cycle into database in asynchronous mode (default 86400s) <br>
</ul> </ul>
@ -7090,7 +7126,7 @@ attr SMA_Energymeter DbLogValueFn
<li><b>traceFlag</b> <li><b>traceFlag</b>
<ul> <ul>
<code> <code>
attr &lt;device&gt; traceFlag [ALL|SQL|CON|ENC|DBD|TXN] <n> attr &lt;device&gt; traceFlag &lt;ALL|SQL|CON|ENC|DBD|TXN&gt;
</code><br> </code><br>
Trace flags are used to enable tracing of specific activities within the DBI and drivers. The attribute is only used for Trace flags are used to enable tracing of specific activities within the DBI and drivers. The attribute is only used for
tracing of errors in case of support. <br><br> tracing of errors in case of support. <br><br>
@ -7122,7 +7158,7 @@ attr SMA_Energymeter DbLogValueFn
</code><br> </code><br>
If set, every &lt;n&gt; seconds the system wide existing database handles are printed out into the logfile. If set, every &lt;n&gt; seconds the system wide existing database handles are printed out into the logfile.
This attribute is only relevant for support cases. (default: 0 = switch off) <br> This attribute is only relevant in case of support. (default: 0 = switch off) <br>
</ul> </ul>
</li> </li>
@ -7134,7 +7170,7 @@ attr SMA_Energymeter DbLogValueFn
<li><b>traceLevel</b> <li><b>traceLevel</b>
<ul> <ul>
<code> <code>
attr &lt;device&gt; traceLevel [0|1|2|3|4|5|6|7] <n> attr &lt;device&gt; traceLevel &lt;0|1|2|3|4|5|6|7&gt;
</code><br> </code><br>
Switch on the tracing function of the module. <br> Switch on the tracing function of the module. <br>
<b>Caution !</b> The attribute is only used for tracing errors or in case of support. If switched on <b>very much entries</b> <b>Caution !</b> The attribute is only used for tracing errors or in case of support. If switched on <b>very much entries</b>
@ -8206,6 +8242,7 @@ attr SMA_Energymeter DbLogValueFn
} }
if ($READING =~ /Einspeisung_Wirkleistung_Zaehler/ && $VALUE < 2){ if ($READING =~ /Einspeisung_Wirkleistung_Zaehler/ && $VALUE < 2){
$IGNORE=1; $IGNORE=1;
}
} }
</pre> </pre>
</ul> </ul>
@ -8436,7 +8473,7 @@ attr SMA_Energymeter DbLogValueFn
<li><b>timeout</b> <li><b>timeout</b>
<ul> <ul>
<code> <code>
attr &lt;device&gt; timeout <n> attr &lt;device&gt; timeout &lt;n&gt;
</code><br> </code><br>
Setzt den Timeout-Wert für den Schreibzyklus in die Datenbank im asynchronen Modus (default 86400s). <br> Setzt den Timeout-Wert für den Schreibzyklus in die Datenbank im asynchronen Modus (default 86400s). <br>
</ul> </ul>
@ -8449,7 +8486,7 @@ attr SMA_Energymeter DbLogValueFn
<li><b>traceFlag</b> <li><b>traceFlag</b>
<ul> <ul>
<code> <code>
attr &lt;device&gt; traceFlag [ALL|SQL|CON|ENC|DBD|TXN] <n> attr &lt;device&gt; traceFlag &lt;ALL|SQL|CON|ENC|DBD|TXN&gt;
</code><br> </code><br>
Bestimmt das Tracing von bestimmten Aktivitäten innerhalb des Datenbankinterfaces und Treibers. Das Attribut ist nur Bestimmt das Tracing von bestimmten Aktivitäten innerhalb des Datenbankinterfaces und Treibers. Das Attribut ist nur
für den Fehler- bzw. Supportfall gedacht. <br><br> für den Fehler- bzw. Supportfall gedacht. <br><br>
@ -8493,7 +8530,7 @@ attr SMA_Energymeter DbLogValueFn
<li><b>traceLevel</b> <li><b>traceLevel</b>
<ul> <ul>
<code> <code>
attr &lt;device&gt; traceLevel [0|1|2|3|4|5|6|7] <n> attr &lt;device&gt; traceLevel &lt;0|1|2|3|4|5|6|7&gt;
</code><br> </code><br>
Schaltet die Trace-Funktion des Moduls ein. <br> Schaltet die Trace-Funktion des Moduls ein. <br>
<b>Achtung !</b> Das Attribut ist nur für den Fehler- bzw. Supportfall gedacht. Es werden <b>sehr viele Einträge</b> in <b>Achtung !</b> Das Attribut ist nur für den Fehler- bzw. Supportfall gedacht. Es werden <b>sehr viele Einträge</b> in
@ -8636,7 +8673,9 @@ attr SMA_Energymeter DbLogValueFn
"Encode": 0 "Encode": 0
}, },
"recommends": { "recommends": {
"FHEM::Meta": 0 "FHEM::Meta": 0,
"Devel::Size": 0,
"Data::Peek": 0
}, },
"suggests": { "suggests": {
"DBD::Pg" :0, "DBD::Pg" :0,