How to define RRD4j persistence for temperature charts


I’m using mapdb persistence as the default service to save all the states of my items, lights etc. However, I know that mapdb can not be used for charts.
I have the following in my sitemap:

Frame {

                Switch item=Weather_Chart_Period label="Chart Period" icon="chart" mappings=[0="Hour", 1="Day", 2="Week"]

                Chart item=Weather_Chart period=h refresh=600000 visibility=[Weather_Chart_Period==0, Weather_Chart_Period=="NULL"]

                Chart item=Weather_Chart period=D refresh=3600000 visibility=[Weather_Chart_Period==1]

                Chart item=Weather_Chart period=W refresh=3600000 visibility=[Weather_Chart_Period==2]


And I have the following in rrd4j.persist

   Strategies {

        everyDay    : "0 0 0 * * ?"

        everyHour   : "0 0 * * * ?"

        everyMinute : "0 * * * * ?"

        default = everyMinute


    Items {

        Temperature*,Weather_Chart* : strategy = everyMinute, restoreOnStartup

        Lights* : strategy = everyChange, restoreOnStartup


But the rrd4j is not being used with mapdb set as default.
If I set rrd4j as default then the charts work fine, but I’m not storing any states of my lights, switches etc
Thanks in advance

You’re not telling your sitemap Chart widgets which persistence service to use.
So they use the default service.
If you would like Chart to use a non-default service, you must specify which one in the Chart widget.

Unrelated, do you really want restore on startup in your rrd4j config? What is mapdb for, if so?

Thanks for that, I was looking through the docs at persistence and it didn’t occur to me to look in there.

Is this the same for non-chart items?

For instance, I have this rule:

rule "Set daily max and min temperature"


    Item Weather_Temperature changed or

    Time cron "0 0 0 * * ?" or

    System started


    val max = Weather_Temperature.maximumSince(now.withTimeAtStartOfDay)

    val min = Weather_Temperature.minimumSince(now.withTimeAtStartOfDay)

    if (max !== null && min !== null) {

        postUpdate(Weather_Temp_Max, max.state)

        postUpdate(Weather_Temp_Min, min.state)



I also need to persist those values of Item Weather_Temperature for that rule to work properly I think

Unrelated, do you really want restore on startup in your rrd4j config? What is mapdb for, if so?

I’m not exactly sure what I’m doing to be totally honest :rofl:

So, I guess I could remove the restore on startup from my rrd4j config, because mapdb is taking care of that?

Yes, if you don’t want to use the default service in persistence functions in a rule, you have to tell it what you do want to use instead. It’s described in the persistence docs that you looked at.

You haven’t said exactly what you are dong with mapdb, but there’s no point in having more than one service doing restores on the same Item

Thanks @rossko57,
mapdb is basically just storing everything and restoring it on startup, so I have removed the restore on startup from the rrd4j.persist file.

I had read that part of the docs on persistence, however I’m unsure how to incorporate it into the rule I posted.

Would it be like this:

val max = Weather_Temperature.maximumSince(now.withTimeAtStartOfDay,"rrd4j")

val min = Weather_Temperature.minimumSince(now.withTimeAtStartOfDay,"rrd4j")

EDIT: Actually, I think that has done it!

Thanks so much for your help :slight_smile:

1 Like

This will use default persistence

If you want it to use rrd4j, tell it so

val max = Weather_Temperature.maximumSince(now.withTimeAtStartOfDay, "rrd4j")
1 Like


Thanks again :slight_smile: