OH2 is very flexible and can be configred the way everyone needs in his own setup. Basically I do not want to push every single bit & piece into a database since I dont need it. Thus I like the ability to configure it the way I like it. The OH2 docu is under heavy construction right now and lots of tutorials are added already. For the persistance tutorial the page has been created, bu no content yet.
Here's a short list of action items you an try to set it up:
- PaperUI > Add-ons > Persistance. Install RRD4J Addon
- add a local config file: /etc/openhab/persistance/rrd4j.persist
- The content should look like this:
// for rrd charts, we need a cron strategy
everyMinute : "0 * * * * ?"
default = everyChange
* : strategy = everyUpdate, everyMinute
Remark: The * will persist ALL your item. If you dont want that, take a look at this best practive which I can really recommend
- Now you will see that RRD databases are populated in /var/lib/openhab2/persistence/rrd4j
- To see a graph you have to add an item to you're sitemap like this:
Chart item=item_name period=D refresh=30000
To have it nice and sexy, I can recommend the following lines for your sitemap:
Switch item=chart_period label="Graph Zeitraum" mappings=[0="Tag", 1="Woche", 2="Monat", 3="Jahr"]
Chart item=gOG_temp period=D refresh=30000 visibility=[chart_period==0, chart_period=="Uninitialized"]
Chart item=gOG_temp period=W refresh=30000 visibility=[chart_period==1]
Chart item=gOG_temp period=M refresh=30000 visibility=[chart_period==2]
Chart item=gOG_temp period=Y refresh=30000 visibility=[chart_period==3]
You will need an additional item called chart_period which will be displayed along with the graph. By choosing the Value for chart_period, the graph below will update accoring to your requested time frame.
Here's the item definition:
// To choose a proper cahrt period in a sitemap
// mappings=[0="Tag", 1="Woche", 2="Monat", 3="Jahr"]
Not too difficult, right?
Any questions, let us know.