From e36f27a75fb69baad58b661820de0228bf3348ba Mon Sep 17 00:00:00 2001 From: rapster <> Date: Mon, 26 Oct 2015 11:57:48 +0000 Subject: [PATCH] 93_DbLog: Added support for longpoll SVG. git-svn-id: https://svn.fhem.de/fhem/trunk@9688 2b470e98-0d58-463d-a4d8-8e2adae1ed80 --- fhem/CHANGED | 1 + fhem/FHEM/93_DbLog.pm | 47 ++++++++++++++++++++++++++++++++++--------- 2 files changed, 39 insertions(+), 9 deletions(-) diff --git a/fhem/CHANGED b/fhem/CHANGED index 108bd25b7..95e91e3f2 100644 --- a/fhem/CHANGED +++ b/fhem/CHANGED @@ -1,5 +1,6 @@ # 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. + - feature: 93_DbLog: Added support for longpoll SVG. - feature: contrib/98_openweathermap.pm - add support for stationByZip. e.g. 76133,de will find weather data for Karlsruhe,Germany - bugfix: 38_CO20: fixed error messages on timeout diff --git a/fhem/FHEM/93_DbLog.pm b/fhem/FHEM/93_DbLog.pm index 0090b716d..6c3134e09 100644 --- a/fhem/FHEM/93_DbLog.pm +++ b/fhem/FHEM/93_DbLog.pm @@ -33,14 +33,15 @@ sub DbLog_Initialize($) { my ($hash) = @_; - $hash->{DefFn} = "DbLog_Define"; - $hash->{UndefFn} = "DbLog_Undef"; - $hash->{NotifyFn} = "DbLog_Log"; - $hash->{SetFn} = "DbLog_Set"; - $hash->{GetFn} = "DbLog_Get"; - $hash->{AttrFn} = "DbLog_Attr"; - $hash->{ShutdownFn} = "DbLog_Shutdown"; - $hash->{AttrList} = "disable:0,1 ". + $hash->{DefFn} = "DbLog_Define"; + $hash->{UndefFn} = "DbLog_Undef"; + $hash->{NotifyFn} = "DbLog_Log"; + $hash->{SetFn} = "DbLog_Set"; + $hash->{GetFn} = "DbLog_Get"; + $hash->{AttrFn} = "DbLog_Attr"; + $hash->{SVG_regexpFn} = "DbLog_regexpFn"; + $hash->{ShutdownFn} = "DbLog_Shutdown"; + $hash->{AttrList} = "disable:0,1 ". "DbLogType:Current,History,Current/History ". "shutdownWait ". "suppressUndef:0,1 ". @@ -142,6 +143,32 @@ sub DbLog_Attr(@) return undef; } +################################################################ +# +# Exrahieren des Filters aus der ColumnsSpec (gplot-Datei) +# +# Die grundlegend idee ist das jeder svg plot einen filter hat der angibt +# welches device und reading dargestellt wird so das der plot sich neu +# lädt wenn es ein entsprechendes event gibt. +# +# Parameter: Quell-Instanz-Name, und alle FileLog-Parameter, die diese Instanz betreffen. +# Quelle: http://forum.fhem.de/index.php/topic,40176.msg325200.html#msg325200 +################################################################ +sub DbLog_regexpFn($$) { + my ($name, $filter) = @_; + my $ret; + + my @a = split( ' ', $filter ); + for(my $i = 0; $i < int(@a); $i++) { + my @fld = split(":", $a[$i]); + + $ret .= '|' if( $ret ); + $ret .= $fld[0] .'.'. $fld[1]; + } + + return $ret; +} + ################################################################ # # Parsefunktion, abhaengig vom Devicetyp @@ -501,6 +528,8 @@ sub DbLog_Log($$) { # Log is my entry, Dev is the entry of the changed device my ($hash, $dev) = @_; + Log3 $hash,5, "Notify from Device: ".$dev->{NAME}." recieved"; + return undef if($hash->{STATE} eq "disabled"); # name and type required for parsing @@ -1884,7 +1913,7 @@ DbLog_sampleDataFn($$$$$) # Table Current present, use it for sample data my $dbhf = $defs{$dlName}{DBHF}; - my $query = "select device,reading,value from current where device <> '' group by device,reading order by device,reading"; + my $query = "select device,reading,value from current where device <> '' order by device,reading"; my $sth = $dbhf->prepare( $query ); $sth->execute(); while (my @line = $sth->fetchrow_array()) {