From c981bff9b2e94c7cc08f2742b35a270edf235356 Mon Sep 17 00:00:00 2001 From: nasseeder1 Date: Sun, 22 Oct 2023 14:22:29 +0000 Subject: [PATCH] 93_DbLog: new attribute colType git-svn-id: https://svn.fhem.de/fhem/trunk@28085 2b470e98-0d58-463d-a4d8-8e2adae1ed80 --- fhem/CHANGED | 1 + fhem/FHEM/93_DbLog.pm | 114 +++++++++------ fhem/contrib/DS_Starter/93_DbLog.pm | 212 ++++++++++++++++++---------- 3 files changed, 208 insertions(+), 119 deletions(-) diff --git a/fhem/CHANGED b/fhem/CHANGED index dcd20d76b..1c96b5357 100644 --- a/fhem/CHANGED +++ b/fhem/CHANGED @@ -1,5 +1,6 @@ # Add changes at the top of the list. Keep it in ASCII, and 80-char wide. # Do not insert empty lines here, update check depends on it. + - feature: 93_DbLog: new attribute colType - feature: 76_SolarForecast: design options for graphicHeaderOwnspec - feature: 76_SolarForecast: new attr ctrlGenPVdeviation - feature: 70_ESCVP21net: add reading stateP for on/off diff --git a/fhem/FHEM/93_DbLog.pm b/fhem/FHEM/93_DbLog.pm index eafe255d8..54a52fea8 100644 --- a/fhem/FHEM/93_DbLog.pm +++ b/fhem/FHEM/93_DbLog.pm @@ -56,6 +56,7 @@ no if $] >= 5.017011, warnings => 'experimental::smartmatch'; # Version History intern by DS_Starter: my %DbLog_vNotesIntern = ( + "5.9.3" => "09.10.2023 new attribute colType ", "5.9.2" => "09.10.2023 edit commandref, Forum: https://forum.fhem.de/index.php?msg=1288840 ", "5.9.1" => "15.08.2023 possible use of alternative tables in _DbLog_plotData Forum:134547, fix warnings in ". "_DbLog_SBP_onRun_LogSequential Forum:https://forum.fhem.de/index.php?msg=1284228 ", @@ -211,6 +212,7 @@ sub DbLog_Initialize { "cacheOverflowThreshold ". "colEvent ". "colReading ". + "colType ". "colValue ". "convertTimezone:UTC,none ". "DbLogSelectionMode:Exclude,Include,Exclude/Include ". @@ -484,12 +486,12 @@ sub DbLog_Attr { } } - if($aName eq "colEvent" || $aName eq "colReading" || $aName eq "colValue") { + if($aName =~ /^col[ERTV]/xs) { if ($cmd eq "set" && $aVal) { unless ($aVal =~ /^[0-9]+$/) { return " The Value of $aName is not valid. Use only figures 0-9 !";} } - if ($init_done == 1) { + if ($init_done) { InternalTimer(gettimeofday()+0.8, "DbLog_setinternalcols", $hash, 0); } } @@ -1508,7 +1510,7 @@ sub DbLog_Log { } # Daten auf maximale Länge beschneiden - ($dev_name,$dev_type,$event,$reading,$value,$unit) = DbLog_cutCol($hash,$dev_name,$dev_type,$event,$reading,$value,$unit); + ($dev_name,$dev_type,$event,$reading,$value,$unit) = DbLog_cutCol ($hash, $dev_name, $dev_type, $event, $reading, $value, $unit); my $row = $timestamp."|".$dev_name."|".$dev_type."|".$event."|".$reading."|".$value."|".$unit; @@ -7446,11 +7448,11 @@ sub DbLog_configcheck { $rec .= "UNIT: $DbLog_columns{UNIT}

"; $rec .= "You can change the column width in database by a statement like 'alter table $history modify VALUE varchar(128);' (example for changing field 'VALUE'). "; $rec .= "You can do it for example by executing 'sqlCmd' in DbRep or in a SQL-Editor of your choice. (switch $name to asynchron mode for non-blocking).
"; - $rec .= "Alternatively the field width used by $name can be adjusted by setting attributes 'colEvent', 'colReading', 'colValue'. (pls. refer to commandref)"; + $rec .= "Alternatively the field width used by $name can be adjusted by setting attributes 'colEvent', 'colReading', 'colType', 'colValue'. (pls. refer to commandref)"; } else { $rec = "WARNING - The relation between column width in table $history and the field width used by device $name should be equal but it differs."; - $rec .= "The field width used by $name can be adjusted by setting attributes 'colEvent', 'colReading', 'colValue'. (pls. refer to commandref)"; + $rec .= "The field width used by $name can be adjusted by setting attributes 'colEvent', 'colReading', 'colType', 'colValue'. (pls. refer to commandref)"; $rec .= "Because you use SQLite this is only a warning. Normally the database can handle these differences. "; } } @@ -7548,11 +7550,11 @@ sub DbLog_configcheck { $rec .= "UNIT: $DbLog_columns{UNIT}

"; $rec .= "You can change the column width in database by a statement like 'alter table $current modify VALUE varchar(128);' (example for changing field 'VALUE'). "; $rec .= "You can do it for example by executing 'sqlCmd' in DbRep or in a SQL-Editor of your choice. (switch $name to asynchron mode for non-blocking).
"; - $rec .= "Alternatively the field width used by $name can be adjusted by setting attributes 'colEvent', 'colReading', 'colValue'. (pls. refer to commandref)"; + $rec .= "Alternatively the field width used by $name can be adjusted by setting attributes 'colEvent', 'colReading', 'colType', 'colValue'. (pls. refer to commandref)"; } else { $rec = "WARNING - The relation between column width in table $current and the field width used by device $name should be equal but it differs. "; - $rec .= "The field width used by $name can be adjusted by setting attributes 'colEvent', 'colReading', 'colValue'. (pls. refer to commandref)"; + $rec .= "The field width used by $name can be adjusted by setting attributes 'colEvent', 'colReading', 'colType', 'colValue'. (pls. refer to commandref)"; $rec .= "Because you use SQLite this is only a warning. Normally the database can handle these differences. "; } } @@ -8113,7 +8115,7 @@ sub DbLog_AddLog { } # Daten auf maximale Länge beschneiden - ($dev_name,$dev_type,$event,$dev_reading,$read_val,$ut) = DbLog_cutCol($hash,$dev_name,$dev_type,$event,$dev_reading,$read_val,$ut); + ($dev_name,$dev_type,$event,$dev_reading,$read_val,$ut) = DbLog_cutCol ($hash, $dev_name, $dev_type, $event, $dev_reading, $read_val, $ut); if (AttrVal($name, 'useCharfilter', 0)) { $dev_reading = DbLog_charfilter($dev_reading); @@ -8227,7 +8229,7 @@ sub DbLog_addCacheLine { } no warnings 'uninitialized'; # Daten auf maximale Länge beschneiden - ($i_dev,$i_type,$i_evt,$i_reading,$i_val,$i_unit) = DbLog_cutCol ($hash,$i_dev,$i_type,$i_evt,$i_reading,$i_val,$i_unit); + ($i_dev,$i_type,$i_evt,$i_reading,$i_val,$i_unit) = DbLog_cutCol ($hash, $i_dev, $i_type, $i_evt, $i_reading, $i_val, $i_unit); my $row = $i_timestamp."|".$i_dev."|".$i_type."|".$i_evt."|".$i_reading."|".$i_val."|".$i_unit; $row = DbLog_charfilter($row) if(AttrVal($name, "useCharfilter",0)); @@ -8254,12 +8256,14 @@ return; ######################################################################################### sub DbLog_cutCol { my ($hash,$dn,$dt,$evt,$rd,$val,$unit) = @_; + my $name = $hash->{NAME}; - my $colevent = AttrVal($name, 'colEvent', undef); - my $colreading = AttrVal($name, 'colReading', undef); - my $colvalue = AttrVal($name, 'colValue', undef); + my $colevent = AttrVal ($name, 'colEvent', undef); + my $colreading = AttrVal ($name, 'colReading', undef); + my $coltype = AttrVal ($name, 'colType', undef); + my $colvalue = AttrVal ($name, 'colValue', undef); - if ($hash->{MODEL} ne 'SQLITE' || defined($colevent) || defined($colreading) || defined($colvalue) ) { + if ($hash->{MODEL} ne 'SQLITE' || defined($colevent) || defined($colreading) || defined($coltype) || defined($colvalue) ) { $dn = substr($dn, 0, $hash->{HELPER}{DEVICECOL}); $dt = substr($dt, 0, $hash->{HELPER}{TYPECOL}); $evt = substr($evt, 0, $hash->{HELPER}{EVENTCOL}); @@ -8348,18 +8352,16 @@ return @v; ################################################################ sub DbLog_setinternalcols { my $hash = shift; - my $name = $hash->{NAME}; $hash->{HELPER}{DEVICECOL} = $DbLog_columns{DEVICE}; - $hash->{HELPER}{TYPECOL} = $DbLog_columns{TYPE}; - $hash->{HELPER}{EVENTCOL} = AttrVal($name, "colEvent", $DbLog_columns{EVENT} ); - $hash->{HELPER}{READINGCOL} = AttrVal($name, "colReading", $DbLog_columns{READING}); - $hash->{HELPER}{VALUECOL} = AttrVal($name, "colValue", $DbLog_columns{VALUE} ); + $hash->{HELPER}{TYPECOL} = AttrVal($name, 'colType', $DbLog_columns{TYPE}); + $hash->{HELPER}{EVENTCOL} = AttrVal($name, 'colEvent', $DbLog_columns{EVENT}); + $hash->{HELPER}{READINGCOL} = AttrVal($name, 'colReading', $DbLog_columns{READING}); + $hash->{HELPER}{VALUECOL} = AttrVal($name, 'colValue', $DbLog_columns{VALUE}); $hash->{HELPER}{UNITCOL} = $DbLog_columns{UNIT}; - $hash->{COLUMNS} = "field length used for Device: $hash->{HELPER}{DEVICECOL}, Type: $hash->{HELPER}{TYPECOL}, Event: $hash->{HELPER}{EVENTCOL}, Reading: $hash->{HELPER}{READINGCOL}, Value: $hash->{HELPER}{VALUECOL}, Unit: $hash->{HELPER}{UNITCOL} "; - + $hash->{COLUMNS} = "field length used for Device: $hash->{HELPER}{DEVICECOL}, Type: $hash->{HELPER}{TYPECOL}, Event: $hash->{HELPER}{EVENTCOL}, Reading: $hash->{HELPER}{READINGCOL}, Value: $hash->{HELPER}{VALUECOL}, Unit: $hash->{HELPER}{UNITCOL} "; $hash->{HELPER}{COLSET} = 1; # Statusbit "Columns sind gesetzt" return; @@ -9907,11 +9909,11 @@ return;
  • colEvent <n>

  • @@ -9922,11 +9924,26 @@ return;
  • colReading <n>

    +
  • + +
    + + @@ -9937,11 +9954,11 @@ return;
  • colValue <n>

  • @@ -11784,10 +11801,10 @@ attr SMA_Energymeter DbLogValueFn @@ -11799,10 +11816,25 @@ attr SMA_Energymeter DbLogValueFn + + +
    + + @@ -11814,10 +11846,10 @@ attr SMA_Energymeter DbLogValueFn diff --git a/fhem/contrib/DS_Starter/93_DbLog.pm b/fhem/contrib/DS_Starter/93_DbLog.pm index 1f1e35b0c..7df33c471 100644 --- a/fhem/contrib/DS_Starter/93_DbLog.pm +++ b/fhem/contrib/DS_Starter/93_DbLog.pm @@ -1,6 +1,6 @@ -############################################################################################################################################ -# $Id: 93_DbLog.pm 27617 2023-05-25 19:56:44Z DS_Starter $ -# +############################################################################################################################## +# $Id: 93_DbLog.pm 28036 2023-10-09 14:35:59Z DS_Starter $ +############################################################################################################################## # 93_DbLog.pm # written by Dr. Boris Neubert 2007-12-30 # e-mail: omega at online dot de @@ -12,12 +12,29 @@ # e-mail: heiko dot maaz at t-online dot de # # reduceLog() created by Claudiu Schuster (rapster) adapted by DS_Starter +# +# This script is part of fhem. # -############################################################################################################################################ +# Fhem is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 2 of the License, or +# (at your option) any later version. +# +# Fhem is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with fhem. If not, see . +# +# This copyright notice MUST APPEAR in all copies of the script! +# +############################################################################################################################## # # Leerzeichen entfernen: sed -i 's/[[:space:]]*$//' 93_DbLog.pm # -############################################################################################################################################ +############################################################################################################################## package main; use strict; @@ -39,7 +56,10 @@ no if $] >= 5.017011, warnings => 'experimental::smartmatch'; # Version History intern by DS_Starter: my %DbLog_vNotesIntern = ( - "5.9.1" => "14.08.2023 possible use of alternative tables in _DbLog_plotData Forum:134547 ", + "5.9.3" => "09.10.2023 new attribute colType ", + "5.9.2" => "09.10.2023 edit commandref, Forum: https://forum.fhem.de/index.php?msg=1288840 ", + "5.9.1" => "15.08.2023 possible use of alternative tables in _DbLog_plotData Forum:134547, fix warnings in ". + "_DbLog_SBP_onRun_LogSequential Forum:https://forum.fhem.de/index.php?msg=1284228 ", "5.9.0" => "16.05.2023 Server shutdown -> write cachefile if database connect can't be done during delayed shutdown ". "Forum: https://forum.fhem.de/index.php?topic=133599.0 ", "5.8.8" => "11.05.2023 _DbLog_ParseEvent changed default splitting, Forum: https://forum.fhem.de/index.php?topic=133537.0 ", @@ -192,6 +212,7 @@ sub DbLog_Initialize { "cacheOverflowThreshold ". "colEvent ". "colReading ". + "colType ". "colValue ". "convertTimezone:UTC,none ". "DbLogSelectionMode:Exclude,Include,Exclude/Include ". @@ -465,12 +486,12 @@ sub DbLog_Attr { } } - if($aName eq "colEvent" || $aName eq "colReading" || $aName eq "colValue") { + if($aName =~ /^col[ERTV]/xs) { if ($cmd eq "set" && $aVal) { unless ($aVal =~ /^[0-9]+$/) { return " The Value of $aName is not valid. Use only figures 0-9 !";} } - if ($init_done == 1) { + if ($init_done) { InternalTimer(gettimeofday()+0.8, "DbLog_setinternalcols", $hash, 0); } } @@ -1489,7 +1510,7 @@ sub DbLog_Log { } # Daten auf maximale Länge beschneiden - ($dev_name,$dev_type,$event,$reading,$value,$unit) = DbLog_cutCol($hash,$dev_name,$dev_type,$event,$reading,$value,$unit); + ($dev_name,$dev_type,$event,$reading,$value,$unit) = DbLog_cutCol ($hash, $dev_name, $dev_type, $event, $reading, $value, $unit); my $row = $timestamp."|".$dev_name."|".$dev_type."|".$event."|".$reading."|".$value."|".$unit; @@ -2851,11 +2872,12 @@ sub _DbLog_SBP_onRun_LogSequential { ); } - my $faref = __DbLog_SBP_fieldArrays ($name, $cdata, $subprocess); # Feldarrays erstellen mit Logausgabe - my $ceti = scalar keys %{$cdata}; - my $rv = 0; + my $faref = __DbLog_SBP_fieldArrays ($name, $cdata, $subprocess); # Feldarrays erstellen mit Logausgabe + my $ceti = scalar keys %{$cdata}; + my $ins_hist = 0; # Forum: https://forum.fhem.de/index.php?msg=1284228 + my $rv = 0; - my (@ins,$st,$sth_ih,$ins_hist); + my (@ins,$st,$sth_ih); if (lc($DbLogType) =~ m(history)) { # insert history mit/ohne primary key for my $key (sort {$a<=>$b} keys %{$cdata}) { @@ -2982,7 +3004,7 @@ sub _DbLog_SBP_onRun_LogSequential { if($ins_hist == $ceti) { _DbLog_SBP_Log3Parent ( { name => $name, level => 4, - msg => "$ins_hist of $ceti events inserted into table $history".($usepkh ? " using PK on columns $pkh" : ""), + msg => "$ins_hist of $ceti events inserted into table >$history<".($usepkh ? " using PK on columns $pkh" : ""), oper => 'log3parent', subprocess => $subprocess } @@ -2992,7 +3014,7 @@ sub _DbLog_SBP_onRun_LogSequential { if($usepkh) { _DbLog_SBP_Log3Parent ( { name => $name, level => 3, - msg => "INFO - ".$ins_hist." of $ceti events inserted into table $history due to PK on columns $pkh", + msg => "INFO - ".$ins_hist." of $ceti events inserted into table >$history< due to PK on columns $pkh", oper => 'log3parent', subprocess => $subprocess } @@ -3001,7 +3023,7 @@ sub _DbLog_SBP_onRun_LogSequential { else { _DbLog_SBP_Log3Parent ( { name => $name, level => 2, - msg => "WARNING - only ".$ins_hist." of $ceti events inserted into table $history", + msg => "WARNING - only ".$ins_hist." of $ceti events inserted into table >$history<", oper => 'log3parent', subprocess => $subprocess } @@ -7426,11 +7448,11 @@ sub DbLog_configcheck { $rec .= "UNIT: $DbLog_columns{UNIT}

    "; $rec .= "You can change the column width in database by a statement like 'alter table $history modify VALUE varchar(128);' (example for changing field 'VALUE'). "; $rec .= "You can do it for example by executing 'sqlCmd' in DbRep or in a SQL-Editor of your choice. (switch $name to asynchron mode for non-blocking).
    "; - $rec .= "Alternatively the field width used by $name can be adjusted by setting attributes 'colEvent', 'colReading', 'colValue'. (pls. refer to commandref)"; + $rec .= "Alternatively the field width used by $name can be adjusted by setting attributes 'colEvent', 'colReading', 'colType', 'colValue'. (pls. refer to commandref)"; } else { $rec = "WARNING - The relation between column width in table $history and the field width used by device $name should be equal but it differs."; - $rec .= "The field width used by $name can be adjusted by setting attributes 'colEvent', 'colReading', 'colValue'. (pls. refer to commandref)"; + $rec .= "The field width used by $name can be adjusted by setting attributes 'colEvent', 'colReading', 'colType', 'colValue'. (pls. refer to commandref)"; $rec .= "Because you use SQLite this is only a warning. Normally the database can handle these differences. "; } } @@ -7528,11 +7550,11 @@ sub DbLog_configcheck { $rec .= "UNIT: $DbLog_columns{UNIT}

    "; $rec .= "You can change the column width in database by a statement like 'alter table $current modify VALUE varchar(128);' (example for changing field 'VALUE'). "; $rec .= "You can do it for example by executing 'sqlCmd' in DbRep or in a SQL-Editor of your choice. (switch $name to asynchron mode for non-blocking).
    "; - $rec .= "Alternatively the field width used by $name can be adjusted by setting attributes 'colEvent', 'colReading', 'colValue'. (pls. refer to commandref)"; + $rec .= "Alternatively the field width used by $name can be adjusted by setting attributes 'colEvent', 'colReading', 'colType', 'colValue'. (pls. refer to commandref)"; } else { $rec = "WARNING - The relation between column width in table $current and the field width used by device $name should be equal but it differs. "; - $rec .= "The field width used by $name can be adjusted by setting attributes 'colEvent', 'colReading', 'colValue'. (pls. refer to commandref)"; + $rec .= "The field width used by $name can be adjusted by setting attributes 'colEvent', 'colReading', 'colType', 'colValue'. (pls. refer to commandref)"; $rec .= "Because you use SQLite this is only a warning. Normally the database can handle these differences. "; } } @@ -8093,7 +8115,7 @@ sub DbLog_AddLog { } # Daten auf maximale Länge beschneiden - ($dev_name,$dev_type,$event,$dev_reading,$read_val,$ut) = DbLog_cutCol($hash,$dev_name,$dev_type,$event,$dev_reading,$read_val,$ut); + ($dev_name,$dev_type,$event,$dev_reading,$read_val,$ut) = DbLog_cutCol ($hash, $dev_name, $dev_type, $event, $dev_reading, $read_val, $ut); if (AttrVal($name, 'useCharfilter', 0)) { $dev_reading = DbLog_charfilter($dev_reading); @@ -8207,7 +8229,7 @@ sub DbLog_addCacheLine { } no warnings 'uninitialized'; # Daten auf maximale Länge beschneiden - ($i_dev,$i_type,$i_evt,$i_reading,$i_val,$i_unit) = DbLog_cutCol ($hash,$i_dev,$i_type,$i_evt,$i_reading,$i_val,$i_unit); + ($i_dev,$i_type,$i_evt,$i_reading,$i_val,$i_unit) = DbLog_cutCol ($hash, $i_dev, $i_type, $i_evt, $i_reading, $i_val, $i_unit); my $row = $i_timestamp."|".$i_dev."|".$i_type."|".$i_evt."|".$i_reading."|".$i_val."|".$i_unit; $row = DbLog_charfilter($row) if(AttrVal($name, "useCharfilter",0)); @@ -8234,12 +8256,14 @@ return; ######################################################################################### sub DbLog_cutCol { my ($hash,$dn,$dt,$evt,$rd,$val,$unit) = @_; + my $name = $hash->{NAME}; - my $colevent = AttrVal($name, 'colEvent', undef); - my $colreading = AttrVal($name, 'colReading', undef); - my $colvalue = AttrVal($name, 'colValue', undef); + my $colevent = AttrVal ($name, 'colEvent', undef); + my $colreading = AttrVal ($name, 'colReading', undef); + my $coltype = AttrVal ($name, 'colType', undef); + my $colvalue = AttrVal ($name, 'colValue', undef); - if ($hash->{MODEL} ne 'SQLITE' || defined($colevent) || defined($colreading) || defined($colvalue) ) { + if ($hash->{MODEL} ne 'SQLITE' || defined($colevent) || defined($colreading) || defined($coltype) || defined($colvalue) ) { $dn = substr($dn, 0, $hash->{HELPER}{DEVICECOL}); $dt = substr($dt, 0, $hash->{HELPER}{TYPECOL}); $evt = substr($evt, 0, $hash->{HELPER}{EVENTCOL}); @@ -8328,18 +8352,16 @@ return @v; ################################################################ sub DbLog_setinternalcols { my $hash = shift; - my $name = $hash->{NAME}; $hash->{HELPER}{DEVICECOL} = $DbLog_columns{DEVICE}; - $hash->{HELPER}{TYPECOL} = $DbLog_columns{TYPE}; - $hash->{HELPER}{EVENTCOL} = AttrVal($name, "colEvent", $DbLog_columns{EVENT} ); - $hash->{HELPER}{READINGCOL} = AttrVal($name, "colReading", $DbLog_columns{READING}); - $hash->{HELPER}{VALUECOL} = AttrVal($name, "colValue", $DbLog_columns{VALUE} ); + $hash->{HELPER}{TYPECOL} = AttrVal($name, 'colType', $DbLog_columns{TYPE}); + $hash->{HELPER}{EVENTCOL} = AttrVal($name, 'colEvent', $DbLog_columns{EVENT}); + $hash->{HELPER}{READINGCOL} = AttrVal($name, 'colReading', $DbLog_columns{READING}); + $hash->{HELPER}{VALUECOL} = AttrVal($name, 'colValue', $DbLog_columns{VALUE}); $hash->{HELPER}{UNITCOL} = $DbLog_columns{UNIT}; - $hash->{COLUMNS} = "field length used for Device: $hash->{HELPER}{DEVICECOL}, Type: $hash->{HELPER}{TYPECOL}, Event: $hash->{HELPER}{EVENTCOL}, Reading: $hash->{HELPER}{READINGCOL}, Value: $hash->{HELPER}{VALUECOL}, Unit: $hash->{HELPER}{UNITCOL} "; - + $hash->{COLUMNS} = "field length used for Device: $hash->{HELPER}{DEVICECOL}, Type: $hash->{HELPER}{TYPECOL}, Event: $hash->{HELPER}{EVENTCOL}, Reading: $hash->{HELPER}{READINGCOL}, Value: $hash->{HELPER}{VALUECOL}, Unit: $hash->{HELPER}{UNITCOL} "; $hash->{HELPER}{COLSET} = 1; # Statusbit "Columns sind gesetzt" return; @@ -8665,13 +8687,13 @@ sub DbLog_setVersionInfo { if($modules{$type}{META}{x_prereqs_src} && !$hash->{HELPER}{MODMETAABSENT}) { # META-Daten sind vorhanden $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: 93_DbLog.pm 27617 2023-05-25 19:56:44Z DS_Starter $ im Kopf komplett! vorhanden ) + if($modules{$type}{META}{x_version}) { # {x_version} ( nur gesetzt wenn $Id: 93_DbLog.pm 28036 2023-10-09 14:35:59Z DS_Starter $ im Kopf komplett! vorhanden ) $modules{$type}{META}{x_version} =~ s/1\.1\.1/$v/xsg; } else { $modules{$type}{META}{x_version} = $v; } - return $@ unless (FHEM::Meta::SetInternals($hash)); # FVERSION wird gesetzt ( nur gesetzt wenn $Id: 93_DbLog.pm 27617 2023-05-25 19:56:44Z DS_Starter $ im Kopf komplett! vorhanden ) + return $@ unless (FHEM::Meta::SetInternals($hash)); # FVERSION wird gesetzt ( nur gesetzt wenn $Id: 93_DbLog.pm 28036 2023-10-09 14:35:59Z DS_Starter $ im Kopf komplett! vorhanden ) if(__PACKAGE__ eq "FHEM::$type" || __PACKAGE__ eq $type) { # es wird mit Packages gearbeitet -> Perl übliche Modulversion setzen # mit {->VERSION()} im FHEMWEB kann Modulversion abgefragt werden @@ -8794,13 +8816,10 @@ return;
    For the connection to the database a configuration file is used. - The configuration is stored in a separate file to avoid storing the password in the main configuration file and to have it - visible in the output of the list command. + The configuration file is copied e.g. to /opt/fhem and has the structure shown below. + The specifications are to be adapted according to the used environment (uncomment and change corresponding lines):

    - The configuration file should be copied e.g. to /opt/fhem and has the following structure you have to customize - suitable to your conditions (decomment the appropriate raws and adjust it):

    -
         ####################################################################################
         # database configuration file
    @@ -8814,6 +8833,8 @@ return;
         ####################################################################################
         #%dbconfig= (
         #    connection => "mysql:database=fhem;host=<database host>;port=3306",
    +    #    # if want communication over socket-file instead of TCP/IP transport, use:
    +    #    # connection => "mysql:database=fhem;mysql_socket=</patch/socket-file>",
         #    user => "fhemuser",
         #    password => "fhempassword",
         #    # optional enable(1) / disable(0) UTF-8 support
    @@ -9464,17 +9485,21 @@ return;
       
    • get <name> <in> <out> <from> <to> <column_spec>

      - Read data from the Database used by frontends to plot data without direct - access to the Database.
      + Read data from the Database used by frontends to plot data without direct access to the Database.

      • <in>
        - A dummy parameter for FileLog compatibility. Sessing by defaultto -
        + A parameter to establish compatibility with Filelog.
        + In the definition of an SVG device this parameter corresponds to the specification of :<logfile> at the end of the definition.
        + The following characteristics are allowed:
          -
        • current: reading actual readings from table "current"
        • -
        • history: reading history readings from table "history"
        • -
        • -: identical to "history"
        • +
        • current: the values are read from the "current" table.
        • +
        • history: the values are read from the "history" table.
        • +
        • table_<table>: the values are read from the specified alternative table. The table (name) + must be created in the database with lowercase letters.
          + (example: table_energy, "energy" is the alternative table created in the database)
        • +
        • -: identical as "history

      • @@ -9884,11 +9909,11 @@ return;
      • colEvent <n>

          - The field length of database field EVENT will be adjusted. By this attribute the default value in the DbLog-device can be - adjusted if the field length in the databse was changed nanually. If colEvent=0 is set, the database field - EVENT won't be filled .
          + The field length of database field EVENT is adapted user-specifically. The attribute can be used to change the + default value in the module if the field length in the database was changed manually. + With colEvent=0 the database field EVENT is not filled.
          Note:
          - If the attribute is set, all of the field length limits are valid also for SQLite databases as noticed in Internal COLUMNS !
          + With set attribute all field length limits are also valid for SQLite DB as shown in Internal COLUMNS!
      @@ -9899,11 +9924,26 @@ return;
    • colReading <n>

        - The field length of database field READING will be adjusted. By this attribute the default value in the DbLog-device can be - adjusted if the field length in the databse was changed nanually. If colReading=0 is set, the database field - READING won't be filled .
        + The field length of database field READING is adapted user-specifically. BThe attribute can be used to change the + default value in the module if the field length in the database was changed manually. + With colReading=0 the database field READING is not filled.
        Note:
        - If the attribute is set, all of the field length limits are valid also for SQLite databases as noticed in Internal COLUMNS !
        + With set attribute all field length limits are also valid for SQLite DB as shown in Internal COLUMNS!
        +
      +
    • +
    +
    + +
      + +
    • colType <n>

      + +
        + The field length for the database field TYPE is adapted user-specifically. The attribute can be used to change the + default value in the module if the field length in the database was changed manually. + With colType=0 the database field TYPE is not filled.
        + Note:
        + With set attribute all field length limits are also valid for SQLite DB as shown in Internal COLUMNS!
    @@ -9914,11 +9954,11 @@ return;
  • colValue <n>

      - The field length of database field VALUE will be adjusted. By this attribute the default value in the DbLog-device can be - adjusted if the field length in the databse was changed nanually. If colEvent=0 is set, the database field - VALUE won't be filled .
      + The field length of database field VALUE is adapted user-specifically. The attribute can be used to change the + default value in the module if the field length in the database was changed manually. + With colValue=0 the database field VALUE is not filled.
      Note:
      - If the attribute is set, all of the field length limits are valid also for SQLite databases as noticed in Internal COLUMNS !
      + With set attribute all field length limits are also valid for SQLite DB as shown in Internal COLUMNS!
  • @@ -10650,14 +10690,10 @@ attr SMA_Energymeter DbLogValueFn enthalten.

    Für die Verbindung zur Datenbank wird eine Konfigurationsdatei verwendet. - Die Konfiguration ist in einer sparaten Datei abgelegt um das Datenbankpasswort nicht in Klartext in der - FHEM-Haupt-Konfigurationsdatei speichern zu müssen. - Ansonsten wäre es mittels des list Befehls einfach auslesbar. + Die Konfigurationsdatei wird z.B. nach /opt/fhem kopiert und hat den nachfolgend dargestellten Aufbau. + Die Angaben sind entsprechend der verwendeten Umgebung anzupassen (entsprechende Zeilen entkommentieren und ändern):

    - Die Konfigurationsdatei wird z.B. nach /opt/fhem kopiert und hat folgenden Aufbau, den man an seine Umgebung - anpassen muß (entsprechende Zeilen entkommentieren und anpassen):

    -
         ####################################################################################
         # database configuration file
    @@ -10671,6 +10707,8 @@ attr SMA_Energymeter DbLogValueFn
         ####################################################################################
         #%dbconfig= (
         #    connection => "mysql:database=fhem;host=<database host>;port=3306",
    +    #    # if want communication over socket-file instead of TCP/IP transport, use:
    +    #    # connection => "mysql:database=fhem;mysql_socket=</patch/socket-file>",
         #    user => "fhemuser",
         #    password => "fhempassword",
         #    # optional enable(1) / disable(0) UTF-8 support
    @@ -11352,13 +11390,16 @@ attr SMA_Energymeter DbLogValueFn
     
         
    • <in>
      - Ein Parameter um eine Kompatibilität zum Filelog herzustellen. - Dieser Parameter ist per default immer auf - zu setzen.
      + Ein Parameter um eine Kompatibilität zu Filelog herzustellen.
      + In der Definition eines SVG Devices entspricht dieser Paramter der Angabe von :<logfile> am Ende der Definition.
      Folgende Ausprägungen sind zugelassen:
        -
      • current: die aktuellen Werte aus der Tabelle "current" werden gelesen.
      • -
      • history: die historischen Werte aus der Tabelle "history" werden gelesen.
      • -
      • -: identisch wie "history"
      • +
      • current: die Werte werden aus der Tabelle "current" gelesen.
      • +
      • history: die Werte werden aus der Tabelle "history" gelesen.
      • +
      • table_<Tabelle>: die Werte werden aus der angegeben alternativen Tabelle gelesen. Die Tabelle (Name) + ist in der Datenbank mit Kleinbuchstaben anzulegen.
        + (Beispiel: table_energy, "energy" ist die in der Datenbank angelegte Alternativtabelle)
      • +
      • -: identisch wie "history"

    • @@ -11760,10 +11801,10 @@ attr SMA_Energymeter DbLogValueFn
        Die Feldlänge für das DB-Feld EVENT wird userspezifisch angepasst. Mit dem Attribut kann der Default-Wert im Modul - verändert werden wenn die Feldlänge in der Datenbank manuell geändert wurde. Mit colEvent=0 wird das Datenbankfeld - EVENT nicht gefüllt.
        + verändert werden wenn die Feldlänge in der Datenbank manuell geändert wurde. + Mit colEvent=0 wird das Datenbankfeld EVENT nicht gefüllt.
        Hinweis:
        - Mit gesetztem Attribut gelten alle Feldlängenbegrenzungen auch für SQLite DB wie im Internal COLUMNS angezeigt !
        + Mit gesetztem Attribut gelten alle Feldlängenbegrenzungen auch für SQLite DB wie im Internal COLUMNS angezeigt!
    @@ -11775,10 +11816,25 @@ attr SMA_Energymeter DbLogValueFn
      Die Feldlänge für das DB-Feld READING wird userspezifisch angepasst. Mit dem Attribut kann der Default-Wert im Modul - verändert werden wenn die Feldlänge in der Datenbank manuell geändert wurde. Mit colReading=0 wird das Datenbankfeld - READING nicht gefüllt.
      + verändert werden wenn die Feldlänge in der Datenbank manuell geändert wurde. + Mit colReading=0 wird das Datenbankfeld READING nicht gefüllt.
      Hinweis:
      - Mit gesetztem Attribut gelten alle Feldlängenbegrenzungen auch für SQLite DB wie im Internal COLUMNS angezeigt !
      + Mit gesetztem Attribut gelten alle Feldlängenbegrenzungen auch für SQLite DB wie im Internal COLUMNS angezeigt!
      +
    + + +
    + +
      + +
    • colType <n>

      + +
        + Die Feldlänge für das DB-Feld TYPE wird userspezifisch angepasst. Mit dem Attribut kann der Default-Wert im Modul + verändert werden wenn die Feldlänge in der Datenbank manuell geändert wurde. + Mit colType=0 wird das Datenbankfeld TYPE nicht gefüllt.
        + Hinweis:
        + Mit gesetztem Attribut gelten alle Feldlängenbegrenzungen auch für SQLite DB wie im Internal COLUMNS angezeigt!
    @@ -11790,10 +11846,10 @@ attr SMA_Energymeter DbLogValueFn
      Die Feldlänge für das DB-Feld VALUE wird userspezifisch angepasst. Mit dem Attribut kann der Default-Wert im Modul - verändert werden wenn die Feldlänge in der Datenbank manuell geändert wurde. Mit colValue=0 wird das Datenbankfeld - VALUE nicht gefüllt.
      + verändert werden wenn die Feldlänge in der Datenbank manuell geändert wurde. + Mit colValue=0 wird das Datenbankfeld VALUE nicht gefüllt.
      Hinweis:
      - Mit gesetztem Attribut gelten alle Feldlängenbegrenzungen auch für SQLite DB wie im Internal COLUMNS angezeigt !
      + Mit gesetztem Attribut gelten alle Feldlängenbegrenzungen auch für SQLite DB wie im Internal COLUMNS angezeigt!