How to parameterize HabPanel custom widget

Tags: #<Tag:0x00007efec96c4520>

I feel seriously embarrassed for I was unable to figure this out:

In my HabPanel template based widget (reading the Template Widget Tutorial, I got to frequently access a thing’s item name as in "itemValue('homematic_HmIP_STHO_3014f711a0001f58a9930328_000ED709AED3C6_1_ACTUAL_TEMPERATURE')". This is long and unhandy to use. I wish I could declare a constant with this content and use the constant instead.

Advanced level: I use not only _ACTUAL_TEMPERATURE but also _HUMIDITY and other channels of the same device. Would be lovely to declare the constant to contain the shared part of the item’s name, concat this with the channel name and feed this to itemValue().

Feelin’ like a rookie, not even having an idea of the proper keywords to search for. Help!

If “homematic_HmIP_STHO_3014f711a0001f58a9930328_000ED709AED3C6_1_ACTUAL_TEMPERATURE” is too long for you, why don’t you simply use a shorter name for your item?

Another option would be, that you create your own widget for this. I guess you are going to use it multiple times. Just stick to https://community.openhab.org/t/habpanel-development-advanced-features-start-here/. You can simply create a config-item for the item you want to get the values for and access them in you code.

I wish I could rename my thingies to something human-readable. Would you care to tell where to start the search?

Could not find anything like that in the Paper UI’s Thing Configuration or Homematic Binding page.

The second suggestion, to create a config-item, I did not get it, even after reading the referred article rather carefully.

I don’t know how to do this in PaperUI because I use the config files to create my things and items. It looks like in PaperUI you are not able to change the name of an Item. You have to delete an recreate it. There you have the option to set the name for it.

For the second suggestion:
When you create a widget (and by that I don’t mean a template based widget, just to be clear), in the settings-tab you can add config-settings. There you simply add one with the type “Item”. Then you can use “config.” (replace with the ID you used) to access the item.

Maybe this would have been a better link:

Have a look at the “Settings tab” section and the examples.