mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-03-03 10:46:53 +00:00
DbLog: added ReadingsVal/ReadingsTimestamp
git-svn-id: https://svn.fhem.de/fhem/trunk@5163 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
99f114e739
commit
570984ef57
@ -1,6 +1,8 @@
|
||||
# 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.
|
||||
- SVN
|
||||
- feature: DbLog: Added new function : ReadingsVal/ReadingsTimestamp
|
||||
- feature: Text2Speech: added new attribute TTS_VolumeAdjust
|
||||
- feature: added wrapper module 98_configDB (betateilchen)
|
||||
- feature: new module 70_PHTV.pm (loredo)
|
||||
- feature: JSONMETER: added statistic functions
|
||||
|
@ -1,5 +1,3 @@
|
||||
|
||||
|
||||
##############################################
|
||||
# $Id$
|
||||
#
|
||||
@ -27,6 +25,8 @@ my %columns = ("DEVICE" => 64,
|
||||
"UNIT" => 32
|
||||
);
|
||||
|
||||
sub dbReadings($@);
|
||||
|
||||
################################################################
|
||||
sub DbLog_Initialize($)
|
||||
{
|
||||
@ -690,6 +690,8 @@ DbLog_Get($@)
|
||||
{
|
||||
my ($hash, @a) = @_;
|
||||
|
||||
return dbReadings($hash,@a) if $a[1] =~ m/^Readings/;
|
||||
|
||||
return "Usage: get $a[0] <in> <out> <from> <to> <column_spec>...\n".
|
||||
" where column_spec is <device>:<reading>:<default>:<fn>\n" .
|
||||
" see the #DbLog entries in the .gplot files\n" .
|
||||
@ -1376,6 +1378,25 @@ sub chartQuery($@) {
|
||||
return $jsonstring;
|
||||
}
|
||||
|
||||
#
|
||||
# provide new functions:
|
||||
# get <dbLog> ReadingsVal <device> <reading> <default>
|
||||
# get <dbLog> ReadingsTimestamp <device> <reading> <default>
|
||||
#
|
||||
sub dbReadings($@) {
|
||||
my($hash,@a) = @_;
|
||||
my $dbhf= $hash->{DBHF};
|
||||
return 'Wrong Syntax for ReadingsVal!' unless defined($a[4]);
|
||||
my $query = "select VALUE,TIMESTAMP from current where DEVICE= '$a[2]' and READING= '$a[3]'";
|
||||
# my $query = "select VALUE,TIMESTAMP from history where DEVICE= '$a[2]' and READING= '$a[3]' order by TIMESTAMP desc limit 1";
|
||||
my ($reading,$timestamp) = $dbhf->selectrow_array($query);
|
||||
$reading = (defined($reading)) ? $reading : $a[4];
|
||||
$timestamp = (defined($timestamp)) ? $timestamp : $a[4];
|
||||
return $reading if $a[1] eq 'ReadingsVal';
|
||||
return $timestamp if $a[1] eq 'ReadingsTimestamp';
|
||||
return "Syntax error: $a[1]";
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
=pod
|
||||
@ -1463,6 +1484,14 @@ sub chartQuery($@) {
|
||||
|
||||
<a name="DbLogget"></a>
|
||||
<b>Get</b>
|
||||
<ul>
|
||||
<code>get <name> ReadingsVal <device> <reading> <default></code><br/>
|
||||
<code>get <name> ReadingsTimestamp <device> <reading> <default></code><br/>
|
||||
<br/>
|
||||
Retrieve one single value, use and syntax are similar to ReadingsVal() and ReadingsTimestamp() functions.<br/>
|
||||
</ul>
|
||||
<br/>
|
||||
<br/>
|
||||
<ul>
|
||||
<code>get <name> <infile> <outfile> <from>
|
||||
<to> <column_spec> </code>
|
||||
@ -1754,6 +1783,14 @@ sub chartQuery($@) {
|
||||
|
||||
<a name="DbLogget"></a>
|
||||
<b>Get</b>
|
||||
<ul>
|
||||
<code>get <name> ReadingsVal <device> <reading> <default></code><br/>
|
||||
<code>get <name> ReadingsTimestamp <device> <reading> <default></code><br/>
|
||||
<br/>
|
||||
Liest einen einzelnen Wert aus der Datenbank, Benutzung und Syntax sind weitgehend identisch zu ReadingsVal() und ReadingsTimestamp().<br/>
|
||||
</ul>
|
||||
<br/>
|
||||
<br/>
|
||||
<ul>
|
||||
<code>get <name> <infile> <outfile> <from>
|
||||
<to> <column_spec> </code>
|
||||
|
Loading…
x
Reference in New Issue
Block a user