Persistence has me stumped

  • Platform information:

    • Hardware: Raspberry Pi 4
    • Raspbian Buster
    • Java Runtime Environment: OpenJDK Runtime Environment (Zulu Embedded 8.25.0.76-linux-aarch32hf) (build 1.8.0_152-b76)
    • openHAB version: 2.5.1, but bundle:list shows many addons at 2.5.6
  • Issue of the topic: Persistence not logging errors, but no data in mysql. This system is configured very similarly to another system I run, but which has evolved from Openhab1; this one was started from the ground up on OH2. I’ve used openHAB2 & MySQL persistence setup as a general guide and to cross check my config, but I’ve become blind to whatever is wrong.
    I’m running MariaDB on a Synology NAS. From another system, I can use the mysql command line client to connect via the credentials in mysql.cfg, create tables, insert rows, etc. (I don’t have a mysql client on the OH server)
    When I update the persistence config, I get a message that the model was updated, with no errors.
    netstat -n shows that there is an open connection to the database port on the NAS from the Openhab server.

  • Please post configurations (if applicable):

    • Items configuration related to the issue (sample)
    Number E_LivingRoom_actualTemperature "actual temp [%.1f °F]" (gPersist) { ecobee="<[redacted#runtime.actualTemperature]" }
  • Sitemap configuration related to the issue : n/a
  • Rules code related to the issue: n/a
  • Services configuration related to the issue
mysql.cfg:

    # the database url like 'jdbc:mysql://<host>:<port>/<database>' (without quotes)
    url=jdbc:mysql://10.1.3.60:3307/openhab

    # the database user
    user=openhab

    # the database password
    password=redacted

    # the reconnection counter
    #reconnectCnt=

    # the connection timeout (in seconds)
    #waitTimeout=

    # Use MySQL Server time to store item values (=false) or use openHAB Server time (=true).
    # For new installations, its recommend to set "localtime=true".
    # (optional, defaults to false)
    #localtime=true
eastham.persist 
// persistence strategies have a name and definition and are referred to in the "Items" section
Strategies {
        everyHour : "0 0 * * * ?"
        everyDay  : "0 0 0 * * ?"

        // 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.
 * You can list single items, use "*" for all items or "groupitem*" for all members of a group
 * Item (excl. the group Item itself).
 */
Items {
        gPersist* : strategy = everyChange, everyDay, restoreOnStartup
        // persist the Item state of Heating_Mode and Notifications_Active on every change and restore them from the db at startup
        //Heating_Mode, Notifications_Active: strategy = everyChange, restoreOnStartup

        // additionally, persist all temperature and weather values every hour
        //Temperature*, Weather* : strategy = everyHour
}

I’ve put a Group entry in a sitemap referencing the gPersist group, and it displays the expected items (some configured via .items files, and most via PaperUI.

  • If logs where generated please post these here using code fences:
  • If logs where generated please post these here using code fences:

Did you try to add your TimeZone to the MySQL configuration like:

url=jdbc:mysql://10.1.3.60:3307/openhab?serverTimezone=America/Chicago

Your MariaDB instance runs on port 3307 ( which seems to be standard for MariaDB 10 on Synology ) and not on 3306 as standard MySQL does ?

I would try JDBC persistence (with config jdbc.cfg).

Port 3307 confirmed.
I added ?serverTimezone=America/New_York with no apparent effect (I do know the config is being read; I made a typo the first time and an exception was logged).

One new point: the Items table was created at some point, but had no rows. I stopped OH2, dropped the table, and restarted. The table was re-created, but still no data rows.

If noone helps me spot anything obvious with the current setup, I’ll give jdbc a try next.

eastham.persist

would need to be mysql.persist or mariadb.persist

1 Like

Bingo! mysql.persist did it. Somehow I got the idea that the name didn’t matter (except for .persist) and named it after my primary sitemap.