mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-04-20 19:36:02 +00:00
93_DbRep: consideration of leap year/daylight saving time changed, activate support of Meta.pm
git-svn-id: https://svn.fhem.de/fhem/trunk@19065 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
c001fa2c5b
commit
eb8f7879e0
@ -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.
|
||||||
|
- change: 93_DbRep: consideration of leap year/daylight saving time changed,
|
||||||
|
activate support of Meta.pm
|
||||||
- change: 74_AMADDevice: change to perl packages, add Meta and Installer
|
- change: 74_AMADDevice: change to perl packages, add Meta and Installer
|
||||||
Support
|
Support
|
||||||
- change: 73_AMADCommBridge: change to perl packages, add Meta and Installer
|
- change: 73_AMADCommBridge: change to perl packages, add Meta and Installer
|
||||||
|
@ -45,6 +45,7 @@ use POSIX qw(strftime);
|
|||||||
use Time::HiRes qw(gettimeofday tv_interval);
|
use Time::HiRes qw(gettimeofday tv_interval);
|
||||||
use Scalar::Util qw(looks_like_number);
|
use Scalar::Util qw(looks_like_number);
|
||||||
eval "use DBI;1" or my $DbRepMMDBI = "DBI";
|
eval "use DBI;1" or my $DbRepMMDBI = "DBI";
|
||||||
|
eval "use FHEM::Meta;1" or my $modMetaAbsent = 1;
|
||||||
use DBI::Const::GetInfoType;
|
use DBI::Const::GetInfoType;
|
||||||
use Blocking;
|
use Blocking;
|
||||||
use Color; # colorpicker Widget
|
use Color; # colorpicker Widget
|
||||||
@ -57,6 +58,8 @@ no if $] >= 5.017011, warnings => 'experimental::smartmatch';
|
|||||||
|
|
||||||
# Version History intern
|
# Version History intern
|
||||||
our %DbRep_vNotesIntern = (
|
our %DbRep_vNotesIntern = (
|
||||||
|
"8.17.2" => "28.03.2019 consideration of daylight saving time/leap year changed (func DbRep_corrRelTime) ",
|
||||||
|
"8.17.1" => "24.03.2019 edit Meta data, activate Meta.pm, prevent module from deactivation in case of unavailable Meta.pm ",
|
||||||
"8.17.0" => "20.03.2019 prepare for Meta.pm, new attribute \"sqlCmdVars\" ",
|
"8.17.0" => "20.03.2019 prepare for Meta.pm, new attribute \"sqlCmdVars\" ",
|
||||||
"8.16.0" => "17.03.2019 include sortTopicNum from 99_Utils, allow PRAGMAS leading an SQLIte SQL-Statement in sqlCmd, switch to DbRep_setVersionInfo ",
|
"8.16.0" => "17.03.2019 include sortTopicNum from 99_Utils, allow PRAGMAS leading an SQLIte SQL-Statement in sqlCmd, switch to DbRep_setVersionInfo ",
|
||||||
"8.15.0" => "04.03.2019 readingsRename can rename readings of a given (optional) device ",
|
"8.15.0" => "04.03.2019 readingsRename can rename readings of a given (optional) device ",
|
||||||
@ -371,7 +374,7 @@ sub DbRep_Initialize($) {
|
|||||||
# "device" => "deviceFilter",
|
# "device" => "deviceFilter",
|
||||||
# };
|
# };
|
||||||
|
|
||||||
# FHEM::Meta::InitMod( __FILE__, $hash ); # für Meta.pm (https://forum.fhem.de/index.php/topic,97589.0.html)
|
eval { FHEM::Meta::InitMod( __FILE__, $hash ) }; # für Meta.pm (https://forum.fhem.de/index.php/topic,97589.0.html)
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -401,6 +404,7 @@ sub DbRep_Define($@) {
|
|||||||
$hash->{MODEL} = $hash->{ROLE};
|
$hash->{MODEL} = $hash->{ROLE};
|
||||||
$hash->{HELPER}{DBLOGDEVICE} = $a[2];
|
$hash->{HELPER}{DBLOGDEVICE} = $a[2];
|
||||||
$hash->{HELPER}{IDRETRIES} = 3; # Anzahl wie oft versucht wird initiale Daten zu holen
|
$hash->{HELPER}{IDRETRIES} = 3; # Anzahl wie oft versucht wird initiale Daten zu holen
|
||||||
|
$hash->{HELPER}{MODMETAABSENT} = 1 if($modMetaAbsent); # Modul Meta.pm nicht vorhanden
|
||||||
$hash->{NOTIFYDEV} = "global,".$name; # nur Events dieser Devices an DbRep_Notify weiterleiten
|
$hash->{NOTIFYDEV} = "global,".$name; # nur Events dieser Devices an DbRep_Notify weiterleiten
|
||||||
my $dbconn = $defs{$a[2]}{dbconn};
|
my $dbconn = $defs{$a[2]}{dbconn};
|
||||||
$hash->{DATABASE} = (split(/;|=/, $dbconn))[1];
|
$hash->{DATABASE} = (split(/;|=/, $dbconn))[1];
|
||||||
@ -6427,7 +6431,7 @@ sub mysql_DoDumpClientSide($) {
|
|||||||
my $ead = AttrVal($name, "executeAfterProc", undef);
|
my $ead = AttrVal($name, "executeAfterProc", undef);
|
||||||
my $mysql_commentstring = "-- ";
|
my $mysql_commentstring = "-- ";
|
||||||
my $character_set = "utf8";
|
my $character_set = "utf8";
|
||||||
my $repver = $hash->{VERSION};
|
my $repver = $hash->{HELPER}{VERSION};
|
||||||
my $sql_text = '';
|
my $sql_text = '';
|
||||||
my $sql_file = '';
|
my $sql_file = '';
|
||||||
my $dbpraefix = "";
|
my $dbpraefix = "";
|
||||||
@ -8978,35 +8982,45 @@ sub DbRep_corrRelTime($$$) {
|
|||||||
# year als Jahre seit 1900
|
# year als Jahre seit 1900
|
||||||
# $mon als 0..11
|
# $mon als 0..11
|
||||||
my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst);
|
my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst);
|
||||||
my ($dsec,$dmin,$dhour,$dmday,$dmon,$dyear,$dwday,$dyday,$disdst);
|
my ($dsec,$dmin,$dhour,$dmday,$dmon,$dyear,$dwday,$dyday,$disdst,$fyear,$cyear);
|
||||||
|
(undef,undef,undef,undef,undef,$cyear,undef,undef,$isdst) = localtime(time); # aktuelles Jahr, Sommer/Winterzeit
|
||||||
if($tdtn) {
|
if($tdtn) {
|
||||||
# timeDiffToNow
|
# timeDiffToNow
|
||||||
($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time); # Startzeit Ableitung
|
($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,undef) = localtime(time); # Istzeit
|
||||||
($dsec,$dmin,$dhour,$dmday,$dmon,$dyear,$dwday,$dyday,$disdst) = localtime(time-$tim); # Analyse Zieltimestamp timeDiffToNow
|
($dsec,$dmin,$dhour,$dmday,$dmon,$dyear,$dwday,$dyday,$disdst) = localtime(time-$tim); # Istzeit abzgl. Differenzzeit = Selektionsbeginnzeit
|
||||||
} else {
|
} else {
|
||||||
# timeOlderThan
|
# timeOlderThan
|
||||||
($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time-$tim); # Startzeit Ableitung
|
($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$disdst) = localtime(time-$tim); # Berechnung Selektionsendezeit
|
||||||
my $mints = $hash->{HELPER}{MINTS}?$hash->{HELPER}{MINTS}:"1970-01-01 01:00:00"; # Timestamp des 1. Datensatzes verwenden falls ermittelt
|
my $mints = $hash->{HELPER}{MINTS}?$hash->{HELPER}{MINTS}:"1970-01-01 01:00:00"; # Selektionsstartzeit
|
||||||
my ($yyyy1, $mm1, $dd1, $hh1, $min1, $sec1) = ($mints =~ /(\d+)-(\d+)-(\d+) (\d+):(\d+):(\d+)/);
|
my ($yyyy1, $mm1, $dd1, $hh1, $min1, $sec1) = ($mints =~ /(\d+)-(\d+)-(\d+) (\d+):(\d+):(\d+)/);
|
||||||
my $tsend = timelocal($sec1, $min1, $hh1, $dd1, $mm1-1, $yyyy1-1900);
|
my $tsend = timelocal($sec1, $min1, $hh1, $dd1, $mm1-1, $yyyy1-1900);
|
||||||
($dsec,$dmin,$dhour,$dmday,$dmon,$dyear,$dwday,$dyday,$disdst) = localtime($tsend); # Analyse Zieltimestamp timeOlderThan
|
($dsec,$dmin,$dhour,$dmday,$dmon,$dyear,$dwday,$dyday,undef) = localtime($tsend); # Timestamp Selektionsstartzeit
|
||||||
}
|
}
|
||||||
$year += 1900;
|
$year += 1900; # aktuelles Jahr
|
||||||
$dyear += 1900;
|
$dyear += 1900; # Startjahr der Selektion
|
||||||
my $k = $year - $dyear;
|
$cyear += 1900; # aktuelles Jahr
|
||||||
my $mg = ((int($mon)+1)+(($year-$dyear-1)*12)+(11-int($dmon)+1)); # Gesamtzahl der Monate des Bewertungszeitraumes
|
if($tdtn) {
|
||||||
|
# timeDiffToNow
|
||||||
|
$fyear = $dyear; # Berechnungsjahr -> hier Selektionsbeginn
|
||||||
|
} else {
|
||||||
|
# timeOlderThan
|
||||||
|
$fyear = $year; # Berechnungsjahr -> hier Selektionsende
|
||||||
|
}
|
||||||
|
|
||||||
|
my $k = $cyear - $fyear; # Anzahl Jahre
|
||||||
|
my $mg = ((int($mon)+1)+(($k-1)*12)+(11-int($dmon)+1)); # Gesamtzahl der Monate des Bewertungszeitraumes
|
||||||
my $cly = 0; # Anzahl Schaltjahre innerhalb Beginn und Ende Auswertungszeitraum
|
my $cly = 0; # Anzahl Schaltjahre innerhalb Beginn und Ende Auswertungszeitraum
|
||||||
my $fly = 0; # erstes Schaltjahr nach Start
|
my $fly = 0; # erstes Schaltjahr nach Start
|
||||||
my $lly = 0; # letzes Schaltjahr nach Start
|
my $lly = 0; # letzes Schaltjahr nach Start
|
||||||
while ($dyear+$k >= $dyear) {
|
while ($fyear+$k >= $fyear) {
|
||||||
my $ily = DbRep_IsLeapYear($name,$dyear+$k);
|
my $ily = DbRep_IsLeapYear($name,$fyear+$k);
|
||||||
$cly++ if($ily);
|
$cly++ if($ily);
|
||||||
$fly = $dyear+$k if($ily && !$fly);
|
$fly = $fyear+$k if($ily && !$fly);
|
||||||
$lly = $dyear+$k if($ily);
|
$lly = $fyear+$k if($ily);
|
||||||
$k--;
|
$k--;
|
||||||
}
|
}
|
||||||
# Log3($name, 4, "DbRep $name - countleapyear: $cly firstleapyear: $fly lastleapyear: $lly totalmonth: $mg isdaylight:$isdst destdaylight:$disdst");
|
|
||||||
if( ($fly <= $year && $mon > 1) && ($lly > $dyear || ($lly = $dyear && $dmon < 1)) ) {
|
if( $mon > 1 && ($lly > $fyear || ($lly = $fyear && $dmon < 1)) ) {
|
||||||
$tim += $cly*86400;
|
$tim += $cly*86400;
|
||||||
# Log3($name, 4, "DbRep $name - leap year correction 1");
|
# Log3($name, 4, "DbRep $name - leap year correction 1");
|
||||||
} else {
|
} else {
|
||||||
@ -9015,8 +9029,11 @@ sub DbRep_corrRelTime($$$) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
# Sommer/Winterzeitkorrektur
|
# Sommer/Winterzeitkorrektur
|
||||||
|
(undef,undef,undef,undef,undef,undef,undef,undef,$disdst) = localtime(time-$tim);
|
||||||
$tim += ($disdst-$isdst)*3600 if($disdst != $isdst);
|
$tim += ($disdst-$isdst)*3600 if($disdst != $isdst);
|
||||||
|
|
||||||
|
Log3($name, 4, "DbRep $name - startMonth: $mon endMonth: $dmon lastleapyear: $lly baseYear: $fyear destdaylight:$disdst isdaylight:$isdst");
|
||||||
|
|
||||||
return $tim;
|
return $tim;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -10136,7 +10153,7 @@ sub DbRep_setVersionInfo($) {
|
|||||||
$hash->{HELPER}{PACKAGE} = __PACKAGE__;
|
$hash->{HELPER}{PACKAGE} = __PACKAGE__;
|
||||||
$hash->{HELPER}{VERSION} = $v;
|
$hash->{HELPER}{VERSION} = $v;
|
||||||
|
|
||||||
if($modules{$type}{META}{x_prereqs_src}) {
|
if($modules{$type}{META}{x_prereqs_src} && !$hash->{HELPER}{MODMETAABSENT}) {
|
||||||
# META-Daten sind vorhanden
|
# META-Daten sind vorhanden
|
||||||
$modules{$type}{META}{version} = "v".$v; # Version aus META.json überschreiben, Anzeige mit {Dumper $modules{SMAPortal}{META}}
|
$modules{$type}{META}{version} = "v".$v; # Version aus META.json überschreiben, Anzeige mit {Dumper $modules{SMAPortal}{META}}
|
||||||
if($modules{$type}{META}{x_version}) { # {x_version} ( nur gesetzt wenn $Id$ im Kopf komplett! vorhanden )
|
if($modules{$type}{META}{x_version}) { # {x_version} ( nur gesetzt wenn $Id$ im Kopf komplett! vorhanden )
|
||||||
@ -10145,7 +10162,7 @@ sub DbRep_setVersionInfo($) {
|
|||||||
$modules{$type}{META}{x_version} = $v;
|
$modules{$type}{META}{x_version} = $v;
|
||||||
}
|
}
|
||||||
return $@ unless (FHEM::Meta::SetInternals($hash)); # FVERSION wird gesetzt ( nur gesetzt wenn $Id$ im Kopf komplett! vorhanden )
|
return $@ unless (FHEM::Meta::SetInternals($hash)); # FVERSION wird gesetzt ( nur gesetzt wenn $Id$ im Kopf komplett! vorhanden )
|
||||||
if( __PACKAGE__ eq $type) {
|
if(__PACKAGE__ eq "FHEM::$type" || __PACKAGE__ eq $type) {
|
||||||
# es wird mit Packages gearbeitet -> Perl übliche Modulversion setzen
|
# es wird mit Packages gearbeitet -> Perl übliche Modulversion setzen
|
||||||
# mit {<Modul>->VERSION()} im FHEMWEB kann Modulversion abgefragt werden
|
# mit {<Modul>->VERSION()} im FHEMWEB kann Modulversion abgefragt werden
|
||||||
use version 0.77; our $VERSION = FHEM::Meta::Get( $hash, 'version' );
|
use version 0.77; our $VERSION = FHEM::Meta::Get( $hash, 'version' );
|
||||||
@ -15224,19 +15241,20 @@ sub bdump {
|
|||||||
"Net::FTPSSL": 0,
|
"Net::FTPSSL": 0,
|
||||||
"Net::FTP": 0,
|
"Net::FTP": 0,
|
||||||
"IO::Compress::Gzip": 0,
|
"IO::Compress::Gzip": 0,
|
||||||
"IO::Uncompress::Gunzip": 0
|
"IO::Uncompress::Gunzip": 0,
|
||||||
|
"FHEM::Meta": 0
|
||||||
},
|
},
|
||||||
"suggests": {
|
"suggests": {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"resources": {
|
"resources": {
|
||||||
"bugtracker": {
|
"x_wiki": {
|
||||||
"web": "https://forum.fhem.de/index.php/board,46.0.html",
|
"web": "https://wiki.fhem.de/wiki/DbRep_-_Reporting_und_Management_von_DbLog-Datenbankinhalten",
|
||||||
"x_web_title": "FHEM Forum: Sonstiges"
|
"title": "DbRep - Reporting und Management von DbLog-Datenbankinhalten"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
=end :application/json;q=META.json
|
=end :application/json;q=META.json
|
||||||
|
|
||||||
=cu
|
=cut
|
Loading…
x
Reference in New Issue
Block a user