Pushbutton functionality vs Toggle Raspberry pi gpio pin activation

Hi there, I am running openhabian on a raspberry pi3b and am currently facing a dilemma. I have a switch setup in a sitemap which controls one of the pins on my gpio and it works great! when switched on the pin is energized, and in order to turn it off you have to switch it off, which is working as designed. Trouble is, what I want to do it have a momentary pushbutton activation style. I want the switch to not latch. Is there anyway to have the button represented as a pushbutton rather than a a switch and have it only energize the gpio pin for say… a half second? Thanks in advance for your help.

For your curiosity I am controlling a relay that interfaces with a garage door opener, so basically I want to momentarily switch the relay to open the door.

Write a Rule to do this. Trigger on your Switch Item changing to ON, start a Timer for whatever duration you prefer, which when time is up sends an OFF command to the switch. For such a short duration as half a second, you could just use a delay (sleep) rather than a full Timer function.

For the appearance on the sitemap, see this post

Thanks rossko, I might have to end up doing something like that. The rule part is great, but the invisible buttons thing is pretty janky if i might be honest. They wont look like pushbuttons when im done, will they? Would I be better off just having a button that runs a python script instead that actuates the pin and then time.sleep(0.5) and then deactivates the pin? Thanks again!

Have a try with ‘invisible button’, it works better than you expect.

The UI is the same for triggering a python script, I don’t see how that would help.

Ok, I thought I’d have more control over the type of item choices when not using direct GPIO interfacing (I don’t know why, I guess I just though pushbutton interfaces aren’t too much to ask). I’m working on your suggestion as we speak. One more thing! Once I implement your suggestion, can I then add this function to a HabPanel button? The hab panel button system is just what I’m looking for. The whole reason I’m using openhab is because it has a nice looking interface with an android app.

also, this dick got it working but hasn’t shared any of his details, lol

I don’t know anything about HABpanel. I can’t imagine it incapable of anything that ClassicUI can do.

What “function” do you refer to, UI sending some Command to an Item (and so allowing triggering of rules)? 'course it can. The On-delay-Off rule I outlined is completely independent of any UI, you simply use whatever means you wish to send an ON command to the Item.

This would be more appropriate IMHO.

Yes but realize that Habpanel will not work with the Habdroid app. It only runs in the browser.

From the sitemap perspecitve, he is using that “janky” solution @rossko57 pointed you to. Actually, he really isn’t because he just labeled his button “Toggle” so he doesn’t have to mess with the visibility.

Actually Habpanel is very different and some capabilities with sitemaps are not available or make no sense with Habpanel. For example, there is no way to put a Group of things on Habpanel using something like the Group tag in sitemaps. There is also no phone app, it is 100% web based.

Thanks for taking the time to give me a reply. Unfortunately I have decided that openhab is not the right tool for this project and have migrated to blynk. The project currently is completely functional with garage door state reporting through a reed switch on an input pin. I may use openhab I’m the future as I have a lot of bindable stuff in the house, like an Onkyo receiver and an ecobee thermostat, but for pulsing an output pin on the raspberry pi it’s not worth the effort in my opinion. Thanks again and I’m sure your rule idea would absolutely work.

Absolutely, the power of OH lies in integration, not doing a single task.

rule "pulse garage door"
            Item door_actuator received command ON

But to utilise that, you have to install configure and support all of Openhab. Only makes sense if you want to combine with “turn on driveway light for 5 minutes if it is dark but not between 0100-0600, turn on garage light while door is open, if I’m not at home send me a message”

1 Like

I don’t use OH for this myself. I have a relatively simple python script that toggles the GPIO pin on my Pi in response to an MQTT message sent from OH. It publishes the status of the reed sensors via MQTT as well.

As @rossko57 indicates, the power of OH is that now I can get alerts or cause things to happen in other parts of my home when the garage door opens or closes. That is the type of problem OH is intended to solve.