FHEM Forum

FHEM => Codeschnipsel => Thema gestartet von: Sailor am 02 März 2014, 16:16:39

Titel: Individuelles Log-File mit individueller Eintragsmoeglichkeit
Beitrag von: Sailor am 02 März 2014, 16:16:39
Ein herzerfrischendes MoiMoin vom Programmsel vom hinterm-Deich

Ich habe bereits die "FEHM reference", das WIKI und dieses Forum gewaelzt und komme dennoch irgendwie nicht weiter.

Ausgangslage:
Um einen geeigneten Plot fuer mein Raumklima zu erstellen habe ich mir bereits ein individuelles Log-File erstellt.


###START###### Create combined logfile for bedroom #############################################################START###
define FileLog_BR_Clima FileLog ./log/BR_Clima-%Y-%m.log (BR_RadiatorR_Clima:.*(ValvePosition)):|(BR_Thermostat_Climate:.*(desired-temp|measured-temp|humidity|dewpoint)).*
attr FileLog_BR_Clima logtype text
attr FileLog_BR_Clima room Logs
####END####### Create combined logfile for bedroom ##############################################################END####


Das Log-File wird wunschgemaess erstellt:


2014-03-01_09:51:17 BR_Thermostat_Climate desired-temp: 15
2014-03-01_09:53:56 BR_Thermostat_Climate measured-temp: 17.4
2014-03-01_09:53:56 BR_Thermostat_Climate humidity: 45
2014-03-01_09:53:56 BR_Thermostat_Climate dewpoint: 5.4
2014-03-01_09:53:56 BR_RadiatorR_Clima ValvePosition: 0 %


Der damit verbundene Plot spuckt auch aus was er soll. (Siehe Pre-Plot.png)

Problemstellung:
Ich moechte die Fensteroeffnungen ebenfalls im Plot darstellen, dazu muessen sie jedoch ersteinmal in das Log-File.
Dummerweise erscheinen die Fensterzustaende nur als "open" oder "closed"


2014-03-01_16:32:55 BR_Window open
2014-03-01_16:32:55 BR_Window contact: open (to HMLAN1)
2014-03-01_16:32:56 BR_Window contact: open (to BR_RadiatorR)
2014-03-01_16:32:56 BR_Window contact: open (to BR_RadiatorL)
2014-03-01_16:32:56 BR_Window contact: open (to BR_Thermostat)
2014-03-01_16:32:59 BR_Window closed


Wie bekomme ich also die states des "BR_Window" anstelle "open" und "closed" als "100" und "0" (%) ind das zusaetzlich in das Logfile damit das ganze in etwa wie unten aussieht?


2014-03-01_09:51:17 BR_Thermostat_Climate desired-temp: 15
2014-03-01_09:53:56 BR_Thermostat_Climate measured-temp: 17.4
2014-03-01_09:53:56 BR_Thermostat_Climate humidity: 45
2014-03-01_09:53:56 BR_Thermostat_Climate dewpoint: 5.4
2014-03-01_09:53:56 BR_RadiatorR_Clima ValvePosition: 0 %
2014-03-01_09:53:56 BR_Window 100


Wenn Ihr eine Idee habt oder einen Link kennt, den ich uebersehen habe, dann immer nur heraus damit!

Vielen Dank vorweg!
   Sailor
Titel: Antw:Individuelles Log-File mit individueller Eintragsmoeglichkeit
Beitrag von: Bennemannc am 02 März 2014, 16:25:37
Hallo,

schau mal hier: http://forum.fhem.de/index.php?topic=16939.0 - da wird so etwas nur mit 1 und 0 gemacht.

Gruß Christoph
Titel: Antw:Individuelles Log-File mit individueller Eintragsmoeglichkeit
Beitrag von: Sailor am 02 März 2014, 19:32:37
Hallo Bennemanc

Danke, das war der Hinweis den ich gesucht habe!  8)

Logfile damit gebaut:


###START###### Create combined logfile for bedroom #############################################################START###
define FileLog_BR_Clima FileLog ./log/BR_Clima-%Y-%m.log (BR_Window.*):|(BR_RadiatorR_Clima:.*(ValvePosition)):|(BR_Thermostat_Climate:.*(desired-temp|measured-temp|humidity|dewpoint)).*
attr FileLog_BR_Clima logtype text
attr FileLog_BR_Clima room Logs
####END####### Create combined logfile for bedroom ##############################################################END####


folgende .gplot Datei mit dem Plot-Editor erstellt:


# Created by FHEM/98_SVG.pm, 2014-03-02 19:25:00
set terminal png transparent size <SIZE> crop
set output '<OUT>.png'
set xdata time
set timefmt "%Y-%m-%d_%H:%M:%S"
set xlabel " "
set title 'Bedroom Clima'
set ytics nomirror
set y2tics
set grid y2tics
set ylabel "Humidity / Valve Position (%)"
set y2label "Temperature in °C"
set yrange [0:100]
set y2range [0:30]

#FileLog 4:BR_RadiatorR_Clima.ValvePosition\x3a:0:
#FileLog 4:BR_Thermostat_Climate.humidity\x3a:0:
#FileLog 4:BR_Thermostat_Climate.desired-temp\x3a:0:
#FileLog 4:BR_Thermostat_Climate.measured-temp\x3a:0:
#FileLog 4:BR_Thermostat_Climate.dewpoint\x3a:0:
#FileLog 3:BR_Window.*:0:$fld[2]=~"open"?100:0

plot "<IN>" using 1:2 axes x1y1 title 'Valve Position' ls l3 lw 1 with steps,\
     "<IN>" using 1:2 axes x1y1 title 'Humidity' ls l2fill lw 1 with lines,\
     "<IN>" using 1:2 axes x1y2 title 'Desired Temperature' ls l1 lw 1 with steps,\
     "<IN>" using 1:2 axes x1y2 title 'Measured Temperature' ls l0 lw 1 with lines,\
     "<IN>" using 1:2 axes x1y2 title 'Dewpoint' ls l5 lw 1 with lines,\
     "<IN>" using 1:2 axes x1y1 title 'Window open' ls l4fill lw 1 with steps


Und schon klappts!  :D

Gibt es eigentlich irgendwo eine genaue Beschreibung fuer das "Funktionsfeld" des gplot editors?

Ich habe im Gefuehl, dass da noch einiges Potential drin ist.

Gruss vom Deich
    Sailor