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.
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.
A Number Item controls a scene:
0 = OFF
1 = ON
2 = STARTING
3 = STOPPING
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?
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:
.items:
Number myItem "My Label [MAP(myItem.map):%s]" <myIcon> {myBinding="...", autoupdate="false"}
If this is an Item without any Binding, just omit the part, but set autoupdate=“false”.
myItem.map:
0 = OFF
1 = ON
2 = STARTING
3 = STOPPING
.sitemap:
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 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).