mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-03-09 20:57:11 +00:00
93_DbRep: FHEM command "dbReadingsVal" implemented
git-svn-id: https://svn.fhem.de/fhem/trunk@19281 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
dd2908ffa9
commit
0b4066bbe6
@ -1,5 +1,6 @@
|
|||||||
# 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.
|
||||||
|
- feature: 93_DbRep: FHEM command "dbReadingsVal" implemented
|
||||||
- change: 49_SSCam: Meta.json and minor code change
|
- change: 49_SSCam: Meta.json and minor code change
|
||||||
- change: 50_MOBILEALERTSGW: Checksum check added
|
- change: 50_MOBILEALERTSGW: Checksum check added
|
||||||
- change: 93_DbRep: check index "Report_Idx" during first DB connect
|
- change: 93_DbRep: check index "Report_Idx" during first DB connect
|
||||||
|
@ -58,6 +58,7 @@ no if $] >= 5.017011, warnings => 'experimental::smartmatch';
|
|||||||
|
|
||||||
# Version History intern
|
# Version History intern
|
||||||
our %DbRep_vNotesIntern = (
|
our %DbRep_vNotesIntern = (
|
||||||
|
"8.21.0" => "28.04.2019 implement FHEM command \"dbReadingsVal\" ",
|
||||||
"8.20.1" => "28.04.2019 set index verbose changed, check index \"Report_Idx\" in getInitData ",
|
"8.20.1" => "28.04.2019 set index verbose changed, check index \"Report_Idx\" in getInitData ",
|
||||||
"8.20.0" => "27.04.2019 don't save hash refs in central hash to prevent potential memory leak, new set \"index\" ".
|
"8.20.0" => "27.04.2019 don't save hash refs in central hash to prevent potential memory leak, new set \"index\" ".
|
||||||
"command, \"repository\" added in Meta.json ",
|
"command, \"repository\" added in Meta.json ",
|
||||||
@ -374,8 +375,18 @@ sub DbRep_Initialize($) {
|
|||||||
"userExitFn ".
|
"userExitFn ".
|
||||||
"valueFilter ".
|
"valueFilter ".
|
||||||
$readingFnAttributes;
|
$readingFnAttributes;
|
||||||
|
|
||||||
|
my %hash = (
|
||||||
|
Fn => 'CommandDbReadingsVal',
|
||||||
|
Hlp => '<name> <device:reading> <timestamp> <default>,Get the value of a device:reading combination from database.
|
||||||
|
The value next to the timestamp is returned if found, otherwise the <default>.
|
||||||
|
<name> = name of used DbRep device,
|
||||||
|
<timestamp> = timestamp like YYYY-MM-DD_hh:mm:ss
|
||||||
|
'
|
||||||
|
);
|
||||||
|
$cmds{dbReadingsVal} = \%hash;
|
||||||
|
|
||||||
# Umbenennen von existierenden Attrbuten
|
# Umbenennen von existierenden Attributen
|
||||||
# $hash->{AttrRenameMap} = { "reading" => "readingFilter",
|
# $hash->{AttrRenameMap} = { "reading" => "readingFilter",
|
||||||
# "device" => "deviceFilter",
|
# "device" => "deviceFilter",
|
||||||
# };
|
# };
|
||||||
@ -1493,7 +1504,7 @@ sub DbRep_getInitData($) {
|
|||||||
Log3($name, 3, "DbRep $name - $idxstate. Check ok");
|
Log3($name, 3, "DbRep $name - $idxstate. Check ok");
|
||||||
} else {
|
} else {
|
||||||
$idxstate = "Index $idx doesn't exist. Please create the index by \"set $name index recreate_Report_Idx\" command !";
|
$idxstate = "Index $idx doesn't exist. Please create the index by \"set $name index recreate_Report_Idx\" command !";
|
||||||
Log3($name, 2, "DbRep $name - WARNING - $idxstate");
|
Log3($name, 3, "DbRep $name - WARNING - $idxstate");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -10642,12 +10653,25 @@ return ($ret);
|
|||||||
}
|
}
|
||||||
|
|
||||||
####################################################################################################
|
####################################################################################################
|
||||||
# blockierende DB-Abfrage
|
# blockierende DB-Abfrage
|
||||||
# liefert den Wert eines Device:Readings des nächsmöglichen Logeintrags zum
|
# liefert den Wert eines Device:Readings des nächstmöglichen Logeintrags zum
|
||||||
# angegebenen Zeitpunkt
|
# angegebenen Zeitpunkt
|
||||||
#
|
#
|
||||||
# Aufruf: DbReadingsVal("<dbrep-device>","<device:reading>","<timestamp>,"<default>")
|
# Aufruf als Funktion: DbReadingsVal("<dbrep-device>","<device:reading>","<timestamp>,"<default>")
|
||||||
|
# Aufruf als FHEM-Cmd: DbReadingsVal <dbrep-device> <device:reading> <date_time> <default>
|
||||||
####################################################################################################
|
####################################################################################################
|
||||||
|
sub CommandDbReadingsVal($$) {
|
||||||
|
my ($cl, $param) = @_;
|
||||||
|
|
||||||
|
my @a = split("[ \t][ \t]*", $param);
|
||||||
|
my ($name, $devread, $ts, $default) = @a;
|
||||||
|
$ts =~ s/_/ /;
|
||||||
|
|
||||||
|
my $ret = DbReadingsVal($name, $devread, $ts, $default);
|
||||||
|
|
||||||
|
return $ret;
|
||||||
|
}
|
||||||
|
|
||||||
sub DbReadingsVal($$$$) {
|
sub DbReadingsVal($$$$) {
|
||||||
my ($name, $devread, $ts, $default) = @_;
|
my ($name, $devread, $ts, $default) = @_;
|
||||||
my $hash = $defs{$name};
|
my $hash = $defs{$name};
|
||||||
@ -10659,9 +10683,10 @@ sub DbReadingsVal($$$$) {
|
|||||||
}
|
}
|
||||||
unless($defs{$name}{TYPE} eq "DbRep") {
|
unless($defs{$name}{TYPE} eq "DbRep") {
|
||||||
return ("\"$name\" is not a DbRep-device but of type \"".$defs{$name}{TYPE}."\"");
|
return ("\"$name\" is not a DbRep-device but of type \"".$defs{$name}{TYPE}."\"");
|
||||||
}
|
}
|
||||||
|
$ts =~ s/_/ /;
|
||||||
unless($ts =~ /^(\d{4})-(\d{2})-(\d{2}) (\d{2}):(\d{2}):(\d{2})$/) {
|
unless($ts =~ /^(\d{4})-(\d{2})-(\d{2}) (\d{2}):(\d{2}):(\d{2})$/) {
|
||||||
return ("timestamp has not a valid format. Use \"YYYY-MM-DD hh:mm:ss\" as timestamp.");
|
return ("timestamp has not the valid format. Use \"YYYY-MM-DD hh:mm:ss\" as timestamp.");
|
||||||
}
|
}
|
||||||
my ($dev,$reading) = split(":",$devread);
|
my ($dev,$reading) = split(":",$devread);
|
||||||
unless($dev && $reading) {
|
unless($dev && $reading) {
|
||||||
@ -10828,28 +10853,44 @@ return;
|
|||||||
Further informations you can find as described at <a href="#DbRepattr">attribute</a> "userExitFn".
|
Further informations you can find as described at <a href="#DbRepattr">attribute</a> "userExitFn".
|
||||||
<br><br>
|
<br><br>
|
||||||
|
|
||||||
Once a DbRep-Device is defined, the function <b>DbReadingsVal</b> is provided.
|
Once a DbRep-Device is defined, the Perl function <b>DbReadingsVal</b> provided as well as and the FHEM command <b>dbReadingsVal</b>.
|
||||||
With this function you can, similar to the well known ReadingsVal, get a reading value from database.
|
With this function you can, similar to the well known ReadingsVal, get a reading value from database.
|
||||||
The function execution is carried out blocking.
|
The function execution is carried out blocking. <br><br>
|
||||||
The command syntax is: <br><br>
|
|
||||||
|
|
||||||
<ul>
|
<ul>
|
||||||
<code>DbReadingsVal("<name>","<device:reading>","<timestamp>","<default>") </code> <br><br>
|
The command syntax for the Perl function is: <br><br>
|
||||||
|
|
||||||
|
<code>
|
||||||
|
DbReadingsVal("<name>","<device:reading>","<timestamp>","<default>")
|
||||||
|
</code>
|
||||||
|
<br><br>
|
||||||
|
|
||||||
<b>Examples: </b><br>
|
<b>Examples: </b><br>
|
||||||
$ret = DbReadingsVal("Rep.LogDB1","MyWetter:temperature","2018-01-13 08:00:00",""); <br>
|
my $ret = DbReadingsVal("Rep.LogDB1","MyWetter:temperature","2018-01-13_08:00:00",""); <br>
|
||||||
attr <name> userReadings oldtemp {DbReadingsVal("Rep.LogDB1","MyWetter:temperature","2018-04-13 08:00:00","")}
|
attr <name> userReadings oldtemp {DbReadingsVal("Rep.LogDB1","MyWetter:temperature","2018-04-13_08:00:00","")}
|
||||||
<br><br>
|
<br><br>
|
||||||
|
|
||||||
|
The command syntax for the FHEM command is: <br><br>
|
||||||
|
|
||||||
|
<code>
|
||||||
|
dbReadingsVal <name> <device:reading> <timestamp> <default>
|
||||||
|
</code>
|
||||||
|
<br><br>
|
||||||
|
|
||||||
|
<b>Example: </b><br>
|
||||||
|
dbReadingsVal Rep.LogDB1 MyWetter:temperature 2018-01-13_08:00:00 0
|
||||||
|
<br><br>
|
||||||
|
|
||||||
<table>
|
<table>
|
||||||
<colgroup> <col width=5%> <col width=95%> </colgroup>
|
<colgroup> <col width=5%> <col width=95%> </colgroup>
|
||||||
<tr><td> <b><name></b> </td><td>: name of the DbRep-Device to request </td></tr>
|
<tr><td> <b><name></b> </td><td>: name of the DbRep-Device to request </td></tr>
|
||||||
<tr><td> <b><device:reading></b> </td><td>: device:reading whose value is to deliver </td></tr>
|
<tr><td> <b><device:reading></b> </td><td>: device:reading whose value is to deliver </td></tr>
|
||||||
<tr><td> <b><timestamp></b> </td><td>: timestamp of reading whose value is to deliver (*) in the form "YYYY-MM-DD hh:mm:ss" </td></tr>
|
<tr><td> <b><timestamp></b> </td><td>: timestamp of reading whose value is to deliver (*) in the form "YYYY-MM-DD_hh:mm:ss" </td></tr>
|
||||||
<tr><td> <b><default></b> </td><td>: default value if no reading value can be retrieved </td></tr>
|
<tr><td> <b><default></b> </td><td>: default value if no reading value can be retrieved </td></tr>
|
||||||
</table>
|
</table>
|
||||||
</ul>
|
</ul>
|
||||||
<br>
|
<br>
|
||||||
|
|
||||||
(*) If no value can be retrieved at the <timestamp> exactly requested, the chronological most convenient reading
|
(*) If no value can be retrieved at the <timestamp> exactly requested, the chronological most convenient reading
|
||||||
value is delivered back.
|
value is delivered back.
|
||||||
<br><br>
|
<br><br>
|
||||||
@ -10858,9 +10899,8 @@ return;
|
|||||||
<a href="https://forum.fhem.de/index.php/topic,53584.msg452567.html#msg452567">Modul 93_DbRep - Reporting and Management of database content (DbLog)</a>.<br><br>
|
<a href="https://forum.fhem.de/index.php/topic,53584.msg452567.html#msg452567">Modul 93_DbRep - Reporting and Management of database content (DbLog)</a>.<br><br>
|
||||||
|
|
||||||
<br>
|
<br>
|
||||||
|
|
||||||
|
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
<b>Preparations </b> <br><br>
|
<b>Preparations </b> <br><br>
|
||||||
<ul>
|
<ul>
|
||||||
The module requires the usage of a DbLog instance and the credentials of the database definition will be used. <br>
|
The module requires the usage of a DbLog instance and the credentials of the database definition will be used. <br>
|
||||||
@ -13225,28 +13265,45 @@ sub bdump {
|
|||||||
unabhängig von einer Eventgenerierung. Weitere Informationen dazu ist unter <a href="#DbRepattr">Attribut</a>
|
unabhängig von einer Eventgenerierung. Weitere Informationen dazu ist unter <a href="#DbRepattr">Attribut</a>
|
||||||
"userExitFn" beschrieben. <br><br>
|
"userExitFn" beschrieben. <br><br>
|
||||||
|
|
||||||
Sobald ein DbRep-Device definiert ist, wird die Funktion <b>DbReadingsVal</b> zur Verfügung gestellt.
|
Sobald ein DbRep-Device definiert ist, wird sowohl die Perl Funktion <b>DbReadingsVal</b> als auch das FHEM Kommando
|
||||||
|
<b>dbReadingsVal</b> zur Verfügung gestellt.
|
||||||
Mit dieser Funktion läßt sich, ähnlich dem allgemeinen ReadingsVal, der Wert eines Readings aus der Datenbank abrufen.
|
Mit dieser Funktion läßt sich, ähnlich dem allgemeinen ReadingsVal, der Wert eines Readings aus der Datenbank abrufen.
|
||||||
Die Funktionsausführung erfolgt blockierend.
|
Die Funktionsausführung erfolgt blockierend. <br><br>
|
||||||
Die Befehlssyntax ist: <br><br>
|
|
||||||
|
|
||||||
<ul>
|
<ul>
|
||||||
<code>DbReadingsVal("<name>","<device:reading>","<timestamp>","<default>") </code> <br><br>
|
Die Befehlssyntax für die Perl Funktion ist: <br><br>
|
||||||
|
|
||||||
|
<code>
|
||||||
|
DbReadingsVal("<name>","<device:reading>","<timestamp>","<default>")
|
||||||
|
</code>
|
||||||
|
<br><br>
|
||||||
|
|
||||||
<b>Beispiele: </b><br>
|
<b>Beispiele: </b><br>
|
||||||
$ret = DbReadingsVal("Rep.LogDB1","MyWetter:temperature","2018-01-13 08:00:00",""); <br>
|
$ret = DbReadingsVal("Rep.LogDB1","MyWetter:temperature","2018-01-13_08:00:00",""); <br>
|
||||||
attr <name> userReadings oldtemp {DbReadingsVal("Rep.LogDB1","MyWetter:temperature","2018-04-13 08:00:00","")}
|
attr <name> userReadings oldtemp {DbReadingsVal("Rep.LogDB1","MyWetter:temperature","2018-04-13_08:00:00","")}
|
||||||
<br><br>
|
<br><br>
|
||||||
|
|
||||||
|
Die Befehlssyntax als FHEM Kommando ist: <br><br>
|
||||||
|
|
||||||
|
<code>
|
||||||
|
dbReadingsVal <name> <device:reading> <timestamp> <default>
|
||||||
|
</code>
|
||||||
|
<br><br>
|
||||||
|
|
||||||
|
<b>Beispiel: </b><br>
|
||||||
|
dbReadingsVal Rep.LogDB1 MyWetter:temperature 2018-01-13_08:00:00 0
|
||||||
|
<br><br>
|
||||||
|
|
||||||
<table>
|
<table>
|
||||||
<colgroup> <col width=5%> <col width=95%> </colgroup>
|
<colgroup> <col width=5%> <col width=95%> </colgroup>
|
||||||
<tr><td> <b><name></b> </td><td>: Name des abzufragenden DbRep-Device </td></tr>
|
<tr><td> <b><name></b> </td><td>: Name des abzufragenden DbRep-Device </td></tr>
|
||||||
<tr><td> <b><device:reading></b> </td><td>: Device:Reading dessen Wert geliefert werden soll </td></tr>
|
<tr><td> <b><device:reading></b> </td><td>: Device:Reading dessen Wert geliefert werden soll </td></tr>
|
||||||
<tr><td> <b><timestamp></b> </td><td>: Zeitpunkt des zu liefernden Readingwertes (*) in der Form "YYYY-MM-DD hh:mm:ss" </td></tr>
|
<tr><td> <b><timestamp></b> </td><td>: Zeitpunkt des zu liefernden Readingwertes (*) im Format "YYYY-MM-DD_hh:mm:ss" </td></tr>
|
||||||
<tr><td> <b><default></b> </td><td>: Defaultwert falls kein Readingwert ermittelt werden konnte </td></tr>
|
<tr><td> <b><default></b> </td><td>: Defaultwert falls kein Readingwert ermittelt werden konnte </td></tr>
|
||||||
</table>
|
</table>
|
||||||
</ul>
|
</ul>
|
||||||
<br>
|
<br>
|
||||||
|
|
||||||
(*) Es wird der zeitlich zu <timestamp> passendste Readingwert zurück geliefert, falls kein Wert exakt zu dem
|
(*) Es wird der zeitlich zu <timestamp> passendste Readingwert zurück geliefert, falls kein Wert exakt zu dem
|
||||||
angegebenen Zeitpunkt geloggt wurde.
|
angegebenen Zeitpunkt geloggt wurde.
|
||||||
<br><br>
|
<br><br>
|
||||||
|
@ -58,6 +58,7 @@ no if $] >= 5.017011, warnings => 'experimental::smartmatch';
|
|||||||
|
|
||||||
# Version History intern
|
# Version History intern
|
||||||
our %DbRep_vNotesIntern = (
|
our %DbRep_vNotesIntern = (
|
||||||
|
"8.21.0" => "28.04.2019 implement FHEM command \"dbReadingsVal\" ",
|
||||||
"8.20.1" => "28.04.2019 set index verbose changed, check index \"Report_Idx\" in getInitData ",
|
"8.20.1" => "28.04.2019 set index verbose changed, check index \"Report_Idx\" in getInitData ",
|
||||||
"8.20.0" => "27.04.2019 don't save hash refs in central hash to prevent potential memory leak, new set \"index\" ".
|
"8.20.0" => "27.04.2019 don't save hash refs in central hash to prevent potential memory leak, new set \"index\" ".
|
||||||
"command, \"repository\" added in Meta.json ",
|
"command, \"repository\" added in Meta.json ",
|
||||||
@ -374,8 +375,18 @@ sub DbRep_Initialize($) {
|
|||||||
"userExitFn ".
|
"userExitFn ".
|
||||||
"valueFilter ".
|
"valueFilter ".
|
||||||
$readingFnAttributes;
|
$readingFnAttributes;
|
||||||
|
|
||||||
|
my %hash = (
|
||||||
|
Fn => 'CommandDbReadingsVal',
|
||||||
|
Hlp => '<name> <device:reading> <timestamp> <default>,Get the value of a device:reading combination from database.
|
||||||
|
The value next to the timestamp is returned if found, otherwise the <default>.
|
||||||
|
<name> = name of used DbRep device,
|
||||||
|
<timestamp> = timestamp like YYYY-MM-DD_hh:mm:ss
|
||||||
|
'
|
||||||
|
);
|
||||||
|
$cmds{dbReadingsVal} = \%hash;
|
||||||
|
|
||||||
# Umbenennen von existierenden Attrbuten
|
# Umbenennen von existierenden Attributen
|
||||||
# $hash->{AttrRenameMap} = { "reading" => "readingFilter",
|
# $hash->{AttrRenameMap} = { "reading" => "readingFilter",
|
||||||
# "device" => "deviceFilter",
|
# "device" => "deviceFilter",
|
||||||
# };
|
# };
|
||||||
@ -1493,7 +1504,7 @@ sub DbRep_getInitData($) {
|
|||||||
Log3($name, 3, "DbRep $name - $idxstate. Check ok");
|
Log3($name, 3, "DbRep $name - $idxstate. Check ok");
|
||||||
} else {
|
} else {
|
||||||
$idxstate = "Index $idx doesn't exist. Please create the index by \"set $name index recreate_Report_Idx\" command !";
|
$idxstate = "Index $idx doesn't exist. Please create the index by \"set $name index recreate_Report_Idx\" command !";
|
||||||
Log3($name, 2, "DbRep $name - WARNING - $idxstate");
|
Log3($name, 3, "DbRep $name - WARNING - $idxstate");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -10642,12 +10653,25 @@ return ($ret);
|
|||||||
}
|
}
|
||||||
|
|
||||||
####################################################################################################
|
####################################################################################################
|
||||||
# blockierende DB-Abfrage
|
# blockierende DB-Abfrage
|
||||||
# liefert den Wert eines Device:Readings des nächsmöglichen Logeintrags zum
|
# liefert den Wert eines Device:Readings des nächstmöglichen Logeintrags zum
|
||||||
# angegebenen Zeitpunkt
|
# angegebenen Zeitpunkt
|
||||||
#
|
#
|
||||||
# Aufruf: DbReadingsVal("<dbrep-device>","<device:reading>","<timestamp>,"<default>")
|
# Aufruf als Funktion: DbReadingsVal("<dbrep-device>","<device:reading>","<timestamp>,"<default>")
|
||||||
|
# Aufruf als FHEM-Cmd: DbReadingsVal <dbrep-device> <device:reading> <date_time> <default>
|
||||||
####################################################################################################
|
####################################################################################################
|
||||||
|
sub CommandDbReadingsVal($$) {
|
||||||
|
my ($cl, $param) = @_;
|
||||||
|
|
||||||
|
my @a = split("[ \t][ \t]*", $param);
|
||||||
|
my ($name, $devread, $ts, $default) = @a;
|
||||||
|
$ts =~ s/_/ /;
|
||||||
|
|
||||||
|
my $ret = DbReadingsVal($name, $devread, $ts, $default);
|
||||||
|
|
||||||
|
return $ret;
|
||||||
|
}
|
||||||
|
|
||||||
sub DbReadingsVal($$$$) {
|
sub DbReadingsVal($$$$) {
|
||||||
my ($name, $devread, $ts, $default) = @_;
|
my ($name, $devread, $ts, $default) = @_;
|
||||||
my $hash = $defs{$name};
|
my $hash = $defs{$name};
|
||||||
@ -10659,9 +10683,10 @@ sub DbReadingsVal($$$$) {
|
|||||||
}
|
}
|
||||||
unless($defs{$name}{TYPE} eq "DbRep") {
|
unless($defs{$name}{TYPE} eq "DbRep") {
|
||||||
return ("\"$name\" is not a DbRep-device but of type \"".$defs{$name}{TYPE}."\"");
|
return ("\"$name\" is not a DbRep-device but of type \"".$defs{$name}{TYPE}."\"");
|
||||||
}
|
}
|
||||||
|
$ts =~ s/_/ /;
|
||||||
unless($ts =~ /^(\d{4})-(\d{2})-(\d{2}) (\d{2}):(\d{2}):(\d{2})$/) {
|
unless($ts =~ /^(\d{4})-(\d{2})-(\d{2}) (\d{2}):(\d{2}):(\d{2})$/) {
|
||||||
return ("timestamp has not a valid format. Use \"YYYY-MM-DD hh:mm:ss\" as timestamp.");
|
return ("timestamp has not the valid format. Use \"YYYY-MM-DD hh:mm:ss\" as timestamp.");
|
||||||
}
|
}
|
||||||
my ($dev,$reading) = split(":",$devread);
|
my ($dev,$reading) = split(":",$devread);
|
||||||
unless($dev && $reading) {
|
unless($dev && $reading) {
|
||||||
@ -10828,28 +10853,44 @@ return;
|
|||||||
Further informations you can find as described at <a href="#DbRepattr">attribute</a> "userExitFn".
|
Further informations you can find as described at <a href="#DbRepattr">attribute</a> "userExitFn".
|
||||||
<br><br>
|
<br><br>
|
||||||
|
|
||||||
Once a DbRep-Device is defined, the function <b>DbReadingsVal</b> is provided.
|
Once a DbRep-Device is defined, the Perl function <b>DbReadingsVal</b> provided as well as and the FHEM command <b>dbReadingsVal</b>.
|
||||||
With this function you can, similar to the well known ReadingsVal, get a reading value from database.
|
With this function you can, similar to the well known ReadingsVal, get a reading value from database.
|
||||||
The function execution is carried out blocking.
|
The function execution is carried out blocking. <br><br>
|
||||||
The command syntax is: <br><br>
|
|
||||||
|
|
||||||
<ul>
|
<ul>
|
||||||
<code>DbReadingsVal("<name>","<device:reading>","<timestamp>","<default>") </code> <br><br>
|
The command syntax for the Perl function is: <br><br>
|
||||||
|
|
||||||
|
<code>
|
||||||
|
DbReadingsVal("<name>","<device:reading>","<timestamp>","<default>")
|
||||||
|
</code>
|
||||||
|
<br><br>
|
||||||
|
|
||||||
<b>Examples: </b><br>
|
<b>Examples: </b><br>
|
||||||
$ret = DbReadingsVal("Rep.LogDB1","MyWetter:temperature","2018-01-13 08:00:00",""); <br>
|
my $ret = DbReadingsVal("Rep.LogDB1","MyWetter:temperature","2018-01-13_08:00:00",""); <br>
|
||||||
attr <name> userReadings oldtemp {DbReadingsVal("Rep.LogDB1","MyWetter:temperature","2018-04-13 08:00:00","")}
|
attr <name> userReadings oldtemp {DbReadingsVal("Rep.LogDB1","MyWetter:temperature","2018-04-13_08:00:00","")}
|
||||||
<br><br>
|
<br><br>
|
||||||
|
|
||||||
|
The command syntax for the FHEM command is: <br><br>
|
||||||
|
|
||||||
|
<code>
|
||||||
|
dbReadingsVal <name> <device:reading> <timestamp> <default>
|
||||||
|
</code>
|
||||||
|
<br><br>
|
||||||
|
|
||||||
|
<b>Example: </b><br>
|
||||||
|
dbReadingsVal Rep.LogDB1 MyWetter:temperature 2018-01-13_08:00:00 0
|
||||||
|
<br><br>
|
||||||
|
|
||||||
<table>
|
<table>
|
||||||
<colgroup> <col width=5%> <col width=95%> </colgroup>
|
<colgroup> <col width=5%> <col width=95%> </colgroup>
|
||||||
<tr><td> <b><name></b> </td><td>: name of the DbRep-Device to request </td></tr>
|
<tr><td> <b><name></b> </td><td>: name of the DbRep-Device to request </td></tr>
|
||||||
<tr><td> <b><device:reading></b> </td><td>: device:reading whose value is to deliver </td></tr>
|
<tr><td> <b><device:reading></b> </td><td>: device:reading whose value is to deliver </td></tr>
|
||||||
<tr><td> <b><timestamp></b> </td><td>: timestamp of reading whose value is to deliver (*) in the form "YYYY-MM-DD hh:mm:ss" </td></tr>
|
<tr><td> <b><timestamp></b> </td><td>: timestamp of reading whose value is to deliver (*) in the form "YYYY-MM-DD_hh:mm:ss" </td></tr>
|
||||||
<tr><td> <b><default></b> </td><td>: default value if no reading value can be retrieved </td></tr>
|
<tr><td> <b><default></b> </td><td>: default value if no reading value can be retrieved </td></tr>
|
||||||
</table>
|
</table>
|
||||||
</ul>
|
</ul>
|
||||||
<br>
|
<br>
|
||||||
|
|
||||||
(*) If no value can be retrieved at the <timestamp> exactly requested, the chronological most convenient reading
|
(*) If no value can be retrieved at the <timestamp> exactly requested, the chronological most convenient reading
|
||||||
value is delivered back.
|
value is delivered back.
|
||||||
<br><br>
|
<br><br>
|
||||||
@ -10858,9 +10899,8 @@ return;
|
|||||||
<a href="https://forum.fhem.de/index.php/topic,53584.msg452567.html#msg452567">Modul 93_DbRep - Reporting and Management of database content (DbLog)</a>.<br><br>
|
<a href="https://forum.fhem.de/index.php/topic,53584.msg452567.html#msg452567">Modul 93_DbRep - Reporting and Management of database content (DbLog)</a>.<br><br>
|
||||||
|
|
||||||
<br>
|
<br>
|
||||||
|
|
||||||
|
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
<b>Preparations </b> <br><br>
|
<b>Preparations </b> <br><br>
|
||||||
<ul>
|
<ul>
|
||||||
The module requires the usage of a DbLog instance and the credentials of the database definition will be used. <br>
|
The module requires the usage of a DbLog instance and the credentials of the database definition will be used. <br>
|
||||||
@ -13225,28 +13265,45 @@ sub bdump {
|
|||||||
unabhängig von einer Eventgenerierung. Weitere Informationen dazu ist unter <a href="#DbRepattr">Attribut</a>
|
unabhängig von einer Eventgenerierung. Weitere Informationen dazu ist unter <a href="#DbRepattr">Attribut</a>
|
||||||
"userExitFn" beschrieben. <br><br>
|
"userExitFn" beschrieben. <br><br>
|
||||||
|
|
||||||
Sobald ein DbRep-Device definiert ist, wird die Funktion <b>DbReadingsVal</b> zur Verfügung gestellt.
|
Sobald ein DbRep-Device definiert ist, wird sowohl die Perl Funktion <b>DbReadingsVal</b> als auch das FHEM Kommando
|
||||||
|
<b>dbReadingsVal</b> zur Verfügung gestellt.
|
||||||
Mit dieser Funktion läßt sich, ähnlich dem allgemeinen ReadingsVal, der Wert eines Readings aus der Datenbank abrufen.
|
Mit dieser Funktion läßt sich, ähnlich dem allgemeinen ReadingsVal, der Wert eines Readings aus der Datenbank abrufen.
|
||||||
Die Funktionsausführung erfolgt blockierend.
|
Die Funktionsausführung erfolgt blockierend. <br><br>
|
||||||
Die Befehlssyntax ist: <br><br>
|
|
||||||
|
|
||||||
<ul>
|
<ul>
|
||||||
<code>DbReadingsVal("<name>","<device:reading>","<timestamp>","<default>") </code> <br><br>
|
Die Befehlssyntax für die Perl Funktion ist: <br><br>
|
||||||
|
|
||||||
|
<code>
|
||||||
|
DbReadingsVal("<name>","<device:reading>","<timestamp>","<default>")
|
||||||
|
</code>
|
||||||
|
<br><br>
|
||||||
|
|
||||||
<b>Beispiele: </b><br>
|
<b>Beispiele: </b><br>
|
||||||
$ret = DbReadingsVal("Rep.LogDB1","MyWetter:temperature","2018-01-13 08:00:00",""); <br>
|
$ret = DbReadingsVal("Rep.LogDB1","MyWetter:temperature","2018-01-13_08:00:00",""); <br>
|
||||||
attr <name> userReadings oldtemp {DbReadingsVal("Rep.LogDB1","MyWetter:temperature","2018-04-13 08:00:00","")}
|
attr <name> userReadings oldtemp {DbReadingsVal("Rep.LogDB1","MyWetter:temperature","2018-04-13_08:00:00","")}
|
||||||
<br><br>
|
<br><br>
|
||||||
|
|
||||||
|
Die Befehlssyntax als FHEM Kommando ist: <br><br>
|
||||||
|
|
||||||
|
<code>
|
||||||
|
dbReadingsVal <name> <device:reading> <timestamp> <default>
|
||||||
|
</code>
|
||||||
|
<br><br>
|
||||||
|
|
||||||
|
<b>Beispiel: </b><br>
|
||||||
|
dbReadingsVal Rep.LogDB1 MyWetter:temperature 2018-01-13_08:00:00 0
|
||||||
|
<br><br>
|
||||||
|
|
||||||
<table>
|
<table>
|
||||||
<colgroup> <col width=5%> <col width=95%> </colgroup>
|
<colgroup> <col width=5%> <col width=95%> </colgroup>
|
||||||
<tr><td> <b><name></b> </td><td>: Name des abzufragenden DbRep-Device </td></tr>
|
<tr><td> <b><name></b> </td><td>: Name des abzufragenden DbRep-Device </td></tr>
|
||||||
<tr><td> <b><device:reading></b> </td><td>: Device:Reading dessen Wert geliefert werden soll </td></tr>
|
<tr><td> <b><device:reading></b> </td><td>: Device:Reading dessen Wert geliefert werden soll </td></tr>
|
||||||
<tr><td> <b><timestamp></b> </td><td>: Zeitpunkt des zu liefernden Readingwertes (*) in der Form "YYYY-MM-DD hh:mm:ss" </td></tr>
|
<tr><td> <b><timestamp></b> </td><td>: Zeitpunkt des zu liefernden Readingwertes (*) im Format "YYYY-MM-DD_hh:mm:ss" </td></tr>
|
||||||
<tr><td> <b><default></b> </td><td>: Defaultwert falls kein Readingwert ermittelt werden konnte </td></tr>
|
<tr><td> <b><default></b> </td><td>: Defaultwert falls kein Readingwert ermittelt werden konnte </td></tr>
|
||||||
</table>
|
</table>
|
||||||
</ul>
|
</ul>
|
||||||
<br>
|
<br>
|
||||||
|
|
||||||
(*) Es wird der zeitlich zu <timestamp> passendste Readingwert zurück geliefert, falls kein Wert exakt zu dem
|
(*) Es wird der zeitlich zu <timestamp> passendste Readingwert zurück geliefert, falls kein Wert exakt zu dem
|
||||||
angegebenen Zeitpunkt geloggt wurde.
|
angegebenen Zeitpunkt geloggt wurde.
|
||||||
<br><br>
|
<br><br>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user