Custom daily total graphs

I understand with 1.7 I can create custom graphs, but from the Wiki I could not see where to do this. I am looking to store the daily solar kwh total every night. To do that I need to use ABSOLUTE with a step of 86400. Any pointers on how to implement?

This is what I was using with my old MRTG based system:

/usr/bin/rrdtool create rrd/daily_power.rrd --step=86400 \
DS:power_in:ABSOLUTE:172800:0:500 \
DS:solar:ABSOLUTE:172800:0:500 \
DS:power_out:ABSOLUTE:172800:0:500 \
RRA:MAX:0.5:1:720

If you are using rrd4j, even though the value is only saved once a day you must save it to rrd4j every minute or charting will not work. It is a limitation of rrd4j.

You can have rrd4j generate the charts or, if you prefer or are using a different persistence, you can use the built in charting servlet.

If using rrd4j you can get a chart using something like:

 Image url="http://localhost:8080/rrdchart.png?items=Weather_Humidity&period=W" refresh=30000

If using the charting servlet you would use something like

 Image url="http://localhost:8080/chart.png?items=Weather_Humidity&period=W" refresh=30000

The documentation for what are valid periods and other parameters is here.

Habmin and Habmin2 are supposed to have a pretty good charting capability but I’ve never been able to get them to work.

1 Like

What do they mean by “default charts” on that page? Where does the chart generator get the data for the “default charts”?

“Default” is probably a misnomer. When using rrd4j charts, the chart comes from the rrd4j database itself. When using “default” charts, an openHAB developed servlet generates the charts using the data in the default persistence.

I thought the 1 min thing was because all the rrd4j stuff was hard coded until 1.7 and that after that release you could make changes.

What it does not say is where to make the changes.

As far as saving every min, I don’t have the total values for the day until the end of the day, so I can’t save it every min.

You might know more than I do but I know that in 1.7.1, using the default settings, you have to use an every minute strategy or else charts and history doesn’t work. I’ve not played around with the settings that were exposed in the update to 1.7.

The changes would be made to the rrd4j section of openhab.cfg.

Store the value at the end of the day into an Item. The persistence strategy will cause that value to save to rrd4j every minute whether it changes or not. Just because you are saving it every minute doesn’t mean you need the value to change every minute.

You can experiment with the settings too to see if you can set a step value that doesn’t require once per minute but that is beyond what I’ve researched thus far. Because the rrd4j DB is fixed sized I don’t really worry about writing infrequently changing values to the DB every minute.

I had the understanding that this is a limitation of the rrd database itself in that when you draw a chart, it is looking at a specific period and is drawing the chart based on that particular X,Y coordinate, however RRD does not have the ability to pull a specific value from a particular date/time.

Not looking at pulling values. I know it works in RRD because that is what I was using before OpenHab. To make it work you have to make a step a day and use ABSOLUTE and put the value in just before midnight.

/usr/bin/rrdtool create rrd/daily_power.rrd --step=86400 \
DS:power_in:ABSOLUTE:172800:0:500 \
DS:solar:ABSOLUTE:172800:0:500 \
DS:power_out:ABSOLUTE:172800:0:500 \
RRA:MAX:0.5:1:720

Just not sure how to do it in OpenHab.

Making a lot of progress, if I use the following in my openhab.cfg:

rrd4j:today_solar.def=ABSOLUTE,172800,0,500,86400 
rrd4j:today_solar.items=Today_Solar_kWh
rrd4j:today_solar.archives=MAX,0.5,1,730

I then configure rrd4j.persist to store the values every night (just before midnight). When I look at the graphs they show full bar for a day just like what I want without storing data every min, the only issue now is that the values look wrong.

1 Like

Good news! It would be very helpful to add a paragraph to the rrd4j wiki page once you get it working, or add an example because I think this is very useful info that is clearly not covered anywhere.

Yep, will do! Any way to read .rrd files so I can debug the value issue? I thought I could use rrdtools but the binary format is different then rrd4j.

I don’t know of any. I spent all of five minutes looking yesterday and couldn’t find anything. I’m surprised there isn’t an rrd4j command line tool one can use to “log in” to the DB and run sql queries.

Ya, I know, its quite frustrating… I see why rrd4j uses their own format, it lets them be cross platform where normal .rrd files can’t move between platforms.

Works!!!

I had to use GAUGE rather then ABSOLUTE for some reason. Also the data in the graph is shifted just a little bit, not sure why since it was entered at 00 59 23 * * *.

Well worked the first two days, now I get:

2015-12-04 23:59:00 DEBUG o.o.p.r.internal.RRD4jService[:111]- Stored 'Today_Propane_Used' with state '0.96240000000000003321787289678468368947505950927734375' in rrd4j database (again)
2015-12-04 23:59:00 DEBUG o.o.p.r.internal.RRD4jService[:130]- Stored 'Today_Propane_Used' with state '1.84799999999999973763209482058300636708736419677734375' in rrd4j database
2015-12-04 23:59:00 DEBUG o.o.p.r.internal.RRD4jService[:111]- Stored 'Today_Generator_Runtime' with state '23.983312219999998404773577931337058544158935546875' in rrd4j database (again)
2015-12-04 23:59:00 DEBUG o.o.p.r.internal.RRD4jService[:130]- Stored 'Today_Generator_Runtime' with state '23.983312219999998404773577931337058544158935546875' in rrd4j database
2015-12-04 23:59:00 DEBUG o.o.p.r.internal.RRD4jService[:111]- Stored 'Today_Water_Used' with state '451' in rrd4j database (again)
2015-12-04 23:59:00 DEBUG o.o.p.r.internal.RRD4jService[:130]- Stored 'Today_Water_Used' with state '186' in rrd4j database
2015-12-04 23:59:00 DEBUG o.o.p.r.internal.RRD4jService[:111]- Stored 'Today_Solar_kWh' with state '24.89999999999999857891452847979962825775146484375' in rrd4j database (again)
2015-12-04 23:59:00 DEBUG o.o.p.r.internal.RRD4jService[:130]- Stored 'Today_Solar_kWh' with state '23.7' in rrd4j database
2015-12-04 23:59:00 DEBUG o.o.p.r.internal.RRD4jService[:111]- Stored 'Today_Out_kWh' with state '34.3599999999999994315658113919198513031005859375' in rrd4j database (again)
2015-12-04 23:59:00 DEBUG o.o.p.r.internal.RRD4jService[:130]- Stored 'Today_Out_kWh' with state '42.49' in rrd4j database

Not sure where (again) is coming from.