mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-04-21 07:56:03 +00:00
93_DbRep: contrib 8.4.0
git-svn-id: https://svn.fhem.de/fhem/trunk@17586 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
66f6fb489b
commit
a5a78db35c
@ -41,10 +41,24 @@ package main;
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
use POSIX qw(strftime);
|
||||
use Time::HiRes qw(gettimeofday tv_interval);
|
||||
use Scalar::Util qw(looks_like_number);
|
||||
eval "use DBI;1" or my $DbRepMMDBI = "DBI";
|
||||
use DBI::Const::GetInfoType;
|
||||
use Blocking;
|
||||
use Color; # colorpicker Widget
|
||||
use Time::Local;
|
||||
use Encode qw(encode_utf8);
|
||||
use IO::Compress::Gzip qw(gzip $GzipError);
|
||||
use IO::Uncompress::Gunzip qw(gunzip $GunzipError);
|
||||
# no if $] >= 5.018000, warnings => 'experimental';
|
||||
no if $] >= 5.017011, warnings => 'experimental::smartmatch';
|
||||
|
||||
# Versions History intern
|
||||
our %DbRep_vNotesIntern = (
|
||||
"8.3.0" => "17.10.2018 reduceLog from DbLog integrated to DbRep, textField-long as default for sqlCmd, both attributes timeOlderThan and timeDiffToNow can be set at same time",
|
||||
"8.4.0" => "22.10.2018 countEntries for every reading if multiple readings set, versionNotes changed to support en/de ",
|
||||
"8.3.0" => "17.10.2018 reduceLog from DbLog integrated into DbRep, textField-long as default for sqlCmd, both attributes timeOlderThan and timeDiffToNow can be set at same time",
|
||||
"8.2.3" => "07.10.2018 check availability of DbLog-device at definition time of DbRep-device ",
|
||||
"8.2.2" => "07.10.2018 DbRep_getMinTs changed, fix don't get the real min timestamp in rare cases ",
|
||||
"8.2.1" => "07.10.2018 \$hash->{dbloghash}{HELPER}{REOPEN_RUNS_UNTIL} contains time until DB is closed ",
|
||||
@ -99,175 +113,13 @@ our %DbRep_vNotesIntern = (
|
||||
"7.3.1" => "08.01.2018 fix syntax error for perl < 5.20 ",
|
||||
"7.3.0" => "07.01.2018 DbRep-charfilter avoid control characters in datasets to export, impfile_Push errortext improved, expfile_DoParse changed to use aggregation for split selects in timeslices (avoid heavy memory consumption) ",
|
||||
"7.2.1" => "04.01.2018 bugfix month out of range that causes fhem crash ",
|
||||
"7.2.0" => "27.12.2017 new attribute 'seqDoubletsVariance' ",
|
||||
"7.1.0" => "22.12.2017 new attribute timeYearPeriod for reports correspondig to e.g. electricity billing, bugfix connection check is running after restart allthough dev is disabled ",
|
||||
"7.0.0" => "18.12.2017 don't set \$runtime_string_first,\$runtime_string_next,\$ts if time/aggregation-attributes not set, change_Push redesigned, new command get blockinginfo, identify if reopen is running on dblog-device and postpone the set-command ",
|
||||
"6.4.3" => "17.12.2017 bugfix in delSeqDoublets, fetchrows if datasets contain characters like \"' <blank> and s.o. ",
|
||||
"6.4.2" => "15.12.2017 change 'delSeqDoublets' to respect attribute 'limit' (adviceDelete,adviceRemain), commandref revised ",
|
||||
"6.4.1" => "13.12.2017 new Attribute 'sqlResultFieldSep' for field separate options of sqlCmd result ",
|
||||
"6.4.0" => "10.12.2017 prepare module for usage of datetime picker widget (Forum:#35736) ",
|
||||
"6.3.2" => "05.12.2017 make direction of fetchrows switchable ASC <-> DESC by attribute fetchRoute ",
|
||||
"6.3.1" => "04.12.2017 fix DBD::mysql::st execute failed: Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'DEVELfhem.history.TIMESTAMP' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by Forum:https://forum.fhem.de/index.php/topic,65860.msg725595.html#msg725595 , fix currentfillup_Push PostgreSQL -> use \$runtime_string_next as Timestring during current insert ",
|
||||
"6.3.0" => "04.12.2017 support addition format d:xx h:xx m:xx s:xx for attributes timeDiffToNow, timeOlderThan ",
|
||||
"6.2.3" => "04.12.2017 fix localtime(time); (current time deduction) in DbRep_createTimeArray ",
|
||||
"6.2.2" => "01.12.2017 support all aggregations for delSeqDoublets, better output filesize when mysql dump finished ",
|
||||
"6.2.1" => "30.11.2017 support delSeqDoublets without device,reading is set and support device-devspec, reading list, minor fixes in delSeqDoublets ",
|
||||
"6.2.0" => "29.11.2017 enhanced command delSeqDoublets by 'delete' ",
|
||||
"6.1.0" => "29.11.2017 new command delSeqDoublets (adviceRemain,adviceDelete), add Option to LASTCMD ",
|
||||
"6.0.0" => "18.11.2017 FTP transfer dumpfile after dump, delete old dumpfiles within Blockingcall (avoid freezes) commandref revised, minor fixes ",
|
||||
"5.8.6" => "30.10.2017 don't limit attr reading, device if the attr contains a list ",
|
||||
"5.8.5" => "19.10.2017 filter unwanted characters in 'procinfo'-result ",
|
||||
"5.8.4" => "17.10.2017 DbRep_createSelectSql, DbRep_createDeleteSql, currentfillup_Push switch to devspec ",
|
||||
"5.8.3" => "16.10.2017 change to use DbRep_createSelectSql: minValue,diffValue - DbRep_createDeleteSql: delEntries ",
|
||||
"5.8.2" => "15.10.2017 sub DbRep_createTimeArray ",
|
||||
"5.8.1" => "15.10.2017 change to use DbRep_createSelectSql: sumValue,averageValue,exportToFile,maxValue ",
|
||||
"5.8.0" => "15.10.2017 adapt DbRep_createSelectSql for better performance if time/aggregation not set, can set table as flexible argument for countEntries, fetchrows (default: history), minor fixes ",
|
||||
"5.7.1" => "13.10.2017 tableCurrentFillup fix for PostgreSQL, commandref revised ",
|
||||
"5.7.0" => "09.10.2017 tableCurrentPurge, tableCurrentFillup ",
|
||||
"5.6.4" => "05.10.2017 abortFn's adapted to use abortArg (Forum:77472) ",
|
||||
"5.6.3" => "01.10.2017 fix crash of fhem due to wrong rmday-calculation if month is changed, Forum:#77328 ",
|
||||
"5.6.2" => "28.08.2017 commandref revised ",
|
||||
"5.6.1" => "18.07.2017 commandref revised, minor fixes ",
|
||||
"5.6.0" => "17.07.2017 default timeout changed to 86400, new get-command 'procinfo' (MySQL) ",
|
||||
"5.5.2" => "16.07.2017 dbmeta_DoParse -> show variables (no global) ",
|
||||
"5.5.1" => "16.07.2017 wrong text output in state when restoreMySQL was aborted by timeout ",
|
||||
"5.5.0" => "10.07.2017 replace \$hash->{dbloghash}{DBMODEL} by \$hash->{dbloghash}{MODEL} (DbLog was changed) ",
|
||||
"5.4.0" => "03.07.2017 restoreMySQL - restore of csv-files (from dumpServerSide), RestoreRowsHistory/ DumpRowsHistory, Commandref revised ",
|
||||
"5.3.1" => "28.06.2017 vacuum for SQLite added, readings enhanced for optimizeTables / vacuum, commandref revised ",
|
||||
"5.3.0" => "26.06.2017 change of DbRep_mysqlOptimizeTables, new command optimizeTables ",
|
||||
"5.2.1" => "25.06.2017 bugfix in sqlCmd_DoParse (PRAGMA, UTF8, SHOW) ",
|
||||
"5.2.0" => "14.06.2017 UTF-8 support for MySQL (fetchrows, srvinfo, expfile, impfile, insert) ",
|
||||
"5.1.0" => "13.06.2017 column 'UNIT' added to fetchrow result ",
|
||||
"5.0.6" => "13.06.2017 add Aria engine to DbRep_mysqlOptimizeTables ",
|
||||
"5.0.5" => "12.06.2017 bugfixes in DbRep_DumpAborted, some changes in dumpMySQL, optimizeTablesBeforeDump added to mysql_DoDumpServerSide, new reading DumpFileCreatedSize ",
|
||||
"5.0.4" => "09.06.2017 some improvements and changes of mysql_DoDump, commandref revised, new attributes executeBeforeDump, executeAfterDump ",
|
||||
"5.0.3" => "07.06.2017 mysql_DoDumpServerSide added ",
|
||||
"5.0.2" => "06.06.2017 little improvements in mysql_DoDumpClientSide ",
|
||||
"5.0.1" => "05.06.2017 dependencies between dumpMemlimit and dumpSpeed created, enhanced verbose 5 logging ",
|
||||
"5.0.0" => "04.06.2017 MySQL Dump nonblocking added ",
|
||||
"4.16.1" => "22.05.2017 encode json without JSON module, requires at least fhem.pl 14348 2017-05-22 20:25:06Z ",
|
||||
"4.16.0" => "22.05.2017 format json as option of sqlResultFormat, state will never be deleted in 'DbRep_delread' ",
|
||||
"4.15.1" => "20.05.2017 correction of commandref ",
|
||||
"4.15.0" => "17.05.2017 SUM(VALUE),AVG(VALUE) recreated for PostgreSQL, Code reviewed and optimized ",
|
||||
"4.14.2" => "16.05.2017 SQL-Statements optimized for Wildcard '%' usage if used, Wildcard '_' isn't supported furthermore, \"averageValue\", \"sumValue\", \"maxValue\", \"minValue\", \"countEntries\" performance optimized, commandref revised ",
|
||||
"4.14.1" => "16.05.2017 limitation of fetchrows result datasets to 1000 by attr limit ",
|
||||
"4.14.0" => "15.05.2017 UserExitFn added as separate sub (DbRep_userexit) and attr userExitFn defined, new subs ReadingsBulkUpdateTimeState, ReadingsBulkUpdateValue, ReadingsSingleUpdateValue, commandref revised ",
|
||||
"4.13.7" => "11.05.2017 attribute sqlResultSingleFormat became sqlResultFormat, sqlResultSingle deleted and sqlCmd contains now all format possibilities (separated,mline,sline,table), commandref revised ",
|
||||
"4.13.6" => "10.05.2017 minor changes ",
|
||||
"4.13.5" => "09.05.2017 cover dbh prepare in eval to avoid crash (sqlResult_DoParse) ",
|
||||
"4.13.4" => "09.05.2017 attribute sqlResultSingleFormat: mline sline table, attribute 'allowDeletion' is now also valid for sqlResult, sqlResultSingle and delete command is forced ",
|
||||
"4.13.3" => "09.05.2017 flexible format of reading SqlResultRow_xxx for proper and sort sequence ",
|
||||
"4.13.2" => "09.05.2017 sqlResult, sqlResultSingle are able to execute delete, insert, update commands error corrections ",
|
||||
"4.13.1" => "09.05.2017 change substitution in sqlResult, sqlResult_DoParse ",
|
||||
"4.13.0" => "09.05.2017 acceptance of viegener change with some corrections (separating lines with ]|[ in Singleline) ",
|
||||
"4.12.3" => "07.05.2017 New sets sqlSelect execute arbitrary sql command returning each row as single reading (fields separated with |) allowing replacement of timestamp values according to attribute definition --> §timestamp_begin§ etc and sqlSelectSingle for executing an sql command returning a single reading (separating lines with §) ",
|
||||
"4.12.2" => "17.04.2017 DbRep_checkUsePK changed ",
|
||||
"4.12.1" => "07.04.2017 get tableinfo changed for MySQL ",
|
||||
"4.12.0" => "31.03.2017 support of primary key for insert functions ",
|
||||
"4.11.4" => "29.03.2017 bugfix timestamp in minValue, maxValue if VALUE contains more than one numeric value (like in sysmon) ",
|
||||
"4.11.3" => "26.03.2017 usage of daylight saving time changed to avoid wrong selection when wintertime switch to summertime, minor bug fixes ",
|
||||
"4.11.2" => "16.03.2017 bugfix in func dbmeta_DoParse (SQLITE_DB_FILENAME) ",
|
||||
"4.11.1" => "28.02.2017 commandref completed ",
|
||||
"4.11.0" => "18.02.2017 added [current|previous]_[month|week|day|hour]_begin and [current|previous]_[month|week|day|hour]_end as options of timestamp ",
|
||||
"4.10.3" => "01.02.2017 rename reading 'diff-overrun_limit-' to 'diff_overrun_limit_', DbRep_collaggstr day aggregation changed back from 4.7.5 change ",
|
||||
"4.10.2" => "16.01.2017 bugfix uninitialized value \$renmode if RenameAgent ",
|
||||
"4.10.1" => "30.11.2016 bugfix importFromFile format problem if UNIT-field wasn't set ",
|
||||
"4.10.0" => "28.12.2016 del_DoParse changed to use Wildcards, del_ParseDone changed to use readingNameMap ",
|
||||
"4.9.0" => "23.12.2016 function readingRename added ",
|
||||
"4.8.6" => "17.12.2016 new bugfix group by-clause due to incompatible changes made in MyQL 5.7.5 (Forum #msg541103) ",
|
||||
"4.8.5" => "16.12.2016 bugfix group by-clause due to Forum #msg540610 ",
|
||||
"4.8.4" => "13.12.2016 added 'group by ...,table_schema' to select in dbmeta_DoParse due to Forum #msg539228, commandref adapted, changed 'not_enough_data_in_period' to 'less_data_in_period' ",
|
||||
"4.8.3" => "12.12.2016 balance diff to next period if value of period is 0 between two periods with values ",
|
||||
"4.8.2" => "10.12.2016 bugfix negativ diff if balanced ",
|
||||
"4.8.1" => "10.12.2016 added balance diff to diffValue, a difference between the last value of an old aggregation period to the first value of a new aggregation period will be take over now ",
|
||||
"4.8.0" => "09.12.2016 diffValue selection chenged to 'between' ",
|
||||
"4.7.7" => "08.12.2016 code review ",
|
||||
"4.7.6" => "07.12.2016 DbRep version as internal, check if perl module DBI is installed ",
|
||||
"4.7.5" => "05.12.2016 DbRep_collaggstr day aggregation changed ",
|
||||
"4.7.4" => "28.11.2016 sub DbRep_calcount changed due to Forum #msg529312 ",
|
||||
"4.7.3" => "20.11.2016 new diffValue function made suitable to SQLite ",
|
||||
"4.7.2" => "20.11.2016 commandref adapted, state = Warnings adapted ",
|
||||
"4.7.1" => "17.11.2016 changed fieldlength to DbLog new standard, diffValue state Warnings due to several situations and generate readings not_enough_data_in_period, diff-overrun_limit ",
|
||||
"4.7.0" => "16.11.2016 sub diffValue changed due to Forum #msg520154, attr diffAccept added, diffValue now able to calculate if counter was going to 0 ",
|
||||
"4.6.0" => "31.10.2016 bugfix calc issue due to daylight saving time end (winter time) ",
|
||||
"4.5.1" => "18.10.2016 get svrinfo contains SQLite database file size (MB), modified timeout routine ",
|
||||
"4.5.0" => "17.10.2016 get data of dbstatus, dbvars, tableinfo, svrinfo (database dependend) ",
|
||||
"4.4.0" => "13.10.2016 get function prepared ",
|
||||
"4.3.0" => "11.10.2016 Preparation of get metadata ",
|
||||
"4.2.0" => "10.10.2016 allow SQL-Wildcards (% _) in attr reading & attr device ",
|
||||
"4.1.3" => "09.10.2016 bugfix delEntries running on SQLite ",
|
||||
"4.1.2" => "08.10.2016 old device in DEF of connected DbLog device will substitute by renamed device if it is present in DEF ",
|
||||
"4.1.1" => "06.10.2016 NotifyFn is getting events from global AND own device, set is reduced if ROLE=Agent, english commandref enhanced ",
|
||||
"4.1.0" => "05.10.2016 DbRep_Attr changed ",
|
||||
"4.0.0" => "04.10.2016 Internal/Attribute ROLE added, sub DbRep_firstconnect changed NotifyFN activated to start deviceRename if ROLE=Agent ",
|
||||
"3.13.0" => "03.10.2016 added deviceRename to rename devices in database, new Internal DATABASE ",
|
||||
"3.12.0" => "02.10.2016 function minValue added ",
|
||||
"3.11.1" => "30.09.2016 bugfix include first and next day in calculation if Timestamp is exactly 'YYYY-MM-DD 00:00:00' ",
|
||||
"3.11.0" => "29.09.2016 maxValue calculation moved to background to reduce FHEM-load ",
|
||||
"3.10.1" => "28.09.2016 sub impFile -> changed \$dbh->{AutoCommit} = 0 to \$dbh->begin_work ",
|
||||
"3.10.0" => "27.09.2016 diffValue calculation moved to background to reduce FHEM-load, new reading background_processing_time ",
|
||||
"3.9.1" => "27.09.2016 Internal 'LASTCMD' added ",
|
||||
"3.9.0" => "26.09.2016 new function importFromFile to import data from file (CSV format) ",
|
||||
"3.8.0" => "16.09.2016 new attr readingPreventFromDel to prevent readings from deletion when a new operation starts ",
|
||||
"3.7.3" => "11.09.2016 changed format of diffValue-reading if no value was selected ",
|
||||
"3.7.2" => "04.09.2016 problem in diffValue fixed if if no value was selected ",
|
||||
"3.7.1" => "31.08.2016 Reading 'errortext' added, commandref continued, exportToFile changed, diffValue changed to fix wrong timestamp if error occur ",
|
||||
"3.7.0" => "30.08.2016 exportToFile added exports data to file (CSV format) ",
|
||||
"3.6.0" => "29.08.2016 plausibility checks of database column character length ",
|
||||
"3.5.2" => "21.08.2016 fit to new commandref style ",
|
||||
"3.5.1" => "20.08.2016 commandref continued ",
|
||||
"3.5.0" => "18.08.2016 new attribute timeOlderThan ",
|
||||
"3.4.4" => "12.08.2016 current_year_begin, previous_year_begin, current_year_end, previous_year_end added as possible values for timestmp attribute ",
|
||||
"3.4.3" => "09.08.2016 fields for input using 'insert' changed to 'date,time,value,unit'. Attributes device, reading will be used to complete dataset, now more informations available about faulty datasets in arithmetic operations ",
|
||||
"3.4.2" => "05.08.2016 commandref complemented, fieldlength used in function 'insert' trimmed to 32 ",
|
||||
"3.4.1" => "04.08.2016 check of numeric value type in functions maxvalue, diffvalue ",
|
||||
"3.4.0" => "03.08.2016 function 'insert' added ",
|
||||
"3.3.3" => "16.07.2016 bugfix of aggregation=week if month start is 01 and month end is 12 AND the last week of december is '01' like in 2014 (checked in version 11804) ",
|
||||
"3.3.2" => "16.07.2016 readings completed with begin of selection range to ensure valid reading order, also done if readingNameMap is set ",
|
||||
"3.3.1" => "15.07.2016 function 'diffValue' changed, write '-' if no value ",
|
||||
"3.3.0" => "12.07.2016 function 'diffValue' added ",
|
||||
"3.2.1" => "12.07.2016 DbRep_Notify prepared, switched from readingsSingleUpdate to readingsBulkUpdate ",
|
||||
"3.2.0" => "11.07.2016 handling of db-errors is relocated to blockingcall-subs (checked in version 11785) ",
|
||||
"3.1.1" => "10.07.2016 state turns to initialized and connected after attr 'disabled' is switched from '1' to '0' ",
|
||||
"3.1.0" => "09.07.2016 new Attr 'timeDiffToNow' and change subs according to that ",
|
||||
"3.0.0" => "04.07.2016 no selection if timestamp isn't set and aggregation isn't set with fetchrows, delEntries ",
|
||||
"2.9.9" => "03.07.2016 english version of commandref completed ",
|
||||
"2.9.8" => "01.07.2016 changed fetchrows_ParseDone to handle readingvalues with whitespaces correctly ",
|
||||
"2.9.7" => "30.06.2016 moved {DBLOGDEVICE} to {HELPER}{DBLOGDEVICE} ",
|
||||
"2.9.6" => "30.06.2016 sql-call changed for countEntries, averageValue, sumValue avoiding problems if no timestamp is set and aggregation is set ",
|
||||
"2.9.5" => "30.06.2016 format of readingnames changed again (substitute ':' with '-' in time) ",
|
||||
"2.9.4" => "30.06.2016 change readingmap to readingNameMap, prove of unsupported characters added ",
|
||||
"2.9.3" => "27.06.2016 format of readingnames changed avoiding some problems after restart and splitting ",
|
||||
"2.9.2" => "27.06.2016 use Time::Local added, DbRep_firstconnect added ",
|
||||
"2.9.1" => "26.06.2016 german commandref added ",
|
||||
"2.9.0" => "25.06.2016 attributes showproctime, timeout added ",
|
||||
"2.8.1" => "24.06.2016 sql-creation of sumValue, maxValue, fetchrows changed main-routine changed ",
|
||||
"2.8.0" => "24.06.2016 function averageValue changed to nonblocking function ",
|
||||
"2.7.1" => "24.06.2016 changed blockingcall routines, changed to unique abort-function ",
|
||||
"2.7.0" => "23.06.2016 changed function countEntries to nonblocking ",
|
||||
"2.6.3" => "22.06.2016 abort-routines changed, dbconnect-routines changed ",
|
||||
"2.6.2" => "21.06.2016 aggregation week corrected ",
|
||||
"2.6.1" => "20.06.2016 routine maxval_ParseDone corrected ",
|
||||
"2.6.0" => "31.05.2016 maxValue changed to nonblocking function ",
|
||||
"2.5.3" => "31.05.2016 function delEntries changed ",
|
||||
"2.5.2" => "31.05.2016 ping check changed, DbRep_Connect changed ",
|
||||
"2.5.1" => "30.05.2016 sleep in nb-functions deleted ",
|
||||
"2.5.0" => "30.05.2016 changed to use own \$dbh with DbLog-credentials, function sumValue, fetchrows ",
|
||||
"2.4.2" => "29.05.2016 function sumValue changed ",
|
||||
"2.4.1" => "29.05.2016 function fetchrow changed ",
|
||||
"2.4.0" => "29.05.2016 changed to nonblocking function for sumValue ",
|
||||
"2.3.0" => "28.05.2016 changed sumValue to 'prepare' with placeholders ",
|
||||
"2.2.0" => "27.05.2016 changed fetchrow and delEntries function to 'prepare' with placeholders added nonblocking function for delEntries ",
|
||||
"2.1.0" => "25.05.2016 codechange ",
|
||||
"2.0.0" => "24.05.2016 added nonblocking function for fetchrow ",
|
||||
"1.2.0" => "21.05.2016 function and attribute for delEntries added ",
|
||||
"1.1.0" => "20.05.2016 change result-format of 'count', move runtime-counter to sub DbRep_collaggstr ",
|
||||
"1.0.0" => "19.05.2016 Initial"
|
||||
);
|
||||
|
||||
# Versions History extern:
|
||||
our %DbRep_vNotesExtern = (
|
||||
"8.3.0" => "17.10.2018 reduceLog from DbLog integrated to DbRep, textField-long as default for sqlCmd, both attributes timeOlderThan and timeDiffToNow can be set at same time -> so the selection time between can be calculated dynamically ",
|
||||
"8.4.0" => "22.10.2018 countEntries for every reading and summary created with \"ALLREADINGS\" if multiple readings set, versionNotes changed to support en/de ",
|
||||
"8.3.0" => "17.10.2018 reduceLog from DbLog integrated into DbRep, textField-long as default for sqlCmd, both attributes timeOlderThan and timeDiffToNow can be set at same time -> so the selection time between can be calculated dynamically ",
|
||||
"8.2.2" => "07.10.2018 fix don't get the real min timestamp in rare cases ",
|
||||
"8.2.0" => "05.10.2018 direct help for attributes ",
|
||||
"8.1.0" => "01.10.2018 new get versionNotes command ",
|
||||
@ -334,7 +186,7 @@ our %DbRep_vNotesExtern = (
|
||||
"4.7.3" => "20.11.2016 new diffValue function made suitable to SQLite ",
|
||||
"4.6.0" => "31.10.2016 bugfix calc issue due to daylight saving time end (winter time) ",
|
||||
"4.5.1" => "18.10.2016 get svrinfo contains SQLite database file size (MB), modified timeout routine ",
|
||||
"4.2.0" => "10.10.2016 allow SQL-Wildcards (% _) in attr reading & attr device ",
|
||||
"4.2.0" => "10.10.2016 allow SQL-Wildcards (\% _) in attr reading & attr device ",
|
||||
"4.1.3" => "09.10.2016 bugfix delEntries running on SQLite ",
|
||||
"3.13.0" => "03.10.2016 added deviceRename to rename devices in database, new Internal DATABASE ",
|
||||
"3.12.0" => "02.10.2016 function minValue added ",
|
||||
@ -368,25 +220,17 @@ our %DbRep_vNotesExtern = (
|
||||
"1.0.0" => "19.05.2016 Initial"
|
||||
);
|
||||
|
||||
# Hint Hash
|
||||
our %DbRep_vHintsExt = (
|
||||
# Hint Hash en
|
||||
our %DbRep_vHintsExt_en = (
|
||||
"2" => "<a href='https://www.dwd.de/DE/leistungen/klimadatendeutschland/beschreibung_tagesmonatswerte.html'>Rules</a> of german weather service for calculation of average temperatures. ",
|
||||
"1" => "Some helpful <a href=\"https://wiki.fhem.de/wiki/DbRep_-_Reporting_und_Management_von_DbLog-Datenbankinhalten#Praxisbeispiele_.2F_Hinweise_und_L.C3.B6sungsans.C3.A4tze_f.C3.BCr_verschiedene_Aufgaben\">FHEM-Wiki</a> Entries"
|
||||
"1" => "Some helpful <a href=\"https://wiki.fhem.de/wiki/DbRep_-_Reporting_und_Management_von_DbLog-Datenbankinhalten#Praxisbeispiele_.2F_Hinweise_und_L.C3.B6sungsans.C3.A4tze_f.C3.BCr_verschiedene_Aufgaben\">FHEM-Wiki</a> Entries."
|
||||
);
|
||||
|
||||
use POSIX qw(strftime);
|
||||
use Time::HiRes qw(gettimeofday tv_interval);
|
||||
use Scalar::Util qw(looks_like_number);
|
||||
eval "use DBI;1" or my $DbRepMMDBI = "DBI";
|
||||
use DBI::Const::GetInfoType;
|
||||
use Blocking;
|
||||
use Color; # colorpicker Widget
|
||||
use Time::Local;
|
||||
use Encode qw(encode_utf8);
|
||||
use IO::Compress::Gzip qw(gzip $GzipError);
|
||||
use IO::Uncompress::Gunzip qw(gunzip $GunzipError);
|
||||
# no if $] >= 5.018000, warnings => 'experimental';
|
||||
no if $] >= 5.017011, warnings => 'experimental::smartmatch';
|
||||
# Hint Hash de
|
||||
our %DbRep_vHintsExt_de = (
|
||||
"2" => "<a href='https://www.dwd.de/DE/leistungen/klimadatendeutschland/beschreibung_tagesmonatswerte.html'>Regularien</a> des deutschen Wetterdienstes zur Berechnung von Durchschnittstemperaturen. ",
|
||||
"1" => "Hilfreiche Hinweise zu DbRep im <a href=\"https://wiki.fhem.de/wiki/DbRep_-_Reporting_und_Management_von_DbLog-Datenbankinhalten#Praxisbeispiele_.2F_Hinweise_und_L.C3.B6sungsans.C3.A4tze_f.C3.BCr_verschiedene_Aufgaben\">FHEM-Wiki</a>."
|
||||
);
|
||||
|
||||
sub DbRep_Main($$;$);
|
||||
sub DbLog_cutCol($$$$$$$); # DbLog-Funktion nutzen um Daten auf maximale Länge beschneiden
|
||||
@ -976,7 +820,7 @@ sub DbRep_Get($@) {
|
||||
(($dbmodel eq "MYSQL")?"tableinfo:noArg ":"").
|
||||
(($dbmodel eq "MYSQL")?"procinfo:noArg ":"").
|
||||
(($dbmodel eq "MYSQL")?"dbvars:noArg ":"").
|
||||
"versionNotes:noArg "
|
||||
"versionNotes "
|
||||
;
|
||||
|
||||
return if(IsDisabled($name));
|
||||
@ -1032,62 +876,82 @@ sub DbRep_Get($@) {
|
||||
return $err?$err:$ret;
|
||||
|
||||
} elsif ($opt =~ /versionNotes/) {
|
||||
my $header = "<b>Module release information table</b><br>";
|
||||
my $header = "<b>Module release information</b><br>";
|
||||
my $header1 = "<b>Helpful hints</b><br>";
|
||||
|
||||
my %hs;
|
||||
|
||||
# Ausgabetabelle erstellen
|
||||
my ($ret,$val0,$val1);
|
||||
my $i = 0;
|
||||
|
||||
$ret = "<html>";
|
||||
|
||||
$ret .= sprintf("<div class=\"makeTable wide\"; style=\"text-align:left\">$header1 <br>");
|
||||
$ret .= "<table class=\"block wide internals\">";
|
||||
$ret .= "<tbody>";
|
||||
$ret .= "<tr class=\"even\">";
|
||||
$i = 0;
|
||||
foreach my $key (reverse sort(keys %DbRep_vHintsExt)) {
|
||||
$val0 = $DbRep_vHintsExt{$key};
|
||||
$ret .= sprintf("<td style=\"vertical-align:top\"><b>$key</b> </td><td style=\"vertical-align:top\">$val0</td>" );
|
||||
$ret .= "</tr>";
|
||||
$i++;
|
||||
if ($i & 1) {
|
||||
# $i ist ungerade
|
||||
$ret .= "<tr class=\"odd\">";
|
||||
# Hints
|
||||
if(!$prop || $prop =~ /hints/ || $prop =~ /[\d]+/) {
|
||||
$ret .= sprintf("<div class=\"makeTable wide\"; style=\"text-align:left\">$header1 <br>");
|
||||
$ret .= "<table class=\"block wide internals\">";
|
||||
$ret .= "<tbody>";
|
||||
$ret .= "<tr class=\"even\">";
|
||||
if($prop && $prop =~ /[\d]+/) {
|
||||
if(AttrVal("global","language","EN") eq "DE") {
|
||||
%hs = ( $prop => $DbRep_vHintsExt_de{$prop} );
|
||||
} else {
|
||||
%hs = ( $prop => $DbRep_vHintsExt_en{$prop} );
|
||||
}
|
||||
} else {
|
||||
$ret .= "<tr class=\"even\">";
|
||||
if(AttrVal("global","language","EN") eq "DE") {
|
||||
%hs = %DbRep_vHintsExt_de;
|
||||
} else {
|
||||
%hs = %DbRep_vHintsExt_en;
|
||||
}
|
||||
}
|
||||
$i = 0;
|
||||
foreach my $key (reverse sort(keys %hs)) {
|
||||
$val0 = $hs{$key};
|
||||
$ret .= sprintf("<td style=\"vertical-align:top\"><b>$key</b> </td><td style=\"vertical-align:top\">$val0</td>" );
|
||||
$ret .= "</tr>";
|
||||
$i++;
|
||||
if ($i & 1) {
|
||||
# $i ist ungerade
|
||||
$ret .= "<tr class=\"odd\">";
|
||||
} else {
|
||||
$ret .= "<tr class=\"even\">";
|
||||
}
|
||||
}
|
||||
}
|
||||
$ret .= "</tr>";
|
||||
$ret .= "</tbody>";
|
||||
$ret .= "</table>";
|
||||
$ret .= "</div>";
|
||||
$ret .= "</tr>";
|
||||
$ret .= "</tbody>";
|
||||
$ret .= "</table>";
|
||||
$ret .= "</div>";
|
||||
}
|
||||
|
||||
$ret .= sprintf("<div class=\"makeTable wide\"; style=\"text-align:left\">$header <br>");
|
||||
$ret .= "<table class=\"block wide internals\">";
|
||||
$ret .= "<tbody>";
|
||||
$ret .= "<tr class=\"even\">";
|
||||
$i = 0;
|
||||
foreach my $key (reverse sort(keys %DbRep_vNotesExtern)) {
|
||||
($val0,$val1) = split(/\s/,$DbRep_vNotesExtern{$key},2);
|
||||
$ret .= sprintf("<td style=\"vertical-align:top\"><b>$key</b> </td><td style=\"vertical-align:top\">$val0 </td><td>$val1</td>" );
|
||||
$ret .= "</tr>";
|
||||
$i++;
|
||||
if ($i & 1) {
|
||||
# $i ist ungerade
|
||||
$ret .= "<tr class=\"odd\">";
|
||||
} else {
|
||||
$ret .= "<tr class=\"even\">";
|
||||
# Notes
|
||||
if(!$prop || $prop =~ /rel/) {
|
||||
$ret .= sprintf("<div class=\"makeTable wide\"; style=\"text-align:left\">$header <br>");
|
||||
$ret .= "<table class=\"block wide internals\">";
|
||||
$ret .= "<tbody>";
|
||||
$ret .= "<tr class=\"even\">";
|
||||
$i = 0;
|
||||
foreach my $key (reverse sort(keys %DbRep_vNotesExtern)) {
|
||||
($val0,$val1) = split(/\s/,$DbRep_vNotesExtern{$key},2);
|
||||
$ret .= sprintf("<td style=\"vertical-align:top\"><b>$key</b> </td><td style=\"vertical-align:top\">$val0 </td><td>$val1</td>" );
|
||||
$ret .= "</tr>";
|
||||
$i++;
|
||||
if ($i & 1) {
|
||||
# $i ist ungerade
|
||||
$ret .= "<tr class=\"odd\">";
|
||||
} else {
|
||||
$ret .= "<tr class=\"even\">";
|
||||
}
|
||||
}
|
||||
}
|
||||
$ret .= "</tr>";
|
||||
$ret .= "</tbody>";
|
||||
$ret .= "</table>";
|
||||
$ret .= "</div>";
|
||||
$ret .= "</tr>";
|
||||
$ret .= "</tbody>";
|
||||
$ret .= "</table>";
|
||||
$ret .= "</div>";
|
||||
}
|
||||
|
||||
$ret .= "</html>";
|
||||
|
||||
return $ret;
|
||||
return $ret;
|
||||
|
||||
} else {
|
||||
return "$getlist";
|
||||
@ -2692,7 +2556,7 @@ sub count_DoParse($) {
|
||||
my $dbuser = $dbloghash->{dbuser};
|
||||
my $dblogname = $dbloghash->{NAME};
|
||||
my $dbpassword = $attr{"sec$dblogname"}{secret};
|
||||
my ($dbh,$sql,$sth,$err,$selspec);
|
||||
my ($dbh,$sql,$sth,$err);
|
||||
|
||||
# Background-Startzeit
|
||||
my $bst = [gettimeofday];
|
||||
@ -2714,22 +2578,34 @@ sub count_DoParse($) {
|
||||
# Timestampstring to Array
|
||||
my @ts = split("\\|", $ts);
|
||||
Log3 ($name, 5, "DbRep $name - Timestamp-Array: \n@ts");
|
||||
|
||||
|
||||
# SQL-Startzeit
|
||||
my $st = [gettimeofday];
|
||||
|
||||
# DB-Abfrage zeilenweise für jeden Timearray-Eintrag
|
||||
my $arrstr;
|
||||
my ($arrstr,@rsf,$ttail);
|
||||
my $addon = "group by READING";
|
||||
my $selspec = "READING, COUNT(*)";
|
||||
|
||||
foreach my $row (@ts) {
|
||||
my @a = split("#", $row);
|
||||
my $runtime_string = $a[0];
|
||||
my $runtime_string_first = $a[1];
|
||||
my $runtime_string_next = $a[2];
|
||||
my $runtime_string_next = $a[2];
|
||||
my $tc = 0;
|
||||
|
||||
if($aggregation eq "hour") {
|
||||
@rsf = split(/[" "\|":"]/,$runtime_string_first);
|
||||
$ttail = $rsf[0]."_".$rsf[1]."|";
|
||||
} else {
|
||||
@rsf = split(" ",$runtime_string_first);
|
||||
$ttail = $rsf[0]."|";
|
||||
}
|
||||
|
||||
if ($IsTimeSet || $IsAggrSet) {
|
||||
$sql = DbRep_createSelectSql($hash,$table,"COUNT(*)",$device,$reading,"'$runtime_string_first'","'$runtime_string_next'",'');
|
||||
$sql = DbRep_createSelectSql($hash,$table,$selspec,$device,$reading,"'$runtime_string_first'","'$runtime_string_next'",$addon);
|
||||
} else {
|
||||
$sql = DbRep_createSelectSql($hash,$table,"COUNT(*)",$device,$reading,undef,undef,'');
|
||||
$sql = DbRep_createSelectSql($hash,$table,$selspec,$device,$reading,undef,undef,$addon);
|
||||
}
|
||||
Log3 ($name, 4, "DbRep $name - SQL execute: $sql");
|
||||
|
||||
@ -2744,16 +2620,15 @@ sub count_DoParse($) {
|
||||
}
|
||||
|
||||
# DB-Abfrage -> Ergebnis in @arr aufnehmen
|
||||
my @line = $sth->fetchrow_array();
|
||||
|
||||
Log3 ($name, 5, "DbRep $name - SQL result: $line[0]") if($line[0]);
|
||||
|
||||
if($aggregation eq "hour") {
|
||||
my @rsf = split(/[" "\|":"]/,$runtime_string_first);
|
||||
$arrstr .= $runtime_string."#".$line[0]."#".$rsf[0]."_".$rsf[1]."|";
|
||||
} else {
|
||||
my @rsf = split(" ",$runtime_string_first);
|
||||
$arrstr .= $runtime_string."#".$line[0]."#".$rsf[0]."|";
|
||||
while (my @line = $sth->fetchrow_array()) {
|
||||
Log3 ($name, 5, "DbRep $name - SQL result: @line") if(@line);
|
||||
$tc += $line[1] if($line[1]); # total count für Reading
|
||||
$arrstr .= $runtime_string."#".$line[0]."#".$line[1]."#".$ttail;
|
||||
}
|
||||
# total count (über alle selected Readings) für Zeitabschnitt hinzufügen wenn Reagingsliste angegeben
|
||||
my (undef,undef,undef,$ranz) = DbRep_specsForSql($hash,$device,$reading);
|
||||
if($ranz > 1) {
|
||||
$arrstr .= $runtime_string."#"."ALLREADINGS"."#".$tc."#".$ttail;
|
||||
}
|
||||
}
|
||||
|
||||
@ -2771,7 +2646,7 @@ sub count_DoParse($) {
|
||||
|
||||
$rt = $rt.",".$brt;
|
||||
|
||||
return "$name|$arrstr|$device|$reading|$rt|0|$table";
|
||||
return "$name|$arrstr|$device|$rt|0|$table";
|
||||
}
|
||||
|
||||
####################################################################################################
|
||||
@ -2785,12 +2660,10 @@ sub count_ParseDone($) {
|
||||
my $arrstr = decode_base64($a[1]);
|
||||
my $device = $a[2];
|
||||
$device =~ s/[^A-Za-z\/\d_\.-]/\//g;
|
||||
my $reading = $a[3];
|
||||
$reading =~ s/[^A-Za-z\/\d_\.-]/\//g;
|
||||
my $bt = $a[4];
|
||||
my $bt = $a[3];
|
||||
my ($rt,$brt) = split(",", $bt);
|
||||
my $err = $a[5]?decode_base64($a[5]):undef;
|
||||
my $table = $a[6];
|
||||
my $err = $a[4]?decode_base64($a[4]):undef;
|
||||
my $table = $a[5];
|
||||
my $reading_runtime_string;
|
||||
|
||||
if ($err) {
|
||||
@ -2810,10 +2683,12 @@ sub count_ParseDone($) {
|
||||
|
||||
my @arr = split("\\|", $arrstr);
|
||||
foreach my $row (@arr) {
|
||||
my @a = split("#", $row);
|
||||
my $runtime_string = $a[0];
|
||||
my $c = $a[1];
|
||||
my $rsf = $a[2]."__";
|
||||
my @a = split("#", $row);
|
||||
my $runtime_string = $a[0];
|
||||
my $reading = $a[1];
|
||||
$reading =~ s/[^A-Za-z\/\d_\.-]/\//g;
|
||||
my $c = $a[2];
|
||||
my $rsf = $a[3]."__";
|
||||
|
||||
if (AttrVal($hash->{NAME}, "readingNameMap", "")) {
|
||||
$reading_runtime_string = $rsf.AttrVal($hash->{NAME}, "readingNameMap", "")."__".$runtime_string;
|
||||
@ -10096,11 +9971,28 @@ return;
|
||||
</li> <br>
|
||||
</ul>
|
||||
|
||||
<li><b> countEntries [history|current] </b> - provides the number of table-entries (default: history) between period set
|
||||
by timestamp-<a href="#DbRepattr">attributes</a> if set.
|
||||
If timestamp-attributes are not set, all entries of the table will be count.
|
||||
<li><b> countEntries [history|current] </b> - provides the number of table entries (default: history) between time period set
|
||||
by time.* -<a href="#DbRepattr">attributes</a> if set.
|
||||
If time.* attributes not set, all entries of the table will be count.
|
||||
The <a href="#DbRepattr">attributes</a> "device" and "reading" can be used to
|
||||
limit the evaluation. </li> <br>
|
||||
limit the evaluation. <br>
|
||||
If more than one reading in attribute "reading" is specified, the number of every reading
|
||||
is printed out and the summary is reported labeled by "ALLREADINGS". <br><br>
|
||||
|
||||
The relevant attributes for this function are: <br><br>
|
||||
|
||||
<ul>
|
||||
<table>
|
||||
<colgroup> <col width=5%> <col width=95%> </colgroup>
|
||||
<tr><td> <b>aggregation</b> </td><td>: aggregatiion/grouping of time intervals </td></tr>
|
||||
<tr><td> <b>device</b> </td><td>: selection only of datasets which contain <device> </td></tr>
|
||||
<tr><td> <b>reading</b> </td><td>: selection only of datasets which contain <reading> </td></tr>
|
||||
<tr><td> <b>time.*</b> </td><td>: a number of attributes to limit selection by time </td></tr>
|
||||
</table>
|
||||
</ul>
|
||||
<br>
|
||||
|
||||
</li> <br>
|
||||
|
||||
|
||||
<li><b> delEntries </b> - deletes all database entries or only the database entries specified by <a href="#DbRepattr">attributes</a> Device and/or
|
||||
@ -11081,7 +10973,16 @@ return $ret;
|
||||
</li>
|
||||
<br><br>
|
||||
</ul>
|
||||
<br>
|
||||
|
||||
<li><b> versionNotes [hints | rel | <key>] </b> -
|
||||
Shows realease informations and/or hints about the module. 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 <key>-specification only
|
||||
the hint with the specified number is shown.
|
||||
</li>
|
||||
<br>
|
||||
|
||||
</ul></ul>
|
||||
|
||||
</ul>
|
||||
@ -11092,7 +10993,9 @@ return $ret;
|
||||
|
||||
<br>
|
||||
<ul>
|
||||
Using the module specific attributes you are able to define the scope of evaluation and the aggregation. <br><br>
|
||||
Using the module specific attributes you are able to define the scope of evaluation and the aggregation. <br>
|
||||
The listed attrbutes are not completely relevant for every function of the module. The help of set/get-commands
|
||||
contain explicitly which attributes are relevant for the specific command. <br><br>
|
||||
|
||||
<b>Note for SQL-Wildcard Usage:</b> <br>
|
||||
Within the attribute values of "device" and "reading" you may use SQL-Wildcard "%", Character "_" is not supported as a wildcard.
|
||||
@ -12043,9 +11946,26 @@ sub bdump {
|
||||
<li><b> countEntries [history | current] </b>
|
||||
- liefert die Anzahl der Tabelleneinträge (default: history) in den gegebenen
|
||||
Zeitgrenzen (siehe <a href="#DbRepattr">Attribute</a>).
|
||||
Sind die Timestamps nicht gesetzt werden alle Einträge gezählt.
|
||||
Sind die Timestamps nicht gesetzt, werden alle Einträge der Tabelle gezählt.
|
||||
Beschränkungen durch die <a href="#DbRepattr">Attribute</a> Device bzw. Reading
|
||||
gehen in die Selektion mit ein. </li> <br>
|
||||
gehen in die Selektion mit ein. <br>
|
||||
Ist mehr als ein Reading im Attribut "reading" angegeben, wird die Anzahl jedes einzelnen Readings
|
||||
ausgegeben und zusätzlich eine Summierung, gekennzeichnet mit "ALLREADINGS", erstellt. <br><br>
|
||||
|
||||
Die für diese Funktion relevanten Attribute sind: <br><br>
|
||||
|
||||
<ul>
|
||||
<table>
|
||||
<colgroup> <col width=5%> <col width=95%> </colgroup>
|
||||
<tr><td> <b>aggregation</b> </td><td>: Zusammenfassung/Gruppierung von Zeitintervallen </td></tr>
|
||||
<tr><td> <b>device</b> </td><td>: Selektion nur von Datensätzen die <device> enthalten </td></tr>
|
||||
<tr><td> <b>reading</b> </td><td>: Selektion nur von Datensätzen die <reading> enthalten </td></tr>
|
||||
<tr><td> <b>time.*</b> </td><td>: eine Reihe von Attributen zur Zeitabgrenzung </td></tr>
|
||||
</table>
|
||||
</ul>
|
||||
<br>
|
||||
|
||||
</li> <br>
|
||||
|
||||
<li><b> delEntries </b> - löscht alle oder die durch die <a href="#DbRepattr">Attribute</a> device und/oder
|
||||
reading definierten Datenbankeinträge. Die Eingrenzung über Timestamps erfolgt
|
||||
@ -13111,7 +13031,15 @@ return $ret;
|
||||
# Es werden nur Information der Tabellen "current" und "history" angezeigt
|
||||
</li>
|
||||
<br><br>
|
||||
</ul>
|
||||
</ul>
|
||||
|
||||
<li><b> versionNotes [hints | rel | <key>] </b> -
|
||||
Zeigt Release Informationen und/oder Hinweise zum Modul an. Es sind nur Release Informationen mit
|
||||
Bedeutung für den Modulnutzer enthalten. <br>
|
||||
Sind keine Optionen angegben, werden sowohl Release Informationen als auch Hinweise angezeigt.
|
||||
"rel" zeigt nur Release Informationen und "hints" nur Hinweise an. Mit der <key>-Angabe
|
||||
wird der Hinweis mit der angegebenen Nummer angezeigt.
|
||||
</li>
|
||||
|
||||
<br>
|
||||
</ul></ul>
|
||||
@ -13124,7 +13052,9 @@ return $ret;
|
||||
|
||||
<br>
|
||||
<ul>
|
||||
Über die modulspezifischen Attribute wird die Abgrenzung der Auswertung und die Aggregation der Werte gesteuert. <br><br>
|
||||
Über die modulspezifischen Attribute wird die Abgrenzung der Auswertung und die Aggregation der Werte gesteuert. <br>
|
||||
Die hier aufgeführten Attribute sind nicht für jede Funktion des Moduls bedeutsam. In der Hilfe zu den set/get-Kommandos
|
||||
wird explizit angegeben, welche Attribute für das jeweilige Kommando relevant sind. <br><br>
|
||||
|
||||
<b>Hinweis zur SQL-Wildcard Verwendung:</b> <br>
|
||||
Innerhalb der Attribut-Werte für "device" und "reading" kann SQL-Wildcards "%" angegeben werden.
|
||||
|
Loading…
x
Reference in New Issue
Block a user