diff --git a/fhem/CHANGED b/fhem/CHANGED index 16ff5d7e8..3ff29476c 100644 --- a/fhem/CHANGED +++ b/fhem/CHANGED @@ -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 diff --git a/fhem/FHEM/93_DbLog.pm b/fhem/FHEM/93_DbLog.pm index 719e54782..cef844a16 100644 --- a/fhem/FHEM/93_DbLog.pm +++ b/fhem/FHEM/93_DbLog.pm @@ -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] ...\n". " where column_spec is :::\n" . " see the #DbLog entries in the .gplot files\n" . @@ -1376,6 +1378,25 @@ sub chartQuery($@) { return $jsonstring; } +# +# provide new functions: +# get ReadingsVal +# get ReadingsTimestamp +# +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($@) { Get +
    + get <name> ReadingsVal       <device> <reading> <default>
    + get <name> ReadingsTimestamp <device> <reading> <default>
    +
    + Retrieve one single value, use and syntax are similar to ReadingsVal() and ReadingsTimestamp() functions.
    +
+
+
    get <name> <infile> <outfile> <from> <to> <column_spec> @@ -1754,6 +1783,14 @@ sub chartQuery($@) { Get +
      + get <name> ReadingsVal       <device> <reading> <default>
      + get <name> ReadingsTimestamp <device> <reading> <default>
      +
      + Liest einen einzelnen Wert aus der Datenbank, Benutzung und Syntax sind weitgehend identisch zu ReadingsVal() und ReadingsTimestamp().
      +
    +
    +
      get <name> <infile> <outfile> <from> <to> <column_spec>