93_DbRep: fix readingRename without leading device Forum: #104024, some more fixes
git-svn-id: https://svn.fhem.de/fhem/trunk@20263 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
@@ -1,5 +1,7 @@
|
|||||||
# 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.
|
||||||
|
- bufix: 93_DbRep: fix readingRename without leading device Forum: #104024,
|
||||||
|
some more fixes
|
||||||
- bugfix: 88_Timer: fix code #103848 + added check load file
|
- bugfix: 88_Timer: fix code #103848 + added check load file
|
||||||
- feature: 95_Dashboard: new attr "dashboard_homeTab", "dashboard_webRefresh",
|
- feature: 95_Dashboard: new attr "dashboard_homeTab", "dashboard_webRefresh",
|
||||||
new set command activateTab, bugfixes, comref revised
|
new set command activateTab, bugfixes, comref revised
|
||||||
|
|||||||
@@ -58,6 +58,7 @@ no if $] >= 5.017011, warnings => 'experimental::smartmatch';
|
|||||||
|
|
||||||
# Version History intern
|
# Version History intern
|
||||||
our %DbRep_vNotesIntern = (
|
our %DbRep_vNotesIntern = (
|
||||||
|
"8.27.2" => "27.09.2019 fix export data to file, fix delDoublets if MySQL and VALUE contains \, fix readingRename without leading device ",
|
||||||
"8.27.1" => "22.09.2019 comma are shown in sqlCmdHistory, Forum: #103908 ",
|
"8.27.1" => "22.09.2019 comma are shown in sqlCmdHistory, Forum: #103908 ",
|
||||||
"8.27.0" => "15.09.2019 save memory usage by eliminating \$hash -> {dbloghash}, fix warning uninitialized value \$idevice in split ",
|
"8.27.0" => "15.09.2019 save memory usage by eliminating \$hash -> {dbloghash}, fix warning uninitialized value \$idevice in split ",
|
||||||
"8.26.0" => "07.09.2019 make SQL Wildcard (\%) possible as placeholder in a reading list: https://forum.fhem.de/index.php/topic,101756.0.html ".
|
"8.26.0" => "07.09.2019 make SQL Wildcard (\%) possible as placeholder in a reading list: https://forum.fhem.de/index.php/topic,101756.0.html ".
|
||||||
@@ -765,6 +766,9 @@ sub DbRep_Set($@) {
|
|||||||
DbRep_Main($hash,$opt);
|
DbRep_Main($hash,$opt);
|
||||||
|
|
||||||
} elsif ($opt eq "readingRename") {
|
} elsif ($opt eq "readingRename") {
|
||||||
|
shift @a;
|
||||||
|
shift @a;
|
||||||
|
$prop = join(" ",@a); # Readingname kann Leerzeichen enthalten
|
||||||
$hash->{LASTCMD} = $prop?"$opt $prop":"$opt";
|
$hash->{LASTCMD} = $prop?"$opt $prop":"$opt";
|
||||||
my ($oldread, $newread) = split(",",$prop);
|
my ($oldread, $newread) = split(",",$prop);
|
||||||
if (!$oldread || !$newread) {return "Both entries \"old reading name\", \"new reading name\" are needed. Use \"set $name readingRename oldreadingname,newreadingname\" ";}
|
if (!$oldread || !$newread) {return "Both entries \"old reading name\", \"new reading name\" are needed. Use \"set $name readingRename oldreadingname,newreadingname\" ";}
|
||||||
@@ -4467,12 +4471,12 @@ sub change_Push($) {
|
|||||||
$sth = $dbh->prepare($sql) ;
|
$sth = $dbh->prepare($sql) ;
|
||||||
|
|
||||||
} elsif ($renmode eq "readren") {
|
} elsif ($renmode eq "readren") {
|
||||||
$old = delete $hash->{HELPER}{OLDREAD}; # Wert besteht aus [device]:old_readingname
|
$old = delete $hash->{HELPER}{OLDREAD};
|
||||||
($dev,$old) = split(":",$old,2);
|
($dev,$old) = split(":",$old,2) if($old =~ /:/); # Wert besteht aus [device]:old_readingname, device ist optional
|
||||||
$new = delete $hash->{HELPER}{NEWREAD};
|
$new = delete $hash->{HELPER}{NEWREAD};
|
||||||
|
|
||||||
# SQL zusammenstellen für DB-Operation
|
# SQL zusammenstellen für DB-Operation
|
||||||
Log3 ($name, 5, "DbRep $name -> Rename old reading name \"$old\" ".($dev?"(of device $dev)":"")." to new reading name \"$new\" in database $dblogname ");
|
Log3 ($name, 5, "DbRep $name -> Rename old reading name \"".($dev?"$dev:$old":"$old")."\" to new reading name \"$new\" in database $dblogname ");
|
||||||
|
|
||||||
# prepare DB operation
|
# prepare DB operation
|
||||||
$old =~ s/'/''/g; # escape ' with ''
|
$old =~ s/'/''/g; # escape ' with ''
|
||||||
@@ -4975,6 +4979,7 @@ sub deldoublets_DoParse($) {
|
|||||||
my $dbconn = $dbloghash->{dbconn};
|
my $dbconn = $dbloghash->{dbconn};
|
||||||
my $dbuser = $dbloghash->{dbuser};
|
my $dbuser = $dbloghash->{dbuser};
|
||||||
my $dblogname = $dbloghash->{NAME};
|
my $dblogname = $dbloghash->{NAME};
|
||||||
|
my $model = $dbloghash->{MODEL};
|
||||||
my $dbpassword = $attr{"sec$dblogname"}{secret};
|
my $dbpassword = $attr{"sec$dblogname"}{secret};
|
||||||
my $utf8 = defined($hash->{UTF8})?$hash->{UTF8}:0;
|
my $utf8 = defined($hash->{UTF8})?$hash->{UTF8}:0;
|
||||||
my $limit = AttrVal($name, "limit", 1000);
|
my $limit = AttrVal($name, "limit", 1000);
|
||||||
@@ -5067,6 +5072,7 @@ sub deldoublets_DoParse($) {
|
|||||||
$dev =~ s/'/''/g; # escape ' with ''
|
$dev =~ s/'/''/g; # escape ' with ''
|
||||||
$read =~ s/'/''/g; # escape ' with ''
|
$read =~ s/'/''/g; # escape ' with ''
|
||||||
$val =~ s/'/''/g; # escape ' with ''
|
$val =~ s/'/''/g; # escape ' with ''
|
||||||
|
$val =~ s/\\/\\\\/g if($model eq "MYSQL"); # escape \ with \\ für MySQL
|
||||||
$st = [gettimeofday];
|
$st = [gettimeofday];
|
||||||
my $dsql = "delete FROM $table WHERE TIMESTAMP = '$dt' AND DEVICE = '$dev' AND READING = '$read' AND VALUE = '$val' limit $limit;";
|
my $dsql = "delete FROM $table WHERE TIMESTAMP = '$dt' AND DEVICE = '$dev' AND READING = '$read' AND VALUE = '$val' limit $limit;";
|
||||||
my $sthd = $dbh->prepare($dsql);
|
my $sthd = $dbh->prepare($dsql);
|
||||||
@@ -5420,15 +5426,16 @@ sub expfile_DoParse($) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Log3 ($name, 4, "DbRep $name - Export data to file: $file ".($ml?"splitted to parts of $ml lines":"") );
|
|
||||||
|
|
||||||
$rsf =~ s/[:\s]/_/g;
|
$rsf =~ s/[:\s]/_/g;
|
||||||
my ($f,$e) = split(/\./,$file);
|
my ($f,$e) = $file =~ /(.*)\.(.*)/;
|
||||||
$e = $e?$e:"";
|
$e = $e?$e:"";
|
||||||
$f =~ s/%TSB/$rsf/g;
|
$f =~ s/%TSB/$rsf/g;
|
||||||
my @t = localtime;
|
my @t = localtime;
|
||||||
$f = ResolveDateWildcards($f, @t);
|
$f = ResolveDateWildcards($f, @t);
|
||||||
my $outfile = $f.$part.$e;
|
my $outfile = $f.$part.$e;
|
||||||
|
|
||||||
|
Log3 ($name, 4, "DbRep $name - Export data to file: $outfile ".($ml?"splitted to parts of $ml lines":"") );
|
||||||
|
|
||||||
if (open(FH, ">", $outfile)) {
|
if (open(FH, ">", $outfile)) {
|
||||||
binmode (FH);
|
binmode (FH);
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user