How to change database table persistence gets written to?

Hi there,

OpenHAB uses CoC (Convention over Configuration) for reading and writing persistence data to database (e.g. InfluxDB). If an item is named My_Item it gets saved to database table / time series My_Item.

How do I need to configure my item, so that persistence service uses another name for reading and writing to database, e.g. My_OtherItem?

Thanks in advance


Rename your item

That’s not an option :frowning:

To be more precise on why I hope this fixes my problem: I have a Contact item that I persist in database. I want to count how often this Item changed its state. @rlkoshak suggested (Count number of times a door got opened) to use persistence sumSince() function to do that, but that doesn’t work as @rossko57 explained: Persistence sumSince() doesn't output a valid numer, only zero because a Contact is represented by a string, that can’t be summed.

So if I use the persistence data of the Contact (which gets persisted as 0 and 1) I could take that data, interpret it e.g. as Number and then do a sumSince().

It depends on the database. InfluxDB I think stores Contacts as numbers.

Then create a Number Item and a Rule to set it to 0/1 when the Contact Item changes.

The difficulty with the store-open/closed-as-number thingy is the OH persistence layer. When using the OH tools, it knows what kind of Item is involved and “translates” back, that’s its job.

Alternative access methods should not have that “help”.

Or change your item to a switch item or a number
Using a proxy item if necessary

That isn’t always possible depending on the Channel it’s linked to.