Alias for items?

Due to the way I structure my openHAB configuration, I frequently find myself in a position where I would like to be able to refer to an item using different names. This may sound a bit wierd, so let me explain…

When I add a new device (e.g. a Z-Wave device) to my system, the first thing I do is establish a set of items that maps to the “data points and/or control points” in the device. To me these are device-specific, meaning that I have not yet considered where this devices is located or what function it will be part of. I do, however, add the device items to a debug sitemap for the system that the device belongs to. So, for Z-Wave as an example, I have a sitemap listing all devices, with all items. Here I can quickly check the status of a device, or set it to a certain state if needed. Again, this is only used for debug/development/maintenance of the system.

Now, in this context a certain devices data point will be mapped to an item that reflects the device (and the system that it is part of, e.g. Z-Wave) and the sort of data that is in question. So, as an example the following is a “motion detector” data point from one of my Z-Wave devices:


Later on, when I start using the device I have considered the location of the device and the what type of function that it is used in. As an example the above data point is now to be part of my “security system”.

I would now like the data point to be reflected as part of one of several “motion detectors” belonging to the security system (SEC). In this context I define a virtual device “motion detector” that includes the above data point as well as several virtual data points that control the device, e.g. blocking (do not trigger alarms), latched alarm state, reset (of latched alarm), etc.

So, now I would like the beforementioned data point to be referred to as:


Playing around with this concept, I have until now made it work by using some “proxy rules” to propagate state and command information between the two items, however, this is a bit silly, so I was considering alternatives.

The one that sprang to mind was to introduce the concept of “aliases” for item names.

Since the basic idea behind what I am doing above is to decouple the higher layer items (e.g. SEC_MD01_cMotion) from the actual physical device that implements the data point (e.g. S01D012_cMotion) my suggestion would be to add a new binding type (called “alias”?) that can be used to map an item to another item, something like this:

Contact SEC_MD01_cMotion { alias=“S01D012_cMotion” }

Anyone else see the need for this? Is it a sensible “feature” to have in openHAB? Is it feasible to implement this as a binding like suggested, or could/should it be done differently?

Is this not how OH2 handles the links between things and items? Could you not add multiple items to the physical thing?

Aha! That may very well be true. I am still on openHAB 1.x so I really have no idea.

Can anyone confirm this?

Yes, you can link multiple items to the same channel in OH2. It does seem to me that you might be creating a maintenance nightmare for yourself, but if it fits your system, then go for it :wink:.

I’m not sure I completely understand why you need this. Perhaps a concrete example set of Items and code would help me understand.

My understanding of OH is that Items are themselves supposed to be an abstraction away from the physical device. In OH 2 this abstraction is made even more explicit with the Thing to Item mapping. So it looks to me like you are violating this built in abstraction and then struggling with trying to rebuild this already existing abstraction within the Items files.

For example, at the Item level, to me, beyond the binding config itself, the mapping between the Item and the physical device type (e.g. that it is part of Z-wave) doesn’t belong.

That being said, can you achieve the same thing you are after using Groups? Instead of having two names for the same Item, why not create just the one Item and have it be a member of both the zwave group and sec group? Then on your debug sitemap where you do care about what device the Item represents use the zwave group to build up your sitemap. And for your other sitemap use the SEC group?

Again, I don’t think I really understand what you are trying to achieve so I could be way off base.

+1 for this!