mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-05-04 22:19:38 +00:00
93_InfluxDBLogger.pm: InfluxDB support perl for measurement attribute
git-svn-id: https://svn.fhem.de/fhem/trunk/fhem@23543 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
76224355c4
commit
0b25e08fa2
@ -197,9 +197,16 @@ sub InfluxDBLogger_GetMeasurement($$$)
|
|||||||
my ($hash, $dev_hash, $device, $reading, $value) = @_;
|
my ($hash, $dev_hash, $device, $reading, $value) = @_;
|
||||||
my $name = $hash->{NAME};
|
my $name = $hash->{NAME};
|
||||||
|
|
||||||
my $measurement = AttrVal($name, "measurement", $reading);
|
my $measurement = AttrVal($name, "measurement", undef);
|
||||||
|
|
||||||
|
if (defined $measurement) {
|
||||||
|
$measurement =~ s/\{(.*)\}/eval($1)/ei;
|
||||||
$measurement =~ s/\$DEVICE/$device/ei;
|
$measurement =~ s/\$DEVICE/$device/ei;
|
||||||
$measurement =~ s/\$READINGNAME/$reading/ei;
|
$measurement =~ s/\$READINGNAME/$reading/ei;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$measurement = $reading;
|
||||||
|
}
|
||||||
|
|
||||||
return $measurement;
|
return $measurement;
|
||||||
}
|
}
|
||||||
@ -598,13 +605,15 @@ sub InfluxDBLogger_Rename($$) {
|
|||||||
The keyword $DEVICE will be replaced by the device-name.
|
The keyword $DEVICE will be replaced by the device-name.
|
||||||
The keyword $READINGNAME will be replaced by the reading-name
|
The keyword $READINGNAME will be replaced by the reading-name
|
||||||
Default is $READINGNAME.
|
Default is $READINGNAME.
|
||||||
|
Perl-Expressions can be used in curly braces. $name, $device, $reading, $value are available as variables.
|
||||||
|
attr influx measurement { AttrVal($device, "influx_measurement", $reading)}
|
||||||
</li>
|
</li>
|
||||||
<li><b>tags</b> <code>attr <name> tags <x,y></code><br />
|
<li><b>tags</b> <code>attr <name> tags <x,y></code><br />
|
||||||
This is the list of tags that will be sent to InfluxDB. The keyword $DEVICE will be replaced by the device-name.
|
This is the list of tags that will be sent to InfluxDB. The keyword $DEVICE will be replaced by the device-name.
|
||||||
If this attribute is set it will override the attribute deviceTagName. If the attribute is set to "-"
|
If this attribute is set it will override the attribute deviceTagName. If the attribute is set to "-"
|
||||||
no tags will be written (useful if measurement is set to $DEVICE and fields to $READINGNAME=$READINGVALUE)
|
no tags will be written (useful if measurement is set to $DEVICE and fields to $READINGNAME=$READINGVALUE)
|
||||||
Default is site_name=$DEVICE.
|
Default is site_name=$DEVICE.
|
||||||
Perl-Expression can be used in curly braces to evaluate the alias-attribute as a tag for example. $name, $device, $reading, $value are available as variables.
|
Perl-Expressions can be used in curly braces to evaluate the alias-attribute as a tag for example. $name, $device, $reading, $value are available as variables.
|
||||||
attr influx tags device={AttrVal($device, "alias", "fallback")}
|
attr influx tags device={AttrVal($device, "alias", "fallback")}
|
||||||
</li>
|
</li>
|
||||||
<li><b>fields</b> <code>attr <name> fields <val=$READINGVALUE></code><br />
|
<li><b>fields</b> <code>attr <name> fields <val=$READINGVALUE></code><br />
|
||||||
@ -718,6 +727,8 @@ sub InfluxDBLogger_Rename($$) {
|
|||||||
Das Schlüsselwort $DEVICE wird ersetzt durch den Gerätenamen.
|
Das Schlüsselwort $DEVICE wird ersetzt durch den Gerätenamen.
|
||||||
Das Schlüsselwort $READINGNAME wird ersetzt durch den Readingnamen.
|
Das Schlüsselwort $READINGNAME wird ersetzt durch den Readingnamen.
|
||||||
Standard ist $READINGNAME.
|
Standard ist $READINGNAME.
|
||||||
|
Es können Perl-Ausdrücke in geschweiften Klammern verwendet werden. $name, $device, $reading, $value stehen dabei als Variable zur Verfügung.
|
||||||
|
attr influx measurement { AttrVal($device, "influx_measurement", $reading)}
|
||||||
</li>
|
</li>
|
||||||
<li><b>tags</b> <code>attr <name> tags <x,y></code><br />
|
<li><b>tags</b> <code>attr <name> tags <x,y></code><br />
|
||||||
Dies ist the Liste der tags die an InfluxDB mitgesendet werden. Das Schlüsselwort $DEVICE wird ersetzt durch den Gerätenamen.
|
Dies ist the Liste der tags die an InfluxDB mitgesendet werden. Das Schlüsselwort $DEVICE wird ersetzt durch den Gerätenamen.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user