Charting - Getting Started

I’ve mainly been using OH2 for various basic functionality of turning On/Off various lights along with some rules. But I have never done anything regarding Charting of data.

I know have a Home Energy Meter and would like begin charting its use, but I really have no idea where to begin. I haven’t even added the items in my items file yet either. And the HEM includes measuring of Amps, Watts, KWs, and Volts

I think I probably first need to pick/choose a persistence method and RRD4j is the preferred choice?

I found an old post here but unsure how this was implemented,

Any help in getting started is much appreciated.



Text item=Basement_Fridge valuecolor=[Basement_Fridge>45="red",<45="blue"] {
  Frame {
    Switch item=Day_Period label="Chart Period" mappings=[0="Day", 1="Week", 2="Month", 3="Year"]
    Chart item=Basement_Fridge period=D refresh=10000 visibility=[Day_Period==0]
    Chart item=Basement_Fridge period=W refresh=10000 visibility=[Day_Period==1]
    Chart item=Basement_Fridge period=M refresh=10000 visibility=[Day_Period==2]
    Chart item=Basement_Fridge period=Y refresh=10000 visibility=[Day_Period==3]

Then items:

Number    Day_Period                        "Chart Period"
Number    Basement_Fridge                     "Basement Fridge [%.1f °F]"                             <fridge>        (Temperature)                           {mqtt="<[mosquitto:/house/esp8266/5ccf7f02f391/0:state:default]"}


Thanks. That info is pretty helpful. So based on our items info, your using Mosquitto vs RRD4j for logging the data?

I have some limited experience with Mosquitto having tried Owntracks once in the past so not quite sure how your items line works in getting and retrieving the data.

I’m also curious as to where the actual logging of the data gets stored and possibly retrieved from. ie, if you had a temporary power outage, would you lose any history?

Nope, it is all in rrd4j

I think I followed your example well enough, yet my chart is not showing any data,

I enabled RRD4j persistence and this is my items and site map info.


/* Whole Home Energy Monitor */
Number Day_Period                   "Chart Period"				
Number Home_Energy_Amps				"Home Energy Amps [%s]"		<energy> (Power)		{ channel="zwave:device:1587fb1d72a:node20:meter_current" } 
Number Home_Energy_Watts			"Home Energy Watts [%s]"	<energy> (Power)		{ channel="zwave:device:1587fb1d72a:node20:meter_watts" } 
Number Home_Energy_Kwh				"Home Energy Kwh [%s]"		<energy> (Power)		{ channel="zwave:device:1587fb1d72a:node20:meter_kwh" } 
Number Home_Energy_Volts			"Home Energy Volts [%s]"	<energy> (Power)		{ channel="zwave:device:1587fb1d72a:node20:meter_voltage" } 

Sitemap for charting the Watts

sitemap power label="Power Site Map"
	Text item=Home_Energy_Watts valuecolor=[Home_Energy_Watts>45="red",<45="blue"] {
		Frame {
			Switch item=Day_Period label="Chart Period" mappings=[0="Day", 1="Week", 2="Month", 3="Year"]
			Chart item=Home_Energy_Watts period=D refresh=10000 visibility=[Day_Period==0]
			Chart item=Home_Energy_Watts period=W refresh=10000 visibility=[Day_Period==1]
			Chart item=Home_Energy_Watts period=M refresh=10000 visibility=[Day_Period==2]
			Chart item=Home_Energy_Watts period=Y refresh=10000 visibility=[Day_Period==3]

Also, what is a little strange is the Sitemap refers to this as an “Energy Meter” although I have not labeled anything as such in my items file? I wonder if OH2 is reading something from the zwave device itself in creating that label?

In trying to learn more, I think I’m missing/forgetting 2 steps?

  1. I think I need to edit the rrdj4.cfg config file? But unsure what setting would look like.

  2. Add rrdj4.persist file and define both the Strategies and Items? I did set this up follow an example, but the chart is still empty. Perhaps it needs a few hours to populate?

EDIT. Think I had a error in my persist file in understanding how the * works. In reading, I’m pretty sure that is for only with a group vs a listing of items.

Switching to just try the one item vs a group of Power* has some data populating.


I’ve read somewhere that the RRD chart needs data to be stored at least once per minute, otherwise it will not show data. Maybe that’s why.

In my case, I have a persistence-file etc/openhab2/persistence/rrd4j.persist which is not the best, because every item is stored, but it works:

// Persistence strategies have a name and a definition and are referred to in the "Items" section
Strategies {
	everyMinute	: "0 * * * * ?"
	everyHour	: "0 0 * * * ?"
	everyDay	: "0 0 0 * * ?"

	// If no strategy is specified for an item entry below, the default list will be used.
	default = everyChange 

 * Each line in this section defines for which item(s) which strategy(ies) should be applied.
 * You can list single items, use "*" for all items or "groupitem*" for all members of a group
 * item (excl. the group item itself).
Items {
	* : strategy = everyChange, everyMinute, restoreOnStartup
	undefined : strategy = everyMinute

And I have had the experience that one must be patient.
Don’t know why, but with me it has only displayed the chart at the next day.

Edit: Link to the docs

1 Like

Yeah, my persist file looks pretty much exactly like yours does now after editing it earlier, and i’m showing data in the chart.

Now I’m wondering if there is a way to summarize Usage into hourly/daily/weekly/monthly results? Ie, for Power Consumption, summarizing and total the data into table to show things like min,max,average and total usage for a day, week, month, etc.

I think its all in the database. I just need to learn how to access it :slight_smile: