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.
|
# 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.
|
||||||
|
- feature: 93_DbLog: new attribute colType
|
||||||
- feature: 76_SolarForecast: design options for graphicHeaderOwnspec
|
- feature: 76_SolarForecast: design options for graphicHeaderOwnspec
|
||||||
- feature: 76_SolarForecast: new attr ctrlGenPVdeviation
|
- feature: 76_SolarForecast: new attr ctrlGenPVdeviation
|
||||||
- feature: 70_ESCVP21net: add reading stateP for on/off
|
- 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:
|
# Version History intern by DS_Starter:
|
||||||
my %DbLog_vNotesIntern = (
|
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.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 ".
|
"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 ",
|
"_DbLog_SBP_onRun_LogSequential Forum:https://forum.fhem.de/index.php?msg=1284228 ",
|
||||||
@ -211,6 +212,7 @@ sub DbLog_Initialize {
|
|||||||
"cacheOverflowThreshold ".
|
"cacheOverflowThreshold ".
|
||||||
"colEvent ".
|
"colEvent ".
|
||||||
"colReading ".
|
"colReading ".
|
||||||
|
"colType ".
|
||||||
"colValue ".
|
"colValue ".
|
||||||
"convertTimezone:UTC,none ".
|
"convertTimezone:UTC,none ".
|
||||||
"DbLogSelectionMode:Exclude,Include,Exclude/Include ".
|
"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) {
|
if ($cmd eq "set" && $aVal) {
|
||||||
unless ($aVal =~ /^[0-9]+$/) { return " The Value of $aName is not valid. Use only figures 0-9 !";}
|
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);
|
InternalTimer(gettimeofday()+0.8, "DbLog_setinternalcols", $hash, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1508,7 +1510,7 @@ sub DbLog_Log {
|
|||||||
}
|
}
|
||||||
|
|
||||||
# Daten auf maximale Länge beschneiden
|
# 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;
|
my $row = $timestamp."|".$dev_name."|".$dev_type."|".$event."|".$reading."|".$value."|".$unit;
|
||||||
|
|
||||||
@ -7446,11 +7448,11 @@ sub DbLog_configcheck {
|
|||||||
$rec .= "UNIT: $DbLog_columns{UNIT} <br><br>";
|
$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 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 .= "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 {
|
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 = "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. ";
|
$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 .= "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 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 .= "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 {
|
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 = "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. ";
|
$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
|
# 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)) {
|
if (AttrVal($name, 'useCharfilter', 0)) {
|
||||||
$dev_reading = DbLog_charfilter($dev_reading);
|
$dev_reading = DbLog_charfilter($dev_reading);
|
||||||
@ -8227,7 +8229,7 @@ sub DbLog_addCacheLine {
|
|||||||
}
|
}
|
||||||
|
|
||||||
no warnings 'uninitialized'; # Daten auf maximale Länge beschneiden
|
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;
|
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));
|
$row = DbLog_charfilter($row) if(AttrVal($name, "useCharfilter",0));
|
||||||
@ -8254,12 +8256,14 @@ return;
|
|||||||
#########################################################################################
|
#########################################################################################
|
||||||
sub DbLog_cutCol {
|
sub DbLog_cutCol {
|
||||||
my ($hash,$dn,$dt,$evt,$rd,$val,$unit) = @_;
|
my ($hash,$dn,$dt,$evt,$rd,$val,$unit) = @_;
|
||||||
|
|
||||||
my $name = $hash->{NAME};
|
my $name = $hash->{NAME};
|
||||||
my $colevent = AttrVal($name, 'colEvent', undef);
|
my $colevent = AttrVal ($name, 'colEvent', undef);
|
||||||
my $colreading = AttrVal($name, 'colReading', undef);
|
my $colreading = AttrVal ($name, 'colReading', undef);
|
||||||
my $colvalue = AttrVal($name, 'colValue', 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});
|
$dn = substr($dn, 0, $hash->{HELPER}{DEVICECOL});
|
||||||
$dt = substr($dt, 0, $hash->{HELPER}{TYPECOL});
|
$dt = substr($dt, 0, $hash->{HELPER}{TYPECOL});
|
||||||
$evt = substr($evt, 0, $hash->{HELPER}{EVENTCOL});
|
$evt = substr($evt, 0, $hash->{HELPER}{EVENTCOL});
|
||||||
@ -8348,18 +8352,16 @@ return @v;
|
|||||||
################################################################
|
################################################################
|
||||||
sub DbLog_setinternalcols {
|
sub DbLog_setinternalcols {
|
||||||
my $hash = shift;
|
my $hash = shift;
|
||||||
|
|
||||||
my $name = $hash->{NAME};
|
my $name = $hash->{NAME};
|
||||||
|
|
||||||
$hash->{HELPER}{DEVICECOL} = $DbLog_columns{DEVICE};
|
$hash->{HELPER}{DEVICECOL} = $DbLog_columns{DEVICE};
|
||||||
$hash->{HELPER}{TYPECOL} = $DbLog_columns{TYPE};
|
$hash->{HELPER}{TYPECOL} = AttrVal($name, 'colType', $DbLog_columns{TYPE});
|
||||||
$hash->{HELPER}{EVENTCOL} = AttrVal($name, "colEvent", $DbLog_columns{EVENT} );
|
$hash->{HELPER}{EVENTCOL} = AttrVal($name, 'colEvent', $DbLog_columns{EVENT});
|
||||||
$hash->{HELPER}{READINGCOL} = AttrVal($name, "colReading", $DbLog_columns{READING});
|
$hash->{HELPER}{READINGCOL} = AttrVal($name, 'colReading', $DbLog_columns{READING});
|
||||||
$hash->{HELPER}{VALUECOL} = AttrVal($name, "colValue", $DbLog_columns{VALUE} );
|
$hash->{HELPER}{VALUECOL} = AttrVal($name, 'colValue', $DbLog_columns{VALUE});
|
||||||
$hash->{HELPER}{UNITCOL} = $DbLog_columns{UNIT};
|
$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"
|
$hash->{HELPER}{COLSET} = 1; # Statusbit "Columns sind gesetzt"
|
||||||
|
|
||||||
return;
|
return;
|
||||||
@ -9907,11 +9909,11 @@ return;
|
|||||||
<li><b>colEvent <n> </b> <br><br>
|
<li><b>colEvent <n> </b> <br><br>
|
||||||
<ul>
|
<ul>
|
||||||
|
|
||||||
The field length of database field EVENT will be adjusted. By this attribute the default value in the DbLog-device can be
|
The field length of database field EVENT is adapted user-specifically. The attribute can be used to change the
|
||||||
adjusted if the field length in the databse was changed nanually. If colEvent=0 is set, the database field
|
default value in the module if the field length in the database was changed manually.
|
||||||
EVENT won't be filled . <br>
|
With colEvent=0 the database field EVENT is not filled. <br>
|
||||||
<b>Note:</b> <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>
|
</ul>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
@ -9922,11 +9924,26 @@ return;
|
|||||||
<li><b>colReading <n> </b> <br><br>
|
<li><b>colReading <n> </b> <br><br>
|
||||||
<ul>
|
<ul>
|
||||||
|
|
||||||
The field length of database field READING will be adjusted. By this attribute the default value in the DbLog-device can be
|
The field length of database field READING is adapted user-specifically. BThe attribute can be used to change the
|
||||||
adjusted if the field length in the databse was changed nanually. If colReading=0 is set, the database field
|
default value in the module if the field length in the database was changed manually.
|
||||||
READING won't be filled . <br>
|
With colReading=0 the database field READING is not filled. <br>
|
||||||
<b>Note:</b> <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>
|
</ul>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
@ -9937,11 +9954,11 @@ return;
|
|||||||
<li><b>colValue <n> </b> <br><br>
|
<li><b>colValue <n> </b> <br><br>
|
||||||
<ul>
|
<ul>
|
||||||
|
|
||||||
The field length of database field VALUE will be adjusted. By this attribute the default value in the DbLog-device can be
|
The field length of database field VALUE is adapted user-specifically. The attribute can be used to change the
|
||||||
adjusted if the field length in the databse was changed nanually. If colEvent=0 is set, the database field
|
default value in the module if the field length in the database was changed manually.
|
||||||
VALUE won't be filled . <br>
|
With colValue=0 the database field VALUE is not filled. <br>
|
||||||
<b>Note:</b> <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>
|
</ul>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
@ -11784,10 +11801,10 @@ attr SMA_Energymeter DbLogValueFn
|
|||||||
|
|
||||||
<ul>
|
<ul>
|
||||||
Die Feldlänge für das DB-Feld EVENT wird userspezifisch angepasst. Mit dem Attribut kann der Default-Wert im Modul
|
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
|
verändert werden wenn die Feldlänge in der Datenbank manuell geändert wurde.
|
||||||
EVENT nicht gefüllt. <br>
|
Mit colEvent=0 wird das Datenbankfeld EVENT nicht gefüllt. <br>
|
||||||
<b>Hinweis:</b> <br>
|
<b>Hinweis:</b> <br>
|
||||||
Mit gesetztem Attribut gelten alle Feldlängenbegrenzungen auch für SQLite DB wie im Internal COLUMNS angezeigt ! <br>
|
Mit gesetztem Attribut gelten alle Feldlängenbegrenzungen auch für SQLite DB wie im Internal COLUMNS angezeigt! <br>
|
||||||
</ul>
|
</ul>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
@ -11799,10 +11816,25 @@ attr SMA_Energymeter DbLogValueFn
|
|||||||
|
|
||||||
<ul>
|
<ul>
|
||||||
Die Feldlänge für das DB-Feld READING wird userspezifisch angepasst. Mit dem Attribut kann der Default-Wert im Modul
|
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
|
verändert werden wenn die Feldlänge in der Datenbank manuell geändert wurde.
|
||||||
READING nicht gefüllt. <br>
|
Mit colReading=0 wird das Datenbankfeld READING nicht gefüllt. <br>
|
||||||
<b>Hinweis:</b> <br>
|
<b>Hinweis:</b> <br>
|
||||||
Mit gesetztem Attribut gelten alle Feldlängenbegrenzungen auch für SQLite DB wie im Internal COLUMNS angezeigt ! <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>
|
</ul>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
@ -11814,10 +11846,10 @@ attr SMA_Energymeter DbLogValueFn
|
|||||||
|
|
||||||
<ul>
|
<ul>
|
||||||
Die Feldlänge für das DB-Feld VALUE wird userspezifisch angepasst. Mit dem Attribut kann der Default-Wert im Modul
|
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
|
verändert werden wenn die Feldlänge in der Datenbank manuell geändert wurde.
|
||||||
VALUE nicht gefüllt. <br>
|
Mit colValue=0 wird das Datenbankfeld VALUE nicht gefüllt. <br>
|
||||||
<b>Hinweis:</b> <br>
|
<b>Hinweis:</b> <br>
|
||||||
Mit gesetztem Attribut gelten alle Feldlängenbegrenzungen auch für SQLite DB wie im Internal COLUMNS angezeigt ! <br>
|
Mit gesetztem Attribut gelten alle Feldlängenbegrenzungen auch für SQLite DB wie im Internal COLUMNS angezeigt! <br>
|
||||||
</ul>
|
</ul>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</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
|
# 93_DbLog.pm
|
||||||
# written by Dr. Boris Neubert 2007-12-30
|
# written by Dr. Boris Neubert 2007-12-30
|
||||||
# e-mail: omega at online dot de
|
# e-mail: omega at online dot de
|
||||||
@ -12,12 +12,29 @@
|
|||||||
# e-mail: heiko dot maaz at t-online dot de
|
# e-mail: heiko dot maaz at t-online dot de
|
||||||
#
|
#
|
||||||
# reduceLog() created by Claudiu Schuster (rapster) adapted by DS_Starter
|
# 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
|
# Leerzeichen entfernen: sed -i 's/[[:space:]]*$//' 93_DbLog.pm
|
||||||
#
|
#
|
||||||
############################################################################################################################################
|
##############################################################################################################################
|
||||||
|
|
||||||
package main;
|
package main;
|
||||||
use strict;
|
use strict;
|
||||||
@ -39,7 +56,10 @@ no if $] >= 5.017011, warnings => 'experimental::smartmatch';
|
|||||||
|
|
||||||
# Version History intern by DS_Starter:
|
# Version History intern by DS_Starter:
|
||||||
my %DbLog_vNotesIntern = (
|
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 ".
|
"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 ",
|
"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 ",
|
"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 ".
|
"cacheOverflowThreshold ".
|
||||||
"colEvent ".
|
"colEvent ".
|
||||||
"colReading ".
|
"colReading ".
|
||||||
|
"colType ".
|
||||||
"colValue ".
|
"colValue ".
|
||||||
"convertTimezone:UTC,none ".
|
"convertTimezone:UTC,none ".
|
||||||
"DbLogSelectionMode:Exclude,Include,Exclude/Include ".
|
"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) {
|
if ($cmd eq "set" && $aVal) {
|
||||||
unless ($aVal =~ /^[0-9]+$/) { return " The Value of $aName is not valid. Use only figures 0-9 !";}
|
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);
|
InternalTimer(gettimeofday()+0.8, "DbLog_setinternalcols", $hash, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1489,7 +1510,7 @@ sub DbLog_Log {
|
|||||||
}
|
}
|
||||||
|
|
||||||
# Daten auf maximale Länge beschneiden
|
# 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;
|
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 $faref = __DbLog_SBP_fieldArrays ($name, $cdata, $subprocess); # Feldarrays erstellen mit Logausgabe
|
||||||
my $ceti = scalar keys %{$cdata};
|
my $ceti = scalar keys %{$cdata};
|
||||||
my $rv = 0;
|
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
|
if (lc($DbLogType) =~ m(history)) { # insert history mit/ohne primary key
|
||||||
for my $key (sort {$a<=>$b} keys %{$cdata}) {
|
for my $key (sort {$a<=>$b} keys %{$cdata}) {
|
||||||
@ -2982,7 +3004,7 @@ sub _DbLog_SBP_onRun_LogSequential {
|
|||||||
if($ins_hist == $ceti) {
|
if($ins_hist == $ceti) {
|
||||||
_DbLog_SBP_Log3Parent ( { name => $name,
|
_DbLog_SBP_Log3Parent ( { name => $name,
|
||||||
level => 4,
|
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',
|
oper => 'log3parent',
|
||||||
subprocess => $subprocess
|
subprocess => $subprocess
|
||||||
}
|
}
|
||||||
@ -2992,7 +3014,7 @@ sub _DbLog_SBP_onRun_LogSequential {
|
|||||||
if($usepkh) {
|
if($usepkh) {
|
||||||
_DbLog_SBP_Log3Parent ( { name => $name,
|
_DbLog_SBP_Log3Parent ( { name => $name,
|
||||||
level => 3,
|
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',
|
oper => 'log3parent',
|
||||||
subprocess => $subprocess
|
subprocess => $subprocess
|
||||||
}
|
}
|
||||||
@ -3001,7 +3023,7 @@ sub _DbLog_SBP_onRun_LogSequential {
|
|||||||
else {
|
else {
|
||||||
_DbLog_SBP_Log3Parent ( { name => $name,
|
_DbLog_SBP_Log3Parent ( { name => $name,
|
||||||
level => 2,
|
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',
|
oper => 'log3parent',
|
||||||
subprocess => $subprocess
|
subprocess => $subprocess
|
||||||
}
|
}
|
||||||
@ -7426,11 +7448,11 @@ sub DbLog_configcheck {
|
|||||||
$rec .= "UNIT: $DbLog_columns{UNIT} <br><br>";
|
$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 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 .= "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 {
|
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 = "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. ";
|
$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 .= "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 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 .= "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 {
|
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 = "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. ";
|
$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
|
# 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)) {
|
if (AttrVal($name, 'useCharfilter', 0)) {
|
||||||
$dev_reading = DbLog_charfilter($dev_reading);
|
$dev_reading = DbLog_charfilter($dev_reading);
|
||||||
@ -8207,7 +8229,7 @@ sub DbLog_addCacheLine {
|
|||||||
}
|
}
|
||||||
|
|
||||||
no warnings 'uninitialized'; # Daten auf maximale Länge beschneiden
|
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;
|
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));
|
$row = DbLog_charfilter($row) if(AttrVal($name, "useCharfilter",0));
|
||||||
@ -8234,12 +8256,14 @@ return;
|
|||||||
#########################################################################################
|
#########################################################################################
|
||||||
sub DbLog_cutCol {
|
sub DbLog_cutCol {
|
||||||
my ($hash,$dn,$dt,$evt,$rd,$val,$unit) = @_;
|
my ($hash,$dn,$dt,$evt,$rd,$val,$unit) = @_;
|
||||||
|
|
||||||
my $name = $hash->{NAME};
|
my $name = $hash->{NAME};
|
||||||
my $colevent = AttrVal($name, 'colEvent', undef);
|
my $colevent = AttrVal ($name, 'colEvent', undef);
|
||||||
my $colreading = AttrVal($name, 'colReading', undef);
|
my $colreading = AttrVal ($name, 'colReading', undef);
|
||||||
my $colvalue = AttrVal($name, 'colValue', 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});
|
$dn = substr($dn, 0, $hash->{HELPER}{DEVICECOL});
|
||||||
$dt = substr($dt, 0, $hash->{HELPER}{TYPECOL});
|
$dt = substr($dt, 0, $hash->{HELPER}{TYPECOL});
|
||||||
$evt = substr($evt, 0, $hash->{HELPER}{EVENTCOL});
|
$evt = substr($evt, 0, $hash->{HELPER}{EVENTCOL});
|
||||||
@ -8328,18 +8352,16 @@ return @v;
|
|||||||
################################################################
|
################################################################
|
||||||
sub DbLog_setinternalcols {
|
sub DbLog_setinternalcols {
|
||||||
my $hash = shift;
|
my $hash = shift;
|
||||||
|
|
||||||
my $name = $hash->{NAME};
|
my $name = $hash->{NAME};
|
||||||
|
|
||||||
$hash->{HELPER}{DEVICECOL} = $DbLog_columns{DEVICE};
|
$hash->{HELPER}{DEVICECOL} = $DbLog_columns{DEVICE};
|
||||||
$hash->{HELPER}{TYPECOL} = $DbLog_columns{TYPE};
|
$hash->{HELPER}{TYPECOL} = AttrVal($name, 'colType', $DbLog_columns{TYPE});
|
||||||
$hash->{HELPER}{EVENTCOL} = AttrVal($name, "colEvent", $DbLog_columns{EVENT} );
|
$hash->{HELPER}{EVENTCOL} = AttrVal($name, 'colEvent', $DbLog_columns{EVENT});
|
||||||
$hash->{HELPER}{READINGCOL} = AttrVal($name, "colReading", $DbLog_columns{READING});
|
$hash->{HELPER}{READINGCOL} = AttrVal($name, 'colReading', $DbLog_columns{READING});
|
||||||
$hash->{HELPER}{VALUECOL} = AttrVal($name, "colValue", $DbLog_columns{VALUE} );
|
$hash->{HELPER}{VALUECOL} = AttrVal($name, 'colValue', $DbLog_columns{VALUE});
|
||||||
$hash->{HELPER}{UNITCOL} = $DbLog_columns{UNIT};
|
$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"
|
$hash->{HELPER}{COLSET} = 1; # Statusbit "Columns sind gesetzt"
|
||||||
|
|
||||||
return;
|
return;
|
||||||
@ -8665,13 +8687,13 @@ sub DbLog_setVersionInfo {
|
|||||||
|
|
||||||
if($modules{$type}{META}{x_prereqs_src} && !$hash->{HELPER}{MODMETAABSENT}) { # META-Daten sind vorhanden
|
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}}
|
$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;
|
$modules{$type}{META}{x_version} =~ s/1\.1\.1/$v/xsg;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$modules{$type}{META}{x_version} = $v;
|
$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) {
|
if(__PACKAGE__ eq "FHEM::$type" || __PACKAGE__ eq $type) {
|
||||||
# es wird mit Packages gearbeitet -> Perl übliche Modulversion setzen
|
# es wird mit Packages gearbeitet -> Perl übliche Modulversion setzen
|
||||||
# mit {<Modul>->VERSION()} im FHEMWEB kann Modulversion abgefragt werden
|
# mit {<Modul>->VERSION()} im FHEMWEB kann Modulversion abgefragt werden
|
||||||
@ -8794,13 +8816,10 @@ return;
|
|||||||
<br>
|
<br>
|
||||||
|
|
||||||
For the connection to the database a <b>configuration file</b> is used.
|
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
|
The configuration file is copied e.g. to /opt/fhem and has the structure shown below.
|
||||||
visible in the output of the <a href="https://fhem.de/commandref.html#list">list</a> command.
|
The specifications are to be adapted according to the used environment (uncomment and change corresponding lines):
|
||||||
<br><br>
|
<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>
|
<pre>
|
||||||
####################################################################################
|
####################################################################################
|
||||||
# database configuration file
|
# database configuration file
|
||||||
@ -8814,6 +8833,8 @@ return;
|
|||||||
####################################################################################
|
####################################################################################
|
||||||
#%dbconfig= (
|
#%dbconfig= (
|
||||||
# connection => "mysql:database=fhem;host=<database host>;port=3306",
|
# 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",
|
# user => "fhemuser",
|
||||||
# password => "fhempassword",
|
# password => "fhempassword",
|
||||||
# # optional enable(1) / disable(0) UTF-8 support
|
# # optional enable(1) / disable(0) UTF-8 support
|
||||||
@ -9464,17 +9485,21 @@ return;
|
|||||||
<ul>
|
<ul>
|
||||||
<li><b>get <name> <in> <out> <from> <to> <column_spec> </b> <br><br>
|
<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
|
Read data from the Database used by frontends to plot data without direct access to the Database. <br>
|
||||||
access to the Database. <br>
|
|
||||||
<br>
|
<br>
|
||||||
|
|
||||||
<ul>
|
<ul>
|
||||||
<li><in><br>
|
<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>
|
<ul>
|
||||||
<li>current: reading actual readings from table "current"</li>
|
<li>current: the values are read from the "current" table. </li>
|
||||||
<li>history: reading history readings from table "history"</li>
|
<li>history: the values are read from the "history" table. </li>
|
||||||
<li>-: identical to "history"</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>
|
</ul>
|
||||||
</li>
|
</li>
|
||||||
<br>
|
<br>
|
||||||
@ -9884,11 +9909,11 @@ return;
|
|||||||
<li><b>colEvent <n> </b> <br><br>
|
<li><b>colEvent <n> </b> <br><br>
|
||||||
<ul>
|
<ul>
|
||||||
|
|
||||||
The field length of database field EVENT will be adjusted. By this attribute the default value in the DbLog-device can be
|
The field length of database field EVENT is adapted user-specifically. The attribute can be used to change the
|
||||||
adjusted if the field length in the databse was changed nanually. If colEvent=0 is set, the database field
|
default value in the module if the field length in the database was changed manually.
|
||||||
EVENT won't be filled . <br>
|
With colEvent=0 the database field EVENT is not filled. <br>
|
||||||
<b>Note:</b> <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>
|
</ul>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
@ -9899,11 +9924,26 @@ return;
|
|||||||
<li><b>colReading <n> </b> <br><br>
|
<li><b>colReading <n> </b> <br><br>
|
||||||
<ul>
|
<ul>
|
||||||
|
|
||||||
The field length of database field READING will be adjusted. By this attribute the default value in the DbLog-device can be
|
The field length of database field READING is adapted user-specifically. BThe attribute can be used to change the
|
||||||
adjusted if the field length in the databse was changed nanually. If colReading=0 is set, the database field
|
default value in the module if the field length in the database was changed manually.
|
||||||
READING won't be filled . <br>
|
With colReading=0 the database field READING is not filled. <br>
|
||||||
<b>Note:</b> <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>
|
</ul>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
@ -9914,11 +9954,11 @@ return;
|
|||||||
<li><b>colValue <n> </b> <br><br>
|
<li><b>colValue <n> </b> <br><br>
|
||||||
<ul>
|
<ul>
|
||||||
|
|
||||||
The field length of database field VALUE will be adjusted. By this attribute the default value in the DbLog-device can be
|
The field length of database field VALUE is adapted user-specifically. The attribute can be used to change the
|
||||||
adjusted if the field length in the databse was changed nanually. If colEvent=0 is set, the database field
|
default value in the module if the field length in the database was changed manually.
|
||||||
VALUE won't be filled . <br>
|
With colValue=0 the database field VALUE is not filled. <br>
|
||||||
<b>Note:</b> <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>
|
</ul>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
@ -10650,14 +10690,10 @@ attr SMA_Energymeter DbLogValueFn
|
|||||||
enthalten. <br><br>
|
enthalten. <br><br>
|
||||||
|
|
||||||
Für die Verbindung zur Datenbank wird eine <b>Konfigurationsdatei</b> verwendet.
|
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
|
Die Konfigurationsdatei wird z.B. nach /opt/fhem kopiert und hat den nachfolgend dargestellten Aufbau.
|
||||||
FHEM-Haupt-Konfigurationsdatei speichern zu müssen.
|
Die Angaben sind entsprechend der verwendeten Umgebung anzupassen (entsprechende Zeilen entkommentieren und ändern):
|
||||||
Ansonsten wäre es mittels des <a href="https://fhem.de/commandref_DE.html#list">list</a> Befehls einfach auslesbar.
|
|
||||||
<br><br>
|
<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>
|
<pre>
|
||||||
####################################################################################
|
####################################################################################
|
||||||
# database configuration file
|
# database configuration file
|
||||||
@ -10671,6 +10707,8 @@ attr SMA_Energymeter DbLogValueFn
|
|||||||
####################################################################################
|
####################################################################################
|
||||||
#%dbconfig= (
|
#%dbconfig= (
|
||||||
# connection => "mysql:database=fhem;host=<database host>;port=3306",
|
# 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",
|
# user => "fhemuser",
|
||||||
# password => "fhempassword",
|
# password => "fhempassword",
|
||||||
# # optional enable(1) / disable(0) UTF-8 support
|
# # optional enable(1) / disable(0) UTF-8 support
|
||||||
@ -11352,13 +11390,16 @@ attr SMA_Energymeter DbLogValueFn
|
|||||||
|
|
||||||
<ul>
|
<ul>
|
||||||
<li><in><br>
|
<li><in><br>
|
||||||
Ein Parameter um eine Kompatibilität zum Filelog herzustellen.
|
Ein Parameter um eine Kompatibilität zu Filelog herzustellen. <br>
|
||||||
Dieser Parameter ist per default immer auf <code>-</code> zu setzen.<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>
|
Folgende Ausprägungen sind zugelassen:<br>
|
||||||
<ul>
|
<ul>
|
||||||
<li>current: die aktuellen Werte aus der Tabelle "current" werden gelesen.</li>
|
<li>current: die Werte werden aus der Tabelle "current" gelesen. </li>
|
||||||
<li>history: die historischen Werte aus der Tabelle "history" werden gelesen.</li>
|
<li>history: die Werte werden aus der Tabelle "history" gelesen. </li>
|
||||||
<li>-: identisch wie "history"</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>
|
</ul>
|
||||||
</li>
|
</li>
|
||||||
<br>
|
<br>
|
||||||
@ -11760,10 +11801,10 @@ attr SMA_Energymeter DbLogValueFn
|
|||||||
|
|
||||||
<ul>
|
<ul>
|
||||||
Die Feldlänge für das DB-Feld EVENT wird userspezifisch angepasst. Mit dem Attribut kann der Default-Wert im Modul
|
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
|
verändert werden wenn die Feldlänge in der Datenbank manuell geändert wurde.
|
||||||
EVENT nicht gefüllt. <br>
|
Mit colEvent=0 wird das Datenbankfeld EVENT nicht gefüllt. <br>
|
||||||
<b>Hinweis:</b> <br>
|
<b>Hinweis:</b> <br>
|
||||||
Mit gesetztem Attribut gelten alle Feldlängenbegrenzungen auch für SQLite DB wie im Internal COLUMNS angezeigt ! <br>
|
Mit gesetztem Attribut gelten alle Feldlängenbegrenzungen auch für SQLite DB wie im Internal COLUMNS angezeigt! <br>
|
||||||
</ul>
|
</ul>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
@ -11775,10 +11816,25 @@ attr SMA_Energymeter DbLogValueFn
|
|||||||
|
|
||||||
<ul>
|
<ul>
|
||||||
Die Feldlänge für das DB-Feld READING wird userspezifisch angepasst. Mit dem Attribut kann der Default-Wert im Modul
|
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
|
verändert werden wenn die Feldlänge in der Datenbank manuell geändert wurde.
|
||||||
READING nicht gefüllt. <br>
|
Mit colReading=0 wird das Datenbankfeld READING nicht gefüllt. <br>
|
||||||
<b>Hinweis:</b> <br>
|
<b>Hinweis:</b> <br>
|
||||||
Mit gesetztem Attribut gelten alle Feldlängenbegrenzungen auch für SQLite DB wie im Internal COLUMNS angezeigt ! <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>
|
</ul>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
@ -11790,10 +11846,10 @@ attr SMA_Energymeter DbLogValueFn
|
|||||||
|
|
||||||
<ul>
|
<ul>
|
||||||
Die Feldlänge für das DB-Feld VALUE wird userspezifisch angepasst. Mit dem Attribut kann der Default-Wert im Modul
|
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
|
verändert werden wenn die Feldlänge in der Datenbank manuell geändert wurde.
|
||||||
VALUE nicht gefüllt. <br>
|
Mit colValue=0 wird das Datenbankfeld VALUE nicht gefüllt. <br>
|
||||||
<b>Hinweis:</b> <br>
|
<b>Hinweis:</b> <br>
|
||||||
Mit gesetztem Attribut gelten alle Feldlängenbegrenzungen auch für SQLite DB wie im Internal COLUMNS angezeigt ! <br>
|
Mit gesetztem Attribut gelten alle Feldlängenbegrenzungen auch für SQLite DB wie im Internal COLUMNS angezeigt! <br>
|
||||||
</ul>
|
</ul>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user