Newbie: grey-out unavailable switch

  • Platform information:
    • Hardware: Raspberry pi 3
    • OS: OpenHabian
    • openHAB version: latest
  • Issue of the topic:

Hello All,
i’m new to OH, i’m only been able to install it and setup philips hue lamps via config files and i just discovered the firsts difficults… What i’m trying to do is to grey out the Luce_Camera_Switch when it’s unavailable (turned off by wall switch)
these are my config files


    Dimmer   Luce_Camera_Brightness   "Luminosità Luce Camera"      <slider>    {channel="hue:0100:00178829d4e7:3:brightness"}
    String   Luce_Camera_Alert        "Alert"            {channel="hue:0100:00178829d4e7:3:alert"}
    Switch   Luce_Camera_Switch        "Luce Camera"            {channel="hue:0100:00178829d4e7:3:brightness"}


    sitemap default label="Casa"
    	Frame label="Luci"{
    		Switch item=Luce_Camera_Switch label="Luce Camera"
    		Slider item=Luce_Camera_Brightness visibility=[Luce_Camera_Switch==ON]

thanx in advance

you could look at this

The visibility parameter is used to dynamically show or hide an Item. If the parameter is not provided, the default is to display the Item.

Visibility syntax:

visibility=[item_name operator value, item_name operator value, … ]
Valid comparison operators are:

equal to ==, unequal to !=
less than or equal to <=, greater than or equal to>=
less than <, greater than >
Expressions are evaluated from left to right. The Item will be visible if any one of the comparisons is evaluated as true, otherwise it will be hidden.


visibility=[Day_Time=="Morning", Day_Time=="Afternoon", Temperature>19]

In the third example above, a control for a lawn sprinkler will be visible if it is Morning, OR if it is Afternoon, OR if the temperature is above 19 °C. Combining multiple conditions, for example Morning AND above 19 °C is not supported. To control visibility based upon combining multiple Items, or on more complex conditions, consider defining and using an additional intermediate Item that is set by a Rule. Rules have a rich set of features that can support more involved scenarios.

thanx for your reply, i tryed this:

Switch item=Luce_Camera_Switch label="Luce Camera" visibility=[Luce_Camera_Switch==ON, Luce_Camera_Switch==OFF]

but doesn’t work…

Your definition says the visibility should be ON if

Luce_Camera_Switch is ON AND OFF


Switch item=Luce_Camera_Switch label="Luce Camera" visibility=[Luce_Camera_Switch==ON]
1 Like

in this way i’ll hide the switch if it isn’t turned on, i would like to let it always visible, but disabled if the switch is unreachable…

thanx for your help

That‘s not possible.

Ok, then simply change the color

Switch item=Luce_Camera_Switch label="Luce Camera" labelcolor=[OFF="silver"] valuecolor=[OFF="silver"]

Edit: It is still not disabled, but at least the color is different.

But you can e.g. display a text item if the camera is offline and a switch item if the camera is online

would be great to show a text when the item is unreachable and the switch when the switch is reachable (turned on or turned off), but i’m not so practice and i don’t know how to do it… :slight_smile:

You hide the switch using “visibility” and show the text item using “visibility” with inverted logic

Edit: (Example)

Text label="Luce Camera" visibility=[Luce_Camera_Switch==OFF]
Switch item=Luce_Camera_Switch label="Luce Camera" visibility=[Luce_Camera_Switch==ON]

But one thing: Are you only commanding this item via the UI or is there any rule in the background? If not you can disable it exactly one time :slight_smile:

Edit 2: (i’m to shortsighted today :wink:
One drawback of this is that the text and the switch are at different positions in the ui. But i’m not that experienced with it - maybe somebody else can jump in from here

1 Like

This kind of setup works well, two alternate presentations.
Remember you can make the label on one different, like label="Luce Camera (disabled)"

Tip use visibility .... ==ON and ...!=ON to acount for states like NULL etc.

mmm… maybe I’m doing something wrong…

		Text   label="Luce Camera (Disattivata)" visibility=[Luce_Camera_Switch==NULL]
		Switch item=Luce_Camera_Switch label="Luce Camera" visibility=[Luce_Camera_Switch!=NULL]
		Slider item=Luce_Camera_Brightness visibility=[Luce_Camera_Switch==ON]

if the lamps is turned off via wall switch (I suppose Luce_Camera_Switch==NULL) it should show only the label, but it’s showing the switch and the slider… I’m a little confused…

Perhaps your Item isn’t going to state NULL. Bindings usually set broken devices to UNDEF. What does events.log tell you about it?

the log show me this:

2019-02-04 21:56:53.605 [hingStatusInfoChangedEvent] - 'hue:0100:00178829d4e7:3' changed from ONLINE to OFFLINE: Hue bridge reports light as not reachable.

but I don’t know how to refer to “not reachable”

Okay, well that’s not an Item so you can’t use it in visibility
Wonder what your Items do.

I just trying to setup a Philips Hue bulb… this is my light.items:

Dimmer   Luce_Camera_Brightness   "Luminosità Luce Camera"      <slider>    {channel="hue:0100:00178829d4e7:3:brightness"}
String   Luce_Camera_Alert        "Alert"            {channel="hue:0100:00178829d4e7:3:alert"}
Switch   Luce_Camera_Switch        "Luce Camera"            {channel="hue:0100:00178829d4e7:3:brightness"}

This message comes from the thing itself and if it has no channel that can be connected to this state you need to have a rule that triggers when the thing itself changes. Look for the thing-based triggers:

a rough example in your rule would be

rule "Hue light offline"
when Thing "'hue:0100:00178829d4e7:3" changed 
	var status = getThingStatusInfo("'hue:0100:00178829d4e7:3")


I tryed to create a rule like the one you posted, the problem is that I need a 3rd value… ON when it’s turned on, OFF when turned off and NULL or UNDEF or something else when it’s unreachable, but the sendcommand accept only ON or OFF :frowning:

but you can postUpdate to NULL or UNDEF

Great! With postUpdate it works… also if it takes around 1 minute to update… is there a way to speed up? :slight_smile:
Thanx a lot