Configuration to persist a selected item every 10 seconds

Hi,

I’m working on a rule that detects a sudden change in a value, a step up or down if you like. The detection is not the problem, the data seems to be. I think by design, or better default configuration. I read a lot but don’t quite understand it and don’t want to just try random thing that mess up my openHAB. Hence a question :question:

My openhab has the default rrd4j service with default settings. The item I want to use gets every 10 second a new value. It shows in graph (or the analyse preview). So far so good. However, if I use the persistence methods (like averageBetween) or the API the last minute is missing (also in the rule I’m writing of course). At around exact :uu:mm:00 they all appear. Maybe the kind of data also has influence, after making a step it will remain stable at the new value again.

Reading rrd4j documentation number has a granularity of 10 seconds for the first hour. That’s good. Combining that with the configuration documentation suggests a cronjob with a ‘save’ every minute or at a change. So that explains my observation. Best post on my question I could find seems to suggest that only an added rrd4j.persist could solve my issue while not interfering with defaults on other items. Unfortunate that post doesn’t end with the used configuration :wink:

So my questions:

  1. Is my conclusion right that the default setup takes 10 seconds values BUT persists them once a minute or at a change of value?
  2. Can I add a rrd4j.persist file for just one item to make it save every 10 second and will that leave the default intact?
  3. Assuming yes and yes I came up with the one below, is it right?
    3.1 If the second is no. Should I add the “* : strategy = everyChange, everyMinute” line in my persist file too?
    3.2 Or should I change the “default =” to “everyChange, everyMinute”
    4 I read about the wildcard * for groups. Can it be put anywhere or only at the end? So could I make a “*_10s: strategy = everyUpdate, every10Sec” to automatic change the persistence for all items ending with _10s?

I know, I’m probably too careful and should just try some things. But I’m so happy it all works now :nerd_face:

// persistence strategies have a name and definition and are referred to in the "Items" section
Strategies {
        everyHour : "0 0 * * * ?"
        every10Sec  : "0/10 * * * * ?"

        // 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.
 
Items {
        // my 10 second item
        stepItem: strategy = everyUpdate, every10Sec
}

Default behavior is everyChange, everyMinute (maybe everyUpdate, too, not sure about that) and this will apply to all Items, as long as there is no *.persist file for an installed persistence service.

So, when setting up a rrd4j.persist file for a special Item, you’ll have to setup the file to persist all the other Items accordingly.

// persistence strategies have a name and definition and are referred to in the "Items" section
Strategies {
    everyMinute : "5    * * * * ?"  // try to spread the strategies
    every10Sec  : "0/10 * * * * ?"

    // 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.
 
Items {
    // my 10 second item
    stepItem: strategy = everyUpdate, every10Sec
    *       : strategy = everyUpdate, everyMinute
}

An asterisk at the end of the complete Group Item name marks that Group Item not to be persisted, but to persist the members instead. The * is not a wildcard! Only a * without any Item name is a “catch all” value.

Thanx, copied that in rr4dj.persist file and put it in the …/persistance folder and rebooted the openHAB server. After that:

  • The stepItem was saved every 10 second even when the value was unchanged
  • Another item with fast changing values was saved after every update
  • Another item with slow changing values was saved every minute

So it works and I understand this rrd4j setup a lot more now. And thanx for the bonus, setting up the crons in such a way that the minute and 10 second values don’t persist at the same time. The CPU is grateful for that (especially if I add more 10sec items).

A shame the “*” is not a wildcard. Would be a nice feature :wink:

Well, this would be a nasty hack, and openHAB tries not to encourage the user to nasty hacks :slight_smile:
Simply use the official solution for that (that is, define a group item and add all Items to be persisted to this group Item. you can add as many groups to an Item or as many Items to a Group as you want, so it’s no problem to do it this way.

1 Like

@supersjel
You do have your solution. Regarding the data in 10 second steps, please remember that these data point are kept for the last hour only.

1 Like

Thanx for the warning. I think I could change that with the other rrd4j configuration file. But luckily no need for that, the step detection only uses the last 5 minutes of data :wink:

1 Like