From 0d9cb0a116abbd6efeb3cac8f887bc9d5627d733 Mon Sep 17 00:00:00 2001 From: nasseeder1 Date: Sun, 25 Dec 2022 08:41:56 +0000 Subject: [PATCH] 93_DbLog: contrib 5.5.7 git-svn-id: https://svn.fhem.de/fhem/trunk@26894 2b470e98-0d58-463d-a4d8-8e2adae1ed80 --- fhem/contrib/DS_Starter/93_DbLog.pm | 141 ++++++++++++++++------------ 1 file changed, 83 insertions(+), 58 deletions(-) diff --git a/fhem/contrib/DS_Starter/93_DbLog.pm b/fhem/contrib/DS_Starter/93_DbLog.pm index 19f577206..b8aa65547 100644 --- a/fhem/contrib/DS_Starter/93_DbLog.pm +++ b/fhem/contrib/DS_Starter/93_DbLog.pm @@ -1,5 +1,5 @@ ############################################################################################################################################ -# $Id: 93_DbLog.pm 26750 2022-12-20 16:38:54Z DS_Starter $ +# $Id: 93_DbLog.pm 26750 2022-12-25 16:38:54Z DS_Starter $ # # 93_DbLog.pm # written by Dr. Boris Neubert 2007-12-30 @@ -39,7 +39,7 @@ no if $] >= 5.017011, warnings => 'experimental::smartmatch'; # Version History intern by DS_Starter: my %DbLog_vNotesIntern = ( "5.5.7" => "20.12.2022 cutted _DbLog_SBP_onRun_Log into _DbLog_SBP_onRun_LogArray and _DbLog_SBP_onRun_LogBulk ". - "__DbLog_SBP_onRun_LogCurrent, __DbLog_SBP_fieldArrays, some bugfixes, add drivers to configCheck ", + "__DbLog_SBP_onRun_LogCurrent, __DbLog_SBP_fieldArrays, some bugfixes, add drivers to configCheck, edit comref ", "5.5.6" => "12.12.2022 Serialize with Storable instead of JSON, more code rework ", "5.5.5" => "11.12.2022 Array Log -> may be better error processing ", "5.5.4" => "11.12.2022 Array Log -> print out all cache not saved, DbLog_DelayedShutdown processing changed ", @@ -8295,16 +8295,18 @@ return; attr <device> cacheOverflowThreshold <n>

- In asynchronous log mode, sets the threshold of <n> records above which the cache contents are exported to a file - instead of writing the data to the database.
- The function corresponds to the "exportCache purgecache" set command and uses its settings.
- With this attribute an overload of the server memory can be prevented if the database is not available for a longer period of time. - time (e.g. in case of error or maintenance). If the attribute value is smaller or equal to the value of the - attribute "cacheLimit", the value of "cacheLimit" is used for "cacheOverflowThreshold".
- In this case, the cache will always be written to a file instead of to the database if the threshold value + In asynchronous log mode, sets the threshold of <n> records above which the cache contents are exported to a + file instead of writing the data to the database.
+ The executed function corresponds to the set command "exportCache purgecache" and uses its settings. +

+ + This attribute can be used to prevent an overload of the server memory if the database is not available for a + longer period of time (e.g. in case of error or maintenance). If the attribute value is less than or equal to the + value of the cacheLimit attribute, the value of cacheLimit is used for cacheOverflowThreshold.
+ In this case the cache will always be written to a file instead of to the database if the threshold value has been reached.
- Thus, the data can be specifically written to one or more files with this setting, in order to import them into the - database at a later time with the set command "importCachefile". + With this setting, the data can be written to one or more files in order to import them into the database + at a later time with the set command "importCachefile". @@ -8546,32 +8548,36 @@ return; attr <device> DbLogValueFn {}

- The attribute DbLogValueFn will be propagated to all devices if DbLog is used. - This attribute contains a Perl expression that can use and change values of $TIMESTAMP, $READING, $VALUE (value of - reading) and $UNIT (unit of reading value). That means the changed values are logged.
- Furthermore you have readonly access to $DEVICE (the source device name), $EVENT, $LASTTIMESTAMP and $LASTVALUE - for evaluation in your expression. - The variables $LASTTIMESTAMP and $LASTVALUE contain time and value of the last logged dataset of $DEVICE / $READING.
- If the $TIMESTAMP is to be changed, it must meet the condition "yyyy-mm-dd hh:mm:ss", otherwise the $timestamp wouldn't - be changed. - In addition you can set the variable $IGNORE=1 if you want skip a dataset from logging.
- - The device specific function in "DbLogValueFn" is applied to the dataset before the potential existing attribute - "valueFn" in the DbLog device. + If DbLog is used, the DbLogValueFn attribute is propagated in all devices. + This attribute is set in the source devices and allows to change the values before logging + or exclude the record from logging.

+ + The variables $TIMESTAMP, $READING, $VALUE (value of the reading) and $UNIT (unit of the reading value) + can be accessed and modified before logging to the database.
+ Read access is available to $DEVICE (the name of the source device), $EVENT, $LASTTIMESTAMP, and $LASTVALUE.

+ + The variables $LASTTIMESTAMP and $LASTVALUE contain time and value of the last logged record of + $DEVICE / $READING.
+ If $TIMESTAMP is to be changed, the form "yyyy-mm-dd hh:mm:ss" must be followed. + Otherwise the changed $TIMESTAMP variable will not be applied. + By setting the variable "$IGNORE=1" the record is excluded from logging.

+ + The device specific function in "DbLogValueFn" is applied to the record before the function in the "valueFn" + attribute of the DbLog device.

Example
-
+
 attr SMA_Energymeter DbLogValueFn
 {
-  if ($READING eq "Bezug_WirkP_Kosten_Diff"){
+  if ($READING eq "Bezug_WirkP_Kosten_Diff") {
     $UNIT="Diff-W";
   }
-  if ($READING =~ /Einspeisung_Wirkleistung_Zaehler/ && $VALUE < 2){
+  if ($READING =~ /Einspeisung_Wirkleistung_Zaehler/ && $VALUE < 2) {
     $IGNORE=1;
   }
 }
-       
+
@@ -8952,17 +8958,23 @@ attr SMA_Energymeter DbLogValueFn
  • valueFn
  • @@ -10622,14 +10641,20 @@ attr SMA_Energymeter DbLogValueFn attr <device> valueFn {}

    - - Es kann über einen Perl-Ausdruck auf die Variablen $TIMESTAMP, $DEVICE, $DEVICETYPE, $READING, $VALUE (Wert des Readings) und - $UNIT (Einheit des Readingswert) zugegriffen werden und diese verändern, d.h. die veränderten Werte werden geloggt.
    - Außerdem hat man Lesezugriff auf $EVENT, $LASTTIMESTAMP und $LASTVALUE zur Bewertung im Ausdruck.
    - Die Variablen $LASTTIMESTAMP und $LASTVALUE enthalten Zeit und Wert des zuletzt protokollierten Datensatzes von $DEVICE / $READING.
    - Soll $TIMESTAMP verändert werden, muss die Form "yyyy-mm-dd hh:mm:ss" eingehalten werden. Anderenfalls wird der - geänderte $timestamp nicht übernommen. - Zusätzlich kann durch Setzen der Variable "$IGNORE=1" ein Datensatz vom Logging ausgeschlossen werden.

    + + Dieses Attribut wird im DbLog-Device gesetzt und erlaubt die Veränderung der Werte vor dem Logging + oder den Ausschluß des Datensatzes vom Logging.

    + + Es kann auf die Variablen $TIMESTAMP, $DEVICE (Quellendevice), $DEVICETYPE, $READING, $VALUE (Wert des Readings) und + $UNIT (Einheit des Readingswert) zugegriffen werden und diese vor dem Loggen in die Datenbank verändern.
    + Lesezugriff besteht auf $EVENT, $LASTTIMESTAMP und $LASTVALUE.

    + + Die Variablen $LASTTIMESTAMP und $LASTVALUE enthalten Zeit und Wert des zuletzt protokollierten Datensatzes von + $DEVICE / $READING.
    + Soll $TIMESTAMP verändert werden, muss die Form "yyyy-mm-dd hh:mm:ss" eingehalten werden. + Anderenfalls wird die geänderte $TIMESTAMP Variable nicht übernommen. + Durch Setzen der Variable "$IGNORE=1" wird der Datensatz vom Logging ausgeschlossen. +

    Beispiele