Gray-out switch based on presense?

Hi,

I have sonoff basic wlan relay switches around house. Some of them are offline if light is turned off from physical switch, thus cutting off the power also to sonoff.

In such case I’d like to disable the switch from UI also, so it’s clear for user the GUI switch won’t work, as the sonoff has no power. This would be noticed by wlan presense info, and perhaps somehow grayed out.

So what would be the handiest way in OH to make the GUIs to point out switch is not available? Recommendations?

Hi,

first thing that comes to my mind is to use visibility tag in sitemap or change the text color to grey.
Both ways are discribed here in the documentation

Greetings
Sebastian

1 Like

Thanks, I believe UI should have constant amount of items, so changing the colour is better. Or perhaps changing the colour of switch text, but making switch diasappear. As switch with different colour would still work I assume. The ideal would be to grey it out, and lock it to off.

Anyhow, I’ll play around with options you pointed out.

What you can do is to make the original switch invisible and instead make a text element visible with the same label.

So there is no chance to trigger the switch but you still have the same amount of items in your sitemap.

1 Like

OK, I did that. Here’s a reference for someone else looking to do the same:

        Text label="Eteisvalon kytkin pois päältä" icon=light labelcolor=[network_device_192_168_1_77_online==OFF="red"] visibility=[network_device_192_168_1_77_online==OFF]
        Switch item=sonoff_e1 label="Eteisvalo" icon=light visibility=[network_device_192_168_1_77_online==ON]

They are separate elements, as I didn’t find a way to dyncamically change the switch label text, nor to lock the switch item to off. Which is fine and doable this way, I was just thinking it the other way around.

sorry, beginners question: where does “network_device_192_168_1_77_online” come from? I want to achieve the same with my HUE lights. Sometimes I use a wall-lightswitch and they are completely powered off, like your sonoff switches. Using PaperUI I have created a thing for the lamp and so far I can see only one channel “brightness”. However, PaperUI detects that the lamp is out of power and receives this information from the HUE Bridge, but how?

Stefan

This example is using the “Network” binding, as each Sonoff device is uniquely addressable on the network. You set up a new Thing with the IP address of the device, and one of the Channels in the Thing is “Online”, which is used to create this Item.

However - if your Hue lights don’t provide a way to uniquely identify whether they are accessible or not, then you may not be able to do the same.

It comes from OpenHab PaperUi discovering it. I added the device from PaperUI inbox telling there are new devices. If you have done the same, go to console via ssh, and list items. For any MQTT devices I have manual entries in items list. All IP devices I have just PaperUI definitions, which look like that.

thanks for the explanation. Unfortunately Hue doesn’t provide such a channel. However, PaperUI knows that Hue lamp and/or bridge are online, see screenshot:

hue1
huer2

Any idea how to re-use these information for the sitemap?