2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-04-16 10:46:03 +00:00

93_DbRep: write TYPE uppercase with writeToDB option

git-svn-id: https://svn.fhem.de/fhem/trunk@27026 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
nasseeder1 2023-01-11 18:55:22 +00:00
parent 404e347000
commit 84cf72774b
2 changed files with 352 additions and 335 deletions

View File

@ -1,5 +1,7 @@
# 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.
- change: 93_DbRep: write TYPE uppercase with writeToDB option,
Commandref edited
- bugfix: 59_Weather: fix DarkSky API wrong funtion call
- feature: 72_FRITZBOX: merged old 72_FRITZBOX with last Fork Version
- bugfix: 59_Weather: bugfix function WeatherAsHtmlD not working

View File

@ -59,6 +59,7 @@ no if $] >= 5.017011, warnings => 'experimental::smartmatch';
# Version History intern
my %DbRep_vNotesIntern = (
"8.51.1" => "01.01.2023 write TYPE uppercase with writeToDB option, Commandref edited ",
"8.51.0" => "02.01.2023 online formatting of sqlCmd, sqlCmdHistory, sqlSpecial, Commandref edited, get dbValue removed ".
"sqlCmdBlocking customized like sqlCmd, bugfix avgTimeWeightMean ",
"8.50.10" => "01.01.2023 Commandref edited ",
@ -12713,8 +12714,11 @@ sub DbRep_OutputWriteToDB {
if(!$dbloghash->{HELPER}{COLSET}) {
$err = "No result of \"$hash->{LASTCMD}\" to database written. Cause: column width in \"$hash->{DEF}\" isn't set";
Log3 ($name, 2, "DbRep $name - ERROR - $err");
$err = encode_base64($err,"");
return ($err,$wrt,$irowdone);
}
@ -12723,7 +12727,7 @@ sub DbRep_OutputWriteToDB {
my $aggr = (DbRep_checktimeaggr($hash))[2];
$reading = $optxt."_".$aggr."_".AttrVal($name, "readingNameMap", $reading);
$type = $defs{$device}{TYPE} if($defs{$device}); # $type vom Device ableiten
$type = uc($defs{$device}{TYPE}) if($defs{$device}); # $type vom Device übernehmen
if($optxt =~ /avg|sum/) {
my @arr = split("\\|", $wrstr);
@ -12770,7 +12774,6 @@ sub DbRep_OutputWriteToDB {
}
if (defined $value) {
# Daten auf maximale Länge beschneiden (DbLog-Funktion !)
($device,$type,$event,$reading,$value,$unit) = DbLog_cutCol($dbloghash,$device,$type,$event,$reading,$value,$unit);
if($i == 0) {
@ -12820,7 +12823,6 @@ sub DbRep_OutputWriteToDB {
}
}
if ($value) {
# Daten auf maximale Länge beschneiden (DbLog-Funktion !)
($device,$type,$event,$reading,$value,$unit) = DbLog_cutCol($dbloghash,$device,$type,$event,$reading,$value,$unit);
push(@row_array, "$date $time|$device|$type|$event|$reading|$value|$unit");
}
@ -12831,8 +12833,11 @@ sub DbRep_OutputWriteToDB {
eval {$dbh = DBI->connect("dbi:$dbconn", $dbuser, $dbpassword, { PrintError => 0, RaiseError => 1, AutoCommit => 1, mysql_enable_utf8 => $utf8 });};
if ($@) {
$err = $@;
Log3 ($name, 2, "DbRep $name - ERROR - $@");
$err = encode_base64($err,"");
return ($err,$wrt,$irowdone);
}
@ -12894,8 +12899,7 @@ sub DbRep_OutputWriteToDB {
Log3($name, 2, "DbRep $name - ERROR - $@");
}
# SQL-Startzeit
my $wst = [gettimeofday];
my $wst = [gettimeofday]; # SQL-Startzeit
my $ihs = 0;
my $uhs = 0;
@ -12910,8 +12914,7 @@ sub DbRep_OutputWriteToDB {
$value = $a[5];
$unit = $a[6];
eval {
# update oder insert history
eval { # update oder insert history
if (lc($DbLogType) =~ m(history) ) {
my $rv_uh = $dbh->do("UPDATE history SET TIMESTAMP=\"$timestamp\", DEVICE=\"$device\", READING=\"$reading\", TYPE=\"$type\", EVENT=\"$event\", VALUE=\"$value\", UNIT=\"$unit\" WHERE TIMESTAMP=\"$timestamp\" AND DEVICE=\"$device\" AND READING=\"$reading\"");
$uhs += $rv_uh if($rv_uh);
@ -12924,8 +12927,8 @@ sub DbRep_OutputWriteToDB {
Log3 $hash->{NAME}, 4, "DbRep $name - INSERT history: $row, RESULT: $rv_ih";
}
}
# update oder insert current
if (lc($DbLogType) =~ m(current) ) {
if (lc($DbLogType) =~ m(current) ) { # update oder insert current
my $rv_uc = $dbh->do("UPDATE current SET TIMESTAMP=\"$timestamp\", DEVICE=\"$device\", READING=\"$reading\", TYPE=\"$type\", EVENT=\"$event\", VALUE=\"$value\", UNIT=\"$unit\" WHERE DEVICE=\"$device\" AND READING=\"$reading\"");
if ($rv_uc == 0) {
$sth_ic->execute($timestamp,$device,$type,$event,$reading,$value,$unit);
@ -12935,10 +12938,14 @@ sub DbRep_OutputWriteToDB {
if ($@) {
$err = $@;
Log3 ($name, 2, "DbRep $name - ERROR - $@");
$dbh->rollback;
$dbh->disconnect;
$err = encode_base64($err,"");
return ($err,$wrt,0);
}
}
@ -12951,8 +12958,7 @@ sub DbRep_OutputWriteToDB {
Log3 ($hash->{NAME}, 3, "DbRep $name - number of lines inserted into \"$dblogname\": $ihs");
$irowdone = $ihs + $uhs;
# SQL-Laufzeit ermitteln
$wrt = tv_interval($wst);
$wrt = tv_interval($wst); # SQL-Laufzeit ermitteln
}
return ($err,$wrt,$irowdone);
@ -14223,8 +14229,9 @@ return;
</li><br>
<li><b> dumpMySQL [clientSide | serverSide]</b>
- creates a dump of the connected MySQL database. <br>
<li><b> dumpMySQL [clientSide | serverSide]</b> <br><br>
Creates a dump of the connected MySQL database. <br>
Depending from selected option the dump will be created on Client- or on Server-Side. <br>
The variants differs each other concerning the executing system, the creating location, the usage of
attributes, the function result and the needed hardware ressources. <br>
@ -14235,7 +14242,7 @@ return;
<ul>
<b><u>Option clientSide</u></b> <br>
The dump will be created by client (FHEM-Server) and will be saved in FHEM log-directory by
The dump will be created by client (FHEM-Server) and will be saved in FHEM log-directory ((typical /opt/fhem/log/)) by
default.
The target directory can be set by attribute <a href="#DbRep-attr-dumpDirLocal">dumpDirLocal</a> and has to be
writable by the FHEM process. <br>
@ -14386,9 +14393,10 @@ return;
</ul>
<br>
<br>
</ul>
</li><br>
</ul>
</li>
<br>
<li><b> dumpSQLite </b> - creates a dump of the connected SQLite database. <br>
This function uses the SQLite Online Backup API and allow to create a consistent backup of the
@ -15923,7 +15931,8 @@ sub bdump {
new operation starts </li> <br>
<a id="DbRep-attr-seqDoubletsVariance"></a>
<li><b>seqDoubletsVariance &lt;positive variance [negative variance] [EDGE=negative|positive]&gt; </b> <br>
<li><b>seqDoubletsVariance &lt;positive variance [negative variance] [EDGE=negative|positive]&gt; </b> <br><br>
Accepted variance for the command "set &lt;name&gt; delSeqDoublets". <br>
The value of this attribute describes the variance up to consecutive numeric values (VALUE) of
datasets are handled as identical. If only one numeric value is declared, it is used as
@ -15944,7 +15953,8 @@ sub bdump {
<code>attr &lt;name&gt; seqDoubletsVariance 3.0 2.0 </code> <br>
<code>attr &lt;name&gt; seqDoubletsVariance 1.5 EDGE=negative </code> <br>
</ul>
<br><br>
<br>
<br>
</li>
<a id="DbRep-attr-showproctime"></a>
@ -17088,8 +17098,9 @@ return;
</li> <br>
<li><b> dumpMySQL [clientSide | serverSide]</b>
- erstellt einen Dump der angeschlossenen MySQL-Datenbank. <br>
<li><b> dumpMySQL [clientSide | serverSide]</b> <br><br>
Erstellt einen Dump der angeschlossenen MySQL-Datenbank. <br>
Abhängig von der ausgewählten Option wird der Dump auf der Client- bzw. Serverseite erstellt. <br>
Die Varianten unterscheiden sich hinsichtlich des ausführenden Systems, des Erstellungsortes, der
Attributverwendung, des erzielten Ergebnisses und der benötigten Hardwareressourcen. <br>
@ -17101,7 +17112,7 @@ return;
<ul>
<b><u>Option clientSide</u></b> <br>
Der Dump wird durch den Client (FHEM-Rechner) erstellt und per default im log-Verzeichnis des Clients
gespeichert.
(typisch /opt/fhem/log/) gespeichert.
Das Zielverzeichnis kann mit dem Attribut <a href="#DbRep-attr-dumpDirLocal">dumpDirLocal</a> verändert werden und muß auf
dem Client durch FHEM beschreibbar sein. <br>
Vor dem Dump kann eine Tabellenoptimierung (Attribut "optimizeTablesBeforeDump") oder ein FHEM-Kommando
@ -17253,7 +17264,8 @@ return;
<br>
</ul>
</li><br>
</li>
<br>
<li><b> dumpSQLite </b> - erstellt einen Dump der angeschlossenen SQLite-Datenbank. <br>
Diese Funktion nutzt die SQLite Online Backup API und ermöglicht es konsistente Backups der SQLite-DB
@ -18535,6 +18547,7 @@ sub dbval {
<a id="DbRep-attr-dumpDirLocal"></a>
<li><b>dumpDirLocal </b> <br><br>
<ul>
Zielverzeichnis für die Erstellung von Dumps mit "dumpMySQL clientSide" oder "dumpSQLite". <br>
@ -18820,7 +18833,8 @@ sub bdump {
</li> <br>
<a id="DbRep-attr-seqDoubletsVariance"></a>
<li><b>seqDoubletsVariance &lt;positive Abweichung [negative Abweichung] [EDGE=negative|positive]&gt; </b> <br>
<li><b>seqDoubletsVariance &lt;positive Abweichung [negative Abweichung] [EDGE=negative|positive]&gt; </b> <br><br>
Akzeptierte Abweichung für das Kommando "set &lt;name&gt; delSeqDoublets". <br>
Der Wert des Attributs beschreibt die Abweichung bis zu der aufeinanderfolgende numerische
Werte (VALUE) von Datensätzen als gleich angesehen werden sollen.
@ -18842,7 +18856,8 @@ sub bdump {
<code>attr &lt;name&gt; seqDoubletsVariance 3.0 2.0 </code> <br>
<code>attr &lt;name&gt; seqDoubletsVariance 1.5 EDGE=negative </code> <br>
</ul>
<br><br>
<br>
<br>
</li>
<a id="DbRep-attr-showproctime"></a>