In sitemap: how to change the item label dynamically


I’m aware of the dynamic sitemap features such as visibility, labelcolor, valuecolor. But how can I change the displayed text of the item (the label) using a similar dynamic sitemap rule inside.

Something like:

Switch item=ThisItem mappings=[ON="ON", OFF="OFF"] labeltext=[AnotherItem==2="please wait"]

Alternatively it would also be possible to let the Switch “grey out” (rather than completely disappear using visibility). The labelcolor doesn’t seem to have any effect on a Switch and valuecolor changes the label color AND the text in the buttons.

any pointer on how to achieve such a thing?


The Labeltext isn’t dynamic, instead of this you could define the very same item with different labels and switch the visibility of the item:

Switch item=ThisItem labeltext="please wait" mappings=[ON="ON", OFF="OFF"] visibility=[AnotherItem==2]
Switch item=ThisItem labeltext="normal label [%s]" mappings=[ON="ON", OFF="OFF"] visibility=[AnotherItem!=2]

In fact, you even could setup a Text widget for maintenance message, which will cause the buttons to disappear when displaying the “please wait”.

1 Like

that clever! thanks.

I do have another problem. What I want to do is:

A Number Item controls a scene:
0 = OFF
1 = ON

I have rules that take care for the transition 0->2->1; 1->3->0 - this works!

Now on the sitemap I could like to have a Button showing ON and OFF reflecting:
ON: should be lit when the Item is 2 or 1
OFF: should be lit when the item is 3 or 0
however when I press the button it should “send”:
ON: 2
OFF: 3

So receiving and sending a value is not 1:1.

With your tip I can take care of the label saying “STARTING” or “STOPPING” - that perfect. But this little state machine can’t be done in the sitemap?! Do I really have to introduce a helper item (Switch) and play around with the visibility to achieve something like this?

any help would be great! thanks!

You can setup a mapping to send only 2 or 3 and setup the label to reflect the state of the Item, including a map-file to map the 4 possible states. Of course, the Buttons shouldn’t be shown as pressed while starting or stopping. But if these states aren’t set with the rule, the following should do it:


Number myItem "My Label [MAP(]" <myIcon> {myBinding="...", autoupdate="false"}

If this is an Item without any Binding, just omit the part, but set autoupdate=“false”.

0 = OFF
1 = ON


Switch item=myItem mapping=[2="ON",3="OFF"]

This would result in an Item with two Buttons (ON and OFF) and a Label which reflects the state. As autoupdate is set to “false”, the Buttons won’t stay pressed if the state isn’t set to 2 or 3 through another binding or through myItem.postUpdate([2|3])

Hi @Udo_Hartmann. I have implemented your visibility example shown above in your Apr 30 post above, in my sitemap & items and am using a rule to change the visibility flag as suggested.
However I only see the “please wait” or “normal label” if I refresh my browser. Is this expected behavour? Or am I missing something?
The ON, OFF buttons are hi-lighted nicely in the UI when I click on either one, but I was hoping the visibility of the items would be dynamic as well.

Unfortunately the visibility is not that dynamic :confused: you have to reload the page to take effect.

If the switching doesn’t work at all, maybe you have a typo, so please show your item definition and sitemap in matters of the items, and of course the rule to switch the visibility.

Actually I found that I was mistakenly using the basicui URL. When I switched to the classicui it now works the way I wanted it too. The labels now appear dynamic by your trick with the visibility.
I also see that now my icons are getting refreshed dynamically - for example the light icon is switching from on/off depending on the switch state (on/off), without refreshing the browser.
This is working great now. (BTW… using OH2 beta3).

I use this trick that works on GreentUI but breaks ClasscUI completely

sendCommand(Messg,“MIDNIGHT]” + Clock.state + " It’s alsmost<!–")

This will change String Item to something like : 23:56 It’s alsmost …MIDNIGHT