mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-04-07 19:04:20 +00:00
93_DbLog: new attribute colType
git-svn-id: https://svn.fhem.de/fhem/trunk@28085 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
3f301ce872
commit
c981bff9b2
@ -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
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
@ -7446,11 +7448,11 @@ sub DbLog_configcheck {
|
||||
$rec .= "UNIT: $DbLog_columns{UNIT} <br><br>";
|
||||
$rec .= "You can change the column width in database by a statement like <b>'alter table $history modify VALUE varchar(128);</b>' (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). <br>";
|
||||
$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} <br><br>";
|
||||
$rec .= "You can change the column width in database by a statement like <b>'alter table $current modify VALUE varchar(128);</b>' (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). <br>";
|
||||
$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. ";
|
||||
}
|
||||
}
|
||||
@ -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 $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->{HELPER}{COLSET} = 1; # Statusbit "Columns sind gesetzt"
|
||||
|
||||
return;
|
||||
@ -9907,11 +9909,11 @@ return;
|
||||
<li><b>colEvent <n> </b> <br><br>
|
||||
<ul>
|
||||
|
||||
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 . <br>
|
||||
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. <br>
|
||||
<b>Note:</b> <br>
|
||||
If the attribute is set, all of the field length limits are valid also for SQLite databases as noticed in Internal COLUMNS ! <br>
|
||||
With set attribute all field length limits are also valid for SQLite DB as shown in Internal COLUMNS! <br>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
@ -9922,11 +9924,26 @@ return;
|
||||
<li><b>colReading <n> </b> <br><br>
|
||||
<ul>
|
||||
|
||||
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 . <br>
|
||||
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. <br>
|
||||
<b>Note:</b> <br>
|
||||
If the attribute is set, all of the field length limits are valid also for SQLite databases as noticed in Internal COLUMNS ! <br>
|
||||
With set attribute all field length limits are also valid for SQLite DB as shown in Internal COLUMNS! <br>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
<br>
|
||||
|
||||
<ul>
|
||||
<a id="DbLog-attr-colType"></a>
|
||||
<li><b>colType <n> </b> <br><br>
|
||||
|
||||
<ul>
|
||||
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. <br>
|
||||
<b>Note:</b> <br>
|
||||
With set attribute all field length limits are also valid for SQLite DB as shown in Internal COLUMNS! <br>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
@ -9937,11 +9954,11 @@ return;
|
||||
<li><b>colValue <n> </b> <br><br>
|
||||
<ul>
|
||||
|
||||
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 . <br>
|
||||
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. <br>
|
||||
<b>Note:</b> <br>
|
||||
If the attribute is set, all of the field length limits are valid also for SQLite databases as noticed in Internal COLUMNS ! <br>
|
||||
With set attribute all field length limits are also valid for SQLite DB as shown in Internal COLUMNS! <br>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
@ -11784,8 +11801,8 @@ attr SMA_Energymeter DbLogValueFn
|
||||
|
||||
<ul>
|
||||
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. <br>
|
||||
verändert werden wenn die Feldlänge in der Datenbank manuell geändert wurde.
|
||||
Mit colEvent=0 wird das Datenbankfeld EVENT nicht gefüllt. <br>
|
||||
<b>Hinweis:</b> <br>
|
||||
Mit gesetztem Attribut gelten alle Feldlängenbegrenzungen auch für SQLite DB wie im Internal COLUMNS angezeigt! <br>
|
||||
</ul>
|
||||
@ -11799,8 +11816,23 @@ attr SMA_Energymeter DbLogValueFn
|
||||
|
||||
<ul>
|
||||
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. <br>
|
||||
verändert werden wenn die Feldlänge in der Datenbank manuell geändert wurde.
|
||||
Mit colReading=0 wird das Datenbankfeld READING nicht gefüllt. <br>
|
||||
<b>Hinweis:</b> <br>
|
||||
Mit gesetztem Attribut gelten alle Feldlängenbegrenzungen auch für SQLite DB wie im Internal COLUMNS angezeigt! <br>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
<br>
|
||||
|
||||
<ul>
|
||||
<a id="DbLog-attr-colType"></a>
|
||||
<li><b>colType <n> </b> <br><br>
|
||||
|
||||
<ul>
|
||||
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. <br>
|
||||
<b>Hinweis:</b> <br>
|
||||
Mit gesetztem Attribut gelten alle Feldlängenbegrenzungen auch für SQLite DB wie im Internal COLUMNS angezeigt! <br>
|
||||
</ul>
|
||||
@ -11814,8 +11846,8 @@ attr SMA_Energymeter DbLogValueFn
|
||||
|
||||
<ul>
|
||||
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. <br>
|
||||
verändert werden wenn die Feldlänge in der Datenbank manuell geändert wurde.
|
||||
Mit colValue=0 wird das Datenbankfeld VALUE nicht gefüllt. <br>
|
||||
<b>Hinweis:</b> <br>
|
||||
Mit gesetztem Attribut gelten alle Feldlängenbegrenzungen auch für SQLite DB wie im Internal COLUMNS angezeigt! <br>
|
||||
</ul>
|
||||
|
@ -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
|
||||
@ -13,11 +13,28 @@
|
||||
#
|
||||
# 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 <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
# 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);
|
||||
}
|
||||
}
|
||||
@ -2853,9 +2874,10 @@ sub _DbLog_SBP_onRun_LogSequential {
|
||||
|
||||
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} <br><br>";
|
||||
$rec .= "You can change the column width in database by a statement like <b>'alter table $history modify VALUE varchar(128);</b>' (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). <br>";
|
||||
$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} <br><br>";
|
||||
$rec .= "You can change the column width in database by a statement like <b>'alter table $current modify VALUE varchar(128);</b>' (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). <br>";
|
||||
$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. ";
|
||||
}
|
||||
}
|
||||
@ -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 $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->{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 {<Modul>->VERSION()} im FHEMWEB kann Modulversion abgefragt werden
|
||||
@ -8794,13 +8816,10 @@ return;
|
||||
<br>
|
||||
|
||||
For the connection to the database a <b>configuration file</b> 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 <a href="https://fhem.de/commandref.html#list">list</a> 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):
|
||||
<br><br>
|
||||
|
||||
The <b>configuration file</b> 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): <br><br>
|
||||
|
||||
<pre>
|
||||
####################################################################################
|
||||
# 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;
|
||||
<ul>
|
||||
<li><b>get <name> <in> <out> <from> <to> <column_spec> </b> <br><br>
|
||||
|
||||
Read data from the Database used by frontends to plot data without direct
|
||||
access to the Database. <br>
|
||||
Read data from the Database used by frontends to plot data without direct access to the Database. <br>
|
||||
<br>
|
||||
|
||||
<ul>
|
||||
<li><in><br>
|
||||
A dummy parameter for FileLog compatibility. Sessing by defaultto <code>-</code><br>
|
||||
A parameter to establish compatibility with Filelog. <br>
|
||||
In the definition of an SVG device this parameter corresponds to the specification of :<logfile> at the end of the definition.<br>
|
||||
The following characteristics are allowed:<br>
|
||||
<ul>
|
||||
<li>current: reading actual readings from table "current"</li>
|
||||
<li>history: reading history readings from table "history"</li>
|
||||
<li>-: identical to "history"</li>
|
||||
<li>current: the values are read from the "current" table. </li>
|
||||
<li>history: the values are read from the "history" table. </li>
|
||||
<li>table_<table>: the values are read from the specified alternative table. The table (name)
|
||||
must be created in the database with lowercase letters. <br>
|
||||
(example: table_energy, "energy" is the alternative table created in the database) </li>
|
||||
<li>-: identical as "history </li>
|
||||
</ul>
|
||||
</li>
|
||||
<br>
|
||||
@ -9884,11 +9909,11 @@ return;
|
||||
<li><b>colEvent <n> </b> <br><br>
|
||||
<ul>
|
||||
|
||||
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 . <br>
|
||||
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. <br>
|
||||
<b>Note:</b> <br>
|
||||
If the attribute is set, all of the field length limits are valid also for SQLite databases as noticed in Internal COLUMNS ! <br>
|
||||
With set attribute all field length limits are also valid for SQLite DB as shown in Internal COLUMNS! <br>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
@ -9899,11 +9924,26 @@ return;
|
||||
<li><b>colReading <n> </b> <br><br>
|
||||
<ul>
|
||||
|
||||
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 . <br>
|
||||
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. <br>
|
||||
<b>Note:</b> <br>
|
||||
If the attribute is set, all of the field length limits are valid also for SQLite databases as noticed in Internal COLUMNS ! <br>
|
||||
With set attribute all field length limits are also valid for SQLite DB as shown in Internal COLUMNS! <br>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
<br>
|
||||
|
||||
<ul>
|
||||
<a id="DbLog-attr-colType"></a>
|
||||
<li><b>colType <n> </b> <br><br>
|
||||
|
||||
<ul>
|
||||
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. <br>
|
||||
<b>Note:</b> <br>
|
||||
With set attribute all field length limits are also valid for SQLite DB as shown in Internal COLUMNS! <br>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
@ -9914,11 +9954,11 @@ return;
|
||||
<li><b>colValue <n> </b> <br><br>
|
||||
<ul>
|
||||
|
||||
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 . <br>
|
||||
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. <br>
|
||||
<b>Note:</b> <br>
|
||||
If the attribute is set, all of the field length limits are valid also for SQLite databases as noticed in Internal COLUMNS ! <br>
|
||||
With set attribute all field length limits are also valid for SQLite DB as shown in Internal COLUMNS! <br>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
@ -10650,14 +10690,10 @@ attr SMA_Energymeter DbLogValueFn
|
||||
enthalten. <br><br>
|
||||
|
||||
Für die Verbindung zur Datenbank wird eine <b>Konfigurationsdatei</b> 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 <a href="https://fhem.de/commandref_DE.html#list">list</a> 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):
|
||||
<br><br>
|
||||
|
||||
Die <b>Konfigurationsdatei</b> wird z.B. nach /opt/fhem kopiert und hat folgenden Aufbau, den man an seine Umgebung
|
||||
anpassen muß (entsprechende Zeilen entkommentieren und anpassen): <br><br>
|
||||
|
||||
<pre>
|
||||
####################################################################################
|
||||
# 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,12 +11390,15 @@ attr SMA_Energymeter DbLogValueFn
|
||||
|
||||
<ul>
|
||||
<li><in><br>
|
||||
Ein Parameter um eine Kompatibilität zum Filelog herzustellen.
|
||||
Dieser Parameter ist per default immer auf <code>-</code> zu setzen.<br>
|
||||
Ein Parameter um eine Kompatibilität zu Filelog herzustellen. <br>
|
||||
In der Definition eines SVG Devices entspricht dieser Paramter der Angabe von :<logfile> am Ende der Definition.<br>
|
||||
Folgende Ausprägungen sind zugelassen:<br>
|
||||
<ul>
|
||||
<li>current: die aktuellen Werte aus der Tabelle "current" werden gelesen.</li>
|
||||
<li>history: die historischen Werte aus der Tabelle "history" werden gelesen.</li>
|
||||
<li>current: die Werte werden aus der Tabelle "current" gelesen. </li>
|
||||
<li>history: die Werte werden aus der Tabelle "history" gelesen. </li>
|
||||
<li>table_<Tabelle>: die Werte werden aus der angegeben alternativen Tabelle gelesen. Die Tabelle (Name)
|
||||
ist in der Datenbank mit Kleinbuchstaben anzulegen. <br>
|
||||
(Beispiel: table_energy, "energy" ist die in der Datenbank angelegte Alternativtabelle) </li>
|
||||
<li>-: identisch wie "history" </li>
|
||||
</ul>
|
||||
</li>
|
||||
@ -11760,8 +11801,8 @@ attr SMA_Energymeter DbLogValueFn
|
||||
|
||||
<ul>
|
||||
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. <br>
|
||||
verändert werden wenn die Feldlänge in der Datenbank manuell geändert wurde.
|
||||
Mit colEvent=0 wird das Datenbankfeld EVENT nicht gefüllt. <br>
|
||||
<b>Hinweis:</b> <br>
|
||||
Mit gesetztem Attribut gelten alle Feldlängenbegrenzungen auch für SQLite DB wie im Internal COLUMNS angezeigt! <br>
|
||||
</ul>
|
||||
@ -11775,8 +11816,23 @@ attr SMA_Energymeter DbLogValueFn
|
||||
|
||||
<ul>
|
||||
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. <br>
|
||||
verändert werden wenn die Feldlänge in der Datenbank manuell geändert wurde.
|
||||
Mit colReading=0 wird das Datenbankfeld READING nicht gefüllt. <br>
|
||||
<b>Hinweis:</b> <br>
|
||||
Mit gesetztem Attribut gelten alle Feldlängenbegrenzungen auch für SQLite DB wie im Internal COLUMNS angezeigt! <br>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
<br>
|
||||
|
||||
<ul>
|
||||
<a id="DbLog-attr-colType"></a>
|
||||
<li><b>colType <n> </b> <br><br>
|
||||
|
||||
<ul>
|
||||
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. <br>
|
||||
<b>Hinweis:</b> <br>
|
||||
Mit gesetztem Attribut gelten alle Feldlängenbegrenzungen auch für SQLite DB wie im Internal COLUMNS angezeigt! <br>
|
||||
</ul>
|
||||
@ -11790,8 +11846,8 @@ attr SMA_Energymeter DbLogValueFn
|
||||
|
||||
<ul>
|
||||
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. <br>
|
||||
verändert werden wenn die Feldlänge in der Datenbank manuell geändert wurde.
|
||||
Mit colValue=0 wird das Datenbankfeld VALUE nicht gefüllt. <br>
|
||||
<b>Hinweis:</b> <br>
|
||||
Mit gesetztem Attribut gelten alle Feldlängenbegrenzungen auch für SQLite DB wie im Internal COLUMNS angezeigt! <br>
|
||||
</ul>
|
||||
|
Loading…
x
Reference in New Issue
Block a user