### Charts Persistence & RRD4J

To add Charts to openHAB, the addon Persistence and RRD4J have to be installed.
Notes:
• RRDJ4J is a Round-Robin Database.
• Lear more about the settings: https://github.com/openhab/openhab/wiki/rrd4j-Persistence
Installation persistence-´and rrd4j
$sudo apt-get install openhab-addon-persistence-rrd4j
Set the default peristence in openhab.cfg (/etc/openhab/configurations)
Default Persistence
persistence:default=rrd4j
Build Configuration file to collect data
Create a configuration file rrd4j.persist in the folder /etc/openhab/configurations/persistence.
There are two ways:
a) Via the TinkerForge Brick Viewer
b) As sudo, add the settings, save and move ownership to openhab user.
Set the persistence configuration folder:
$cd /etc/openhab/configurations/persistence
Edit the configuration file (for content see below):
$sudo nano rrd4j.persist
Change the ownership from root to openhab:
$chown openhab: /etc/openhab/configurations/persistence/rrd4j.persist
Content of the Configuration file rrd4j.persist
Strategies {
everyMinute : "0 * * * * ?"
everyHour : "0 0 * * * ?"
everyDay : "0 0 0 * * ?"
default = everyChange
}
//Apply strategy to all items
Items {
* : strategy = everyChange, restoreOnStartup
}
Chart Browser Access
The charts can also be accessed direct via Webbrowser, like
http://IP-OPENHAB:PORT/chart?items=ITEMA,ITEMB,ITEMC&period=W&h=300&w=400
Examples:
http://192.168.0.30:8080/chart?items=TF_AmbientLight&period=h&h=800&w=1200
http://192.168.0.30:8080/chart?items=TF_AmbientLight,TF_Temperature&period=W&h=300&w=400
Delete old rrd files
If issues are encountered displying the chart in the browser, it might help to delete the old rrd files.
$cd /var/lib/openhab/persistence/rrd4j
$sudo rm *.*
Hint on openhab logentry RRD4jService] - Removing invalid defintion component = null heartbeat = 0 ...
There might have several causes, but this one was caused by invaliddefintion is the sitemap file.
Wrong (=an apostroph "missing in the mappings for 2=week:
Switch item=CHART_PERIOD label="Chart Range" mappings=[0="hour", 1="day", 2=week"]
Right
Switch item=CHART_PERIOD label="Chart Range" mappings=[0="hour", 1="day", 2="week"]
Embedding a Chart
Example displaying TinkerForge AmbientLight data with the option to select the period Hour, Day or Week.
weather-station.items
Number TF_AmbientLight "Luminance [%.0f lx]" { tinkerforge="uid=mdh" }
Number CHART_PERIOD
weather-station.rules
Not used.
weather-station.sitemap
sitemap tf_weather_station label="Weather Station"
{
Frame
{
Text item=TF_AmbientLight
Switch item=CHART_PERIOD label="Chart Range" mappings=[0="hour", 1="day", 2="week"]
Chart item=TF_AmbientLight period=h refresh=300 visibility=[CHART_PERIOD==0, CHART_PERIOD=="Uninitialized"]
Chart item=TF_AmbientLight period=D refresh=1800 visibility=[CHART_PERIOD==1]
Chart item=TF_AmbientLight period=W refresh=3600 visibility=[CHART_PERIOD==2]
}
}

Changed: , Category: TinkerForge openHAB, File: T6C267M1986.htm, ID: 1986