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:
What we have to change is:
- Grid aligned (left) – check
- Y-Axis label (left and right) – leave empty
- Tics as (“Txt” val, …) (left) – (“Off” 0, “On” 1)
- Diagram label – leave as it is
- Column – 3
- Function – $fld=~”on”?1:0
- Plot Type – Steps
- 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.