MAP in Label, but not for the Value?

Is it possible to use a MAP transformation in the label for an item in a sitemap, but for the actual item label, and not the item value?

Obviously, not a big deal, but if I’m defining friendly names in one place, it would be nice to keep that just in the MAP, and not a number of different files.

I don’t understand what you are asking. You can use a map in:

  • label for an Item on the Item definition
  • label field on the sitemap entry; the sitemap label will override the Item’s label definition
  • binding config (OH 1.x binding) for bindings that support transformations
  • Thing definition (OH 2.x bindings) for bindings that support transformations
  • Profiles
  • Rule using the transform

I have a device_names.map file, with:
item1 = Item 1 Friendly Name

In a sitemap, for an item, the following fails to transform, I just get the string ‘MAP(…’ as the label:
Default item=item1_Battery label=“MAP(device_names.map):item1 [%.0f %%]”

This does transform, but since it is between the [], it is in the ‘value’ position:
Default item=item1_Battery label="[MAP(device_names.map):item1]"

You are not using the correct syntax.

[MAP(device_names.map):%s]

Note that a transform in the label can only transform the state of the Item, not the Item’s name. And it cannot transform any arbitrary string or value. It can only transform the state.

If you want a friendly name for your Item, well, that is what the part before the [ ] in the label is for.

Switch item1_Battery label="Item 1 Friendly Name [%s]"

Okay. This is the answer I was after: “can only transform the state of the Item, not the Item’s name”.

Thanks!