This might help
http://www.letscontrolit.com/wiki/index ... rial_Rules
I have this as my setup... I actually have two switched set up in devices.
One lightSwitch which has a pull up activated and is push button active low. This is attached to gpio 0 and is the push button on the Sonoff
The Second called lightState is non pull up and an ordinary switch. It just reports on the state of the relay. it is attached to gpio 12.
Rule
on lightSwitch#Switch do
if [lightState#Switch]=0
gpio,12,1
else
gpio,12,0
endif
endon
I cant remember exactly why I came to this solution, It was either so that the use of the physical switch could take into account the state of the relay (ie it would not get out of phase with openhab) or it was because I was having issues with mqqt signals not reaching their destination (which i later solved by attaching the retain flag on Openhab and also the sonoff). I can tell you though it does work very well.
I also use this rule... on my switch named backroomDeskLamp. It means that the physical switch on the desklamp switches both lamps in the room. This has a very high WAF.
on lightSwitch#Switch do
if [lightState#Switch]=0
gpio,12,1
Publish /backroomFloorLamp/gpio/12,1
else
gpio,12,0
Publish /backroomFloorLamp/gpio/12,0
endif
endon