OH 4.2.1 Persistence not creating tables for items

Hi All,

I have recently added some new items to my setup to give smartmeter readings via MQTT.
I modified the file /etc/openhab/persistence/jdbc.persist

Here is a snipped version of my file:

// persistence strategies have a name and a definition and are referred to in the "Items" section
Strategies {
    // if no strategy is specified for an item entry below, the default list will be used
    //             s m h d m w
    everyHour   : "0 0 * * * ?"
    everyDay    : "0 0 0 * * ?"
    every2Minutes : "0 0/2 * 1/1 * ? *"
    every5Minutes : "0 0/5 * 1/1 * ? *"
    every10Minutes : "0 0/10 * 1/1 * ? *"
    default = everyChange
}
Items {
    SS_Smartmeter_Actual* : strategy = every2Minutes,everyHour
    * : strategy = restoreOnStartup
}

In OH, I have multiple items with similar names e.g.:
SS_Smartmeter_Actual_Consumed_L1
SS_Smartmeter_Actual_Consumed_L2
SS_Smartmeter_Actual_Consumed_L3
SS_Smartmeter_Actual_Volts_L1
SS_Smartmeter_Actual_Volts_L2
SS_Smartmeter_Actual_Volts_L3

Normally, the wildcard means that all the above should be persisted, but for some reason this is not the case.
e.g. I have volts L1 & L2 but not 3 in my mariaDB.

I enabled debug logging for org.openhab.persistence.jdbc and I have this:

2024-10-13 21:31:41.285 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'SS_Smartmeter_Actual_Consumed_L3' changed from 1.78 A to 1.79 A
2024-10-13 21:31:42.848 [DEBUG] [jdbc.internal.JdbcPersistenceService] - JDBC::query: item is SS_Smartmeter_Actual_Volts_L3
2024-10-13 21:31:42.849 [DEBUG] [jdbc.internal.JdbcPersistenceService] - JDBC::query: unable to find table for item with name: 'SS_Smartmeter_Actual_Volts_L3', no data in database.

I have never manually created a table for persistence… why is it not doing it automatically?

Maybe this will sort itself out if I leave it long enough? or restart something?

Any suggestions are welcome!
Thanks
Will

The asterisk is not a wildcard :slight_smile: (here)
Instead, an asterisk alone is “all Items”. An Itemname followed by an asterisk is “don’t persist the Item itself, but only its child Items”.
You will either have to list all Items individually or add them to a group Item like that:

Group gPersist_2Minutes
Number:Power SS_Smartmeter_Actual_Consumed_L1 "Power L1" (gPersist_2Minutes) //...
Number:Power SS_Smartmeter_Actual_Consumed_L2 "Power L2" (gPersist_2Minutes) //...
Number:Power SS_Smartmeter_Actual_Consumed_L3 "Power L3" (gPersist_2Minutes) //...
//...

And in jdbc.persist:

// persistence strategies have a name and a definition and are referred to in the "Items" section
Strategies {
    // if no strategy is specified for an item entry below, the default list will be used
    //                s m h d m w
    everyHour      : "0 0 * * * ?"
    everyDay       : "0 0 0 * * ?"
    every2Minutes  : "1 0/2 * * * ?"
    every5Minutes  : "2 0/5 * * * ?"
    every10Minutes : "3 0/10 * * * ?"
    default = everyChange
}
Items {
    gPersist_2Minutes* : strategy = every2Minutes,everyHour
    *                  : strategy = restoreOnStartup
}

Please be aware that:

  • the year in quartz cron expressions is optional. You don’t need to add an asterisk at the end of the expression.
  • 1/1 is the same as * in quartz cron.
  • it’s a good idea to spread persistence jobs in time (so don’t set Second to 0 for all quartz cron jobs)
  • it’s a bad idea to restore every item at startup from database. Most Items should get its current state at startup from its linked add-on
  • gPersist_2Minutes is a complete Item name of a Group Item.
  • an Item can be descendant of as many group Items as you like, but only one of these group Items is allowed to be part of the Semantic Model.

Wow, thanks Udo.

Kind of counter-intuitive, but good to know all the same!