Beginner on/off switch question

Hello, very new to openhab and i have a question on using the switch.

I have cannibalized some cheapo RF controlled outlets to control some lights.
I am using the remote that came with the outlets as a transmitter to turn the outlets on and off using GPIO’s on a Raspberry pi 3 and it does work.

The main problem is the remote transmitter that turns the outlets on has a separate on switch and an off switch for each outlet. Under my very basic setup I currently have to have 2 switches for each light.

What i would like to do is when the switch is turned to “ON” it will turn on a GPIO pin for 1 second, then when the switch is turned to “OFF” it will turn on a different GPIO pin for 1 second.

Is this possible?
Would i use a rule for this? or would this be done in the item section of the switch?

I have had a lot of fun getting to this point, but I am struggling to get the syntax used.
Thanks in advance for any help.

Ryan

You can set up a switch that is used in a rule to do two different things when it’s ON or OFF.
As long as you know how to turn on the pins you want to use.

Basically:

Create a switch item
create a rule that fires when the switch is turned ON
create a rule that fires when the switch is turned OFF

The exact syntax will depend on the command you sending to turn the various pins on.

I would use a ‘proxy’ Item, a switch not bound to any hardware. This is the one to put on your sitemap. Then have rules which are triggered on a change to the proxy (or a received command), and send a ON followed later by OFF to the appropriate GPIO simulated pushbutton.