diff --git a/fhem/FHEM/93_InfluxDBLogger.pm b/fhem/FHEM/93_InfluxDBLogger.pm
index 3bc81d260..711afb013 100644
--- a/fhem/FHEM/93_InfluxDBLogger.pm
+++ b/fhem/FHEM/93_InfluxDBLogger.pm
@@ -50,7 +50,7 @@ sub InfluxDBLogger_Define($$) {
sub InfluxDBLogger_Notify($$)
{
my ($own_hash, $dev_hash) = @_;
- my $name = $own_hash->{NAME}; # own name / hash
+ my $name = $own_hash->{NAME}; # own name
return "" if(IsDisabled($name)); # Return without any further action if the module is disabled
return "" if(!$init_done);
@@ -62,6 +62,14 @@ sub InfluxDBLogger_Notify($$)
return "" if($own_hash->{TYPE} eq $dev_hash->{TYPE}); # avoid endless loops from logger to logger
Log3 $name, 4, "InfluxDBLogger: [$name] notified from device $devName";
+ InfluxDBLogger_BuildAndSend($own_hash, $dev_hash, $events);
+}
+
+sub InfluxDBLogger_BuildAndSend($$$)
+{
+ my ($own_hash, $dev_hash, $events) = @_;
+ my $name = $own_hash->{NAME}; # own name
+
my %map = InfluxDBLogger_BuildMap($own_hash, $dev_hash, $events);
my @incompatible = ();
my ($data,$rows) = InfluxDBLogger_BuildData($own_hash,$dev_hash,\%map,\@incompatible);
@@ -73,6 +81,28 @@ sub InfluxDBLogger_Notify($$)
}
}
+sub InfluxDBLogger_Write($$)
+{
+ my ($hash, $name) = @_;
+ return "" if(IsDisabled($name)); # Return without any further action if the module is disabled
+
+ my @devices = devspec2array($hash->{NOTIFYDEV});
+ foreach my $deviceName (@devices) {
+ my @events = ();
+ Log3 $name, 4, "DEVNAME $deviceName";
+ my $dev_hash = $defs{$deviceName};
+ Log3 $name, 4, "DEVHASH $dev_hash";
+ my $readings = $dev_hash->{READINGS};
+ Log3 $name, 4, "BEFORE READING $readings";
+ foreach my $key (keys %{$readings}) {
+ Log3 $name, 4, "READING $key";
+ my $value = ReadingsVal($deviceName,$key,undef);
+ push(@events, $key . ": " .$value);
+ }
+ InfluxDBLogger_BuildAndSend($hash, $dev_hash, \@events);
+ }
+}
+
sub InfluxDBLogger_Send($$$)
{
my ($own_hash, $data, $rows) = @_;
@@ -395,8 +425,12 @@ sub InfluxDBLogger_Set($$$@)
InfluxDBLogger_ResetStatistics($hash, $name);
return (undef,1);
}
+ elsif ( lc $cmd eq 'write' ) {
+ InfluxDBLogger_Write($hash, $name);
+ return (undef,1);
+ }
else {
- return "Unknown argument $cmd, choose one of resetStatistics:noArg password token";
+ return "Unknown argument $cmd, choose one of resetStatistics:noArg password token write:noArg";
}
}
@@ -565,16 +599,22 @@ sub InfluxDBLogger_Rename($$) {
- password
set <name> password <password>
- Securly stores the password for basic authentication. It is only used if security attribute is set to basic_auth.
+ Securely stores the password for basic authentication. It is only used if security attribute is set to basic_auth.
- token
set <name> token <token>
- Securly stores the token for token based authentication. It is only used if security attribute is set to token.
+ Securely stores the token for token based authentication. It is only used if security attribute is set to token.
- resetStatistics
set <name> resetStatistics
Sets all statistical counters to zero and removes the last error message.
+ - write
+
set <name> set
+ Writes the current values of the configured readings(readingInclude,readingExclude) of the configured devices(devspec) to the database.
+ This is useful e.g. for clean start of the day and end of the day values.
+ Note that the timestamp of the readings are not stored in the database, but the timestamp of the write operation.
+
@@ -591,9 +631,9 @@ sub InfluxDBLogger_Rename($$) {
Only used if security attribute is set to basic_auth
readingInclude attr <name> readingInclude <regex>
- Only reading events that match the regex will be logged(inclusive). Note that readings usually have the format: 'state: on'
+ Only reading events that match the regex will be logged. Note that readings usually have the format: 'state: on'
readingExclude attr <name> readingInclude <regex>
- Only reading events that do not match the regex will be logged(inclusive). Note that readings usually have the format: 'state: on'
+ Only reading events that do not match the regex will be logged. Note that readings usually have the format: 'state: on'
deviceTagName attr <name> deviceTagName <deviceTagName>
This will be the name of the device tag. default is 'site_name'
@@ -697,6 +737,12 @@ sub InfluxDBLogger_Rename($$) {
set <name> resetStatistics
Setzt alle statistischen Zähler auf 0 und entfernt die letzte Fehlermeldung
+ write
+ set <name> set
+ Schreibt die aktuellen Werte der konfigurierten Readings(readingInclude,readingExclude) der konfigurierten Geräte(devspec) in die Datenbank.
+ Dies ist zum Beispiel nützlich für saubere Tagesstart und Tagesendwerte.
+ Hinweis: Der Zeitstempel des Readings wird nicht in der Datenbank gespeichert, sondern der Zeitstempel des Schreibzeitpunktes.
+
@@ -713,9 +759,9 @@ sub InfluxDBLogger_Rename($$) {
Wird nur genutzt wenn das security Attribut auf basic_auth gesetzt wurde
readingInclude attr <name> readingInclude <regex>
- Nur Ereignisse die zutreffen werden geschrieben(inklusiv). Hinweis - das Format eines Ereignisses sieht so aus: 'state: on'
+ Nur Ereignisse die zutreffen werden geschrieben. Hinweis - das Format eines Ereignisses sieht so aus: 'state: on'
readingExclude attr <name> readingExclude <regex>
- Nur Ereignisse die nicht zutreffen werden geschrieben(inklusiv). Hinweis - das Format eines Ereignisses sieht so aus: 'state: on'
+ Nur Ereignisse die nicht zutreffen werden geschrieben. Hinweis - das Format eines Ereignisses sieht so aus: 'state: on'
deviceTagName attr <name> deviceTagName <deviceTagName>
Das ist der Name des tags, in dem der Gerätename gespeichert wird. Standard ist 'site_name'
@@ -763,7 +809,7 @@ sub InfluxDBLogger_Rename($$) {
Anzahl der versuchten Schreibvorgänge. Dies sind nicht die Abgeschlossenen.
succeeded_writes
- Anzahl der erfolgreich geschriebenen Ereignisse. Dies sind die Ereignisse die man in der Datenbank finde wird.
+ Anzahl der erfolgreich geschriebenen Ereignisse. Dies sind die Ereignisse die man in der Datenbank finden wird.
failed_writes
Anzahl der fehlgeschlagenen Ereignisse. Die letzte Fehlermeldung findet man im Reading failed_writes_last_error
@@ -772,7 +818,7 @@ sub InfluxDBLogger_Rename($$) {
Die Fehlermeldung, was recht nützlich ist für systematische Fehler, wie falsche DNS Einträge usw.
dropped_writes
- Anzahl von nicht getätigten Schreibvorgängen aufgrund da nicht numerisch. Siehe conversions um es zu beheben.
+ Anzahl von nicht getätigten Schreibvorgängen da nicht numerisch. Siehe conversions um es zu beheben.
state
Statistics: t=total_writes s=succeeded_writes f=failed_writes e=events