How to create an I/O pushbutton?

Hi guys,
due to my bad english i don´t knwo where or what to search for myself :wink:

I want to create a two-channel switch with I/O, that has no slider and does not change its status.
Very similar to the OH Rollersutter-Switch but only with two buttons.

The reason: I want to create a rule that fires, when one of the two bottons get pressed. For switching on/off i.e. all lights, no matter if there are some of the light already switched on or off.
If you wish, i need a botton with two sides. Like a click-switch…

What is this damn thing called?! :wink:
Where do i find one in OH. I need it for basic UI (Sitemap)


1 Like

I think I know what you mean.

One way to do it is with a String item which automatically resets itself to an idle state, using the expire keyword.

Then, in the sitemap you use a Switch with multiple states, and the idle state can be one of the states – or not!


Item definition:

String twochannelswitch "Switch" <none> {expire="1s,command=IDLE"}


Switch item=twochannelswitch label="Switch []" mappings=["ONE"="One", "TWO"="Two"]


When you press either button, the String item becomes “ONE” or “TWO”, and after a second the string item returns to “IDLE” and the highlight goes away.

I use this all the time, to give commands to things (like my garage door) or to select a scene, select a radio station etc.

1 Like

This might be an XY Problem. If that is truly your end goal you don’t need anything special. Put all your Items into a Group:Switch:OR(ON,OFF) (even the Dimmers and Color Items). Then you can put that Group Item on your sitemap with a Switch. To turn OFF the lights, toggle the switch like any other and the Group will forward that OFF command to all its members. The OR(ON, OFF) means the Group’s state will be ON if any one or more of its members are ON.

No rule, no mappings, nothing more than the Group Item is needed.

Doesn’t this miss the use case of turning the remaining lights ON when some are already on?

I think it all depends on the aggregation function and the desired approach. In this case a “One OFF then OFF” aggregation function would be better (OR(OFF, ON) or AND(ON, OFF)).

But indeed, if you want to go both directions you’d need a proxy Item and a rule. It all depends on the details of the use case.

Fair enough. Hey, partially related, is there a more straightforward, modern way to handle command “buttons”? Let’s say we have four scenes. For example, in my garage, I have scenes for WORK, CLEAN, COZY, and OFF. The String + Expire is a workaround I learned in the days of OH 2.4, is there a better way now? I wonder especially since the app behaviour changed a few months ago and now displays fewer buttons before reverting to a dropdown.

If you are using sitemaps, probably not. The old way is the new way, nothing has really changed concerning sitemaps.

You can create quite involved custom widgets for MainUI (e.g. Remote Control Widget) so you could create something with any number of buttons arranged any way you want. But that’s obviously going to be more learning and work.

One day, when I’ve set everything up in sitemap so my house functions, I will try to tackle MainUI again. :slight_smile:

I eased myself into it. I started with the semantic model and let OH build the UI for me. Then I did some customization of it with custom default list Item widgets, visibility, and pruning my semantic model and have ended up with something every bit as useful as my old sitemaps. Though for me, the home automation is mostly that, automated. My main UI page is just

and the only part of that that anyone besides me uses or cares about are the first two. Everything else is either completely automated or controlled in a more ad hoc manner through Google Assistant or the like.

But, there will be times where I’ll want to know something or control something unusual. For example, I recently wanted to see how the radon mitigation system I’ve installed is working. All I ever did was add the Item situated into the model and leave persistence the default. But on an adhoc basis, without even being an admin user, I can bring up the Item and get a chart.

That, to me, is where the power of MainUI and having a default persistence set up comes into play. For day to day interaction we don’t use any of OH’s UIs. But for something adhoc or unusual MainUI is way more flexible with minimal effort. It’s well worth experimenting with.

This does the trick, ty!