mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-03-03 10:46:53 +00:00
93_DbRep: contrib V8.14.1
git-svn-id: https://svn.fhem.de/fhem/trunk@18784 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
f7c30e47ba
commit
3514a654ca
@ -1,5 +1,5 @@
|
|||||||
##########################################################################################################
|
##########################################################################################################
|
||||||
# $Id: 93_DbRep.pm 18488 2019-02-03 07:38:03Z DS_Starter $
|
# $Id: 93_DbRep.pm 18563 2019-02-11 21:10:32Z DS_Starter $
|
||||||
##########################################################################################################
|
##########################################################################################################
|
||||||
# 93_DbRep.pm
|
# 93_DbRep.pm
|
||||||
#
|
#
|
||||||
@ -57,7 +57,9 @@ no if $] >= 5.017011, warnings => 'experimental::smartmatch';
|
|||||||
|
|
||||||
# Versions History intern
|
# Versions History intern
|
||||||
our %DbRep_vNotesIntern = (
|
our %DbRep_vNotesIntern = (
|
||||||
"8.13.0" => "10.02.2019 executeBeforeProc / executeAfterProc for sumValue, maxValue, minValue, diffValue, averageValue ",
|
"8.14.1" => "04.03.2019 Bugfix in deldoublets with SQLite, Forum: https://forum.fhem.de/index.php/topic,53584.msg914489.html#msg914489 ",
|
||||||
|
"8.14.0" => "19.02.2019 delete Readings if !goodReadingName and featurelevel > 5.9 ",
|
||||||
|
"8.13.0" => "11.02.2019 executeBeforeProc / executeAfterProc for sumValue, maxValue, minValue, diffValue, averageValue ",
|
||||||
"8.12.0" => "10.02.2019 executeBeforeProc / executeAfterProc for sqlCmd ",
|
"8.12.0" => "10.02.2019 executeBeforeProc / executeAfterProc for sqlCmd ",
|
||||||
"8.11.2" => "03.02.2019 fix no running tableCurrentFillup if database is closed ",
|
"8.11.2" => "03.02.2019 fix no running tableCurrentFillup if database is closed ",
|
||||||
"8.11.1" => "25.01.2019 fix sort of versionNotes ",
|
"8.11.1" => "25.01.2019 fix sort of versionNotes ",
|
||||||
@ -137,7 +139,7 @@ our %DbRep_vNotesIntern = (
|
|||||||
|
|
||||||
# Versions History extern:
|
# Versions History extern:
|
||||||
our %DbRep_vNotesExtern = (
|
our %DbRep_vNotesExtern = (
|
||||||
"8.12.0" => "10.02.2019 executeBeforeProc / executeAfterProc is now available for sqlCmd ",
|
"8.13.0" => "11.02.2019 executeBeforeProc / executeAfterProc is now available for sqlCmd,sumValue, maxValue, minValue, diffValue, averageValue ",
|
||||||
"8.11.0" => "24.01.2019 command exportToFile or attribute \"expimpfile\" accepts option \"MAXLINES=\" ",
|
"8.11.0" => "24.01.2019 command exportToFile or attribute \"expimpfile\" accepts option \"MAXLINES=\" ",
|
||||||
"8.10.0" => "19.01.2019 In commands sqlCmd, dbValue you may now use SQL session variables like \"SET \@open:=NULL,\@closed:=NULL; SELECT ...\", Forum:#96082",
|
"8.10.0" => "19.01.2019 In commands sqlCmd, dbValue you may now use SQL session variables like \"SET \@open:=NULL,\@closed:=NULL; SELECT ...\", Forum:#96082",
|
||||||
"8.9.0" => "07.11.2018 new command set delDoublets added. This command allows to delete multiple occuring identical records. ",
|
"8.9.0" => "07.11.2018 new command set delDoublets added. This command allows to delete multiple occuring identical records. ",
|
||||||
@ -4851,10 +4853,19 @@ sub deldoublets_DoParse($) {
|
|||||||
$table = "history";
|
$table = "history";
|
||||||
$selspec = "TIMESTAMP,DEVICE,READING,VALUE,count(*)";
|
$selspec = "TIMESTAMP,DEVICE,READING,VALUE,count(*)";
|
||||||
$addon = "GROUP BY TIMESTAMP, DEVICE, READING, VALUE ASC HAVING count(*) > 1";
|
$addon = "GROUP BY TIMESTAMP, DEVICE, READING, VALUE ASC HAVING count(*) > 1";
|
||||||
|
if($dbloghash->{MODEL} eq 'SQLITE') {
|
||||||
|
$addon = "GROUP BY TIMESTAMP, DEVICE, READING, VALUE HAVING count(*) > 1 ORDER BY TIMESTAMP ASC"; # Forum: https://forum.fhem.de/index.php/topic,53584.msg914489.html#msg914489
|
||||||
|
}
|
||||||
|
|
||||||
# SQL zusammenstellen für DB-Abfrage
|
# SQL zusammenstellen für DB-Abfrage
|
||||||
$sql = DbRep_createSelectSql($hash,$table,$selspec,$device,$reading,"?","?",$addon);
|
$sql = DbRep_createSelectSql($hash,$table,$selspec,$device,$reading,"?","?",$addon);
|
||||||
$sth = $dbh->prepare_cached($sql);
|
eval{$sth = $dbh->prepare_cached($sql);};
|
||||||
|
if ($@) {
|
||||||
|
$err = encode_base64($@,"");
|
||||||
|
Log3 ($name, 2, "DbRep $name - $@");
|
||||||
|
$dbh->disconnect;
|
||||||
|
return "$name|''|''|$err|''|$opt";
|
||||||
|
}
|
||||||
|
|
||||||
# DB-Abfrage zeilenweise für jeden Timearray-Eintrag
|
# DB-Abfrage zeilenweise für jeden Timearray-Eintrag
|
||||||
my @todel;
|
my @todel;
|
||||||
@ -9084,6 +9095,8 @@ sub DbRep_delread($;$$) {
|
|||||||
my ($hash,$shutdown) = @_;
|
my ($hash,$shutdown) = @_;
|
||||||
my $name = $hash->{NAME};
|
my $name = $hash->{NAME};
|
||||||
my @allrds = keys%{$defs{$name}{READINGS}};
|
my @allrds = keys%{$defs{$name}{READINGS}};
|
||||||
|
my $featurelevel = AttrVal("global","featurelevel",99.99);
|
||||||
|
|
||||||
if($shutdown) {
|
if($shutdown) {
|
||||||
my $do = 0;
|
my $do = 0;
|
||||||
foreach my $key(@allrds) {
|
foreach my $key(@allrds) {
|
||||||
@ -9092,6 +9105,11 @@ sub DbRep_delread($;$$) {
|
|||||||
$do = 1;
|
$do = 1;
|
||||||
delete($defs{$name}{READINGS}{$key});
|
delete($defs{$name}{READINGS}{$key});
|
||||||
}
|
}
|
||||||
|
# Reading löschen wenn Featuelevel > 5.9 und zu lang nach der neuen Festlegung
|
||||||
|
if($do == 0 && $featurelevel > 5.9 && !goodReadingName($key)) {
|
||||||
|
$do = 1;
|
||||||
|
delete($defs{$name}{READINGS}{$key});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
WriteStatefile() if($do == 1);
|
WriteStatefile() if($do == 1);
|
||||||
return undef;
|
return undef;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user