2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-05-05 08:20:23 +00:00

93_DbRep: values next_day_begin, next_day_end for time attributes

git-svn-id: https://svn.fhem.de/fhem/trunk@23163 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
nasseeder1 2020-11-15 15:55:09 +00:00
parent d1c728c7f5
commit 29385a29b1
2 changed files with 201 additions and 150 deletions

View File

@ -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_DbRep: values next_day_begin, next_day_end for time attributes
- feature: 23_LUXTRONIK2: new set parameter opModeVentilation
- feature: 93_DbRep: new attrbute avgDailyMeanGWSwithGTS for Grassland
temperature sum calculation

View File

@ -57,6 +57,7 @@ no if $] >= 5.017011, warnings => 'experimental::smartmatch';
# Version History intern
my %DbRep_vNotesIntern = (
"8.42.0" => "14.11.2020 new vals next_day_begin, next_day_end for time attr Forum: https://forum.fhem.de/index.php/topic,53584.msg1100040.html#msg1100040 ",
"8.41.0" => "08.11.2020 new attrbute avgDailyMeanGWSwithGTS for Grassland temperature sum, minor bugfixes in create time array ",
"8.40.8" => "17.09.2020 sqlCmd supports PREPARE statament Forum: #114293, commandRef revised ",
"8.40.7" => "03.09.2020 rename getter dbValue to sqlCmdBlocking, consider attr timeout in function DbRep_sqlCmdBlocking (blocking function), commandRef revised ",
@ -735,7 +736,7 @@ sub DbRep_Set {
} elsif ($opt =~ m/delEntries|tableCurrentPurge/ && $hash->{ROLE} ne "Agent") {
$hash->{LASTCMD} = $prop?"$opt $prop":"$opt";
delete $hash->{HELPER}{DELENTRIES};
delete $hash->{HELPER}{DELENTRIES};
if (!AttrVal($hash->{NAME}, "allowDeletion", undef)) {
return " Set attribute 'allowDeletion' if you want to allow deletion of any database entries. Use it with care !";
@ -990,11 +991,11 @@ sub DbRep_Get {
} elsif ($opt =~ /sqlCmdBlocking|dbValue/) {
return qq{get "$opt" needs at least an argument} if ( @a < 3 );
if($opt eq "dbValue") {
Log3($name, 1, qq{$name - WARNING - the command "dbValue" is deprecated and will be removed soon. Please use "sqlCmdBlocking" instead.});
}
if($opt eq "dbValue") {
Log3($name, 1, qq{$name - WARNING - the command "dbValue" is deprecated and will be removed soon. Please use "sqlCmdBlocking" instead.});
}
my @cmd = @a;
my @cmd = @a;
shift @cmd; shift @cmd;
my $sqlcmd = join " ", @cmd;
@ -1302,7 +1303,7 @@ sub DbRep_Attr {
if ($aName eq "timeYearPeriod") {
# 06-01 02-28
unless ($aVal =~ /^(\d{2})-(\d{2}) (\d{2})-(\d{2})$/ )
unless ($aVal =~ /^(\d{2})-(\d{2})\s(\d{2})-(\d{2})$/x )
{ return "The Value of \"$aName\" isn't valid. Set the account period as \"MM-DD MM-DD\".";}
my ($mm1, $dd1, $mm2, $dd2) = ($aVal =~ /^(\d{2})-(\d{2}) (\d{2})-(\d{2})$/);
my (undef,undef,undef,$mday,$mon,$year1,undef,undef,undef) = localtime(time); # Istzeit Ableitung
@ -1326,21 +1327,48 @@ sub DbRep_Attr {
delete($attr{$name}{timestamp_end}) if ($attr{$name}{timestamp_end});
delete($attr{$name}{timeDiffToNow}) if ($attr{$name}{timeDiffToNow});
delete($attr{$name}{timeOlderThan}) if ($attr{$name}{timeOlderThan});
return undef;
return;
}
if ($aName eq "timestamp_begin" || $aName eq "timestamp_end") {
my ($a,$b,$c) = split('_',$aVal);
if ($a =~ /^current$|^previous$/ && $b =~ /^hour$|^day$|^week$|^month$|^year$/ && $c =~ /^begin$|^end$/) {
delete($attr{$name}{timeDiffToNow}) if ($attr{$name}{timeDiffToNow});
delete($attr{$name}{timeOlderThan}) if ($attr{$name}{timeOlderThan});
delete($attr{$name}{timeYearPeriod}) if ($attr{$name}{timeYearPeriod});
return undef;
}
$aVal = DbRep_formatpicker($aVal);
unless ($aVal =~ /^(\d{4})-(\d{2})-(\d{2}) (\d{2}):(\d{2}):(\d{2})$/)
{return " The Value of $aName is not valid. Use format YYYY-MM-DD HH:MM:SS or one of \"current_[year|month|day|hour]_begin\",\"current_[year|month|day|hour]_end\", \"previous_[year|month|day|hour]_begin\", \"previous_[year|month|day|hour]_end\" !";}
my @dtas = qw(current_year_begin
current_year_end
previous_year_begin
previous_year_end
current_month_begin
current_month_end
previous_month_begin
previous_month_end
current_week_begin
current_week_end
previous_week_begin
previous_week_end
current_day_begin
current_day_end
previous_day_begin
previous_day_end
next_day_begin
next_day_end
current_hour_begin
current_hour_end
previous_hour_begin
previous_hour_end
);
my ($yyyy, $mm, $dd, $hh, $min, $sec) = ($aVal =~ /(\d+)-(\d+)-(\d+) (\d+):(\d+):(\d+)/);
if ($aVal ~~ @dtas) {
delete($attr{$name}{timeDiffToNow});
delete($attr{$name}{timeOlderThan});
delete($attr{$name}{timeYearPeriod});
return;
}
$aVal = DbRep_formatpicker($aVal);
if ($aVal !~ /^(\d{4})-(\d{2})-(\d{2})\s(\d{2}):(\d{2}):(\d{2})$/x)
{return "The Value of $aName is not valid. Use format YYYY-MM-DD HH:MM:SS or one of:\n".
"current_[year|month|day|hour]_begin, current_[year|month|day|hour]_end,\n".
"previous_[year|month|day|hour]_begin, previous_[year|month|day|hour]_end,\n".
"next_day_begin, next_day_end";}
my ($yyyy, $mm, $dd, $hh, $min, $sec) = ($aVal =~ /(\d+)-(\d+)-(\d+)\s(\d+):(\d+):(\d+)/x);
eval { my $epoch_seconds_begin = timelocal($sec, $min, $hh, $dd, $mm-1, $yyyy-1900); };
@ -1348,9 +1376,9 @@ sub DbRep_Attr {
my @l = split (/at/, $@);
return " The Value of $aName is out of range - $l[0]";
}
delete($attr{$name}{timeDiffToNow}) if ($attr{$name}{timeDiffToNow});
delete($attr{$name}{timeOlderThan}) if ($attr{$name}{timeOlderThan});
delete($attr{$name}{timeYearPeriod}) if ($attr{$name}{timeYearPeriod});
delete($attr{$name}{timeDiffToNow});
delete($attr{$name}{timeOlderThan});
delete($attr{$name}{timeYearPeriod});
}
if ($aName =~ /ftpTimeout|timeout|diffAccept/) {
unless ($aVal =~ /^[0-9]+$/) { return " The Value of $aName is not valid. Use only figures 0-9 without decimal places !";}
@ -1361,16 +1389,16 @@ sub DbRep_Attr {
if ($aName eq "timeDiffToNow") {
unless ($aVal =~ /^[0-9]+$/ || $aVal =~ /^\s*[ydhms]:([\d]+)\s*/ && $aVal !~ /.*,.*/ )
{ return "The Value of \"$aName\" isn't valid. Set simple seconds like \"86400\" or use form like \"y:1 d:10 h:6 m:12 s:20\". Refer to commandref !";}
delete($attr{$name}{timestamp_begin}) if ($attr{$name}{timestamp_begin});
delete($attr{$name}{timestamp_end}) if ($attr{$name}{timestamp_end});
delete($attr{$name}{timeYearPeriod}) if ($attr{$name}{timeYearPeriod});
delete($attr{$name}{timestamp_begin});
delete($attr{$name}{timestamp_end});
delete($attr{$name}{timeYearPeriod});
}
if ($aName eq "timeOlderThan") {
unless ($aVal =~ /^[0-9]+$/ || $aVal =~ /^\s*[ydhms]:([\d]+)\s*/ && $aVal !~ /.*,.*/ )
{ return "The Value of \"$aName\" isn't valid. Set simple seconds like \"86400\" or use form like \"y:1 d:10 h:6 m:12 s:20\". Refer to commandref !";}
delete($attr{$name}{timestamp_begin}) if ($attr{$name}{timestamp_begin});
delete($attr{$name}{timestamp_end}) if ($attr{$name}{timestamp_end});
delete($attr{$name}{timeYearPeriod}) if ($attr{$name}{timeYearPeriod});
delete($attr{$name}{timestamp_begin});
delete($attr{$name}{timestamp_end});
delete($attr{$name}{timeYearPeriod});
}
if ($aName eq "dumpMemlimit" || $aName eq "dumpSpeed") {
unless ($aVal =~ /^[0-9]+$/) { return "The Value of $aName is not valid. Use only figures 0-9 without decimal places.";}
@ -1991,7 +2019,7 @@ sub DbRep_Main {
my $othants = fhemTimeLocal($sec2, $min2, $hh2, $dd2, $mm2-1, $yyyy2-1900);
if($nthants > $othants) {
ReadingsSingleUpdateValue ($hash, "state", "Error - Wrong time limits. The <nn> (days newer than) option must be greater than the <no> (older than) one !", 1);
return;
return;
}
}
@ -2094,11 +2122,11 @@ sub DbRep_Main {
if($nthants > $othants) {
ReadingsSingleUpdateValue ($hash, "state", "Error - Wrong time limits. The <nn> (days newer than) option must be greater than the <no> (older than) one !", 1);
return;
return;
}
$hash->{HELPER}{RUNNING_REDUCELOG} = BlockingCall("DbRep_reduceLog", "$name|$device|$reading|$runtime_string_first|$runtime_string_next", "DbRep_reduceLogDone", $to, "DbRep_reduceLogAborted", $hash);
$hash->{HELPER}{RUNNING_REDUCELOG}{loglevel} = 5 if($hash->{HELPER}{RUNNING_REDUCELOG}); # Forum #77057
ReadingsSingleUpdateValue ($hash, "state", "reduceLog database is running - be patient and see Logfile !", 1);
ReadingsSingleUpdateValue ($hash, "state", "reduceLog database is running - be patient and see Logfile !", 1);
return;
}
@ -2151,7 +2179,7 @@ sub DbRep_createTimeArray {
if ($mep <= $mbp && $c <= $e) {
$ybp--;
}
else {
else {
$yep++;
}
@ -2162,38 +2190,38 @@ sub DbRep_createTimeArray {
if (AttrVal($name,"timestamp_begin","") eq "current_year_begin" ||
AttrVal($name,"timestamp_end","") eq "current_year_begin") {
$tsbegin = strftime "%Y-%m-%d %T",localtime(timelocal(0,0,0,1,0,$year)) if(AttrVal($name,"timestamp_begin","") eq "current_year_begin");
$tsend = strftime "%Y-%m-%d %T",localtime(timelocal(0,0,0,1,0,$year)) if(AttrVal($name,"timestamp_end","") eq "current_year_begin");
$tsend = strftime "%Y-%m-%d %T",localtime(timelocal(0,0,0,1,0,$year)) if(AttrVal($name,"timestamp_end","") eq "current_year_begin");
}
if (AttrVal($name, "timestamp_begin", "") eq "current_year_end" ||
AttrVal($name, "timestamp_end", "") eq "current_year_end") {
$tsbegin = strftime "%Y-%m-%d %T",localtime(timelocal(59,59,23,31,11,$year)) if(AttrVal($name,"timestamp_begin","") eq "current_year_end");
$tsend = strftime "%Y-%m-%d %T",localtime(timelocal(59,59,23,31,11,$year)) if(AttrVal($name,"timestamp_end","") eq "current_year_end");
$tsend = strftime "%Y-%m-%d %T",localtime(timelocal(59,59,23,31,11,$year)) if(AttrVal($name,"timestamp_end","") eq "current_year_end");
}
if (AttrVal($name, "timestamp_begin", "") eq "previous_year_begin" ||
AttrVal($name, "timestamp_end", "") eq "previous_year_begin") {
$tsbegin = strftime "%Y-%m-%d %T",localtime(timelocal(0,0,0,1,0,$year-1)) if(AttrVal($name, "timestamp_begin", "") eq "previous_year_begin");
$tsend = strftime "%Y-%m-%d %T",localtime(timelocal(0,0,0,1,0,$year-1)) if(AttrVal($name, "timestamp_end", "") eq "previous_year_begin");
$tsend = strftime "%Y-%m-%d %T",localtime(timelocal(0,0,0,1,0,$year-1)) if(AttrVal($name, "timestamp_end", "") eq "previous_year_begin");
}
if (AttrVal($name, "timestamp_begin", "") eq "previous_year_end" ||
AttrVal($name, "timestamp_end", "") eq "previous_year_end") {
$tsbegin = strftime "%Y-%m-%d %T",localtime(timelocal(59,59,23,31,11,$year-1)) if(AttrVal($name, "timestamp_begin", "") eq "previous_year_end");
$tsend = strftime "%Y-%m-%d %T",localtime(timelocal(59,59,23,31,11,$year-1)) if(AttrVal($name, "timestamp_end", "") eq "previous_year_end");
$tsend = strftime "%Y-%m-%d %T",localtime(timelocal(59,59,23,31,11,$year-1)) if(AttrVal($name, "timestamp_end", "") eq "previous_year_end");
}
if (AttrVal($name, "timestamp_begin", "") eq "current_month_begin" ||
AttrVal($name, "timestamp_end", "") eq "current_month_begin") {
$tsbegin = strftime "%Y-%m-%d %T",localtime(timelocal(0,0,0,1,$mon,$year)) if(AttrVal($name, "timestamp_begin", "") eq "current_month_begin");
$tsend = strftime "%Y-%m-%d %T",localtime(timelocal(0,0,0,1,$mon,$year)) if(AttrVal($name, "timestamp_end", "") eq "current_month_begin");
$tsend = strftime "%Y-%m-%d %T",localtime(timelocal(0,0,0,1,$mon,$year)) if(AttrVal($name, "timestamp_end", "") eq "current_month_begin");
}
if (AttrVal($name, "timestamp_begin", "") eq "current_month_end" ||
AttrVal($name, "timestamp_end", "") eq "current_month_end") {
$dim = $mon-1?30+(($mon+1)*3%7<4):28+!($year%4||$year%400*!($year%100));
$tsbegin = strftime "%Y-%m-%d %T",localtime(timelocal(59,59,23,$dim,$mon,$year)) if(AttrVal($name, "timestamp_begin", "") eq "current_month_end");
$tsend = strftime "%Y-%m-%d %T",localtime(timelocal(59,59,23,$dim,$mon,$year)) if(AttrVal($name, "timestamp_end", "") eq "current_month_end");
$tsend = strftime "%Y-%m-%d %T",localtime(timelocal(59,59,23,$dim,$mon,$year)) if(AttrVal($name, "timestamp_end", "") eq "current_month_end");
}
if (AttrVal($name, "timestamp_begin", "") eq "previous_month_begin" ||
@ -2201,7 +2229,7 @@ sub DbRep_createTimeArray {
$ryear = ($mon-1<0)?$year-1:$year;
$rmon = ($mon-1<0)?11:$mon-1;
$tsbegin = strftime "%Y-%m-%d %T",localtime(timelocal(0,0,0,1,$rmon,$ryear)) if(AttrVal($name, "timestamp_begin", "") eq "previous_month_begin");
$tsend = strftime "%Y-%m-%d %T",localtime(timelocal(0,0,0,1,$rmon,$ryear)) if(AttrVal($name, "timestamp_end", "") eq "previous_month_begin");
$tsend = strftime "%Y-%m-%d %T",localtime(timelocal(0,0,0,1,$rmon,$ryear)) if(AttrVal($name, "timestamp_end", "") eq "previous_month_begin");
}
if (AttrVal($name, "timestamp_begin", "") eq "previous_month_end" ||
@ -2210,7 +2238,7 @@ sub DbRep_createTimeArray {
$rmon = ($mon-1<0)?11:$mon-1;
$dim = $rmon-1?30+(($rmon+1)*3%7<4):28+!($ryear%4||$ryear%400*!($ryear%100));
$tsbegin = strftime "%Y-%m-%d %T",localtime(timelocal(59,59,23,$dim,$rmon,$ryear)) if(AttrVal($name, "timestamp_begin", "") eq "previous_month_end");
$tsend = strftime "%Y-%m-%d %T",localtime(timelocal(59,59,23,$dim,$rmon,$ryear)) if(AttrVal($name, "timestamp_end", "") eq "previous_month_end");
$tsend = strftime "%Y-%m-%d %T",localtime(timelocal(59,59,23,$dim,$rmon,$ryear)) if(AttrVal($name, "timestamp_end", "") eq "previous_month_end");
}
if (AttrVal($name, "timestamp_begin", "") eq "current_week_begin" ||
@ -2224,7 +2252,7 @@ sub DbRep_createTimeArray {
$tsub = 518400 if($wday == 0); # wenn Start am "So" dann Korrektur -6 Tage
($rsec,$rmin,$rhour,$rmday,$rmon,$ryear) = localtime(time-$tsub);
$tsbegin = strftime "%Y-%m-%d %T",localtime(timelocal(0,0,0,$rmday,$rmon,$ryear)) if(AttrVal($name, "timestamp_begin", "") eq "current_week_begin");
$tsend = strftime "%Y-%m-%d %T",localtime(timelocal(0,0,0,$rmday,$rmon,$ryear)) if(AttrVal($name, "timestamp_end", "") eq "current_week_begin");
$tsend = strftime "%Y-%m-%d %T",localtime(timelocal(0,0,0,$rmday,$rmon,$ryear)) if(AttrVal($name, "timestamp_end", "") eq "current_week_begin");
}
if (AttrVal($name, "timestamp_begin", "") eq "current_week_end" ||
@ -2238,7 +2266,7 @@ sub DbRep_createTimeArray {
$tadd = 0 if($wday == 0); # wenn Start am "So" keine Korrektur
($rsec,$rmin,$rhour,$rmday,$rmon,$ryear) = localtime(time+$tadd);
$tsbegin = strftime "%Y-%m-%d %T",localtime(timelocal(59,59,23,$rmday,$rmon,$ryear)) if(AttrVal($name, "timestamp_begin", "") eq "current_week_end");
$tsend = strftime "%Y-%m-%d %T",localtime(timelocal(59,59,23,$rmday,$rmon,$ryear)) if(AttrVal($name, "timestamp_end", "") eq "current_week_end");
$tsend = strftime "%Y-%m-%d %T",localtime(timelocal(59,59,23,$rmday,$rmon,$ryear)) if(AttrVal($name, "timestamp_end", "") eq "current_week_end");
}
if (AttrVal($name, "timestamp_begin", "") eq "previous_week_begin" ||
@ -2252,7 +2280,7 @@ sub DbRep_createTimeArray {
$tsub = 1123200 if($wday == 0); # wenn Start am "So" dann Korrektur -13 Tage
($rsec,$rmin,$rhour,$rmday,$rmon,$ryear) = localtime(time-$tsub);
$tsbegin = strftime "%Y-%m-%d %T",localtime(timelocal(0,0,0,$rmday,$rmon,$ryear)) if(AttrVal($name, "timestamp_begin", "") eq "previous_week_begin");
$tsend = strftime "%Y-%m-%d %T",localtime(timelocal(0,0,0,$rmday,$rmon,$ryear)) if(AttrVal($name, "timestamp_end", "") eq "previous_week_begin");
$tsend = strftime "%Y-%m-%d %T",localtime(timelocal(0,0,0,$rmday,$rmon,$ryear)) if(AttrVal($name, "timestamp_end", "") eq "previous_week_begin");
}
if (AttrVal($name, "timestamp_begin", "") eq "previous_week_end" ||
@ -2266,19 +2294,33 @@ sub DbRep_createTimeArray {
$tsub = 604800 if($wday == 0); # wenn Start am "So" dann Korrektur -7 Tage
($rsec,$rmin,$rhour,$rmday,$rmon,$ryear) = localtime(time-$tsub);
$tsbegin = strftime "%Y-%m-%d %T",localtime(timelocal(59,59,23,$rmday,$rmon,$ryear)) if(AttrVal($name, "timestamp_begin", "") eq "previous_week_end");
$tsend = strftime "%Y-%m-%d %T",localtime(timelocal(59,59,23,$rmday,$rmon,$ryear)) if(AttrVal($name, "timestamp_end", "") eq "previous_week_end");
$tsend = strftime "%Y-%m-%d %T",localtime(timelocal(59,59,23,$rmday,$rmon,$ryear)) if(AttrVal($name, "timestamp_end", "") eq "previous_week_end");
}
if (AttrVal($name, "timestamp_begin", "") eq "current_day_begin" ||
AttrVal($name, "timestamp_end", "") eq "current_day_begin") {
$tsbegin = strftime "%Y-%m-%d %T",localtime(timelocal(0,0,0,$mday,$mon,$year)) if(AttrVal($name, "timestamp_begin", "") eq "current_day_begin");
$tsend = strftime "%Y-%m-%d %T",localtime(timelocal(0,0,0,$mday,$mon,$year)) if(AttrVal($name, "timestamp_end", "") eq "current_day_begin");
$tsend = strftime "%Y-%m-%d %T",localtime(timelocal(0,0,0,$mday,$mon,$year)) if(AttrVal($name, "timestamp_end", "") eq "current_day_begin");
}
if (AttrVal($name, "timestamp_begin", "") eq "current_day_end" ||
AttrVal($name, "timestamp_end", "") eq "current_day_end") {
$tsbegin = strftime "%Y-%m-%d %T",localtime(timelocal(59,59,23,$mday,$mon,$year)) if(AttrVal($name, "timestamp_begin", "") eq "current_day_end");
$tsend = strftime "%Y-%m-%d %T",localtime(timelocal(59,59,23,$mday,$mon,$year)) if(AttrVal($name, "timestamp_end", "") eq "current_day_end");
$tsend = strftime "%Y-%m-%d %T",localtime(timelocal(59,59,23,$mday,$mon,$year)) if(AttrVal($name, "timestamp_end", "") eq "current_day_end");
}
if (AttrVal($name, "timestamp_begin", "") eq "next_day_begin" ||
AttrVal($name, "timestamp_end", "") eq "next_day_begin") {
($rsec,$rmin,$rhour,$rmday,$rmon,$ryear) = localtime(time+86400); # Istzeit + 1 Tag
$tsbegin = strftime "%Y-%m-%d %T",localtime(timelocal(0,0,0,$rmday,$rmon,$ryear)) if(AttrVal($name, "timestamp_begin", "") eq "next_day_begin");
$tsend = strftime "%Y-%m-%d %T",localtime(timelocal(0,0,0,$rmday,$rmon,$ryear)) if(AttrVal($name, "timestamp_end", "") eq "next_day_begin");
}
if (AttrVal($name, "timestamp_begin", "") eq "next_day_end" ||
AttrVal($name, "timestamp_end", "") eq "next_day_end") {
($rsec,$rmin,$rhour,$rmday,$rmon,$ryear) = localtime(time+86400); # Istzeit + 1 Tag
$tsbegin = strftime "%Y-%m-%d %T",localtime(timelocal(59,59,23,$rmday,$rmon,$ryear)) if(AttrVal($name, "timestamp_begin", "") eq "next_day_end");
$tsend = strftime "%Y-%m-%d %T",localtime(timelocal(59,59,23,$rmday,$rmon,$ryear)) if(AttrVal($name, "timestamp_end", "") eq "next_day_end");
}
if (AttrVal($name, "timestamp_begin", "") eq "previous_day_begin" ||
@ -2295,7 +2337,7 @@ sub DbRep_createTimeArray {
$rmday = $rmon-1?30+(($rmon+1)*3%7<4):28+!($ryear%4||$ryear%400*!($ryear%100)); # Achtung: Monat als 1...12 (statt 0...11)
}
$tsbegin = strftime "%Y-%m-%d %T",localtime(timelocal(0,0,0,$rmday,$rmon,$ryear)) if(AttrVal($name, "timestamp_begin", "") eq "previous_day_begin");
$tsend = strftime "%Y-%m-%d %T",localtime(timelocal(0,0,0,$rmday,$rmon,$ryear)) if(AttrVal($name, "timestamp_end", "") eq "previous_day_begin");
$tsend = strftime "%Y-%m-%d %T",localtime(timelocal(0,0,0,$rmday,$rmon,$ryear)) if(AttrVal($name, "timestamp_end", "") eq "previous_day_begin");
}
if (AttrVal($name, "timestamp_begin", "") eq "previous_day_end" ||
@ -2312,19 +2354,19 @@ sub DbRep_createTimeArray {
$rmday = $rmon-1?30+(($rmon+1)*3%7<4):28+!($ryear%4||$ryear%400*!($ryear%100)); # Achtung: Monat als 1...12 (statt 0...11)
}
$tsbegin = strftime "%Y-%m-%d %T",localtime(timelocal(59,59,23,$rmday,$rmon,$ryear)) if(AttrVal($name, "timestamp_begin", "") eq "previous_day_end");
$tsend = strftime "%Y-%m-%d %T",localtime(timelocal(59,59,23,$rmday,$rmon,$ryear)) if(AttrVal($name, "timestamp_end", "") eq "previous_day_end");
$tsend = strftime "%Y-%m-%d %T",localtime(timelocal(59,59,23,$rmday,$rmon,$ryear)) if(AttrVal($name, "timestamp_end", "") eq "previous_day_end");
}
if (AttrVal($name, "timestamp_begin", "") eq "current_hour_begin" ||
AttrVal($name, "timestamp_end", "") eq "current_hour_begin") {
$tsbegin = strftime "%Y-%m-%d %T",localtime(timelocal(0,0,$hour,$mday,$mon,$year)) if(AttrVal($name, "timestamp_begin", "") eq "current_hour_begin");
$tsend = strftime "%Y-%m-%d %T",localtime(timelocal(0,0,$hour,$mday,$mon,$year)) if(AttrVal($name, "timestamp_end", "") eq "current_hour_begin");
$tsend = strftime "%Y-%m-%d %T",localtime(timelocal(0,0,$hour,$mday,$mon,$year)) if(AttrVal($name, "timestamp_end", "") eq "current_hour_begin");
}
if (AttrVal($name, "timestamp_begin", "") eq "current_hour_end" ||
AttrVal($name, "timestamp_end", "") eq "current_hour_end") {
$tsbegin = strftime "%Y-%m-%d %T",localtime(timelocal(59,59,$hour,$mday,$mon,$year)) if(AttrVal($name, "timestamp_begin", "") eq "current_hour_end");
$tsend = strftime "%Y-%m-%d %T",localtime(timelocal(59,59,$hour,$mday,$mon,$year)) if(AttrVal($name, "timestamp_end", "") eq "current_hour_end");
$tsend = strftime "%Y-%m-%d %T",localtime(timelocal(59,59,$hour,$mday,$mon,$year)) if(AttrVal($name, "timestamp_end", "") eq "current_hour_end");
}
if (AttrVal($name, "timestamp_begin", "") eq "previous_hour_begin" ||
@ -2346,7 +2388,7 @@ sub DbRep_createTimeArray {
}
}
$tsbegin = strftime "%Y-%m-%d %T",localtime(timelocal(0,0,$rhour,$rmday,$rmon,$ryear)) if(AttrVal($name, "timestamp_begin", "") eq "previous_hour_begin");
$tsend = strftime "%Y-%m-%d %T",localtime(timelocal(0,0,$rhour,$rmday,$rmon,$ryear)) if(AttrVal($name, "timestamp_end", "") eq "previous_hour_begin");
$tsend = strftime "%Y-%m-%d %T",localtime(timelocal(0,0,$rhour,$rmday,$rmon,$ryear)) if(AttrVal($name, "timestamp_end", "") eq "previous_hour_begin");
}
if (AttrVal($name, "timestamp_begin", "") eq "previous_hour_end" || AttrVal($name, "timestamp_end", "") eq "previous_hour_end") {
@ -2369,7 +2411,7 @@ sub DbRep_createTimeArray {
}
$tsbegin = strftime "%Y-%m-%d %T",localtime(timelocal(59,59,$rhour,$rmday,$rmon,$ryear)) if(AttrVal($name, "timestamp_begin", "") eq "previous_hour_end");
$tsend = strftime "%Y-%m-%d %T",localtime(timelocal(59,59,$rhour,$rmday,$rmon,$ryear)) if(AttrVal($name, "timestamp_end", "") eq "previous_hour_end");
$tsend = strftime "%Y-%m-%d %T",localtime(timelocal(59,59,$rhour,$rmday,$rmon,$ryear)) if(AttrVal($name, "timestamp_end", "") eq "previous_hour_end");
}
my ($yyyy1, $mm1, $dd1, $hh1, $min1, $sec1) = $tsbegin =~ /(\d+)-(\d+)-(\d+)\s(\d+):(\d+):(\d+)/x; # extrahieren der Einzelwerte von Datum/Zeit Beginn
@ -13578,16 +13620,16 @@ return;
The timeout can be set with the attribute <a href="#dbreptimeout">timeout</a>.
<br><br>
<ul>
<b>Examples:</b> <br>
{ fhem("get &lt;name&gt; sqlCmdBlocking select device,count(*) from history where timestamp > '2018-04-01' group by device") } <br>
{ CommandGet(undef,"Rep.LogDB1 sqlCmdBlocking select device,count(*) from history where timestamp > '2018-04-01' group by device") } <br>
get &lt;name&gt; sqlCmdBlocking select device,count(*) from history where timestamp > '2018-04-01' group by device <br>
</ul>
<ul>
<b>Examples:</b> <br>
{ fhem("get &lt;name&gt; sqlCmdBlocking select device,count(*) from history where timestamp > '2018-04-01' group by device") } <br>
{ CommandGet(undef,"Rep.LogDB1 sqlCmdBlocking select device,count(*) from history where timestamp > '2018-04-01' group by device") } <br>
get &lt;name&gt; sqlCmdBlocking select device,count(*) from history where timestamp > '2018-04-01' group by device <br>
</ul>
</li>
<br>
Because of its mode of operation this function is particular convenient for user own perl scripts. <br>
Because of its mode of operation this function is particular convenient for user own perl scripts. <br>
The input accepts multi line commands and delivers multi line results as well.
This command also accept the setting of SQL session variables like "SET @open:=NULL,
@closed:=NULL;". <br>
@ -13610,11 +13652,11 @@ sub dbval {
it can be accessed with e.g. those calls:
<br><br>
<ul>
<b>Examples:</b> <br>
{ dbval("&lt;name&gt;","select count(*) from history") } <br>
$ret = dbval("&lt;name&gt;","select count(*) from history"); <br>
</ul>
<ul>
<b>Examples:</b> <br>
{ dbval("&lt;name&gt;","select count(*) from history") } <br>
$ret = dbval("&lt;name&gt;","select count(*) from history"); <br>
</ul>
<br><br>
@ -13634,14 +13676,14 @@ sub dbval {
</li>
<br><br>
<a name="minTimestamp"></a>
<a name="minTimestamp"></a>
<li><b> minTimestamp </b> - Identifies the oldest timestamp in the database (will be executed implicitely at FHEM start).
The timestamp is used as begin of data selection if no time attribut is set to determine the
start date.
</li>
<br><br>
<a name="procinfo"></a>
<a name="procinfo"></a>
<li><b> procinfo </b> - Reports the existing database processes in a summary table (only MySQL). <br>
Typically only the own processes of the connection user (set in DbLog configuration file) will be
reported. If all precesses have to be reported, the global "PROCESS" right has to be granted to the
@ -13655,7 +13697,7 @@ sub dbval {
<br><br>
<a name="storedCredentials"></a>
<li><b> storedCredentials </b> - Reports the users / passwords stored for database access by the device. <br>
<li><b> storedCredentials </b> - Reports the users / passwords stored for database access by the device. <br>
(only valid if database type is MYSQL)
</li>
<br><br>
@ -13708,9 +13750,9 @@ sub dbval {
</li>
<br>
<br>
It contains only main release informations for module users. <br>
It contains only main release informations for module users. <br>
If no options are specified, both release informations and hints will be shown. "rel" shows
only release informations and "hints" shows only hints. By the &lt;key&gt;-specification only
the hint with the specified number is shown.
@ -14308,6 +14350,8 @@ sub bdump {
<b>current_day_end</b> : matches "&lt;current day&gt; 23:59:59" <br>
<b>previous_day_begin</b> : matches "&lt;previous day&gt; 00:00:00" <br>
<b>previous_day_end</b> : matches "&lt;previous day&gt; 23:59:59" <br>
<b>next_day_begin</b> : matches "&lt;next day&gt; 00:00:00" <br>
<b>next_day_end</b> : matches "&lt;next day&gt; 23:59:59" <br>
<b>current_hour_begin</b> : matches "&lt;current hour&gt;:00:00" <br>
<b>current_hour_end</b> : matches "&lt;current hour&gt;:59:59" <br>
<b>previous_hour_begin</b> : matches "&lt;previous hour&gt;:00:00" <br>
@ -14340,6 +14384,8 @@ sub bdump {
<b>current_day_end</b> : matches "&lt;current day&gt; 23:59:59" <br>
<b>previous_day_begin</b> : matches "&lt;previous day&gt; 00:00:00" <br>
<b>previous_day_end</b> : matches "&lt;previous day&gt; 23:59:59" <br>
<b>next_day_begin</b> : matches "&lt;next day&gt; 00:00:00" <br>
<b>next_day_end</b> : matches "&lt;next day&gt; 23:59:59" <br>
<b>current_hour_begin</b> : matches "&lt;current hour&gt;:00:00" <br>
<b>current_hour_end</b> : matches "&lt;current hour&gt;:59:59" <br>
<b>previous_hour_begin</b> : matches "&lt;previous hour&gt;:00:00" <br>
@ -14846,7 +14892,7 @@ sub bdump {
berücksichtigt wie gesetzte Zeitgrenzen (Attribute time.*). <br>
Fehlen diese Beschränkungen, wird die gesamte Datenbank durchsucht und der angegebene Wert
geändert. <br><br>
</li>
</li>
<ul>
<b>Syntax: </b> <br>
@ -14866,7 +14912,7 @@ sub bdump {
des Perl-Code geändert werden. Der zurückgebene Wert von $VALUE und $UNIT wird in dem Feld
VALUE bzw. UNIT des Datensatzes gespeichert. </li></td></tr>
</table>
</ul>
</ul>
<br>
<ul>
@ -14914,7 +14960,7 @@ sub bdump {
Sind die Timestamps nicht gesetzt, werden alle Einträge der Tabelle gezählt.
Beschränkungen durch die Attribute <a href="#device">device</a> bzw. <a href="#reading">reading</a>
gehen in die Selektion mit ein. <br>
</li>
</li>
Standardmäßig wird die Summe aller Datensätze, gekennzeichnet mit "ALLREADINGS", erstellt.
Ist das Attribut "countEntriesDetail" gesetzt, wird die Anzahl jedes einzelnen Readings
@ -14945,7 +14991,7 @@ sub bdump {
berücksichtigt. Ist das Attribut "aggregation" nicht oder auf "no" gesetzt, wird im Standard die Aggregation
"day" verwendet.
<br><br>
</li>
</li>
<ul>
<table>
@ -16211,14 +16257,14 @@ sub bdump {
Ergebnismenge eingeschränkt werden, um nur gewünschte Ergebnisse abzurufen. Detailinformationen zur Bedeutung der einzelnen Readings
sind <a href="http://dev.mysql.com/doc/refman/5.7/en/server-status-variables.html">hier</a> verfügbar. <br><br>
<ul>
<b>Beispiel</b> <br>
attr &lt;name&gt; showStatus %uptime%,%qcache% <br>
get &lt;name&gt; dbstatus <br>
# Es werden nur Readings erzeugt die im Namen "uptime" und "qcache" enthaltenen
</ul>
</li>
<br><br>
<ul>
<b>Beispiel</b> <br>
attr &lt;name&gt; showStatus %uptime%,%qcache% <br>
get &lt;name&gt; dbstatus <br>
# Es werden nur Readings erzeugt die im Namen "uptime" und "qcache" enthaltenen
</ul>
</li>
<br><br>
<a name="sqlCmdBlocking"></a>
<li><b> sqlCmdBlocking &lt;SQL-Statement&gt;</b> -
@ -16226,14 +16272,14 @@ sub bdump {
Der Timeout kann mit dem Attribut <a href="#dbreptimeout">timeout</a> eingestellt werden.
<br><br>
<ul>
<b>Beispiele:</b> <br>
{ fhem("get &lt;name&gt; sqlCmdBlocking select device,count(*) from history where timestamp > '2018-04-01' group by device") } <br>
{ CommandGet(undef,"Rep.LogDB1 sqlCmdBlocking select device,count(*) from history where timestamp > '2018-04-01' group by device") } <br>
get &lt;name&gt; sqlCmdBlocking select device,count(*) from history where timestamp > '2018-04-01' group by device <br>
</ul>
<ul>
<b>Beispiele:</b> <br>
{ fhem("get &lt;name&gt; sqlCmdBlocking select device,count(*) from history where timestamp > '2018-04-01' group by device") } <br>
{ CommandGet(undef,"Rep.LogDB1 sqlCmdBlocking select device,count(*) from history where timestamp > '2018-04-01' group by device") } <br>
get &lt;name&gt; sqlCmdBlocking select device,count(*) from history where timestamp > '2018-04-01' group by device <br>
</ul>
</li>
<br>
<br>
Diese Funktion ist durch ihre Arbeitsweise speziell für den Einsatz in benutzerspezifischen Scripten geeignet. <br>
Die Eingabe akzeptiert Mehrzeiler und gibt ebenso mehrzeilige Ergebisse zurück.
@ -16246,7 +16292,7 @@ sub bdump {
wird nicht aufgerufen.
<br><br>
Erstellt man eine kleine Routine in 99_myUtils, wie z.B.:
Erstellt man eine kleine Routine in 99_myUtils, wie z.B.:
<br>
<pre>
sub dbval {
@ -16259,12 +16305,12 @@ sub dbval {
kann sqlCmdBlocking vereinfacht verwendet werden mit Aufrufen wie:
<br><br>
<ul>
<b>Beispiele:</b> <br>
{ dbval("&lt;name&gt;","select count(*) from history") } <br>
oder <br>
$ret = dbval("&lt;name&gt;","select count(*) from history"); <br>
</ul>
<ul>
<b>Beispiele:</b> <br>
{ dbval("&lt;name&gt;","select count(*) from history") } <br>
oder <br>
$ret = dbval("&lt;name&gt;","select count(*) from history"); <br>
</ul>
<br><br>
@ -16275,14 +16321,14 @@ sub dbval {
abzurufen. Weitere Informationen zur Bedeutung der ausgegebenen Variablen sind
<a href="http://dev.mysql.com/doc/refman/5.7/en/server-system-variables.html">hier</a> verfügbar. <br><br>
<ul>
<b>Beispiel</b> <br>
attr &lt;name&gt; showVariables %version%,%query_cache% <br>
get &lt;name&gt; dbvars <br>
# Es werden nur Readings erzeugt die im Namen "version" und "query_cache" enthalten
</ul>
</li>
<br><br>
<ul>
<b>Beispiel</b> <br>
attr &lt;name&gt; showVariables %version%,%query_cache% <br>
get &lt;name&gt; dbvars <br>
# Es werden nur Readings erzeugt die im Namen "version" und "query_cache" enthalten
</ul>
</li>
<br><br>
<a name="minTimestamp"></a>
<li><b> minTimestamp </b> - Ermittelt den Zeitstempel des ältesten Datensatzes in der Datenbank (wird implizit beim Start von
@ -16316,14 +16362,14 @@ sub dbval {
Weitere Erläuterungen zu den gelieferten Informationen sind
<a href="https://msdn.microsoft.com/en-us/library/ms711681(v=vs.85).aspx">hier</a> zu finden. <br><br>
<ul>
<b>Beispiel</b> <br>
attr &lt;name&gt; showSvrInfo %SQL_CATALOG_TERM%,%NAME% <br>
get &lt;name&gt; svrinfo <br>
# Es werden nur Readings erzeugt die im Namen "SQL_CATALOG_TERM" und "NAME" enthalten
</ul>
</li>
<br><br>
<ul>
<b>Beispiel</b> <br>
attr &lt;name&gt; showSvrInfo %SQL_CATALOG_TERM%,%NAME% <br>
get &lt;name&gt; svrinfo <br>
# Es werden nur Readings erzeugt die im Namen "SQL_CATALOG_TERM" und "NAME" enthalten
</ul>
</li>
<br><br>
<a name="tableinfo"></a>
<li><b> tableinfo </b> - ruft Tabelleninformationen aus der mit dem DbRep-Device verbundenen Datenbank ab (MySQL).
@ -16331,14 +16377,14 @@ sub dbval {
Mit dem Attribut <a href="#showTableInfo">showTableInfo</a> können die Ergebnisse eingeschränkt werden. Erläuterungen zu den erzeugten
Readings sind <a href="http://dev.mysql.com/doc/refman/5.7/en/show-table-status.html">hier</a> zu finden. <br><br>
<ul>
<b>Beispiel</b> <br>
attr &lt;name&gt; showTableInfo current,history <br>
get &lt;name&gt; tableinfo <br>
# Es werden nur Information der Tabellen "current" und "history" angezeigt
</ul>
</li>
<br><br>
<ul>
<b>Beispiel</b> <br>
attr &lt;name&gt; showTableInfo current,history <br>
get &lt;name&gt; tableinfo <br>
# Es werden nur Information der Tabellen "current" und "history" angezeigt
</ul>
</li>
<br><br>
<a name="versionNotes"></a>
<li><b> versionNotes [hints | rel | &lt;key&gt;] </b> -
@ -16356,9 +16402,9 @@ sub dbval {
</li>
<br>
Sind keine Optionen angegeben, werden sowohl Release Informationen als auch Hinweise angezeigt.
Es sind nur Release Informationen mit Bedeutung für den Modulnutzer enthalten. <br>
<br>
Sind keine Optionen angegeben, werden sowohl Release Informationen als auch Hinweise angezeigt.
Es sind nur Release Informationen mit Bedeutung für den Modulnutzer enthalten. <br>
<br>
@ -16959,6 +17005,8 @@ sub bdump {
<b>current_day_end</b> : entspricht "&lt;aktueller Tag&gt; 23:59:59" <br>
<b>previous_day_begin</b> : entspricht "&lt;Vortag&gt; 00:00:00" <br>
<b>previous_day_end</b> : entspricht "&lt;Vortag&gt; 23:59:59" <br>
<b>next_day_begin</b> : entspricht "&lt;nächster Tag&gt; 00:00:00" <br>
<b>next_day_end</b> : entspricht "&lt;nächster Tag&gt; 23:59:59" <br>
<b>current_hour_begin</b> : entspricht "&lt;aktuelle Stunde&gt;:00:00" <br>
<b>current_hour_end</b> : entspricht "&lt;aktuelle Stunde&gt;:59:59" <br>
<b>previous_hour_begin</b> : entspricht "&lt;vorherige Stunde&gt;:00:00" <br>
@ -16990,6 +17038,8 @@ sub bdump {
<b>current_day_end</b> : entspricht "&lt;aktueller Tag&gt; 23:59:59" <br>
<b>previous_day_begin</b> : entspricht "&lt;Vortag&gt; 00:00:00" <br>
<b>previous_day_end</b> : entspricht "&lt;Vortag&gt; 23:59:59" <br>
<b>next_day_begin</b> : entspricht "&lt;nächster Tag&gt; 00:00:00" <br>
<b>next_day_end</b> : entspricht "&lt;nächster Tag&gt; 23:59:59" <br>
<b>current_hour_begin</b> : entspricht "&lt;aktuelle Stunde&gt;:00:00" <br>
<b>current_hour_end</b> : entspricht "&lt;aktuelle Stunde&gt;:59:59" <br>
<b>previous_hour_begin</b> : entspricht "&lt;vorherige Stunde&gt;:00:00" <br>