mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-01-31 06:39:11 +00:00
93_DbLog: check valid Event Time limit, Forum: #139847
git-svn-id: https://svn.fhem.de/fhem/trunk@29393 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
93e088fa13
commit
44c513ceb4
@ -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_DbLog: check valid Event Time limit, Forum: #139847
|
||||
- bugfix: 93_DbRep: fix check changeValue Forum: #139950
|
||||
- change: 01_FHEMWEB: add filtered Event Monitor to detail view
|
||||
- feature: 76_SolarForecast: attr setupRadiationAPI and setupWeatherDev1 can
|
||||
|
@ -58,6 +58,7 @@ use vars qw($FW_ME $FW_subdir); # predeclar
|
||||
|
||||
# Version History intern by DS_Starter:
|
||||
my %DbLog_vNotesIntern = (
|
||||
"5.10.3" => "01.12.2024 check valid Time limit 1970-01-01 00:00:00 of Event time, Forum: #139847 ",
|
||||
"5.10.2" => "21.07.2024 _DbLog_copyCache: Copy process changed to minimize memory usage after reopen ",
|
||||
"5.10.1" => "01.04.2024 _DbLog_plotData: avoid possible uninitialized value \$out_value (SVG: Argument '' isn't numeric) ".
|
||||
"replace Smartmatch Forum:#137776 ",
|
||||
@ -881,12 +882,10 @@ sub _DbLog_setaddCacheLine { ## no critic "not used"
|
||||
return "Syntax error in set $opt command. Use this line format: YYYY-MM-DD HH:MM:SS|<device>|<type>|<event>|<reading>|<value>|[<unit>] ";
|
||||
}
|
||||
|
||||
my ($yyyy, $mm, $dd, $hh, $min, $sec) = ($i_timestamp =~ /(\d+)-(\d+)-(\d+) (\d+):(\d+):(\d+)/);
|
||||
eval { my $ts = timelocal($sec, $min, $hh, $dd, $mm-1, $yyyy-1900); };
|
||||
my $err = DbLog_checkValidTime ($i_timestamp);
|
||||
|
||||
if ($@) {
|
||||
my @l = split /at/, $@;
|
||||
return "Timestamp is out of range - $l[0]";
|
||||
if ($err) {
|
||||
return "Timestamp is out of range: $err";
|
||||
}
|
||||
|
||||
DbLog_addCacheLine ( { hash => $hash,
|
||||
@ -1216,7 +1215,7 @@ sub DbLog_Log {
|
||||
}
|
||||
}
|
||||
|
||||
my ($event,$reading,$value,$unit,$err,$DoIt);
|
||||
my ($event, $reading, $value, $unit, $err, $DoIt, $epoch_seconds_begin);
|
||||
|
||||
my $memcount = 0;
|
||||
my $re = $hash->{REGEXP};
|
||||
@ -1403,14 +1402,13 @@ sub DbLog_Log {
|
||||
next;
|
||||
}
|
||||
|
||||
my ($yyyy, $mm, $dd, $hh, $min, $sec) = ($TIMESTAMP =~ /(\d+)-(\d+)-(\d+) (\d+):(\d+):(\d+)/);
|
||||
$err = DbLog_checkValidTime ($TIMESTAMP);
|
||||
|
||||
eval { my $epoch_seconds_begin = timelocal($sec, $min, $hh, $dd, $mm-1, $yyyy-1900); };
|
||||
if (!$@) {
|
||||
$timestamp = $TIMESTAMP;
|
||||
if ($err) {
|
||||
Log3 ($name, 2, "$name - TIMESTAMP >$TIMESTAMP< got from DbLogValueFn in $dev_name is invalid: $err");
|
||||
}
|
||||
else {
|
||||
Log3 ($name, 2, "$name - TIMESTAMP got from DbLogValueFn in $dev_name is invalid: $TIMESTAMP");
|
||||
$timestamp = $TIMESTAMP;
|
||||
}
|
||||
|
||||
$reading = $READING if($READING ne '');
|
||||
@ -1448,14 +1446,13 @@ sub DbLog_Log {
|
||||
next;
|
||||
}
|
||||
|
||||
my ($yyyy, $mm, $dd, $hh, $min, $sec) = ($TIMESTAMP =~ /(\d+)-(\d+)-(\d+) (\d+):(\d+):(\d+)/);
|
||||
$err = DbLog_checkValidTime ($TIMESTAMP);
|
||||
|
||||
eval { my $epoch_seconds_begin = timelocal($sec, $min, $hh, $dd, $mm-1, $yyyy-1900); };
|
||||
if (!$@) {
|
||||
$timestamp = $TIMESTAMP;
|
||||
if ($err) {
|
||||
Log3 ($name, 2, "$name - Parameter TIMESTAMP >$TIMESTAMP< got from valueFn is invalid: $err");
|
||||
}
|
||||
else {
|
||||
Log3 ($name, 2, "$name - Parameter TIMESTAMP got from valueFn is invalid: $TIMESTAMP");
|
||||
$timestamp = $TIMESTAMP;
|
||||
}
|
||||
|
||||
$dev_name = $DEVICE if($DEVICE ne '');
|
||||
@ -1466,6 +1463,13 @@ sub DbLog_Log {
|
||||
$event = $EVENT if(defined $EVENT);
|
||||
}
|
||||
|
||||
$err = DbLog_checkValidTime ($timestamp);
|
||||
|
||||
if ($err) {
|
||||
Log3 ($name, 2, "$name - timestamp >$timestamp< is invalid: ".$err.". The dataset is ignored.");
|
||||
next;
|
||||
}
|
||||
|
||||
# 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);
|
||||
|
||||
@ -3261,7 +3265,7 @@ sub _DbLog_SBP_onRun_LogArray {
|
||||
|
||||
__DbLog_SBP_sendToParent ($subprocess, $ret);
|
||||
|
||||
return;
|
||||
return $error;
|
||||
};
|
||||
|
||||
_DbLog_SBP_dbhRaiseError ($dbh);
|
||||
@ -3976,7 +3980,7 @@ sub _DbLog_SBP_onRun_importCachefile {
|
||||
if (!$error && $nins_hist && keys %{$rowlback}) {
|
||||
_DbLog_SBP_Log3Parent ( { name => $name,
|
||||
level => 2,
|
||||
msg => "WARNING - $nins_hist datasets from $infile were not imported:",
|
||||
msg => "WARNING - $nins_hist datasets from $infile were not imported.",
|
||||
oper => 'log3parent',
|
||||
subprocess => $subprocess
|
||||
}
|
||||
@ -8022,7 +8026,7 @@ sub DbLog_AddLog {
|
||||
|
||||
my ($dev_type,$dev_name,$dev_reading,$read_val,$event,$ut);
|
||||
my $memcount;
|
||||
my $ts;
|
||||
my ($ts, $err);
|
||||
|
||||
return if(IsDisabled($name) || !$hash->{HELPER}{COLSET} || $init_done != 1);
|
||||
|
||||
@ -8128,7 +8132,6 @@ sub DbLog_AddLog {
|
||||
my $ctz = AttrVal($name, 'convertTimezone', 'none'); # convert time zone
|
||||
|
||||
if($ctz ne 'none') {
|
||||
my $err;
|
||||
my $params = {
|
||||
name => $name,
|
||||
dtstring => $ts,
|
||||
@ -8172,14 +8175,13 @@ sub DbLog_AddLog {
|
||||
next;
|
||||
}
|
||||
|
||||
my ($yyyy, $mm, $dd, $hh, $min, $sec) = ($TIMESTAMP =~ /(\d+)-(\d+)-(\d+) (\d+):(\d+):(\d+)/);
|
||||
$err = DbLog_checkValidTime ($TIMESTAMP);
|
||||
|
||||
eval { my $epoch_seconds_begin = timelocal($sec, $min, $hh, $dd, $mm-1, $yyyy-1900); };
|
||||
if (!$@) {
|
||||
$ts = $TIMESTAMP;
|
||||
if ($err) {
|
||||
Log3 ($name, 2, "$name - Parameter TIMESTAMP >$TIMESTAMP< got from valueFn is invalid: $err");
|
||||
}
|
||||
else {
|
||||
Log3 ($name, 2, "$name - Parameter TIMESTAMP got from valueFn is invalid: $TIMESTAMP");
|
||||
$ts = $TIMESTAMP;
|
||||
}
|
||||
|
||||
$dev_name = $DEVICE if($DEVICE ne '');
|
||||
@ -8288,14 +8290,13 @@ sub DbLog_addCacheLine {
|
||||
next;
|
||||
}
|
||||
|
||||
my ($yyyy, $mm, $dd, $hh, $min, $sec) = ($TIMESTAMP =~ /(\d+)-(\d+)-(\d+) (\d+):(\d+):(\d+)/);
|
||||
my $err = DbLog_checkValidTime ($TIMESTAMP);
|
||||
|
||||
eval { my $epoch_seconds_begin = timelocal($sec, $min, $hh, $dd, $mm-1, $yyyy-1900); };
|
||||
if (!$@) {
|
||||
$i_timestamp = $TIMESTAMP;
|
||||
if ($err) {
|
||||
Log3 ($name, 2, "$name - Parameter TIMESTAMP >$TIMESTAMP< got from valueFn is invalid: $err");
|
||||
}
|
||||
else {
|
||||
Log3 ($name, 2, "$name - Parameter TIMESTAMP got from valueFn is invalid: $TIMESTAMP");
|
||||
$i_timestamp = $TIMESTAMP;
|
||||
}
|
||||
|
||||
$i_dev = $DEVICE if($DEVICE ne '');
|
||||
@ -8796,6 +8797,31 @@ sub DbLog_checkTimeformat {
|
||||
return;
|
||||
}
|
||||
|
||||
#################################################################
|
||||
# valide Zeitangabe prüfen
|
||||
#################################################################
|
||||
sub DbLog_checkValidTime {
|
||||
my $timestamp = shift;
|
||||
|
||||
my $esb;
|
||||
|
||||
my ($yyyy, $mm, $dd, $hh, $min, $sec) = ($timestamp =~ /(\d+)-(\d+)-(\d+) (\d+):(\d+):(\d+)/);
|
||||
|
||||
eval { $esb = timelocal ($sec, $min, $hh, $dd, $mm-1, $yyyy-1900); };
|
||||
if ($@) {
|
||||
my @l = split /at/, $@;
|
||||
return $l[0];
|
||||
}
|
||||
|
||||
$esb = fhemTimeLocal ($sec, $min, $hh, $dd, $mm-1, $yyyy-1900);
|
||||
|
||||
if ($esb <= 0) {
|
||||
return "Time limit undershot: $esb";
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
################################################################
|
||||
# Versionierungen des Moduls setzen
|
||||
# Die Verwendung von Meta.pm und Packages wird berücksichtigt
|
||||
|
Loading…
Reference in New Issue
Block a user