Need help by setting up a button which sbould turn my relay on for 1 second on a raspberry pi 3 through gpio

hi, i want to use a button as a switch, which turns my relay through a gpio on and after 1 second off again. something like a push button

i have tried a few things, but nothing did really work

default.items

Switch one{ gpio="pin:2 activelow:yes" }
Switch two{ gpio="pin:3 activelow:yes" }
Switch three{ gpio="pin:4 activelow:yes" }
Switch four{ gpio="pin:5 activelow:yes" }
Switch five{ gpio="pin:6 activelow:yes" }
Switch six{ gpio="pin:7 activelow:yes" }
Switch seven{ gpio="pin:8 activelow:yes" }
Switch eight{ gpio="pin:9 activelow:yes" }

here i have listet all relay channels

rule "computer an"
when
        item seven changed from OFF to ON
then
        Thread::sleep(5000)
        seven.sendCommand(OFF)
end

and here i tried to set my gpio pin 7 back and deactivate the relay

but my 7th switch acts the same as the others do.

how can i do this?

Here’s how I was shown to do that…My use was for a sliding gate relay

Install the EXPIRE binding and then add it to your switch as shown below…

Switch FGate "Front Gate" [ "Switchable" ] { channel="zwave:device:ad34b696:node4:switch_binary",expire="1s,command=OFF",autoupdate="false" }

This will turn the switch on for 1s and then back off.

Hope this helps.

1 Like

Will that work for .1s or 500ms? Can’t seem to get that to work.

Switch seven [ "Switchable"] { gpio="pin:8 activelow:yes",expire="2s,command=OFF",autoupdate="false" }

i have tried that, but that did not work (i dont get a gpio output anymore), but how do i install the expire binding, i tried it by following

apt-get install openhab-addon-binding-expire

but then i get this E: Unable to locate package openhab-addon-binding-expire

I installed the binding via PaperUI

It’s a 1.X binding so you need to enable “include Legacy 1.x bindings” under System -> Configuraton

okay i have installed openhab 1.8 installed, do i need openhab2 ?

I made the move to OH 2 as I wanted to use some of the newer features…You don’t have to upgrade unless you want to move to the new feature set.

You can download the .JAR file of the Expire binding from the link below…place it in your “Addons” folder.

https://openhab.ci.cloudbees.com/job/openHAB1-Addons/lastSuccessfulBuild/artifact/bundles/binding/org.openhab.binding.expire/target/org.openhab.binding.expire-1.9.0-SNAPSHOT.jar

ok i will try install that, but first the link is broken, it says error 404 file not found and where is my addons folder? or do i have to create it first?

That’s weird…that url is on the binding page:

Let me see if I can find it somewhere else.

The addon folder should be found here:

/usr/share/openhab/addons.

Here’s how to install bindings:

you can download the file here:

https://openhab.ci.cloudbees.com/job/openHAB1-Addons/lastSuccessfulBuild/artifact/bundles/binding/org.openhab.binding.expire/target/org.openhab.binding.expire-1.10.0-SNAPSHOT.jar

okay i have copied the file into the addons folder and rebooted my raspberry, but it did not bring me any changes so far

is this really the correct version? i have read in the changelog

1.9.0 initial release

and i have 1.8.3

From what I know you can use any of the 1.x versions with the 1.8 version of OH.

I’m sure someone else here will correct me if I’m wrong.

okay, maybe im gonna move to OH2 tonight and see, if it is working there

From what I’ve tested it only works in full second increments.

@watou may be able to confirm this, but I was only able to get full seconds to work.

It works perfectly on OH2 without any problemy, thank you :wink:

My pleasure…glad I could help out!