Disable persistence service for item?

I have some items, which I read and in the rule I’m doing a recalculation and working with recalculated value stored in other item. So for me doesn’t make sane to store a data before recalculation. Is it possible somehow disable store a data before recalcultion or store only data for short time period like one day ?

Thanks
Alex

Make a group called “persistence”, do all items you like to get stored into this group and make a persistence file … I asked that several times it’s not possible to exclude items in the persistence config…maybe a feature request but don’t know how the programming is behind…

thanks, but not clear for me. I created a test group and item :

but how to set a persistence only for this group isn’t clear for me

also I don’t know, if it’s possible make a item list more clear. Mean that now I can see a mixture of all. Groups, items… Is it possible see only groups and items when I will open a group ?

You can have a look here

But you can also use the time filter option for this specific item

Filters {
  thirtySeconds : T 30 s
}

oh, thank you.
I will try study how to sort out which items I want with persistence and which without

I read a Persistence guide and for me as noob is very hard to uderstand what and where define, to exclude some items from persistence.
I found, that I must edit a rrd4j.persist file. Create a strategy ? But what is strategy to disable a persistence ?

You can choose which items to persist.

If you use the default rrd4j persistence you can do this:

  • Create an item named gPersistRrd4j with type: Group
  • Reopen the item gPersistRrd4j and click on Change under Direct Group Members
  • Click on Members and add the items which you want to persist. Then click Apply.
  • Edit the file /etc/openhab/persistence/rrd4j.persist:
Strategies {
    everyDay : "0 1 0 ? * * *"
}

Items {
    gPersistRrd4j* : strategy = everyChange
}

All the members of group gPersistRrd4j will be persisted when they change. The other items will not be persisted. The everyDay strategy is probably not needed here.

thanks,
what was :

everyDay : “0 1 0 ? * * *”

it’s time cron ?
and how to check that’s working ?
other items without persistence isn’t possible analyse ?

Yes, that is a quartz cron expression (with seconds). Look here if you want to generate or evaluate it.

If you want to use the strategy, then you have to add it in the Items section. I would also advise to use the restoreOnStartup strategy. The result of using the two extra strategies would be:

Strategies {
    everyDay : "0 1 0 ? * * *"
}

Items {
    gPersistRrd4j* : strategy = everyChange, everyDay, restoreOnStartup

If you are on OH 4 and prefer to work in the UI, you can configure the persistence strategy through MainUI. Settings → Persistene → [Database Name].

Filters are optional. All configurations for rrd4j must include an everyMinute strategy. You cannot use everyDay with rrd4j by itself and doing so with an everMinute strategy is pointless.

To disable persistence for a single Item is unfortunately not possible. You either configure it for all Items or you have to choose each Item you want to be persisted, excluding the Items you don’t want to persist.

@alda1’s suggestion to use Groups is one way to do this without editing the persistence config but now that persistence is possible through the UI, it makes some sense to not spread the persistence config all over your Items and instead centralize the config here.

Anyway to configure persistence to exclude an Item through the UI:

  1. Remove the * Configuration if it exists

  2. Define all the strategies you may want. everyChange, everyUpdate, restoreOnStartup and forecast are built in. rrd4j requires at least an everyMinute strategy too. The UI has a nice cron builder that can help with coming up with the expression if you are not familiar with cron.
    image

  3. If you do want to apply some filters, define the ones you want. Note that filters work on the states of Items, they do not work on the Items themselves. You can’t use a filter to exclude Items from persistence.

  4. Add a Configuration. If you followed @alda1’s advice and are using Groups, select the persistence Group under “Select groups”. If not, select all the Items you want to persist according to this configuration under “Select Items”. You can do both if desired.

  5. Select the strategies to save these Items under. Again, for rrd4j you must choose at least everyMinute.

  6. Select the filters to apply to these Items.

  7. Repeat for the other confiugurations you need.

The most universal way which will work for all persistence add-ons will be to go to Developer Tools → API Explorer → persistence → GET /persistence/items which will return a list of all the Items that are being saved by the specified persistence service. You can use GET /persistence/items/{itemname} to retrieve the actual values stored.

1 Like

This is valuable information. Although I did not find it in the documentation.

Where can you reach these settings? Here is a screenshot of my settings page:

Under System settings, there is a Persistence section, that leads to this:


Clicking on the persistence does not do anything.

Under Add-on settings there is a section RRD4j persistence, which leads to this:

Do I miss something? I am at OH version 4.1.2.

I had the same problem to find it. Last picture : click on the “Persistence configuration” :slight_smile:

The persistence setting menu is a new setting entry coming with openHAB 4.2.0 and therefore not available for 4.1.0.
Persistence configuration via UI is available since openHAB 4.0, however it always was difficult to find, which luckily will change soon.

What is : persistence setting menu ? :roll_eyes:
I know only Persistence configuration via UI

So, in the meantime, you can configure the peristence as I described it, but with the everyMinute strategy as Rich stated:

Strategies {
    everyMinute : "0 * * * * ?"
}

Items {
    * : strategy = everyChange, everyMinute, restoreOnStartup
}

When no configuration is set via UI, means all items are persisted ?
Although configuration is empty ? :

When I will set configuration like this :

Will all selected items persisted with every value change, every hour and restored after reboot/restart ?

And as the rrd4j persistence stores the data in files that remain small and never grow, I would not bother to exclude items from being persisted.

Wait for openHAB 4.2.0 and you’ll see :wink:

I lost track of when it was added. You’ll find the configs here in 4.2.

Yes, see the readme for the add-on. There is a default strategy which applies when there is no configuration. However, once you create a configuration, any configuration, that default becomes disabled.

Usually the default is “every Item everyChange and restoreOnStartup” with rrd4j adding “everyMinute” since that’s required for it to work.

No, because as far as I can tell you’ve not selected any Items. I don’t think the PR that adds the ability to select * for the Items has been merged yet so if you want every Item you need to click on the code tab and add it manually there.

configurations:
  - items:
      - "*"
    strategies:
      - everyMinute
      - everyChange
    filters: []
cronStrategies:
  - name: everyMinute
    cronExpression: 0 */1 * * * ?
defaultStrategies:
  - everyChange
thresholdFilters: []
timeFilters: []
equalsFilters: []
includeFilters: []

But that’s not what was asked for in the original post. You want to exclude one or more Items from persistence. To do that you cannot use *. You have to select all the Items you want to persist, leaving out those you don’t want to persist.

And again, if you are using rrd4j, you must use everyMinute as a strategy. It will not work with everyDay or everyHour.

While this is true over all, each Item results in a separate file between 530k and 738k. A couple hundred files is nothing but if you have thousands that could add up.

Also, if not using zram and running on an SD card, each Item adds more than one write per minute which can be a concern.

2 Likes

When I will configure a persistence strategy, what will happen with old data ?
Will be deleted ? Because data of some items I don’t need and best for me is, when they are deleted from the database. Or how long data are stored ?