Alias at persistence

Hi,

I have a question about the alias concept regarding persistence. In your persistence config, you can give an item or an item group an alias name. The persistence binding can use this alias to store the item values under this name.

The problem I see is when querying the persistence binding for values of a specific item, there is only the item name available, not the alias name.

So, using an alias is making the persistence layer write only? Should the binding always be able to resolve the item state only through to item name, even when using aliases? What is the idea behind the alias name? Have I overlooked something?

Thanks for your answers!

Best regards
Dominik

The persistence layer has the same “lookup table” as defined in xxx.persist file available for write or read access.

The idea of the alias as I understand it, is to allow operation with databases that can be picky about table name lengths. Or, when using persistence to publish to some remote service (it doesn’t only do dbs) you can assign names that are used at the remote end - perhaps these are not editable by you to match your Item names.

Hey @rossko57,

thanks for your answer. What do you mean with “lookup table”? I took a look at some openhab1-addons persistence bindings*. There are two methods to store and query data:

public void store(Item item, String alias)
public Iterable<HistoricItem> query(FilterCriteria filter)

So when storing, we do get the alias. But when querying, we get an object of type FilterCriteria which contains only the item name, no alias. I have checked this by enabling logging for influxdb.

The persistence bindings for mongodb, influxdb, rrd4j, mapdb, … all save the value under the given alias, but query with the item name. Do they all fail to query data when using an alias?

(*Am I right that openhab1-addons is the right place, there is no newer version for OpenHAB 2?)

I simply mean that within xxx.persist is information linking Item names to alias.
Whether the persistence layer is used to write or to query, that same information is available.

No idea. Try it out. I wouldn’t be at all surprised if the alias doesn’t work properly outside of schemes where it’s actually needed. An alias is of zero value with mapdb for example.

Yes.

Here’s a practical example of someone using alias (with no possibility of querying it)

Here’s an erroneous usage of alias to accidentally dump many Items in one db table

It is possible to configure things that don’t work.