JDBC-Persistence: storing values in rules

I am using openhabian 2.3 on a raspi.

I am using several counters which I want to persist on JDBC/SQLite-persistence. These counters will be reset at midnight, but before I want to make sure that they are persisted in my db.

Any idea how to do this just in the rule. Currently I am using 2 cron jobs to do this (one in jdbc.persist and the other in rules).

Would like to have only one job for better Control.
Thanks for any hint.
Georg

Hello Georg,

I do not know if I understand your problem correctly but why dont you create a new rule that updates some counterPersistence items at midnight with your counters.

And for this counterPersistence item you define a “everychange persistence”.

Greetings
Michael

  • item:
Group Counter
number counterp1 (Counter)
  • rule:
rule "save counters"
when
Time cron "55 23 * * * ?"
then
counterp1.postUpdate(counter.status.toString)
end
  • persistence:
.....  
Items {
Counter* : strategy = everyChange
}
......
MyItem.persist("jdbc")

Thanks Rich,
I thought there might be something simple.
Is there a list of all Methods for ITEMS etc. I was searching but haven’t find it.
Have a great evening.
Georg

The best approach I’ve found is to use VSCode with the OH extension, type in the name of an Item with a . and use the arrow keys to browse through the list that will pop up.

You can also go to https://www.eclipse.org/smarthome/documentation/javadoc/index.html and browse to the Class you care about, but that route requires you know a bit more about what type you are working with.