Button == ON when pressed

Hello everyone,

I use OpenHab 4.1.1, on Openhabian, Raspberry.

I would like to have a button that outputs ON as long as the button is pressed!
If you press the button, in the iOS app or in the BasicUI website, by finger or mouse, only then an ON signal should be given. And whenever nothing is pressed (finger or mouse), there should be an OFF signal.
Just like a real mechanical button (without relay or hold) works.

Switch item=button mappings=[ON="Push"]

How is this possible?

Use case:
A roller blind should move up or down while the button is pressed and when the button is released, it should stop.

Thank you very much!

I don’t think what you want is currently supported by Sitemap (BasicUI). However, you can achieve something similar by pressing to start your roller blind, and pressing again to stop it.

Yes, I have been looking for this function for a long time (OH2).

But I still don’t understand what the problem is here?
Is there a roundabout way of finding out whether a button is (currently) being pressed?

It’s just because nobody who could implement it, ever needed such ability. Has there even been a feature request? If there is none, then nobody is even aware of it.

So what you want is the ability for a button UI to send one command on press, and another command on release, right?

This is what I suggested before:

Switch item=button mappings=[ON="Start", OFF="Stop"]

I understand that this is not exactly what you asked

yes, just like a button in real live.

or just: Switch item=button

But no matter how you turn it, you always have to press twice and that is not how a button works :wink:

1 Like

That’s how lots of buttons work…just not the type that you want.

All buttons are switches. In electronics terms, what you want to replicate is a momentary switch, which only maintains a connection as long as it’s pressed (like a keyboard key). The alternative is a toggle switch (like the power button on a simple flashlight).

I’m glad you found that Github issue so that you can support it. As things are right now, @JimT’s suggestion is the easiest way to accomplish something similar to press/depress functionality.

As to why press/depress hasn’t been implemented, my guess is that people have been content to just use two button presses instead (rather than putting in a feature request). It’s also possible that someone did ask before–until recently, there’s been very little work done on sitemaps.

If you want an alternative solution, I use rules to move my rollershutters in specific intervals based on factors such as time of day, temperature, UV level, cloud coverage, and open/closed windows. I’ve also made the intervals available in my site map, so that I can trigger them manually.

The reason this works is that I rarely want to control them manually. My rollershutters move to the right positions based on the environmental conditions, without me having to think about them at all.

Some folks go even further, having their rollershutters constantly adjust throughout the day based on the position of the sun. That’s more than I need, but I love that it’s possible.


I have implemented it in a similar way. Even more complex and automated :wink:

But every now and then you just want to lower or raise the raffstore just enough so that the sun is no longer blinding.

1 Like

For sure. I have a Z-Wave remote control on my desk for just that purpose. But rather than moving my blinds incrementally, it just goes through the progression.

Unfortunately for me, the spot where I tend to get blinding sun is through my balcony door, where I can’t mount an automated blind. I’ve instead used a $5 IKEA blackout blind. :wink: