Puzzled with persistency strategies not being taken into account

Hello,

I’m running Openhab 2.5.M4 (yes, still stuck there, but it is a different story) with influxdb as persistency. I did not have to look at the way my items were persisted in a long time, but recently I re-looked at it for items that should not be persisted everyhour… It seems that they are stored everyhour while I had tried to configure them as to be persisted only in case of change.

My influxdb.persist looks like this

Strategies {
    everyMinute : "0 * * * * ?"
    everyHour   : "0 0 * * * ?"
    everyDay    : "0 0 0 * * ?"
}
Items {
    gNoHourlyPersist* : strategy = everyChange, restoreOnStartup
    *                 : strategy = everyChange, everyHour, restoreOnStartup
}

And my items “not to be persisted everyhour” look like this:

String LastCheckIn "Last Check In [%s]" (gNoHourlyPersist)

The issue I have is the item LastCheckIn is persisted everyHour even if it does not change, while in theory it should not.
As a side note, I have introduced the group “gNoHourlyPersist” recently. I used to have the extensive list of items listed in front of the strategy “everyChange, restoreOnStartup” but had the same problem.

I did try to swap the items line in the persistency configuration file in case the last line would take precedence on the above ones but it did not seem to change anything.

I sense that I miss something simple but I’m not able to find it… Any suggestion on where I should look?

Thanks in advance,

It looks ok to me. My suggestion would be to first look in events.log and verify that the items are not changing. Then put the InfluxDB add-on into debug logging and see if you can see anything that might tell you why it’s saving.

Also, after all changes to a .persist file or group membership, restart oh to make sure it picks up the changes.

But if you have option * persisting everything, every hour … why would you not expect your designated Items to be members of ‘everything’ (and so get persisted every hour)?

I believe it is doing exactly what you asked for. I think you need two groups, one for hourly and one for not.

Or you could reverse the cases - everything gets the minimal config, designated Items get extra config.

Good catch. I saw that and didn’t even recognize it for what it mean means.

Ah, yes, I see. Thanks a lot.

I think I remember that long time ago I tried to get the default mechanism apply for my need, but it seems it does not work as I think it could based on the user documentation.

I tried as below but it seems that it does not apply the default to items not listed in the Items category.

Strategies {
    everyMinute : "0 * * * * ?"
    everyHour   : "0 0 * * * ?"
    everyDay    : "0 0 0 * * ?"
    default = everyChange, everyHour, restoreOnStartup
}
Items {
    gNoHourlyPersist* : strategy = everyChange, restoreOnStartup
}

Based on what you said @rossko57, should I understand that there is no other way than to have a line for each and every type of persistency needed? Is the default only a way to save repeating the type of persistency needed, but not a way to omit stating specifically the items on which default should be applied?

Thanks,

Absolutely correct, and by design. Default strategy is not a default Item selection. You have to specify the Items you want to persist in some way. You are allowed to (and did) specify everything.
There is no “everything except xx” tool, you have to construct this.

Well, yes. You must instruct it, it does not guess or make assumptions and would rightly be criticized if it did.

Ok, thank you, @rossko57. I think I got it.
And yes, I was not suggesting the system should ramdomly guess anything :grinning:, I was thinking/hoping there would be a way to cope with my use case (apply to most of the items the not minimal config) without defining a new group and make those items belong to that group.
I’m only worried that when I’ll add more items in the future I will forget that I should apply this group… I liked the idea of “unless otherwise stated do this”.

Thanks again for your help in clarifying the behaviour.

To repeat -

Items {
    *                  : strategy = everyChange, restoreOnStartup
    gHourlyPersist*    : strategy = everyHour
}

Sorry for not answering earlier, yes, I understand I can do it this way.

In my case, except for a handful of items, I use everyHour as strategy. So reversing the case does not change the fact that I need to add most of the items (existing ones and new ones that I’m adding over time) to this “hourlypersist” group and I need to remember it when adding new items etc…
This is what I was trying to avoid.

Now, maybe what I’m doing wrong is to have everyhour applied by default to nearly everything (except these handful cases).
I read somewhere in the grafana / influxdb usage pages, that not having everyhour flagged was making the graphs not showing continuity… But I might have taken this too much by the letter and extended what was meant for e.g. thermostat setpoint to everything even if it changes often…
I’m reviewing what exactly needs everyHour persistency and will likely change the way I was doing this.

Thanks for the patience.