pilight Plot

Plot state changes with pilight

After equipping my house with an FHEM controlled heating system, I wanted to get some control how often the heating circuits get turned on day by day. Since FHEM is event based and provides plotting functionality, and additionally my pilight module loggs out every state change, everything left to do is to combine these things.

Just to resume what happened in the last articles: I build an automatic heating control system with FHEM, and I used pilight to switch the heating system on or off, room by room. Since you can use pilight for many other use cases, like toggling a bulb or your toaster, the heating system is just an example which hopefully helps understanding the following steps.

Archiving state changes

As usual when you want to plot FHEM data, you have to define a file where your state changes are written to. Let us assume that I want to save the states of my pilight switch device HeizungWozi, then you have to enter the following code to fhem.cfg:

define FileLog_Heizung_Wozi FileLog ./log/Heizung_Wozi-%Y.log HeizungWozi

Et voila, all state changes are now stored in a file.


Creating a state change plot

Now let us create the plot. Therefore, click on the Create SVG plot link in the file log overview like seen in the picture above. Then, following panel will open:

pilight Plot

What we have to change is:

  1. Grid aligned (left) – check
  2. Y-Axis label (left and right) – leave empty
  3. Tics as (“Txt” val, …) (left) – (“Off” 0, “On” 1)
  4. Diagram label – leave as it is
  5. Column – 3
  6. Function – $fld[2]=~”on”?1:0
  7. Plot Type – Steps
  8. Style – IOfill

The last two points are more or less optional.

Now hit Write .gplot file and you are done. You can read more about creating plots in the FHEM wiki.

3 thoughts on “Plot state changes with pilight”

  1. I have problems creating the plot. I get a gplot file looking like this:
    # Created by FHEM/98_SVG.pm, 2015-08-12 14:28:45
    set terminal png transparent size crop
    set output ‘.png’
    set xdata time
    set timefmt “%Y-%m-%d_%H:%M:%S”
    set xlabel ” ”
    set title ”
    set ytics (“Off” 0, “On” 1)
    set y2tics
    set grid ytics
    set ylabel “”
    set y2label “”

    #FileLog_Dorsensor 3:Dorsensor.*::$fld[2]=~”on”?1:0

    plot “” using 1:2 axes x1y1 title ‘Line 1’ ls l0fill lw 1 with steps

    by following your steps, my device is called Dorsensor and the log file looks like this:
    2015-08-12_13:16:27 Dorsensor off
    2015-08-12_13:23:04 Dorsensor on

    Could you post your gplot file so I can compare.
    Thank you in advance.

    1. # Created by FHEM/98_SVG.pm, 2013-12-25 12:00:12
      set terminal png transparent size crop
      set output ‘.png’
      set xdata time
      set timefmt “%Y-%m-%d_%H:%M:%S”
      set xlabel ” ”
      set title ‘
      set ytics
      set y2tics
      set grid ytics
      set ylabel “Humidity”
      set y2label “Temperature”
      set yrange 0:100
      set y2range 0:40

      #FileLog 4:Temp_Wozi.humidity\x3a::
      #FileLog 4:Temp_Wozi.temperature\x3a::

      plot “” using 1:2 axes x1y1 title ‘Humidity’ ls l1 lw 1 with lines,\
      ” using 1:2 axes x1y2 title ‘Temperature’ ls l0 lw 1 with lines

  2. Thank you for the quick reply.
    Is it posible that the gplot file that you gave is for something else (temperatur/humidity log). It doesn’t seem to contain any of the things that you described in your post.

Leave a Reply

Your email address will not be published. Required fields are marked *