Use Button / Switch widget for sensors

@ysc
At the moment the button/switch widgets can only be used for actors (sendCommand is executed). For sensors, only the dummy widget can be used (which has limited features)
My question:
What do think about adding a checkbox to the switch/button widget (lets call it: “Widget is Sensor”). With this checkbox activated, a click on the widget will not execute the send command.
With this feature it would be possible to have the same functionality for actors and sensors.

Typically sensors are placed on the sitemap using Text, not Switch. This will render the Switch unchangeable on the sitemap, essentially doing the same thing you are describing.

You can still use the switch icon and it will change the icon from on and off as the state of the Items changes.

This is exactly as it should be. If you use the switch or button widget for displaying sensor information, it MUST be unchangeable by the user.
You are right, it is possible to use it already. But if you “click” on it, it gives you an error (this is ok)

When I say put it on as Text, I literally mean use

Text item=MySensorSwitch

Rather than

Switch item=MySensirSwitch

This will result in an uneditable and not interactive widget on the sitemap.

I’ll try to change all my Window/Door sensors from “Contact” to "Text and see what happens if a binding uses:

this.updateState(new ChannelUID(getThing().getUID(), CHANNEL_STATE), OpenClosedType.CLOSED); 

to a “Text” item. I think this will result in an error.

Don’t change the Item type. Change the element used on the sitemap.

If you are putting you items on your sitemap using groups this won’t work. You need to put each item on the sitemap individually.

But that does raise an issue. Sensors should be Contacts, not Switches anyway, as you are doing. By default the are put on the sitemap as uneditable widgets.

Maybe you missunderstood me. I use HABpanel as UI. And i only have a items file (thanks to HABpanel you don’t need a sitemap file).

For me it isn’t a problem. I solved it by creating a template widget with this functionality.
But i’m sure for users who don’t like to use java script it would help a lot.
thanks for helping

Out of curiosity, what are your concerns with the Dummy widget, the inability to change colors? It has almost the same features as the Button widget except the colors. If you intend to display a value, the Dummy widget should be the way to go.

That being said, the button widget will be able to do more than send a command to an item in the future (e.g. jump to another dashboard etc.), so I guess “None” as an option for the action would be feasible.

If the command value has to be set to “NONE” it would not be possible to switch the color depending on the state.
OPEN/CLOSED.

I see. This should be reimplemented in the Dummy widget anyway, a Button without an action sounds weird. I’ll consider it.

@ysc
Thanks for thinking about it. You are 100% right it belongs to the dummy widget.

Hi

I have some similar problem.
When I use the Tellstick plugin the items are coded as Switch for the door/window sensors.
I want to use the door and window icon and “Open/Close” states. But the I am unable to change from Switch to Contact in the PaperUI.

Does anyone have a smart “HTML” wrapper that can take the telldus-switch-item with “on/off” state and display it with the window contact Open/Close?

Still a newbie on the HABPanel so detailed examples would be appreciated.

Br
Michael Stjerna

I found the way to do this, well described in the Tellstick documentation :wink:
http://docs.openhab.org/addons/bindings/tellstick/readme.html
Items/Rules file did the trick