jerrod-lankford / GarageQTPi

An MQTT server for a raspberry pi garage door opener. Most commonly used as a HomeAssistant cover component.
MIT License
75 stars 36 forks source link

Relay is triggered on pi startup #35

Open gouldner opened 4 years ago

gouldner commented 4 years ago

I have been using GarageQTPi for a little over a year now however I have a problem after purchasing a new garage door opener.

The old garage door opener had the ability to connect the relay directly to the garage door opener and it was working fine. The new garage door opener doesn't have this ability to I have had to hack a remote by wiring the relay to the button on an extra remote. This is working fine except for one issue. When the Pi boots up the relay triggers once. This opens the garage after a power failure. Not a good thing.

I don't understand why this wouldn't have caused the same issue when the device was wired directly to the garage door opener. But I can't figure out how to solve it.

I have read the thread on https://github.com/Jerrkawz/GarageQTPi/issues/13 These issues don't apply since I had this system working for over a year and the only change is the relay wiring is now going to a remote instead of to a garage door opener. I don't see how this could caused the device to trigger on boot since it is on the other side of the relay. The relay is triggering but the Raspberry Pi has not changed and it is still wired to same pins I used before when it was working.

Another test I performed was to change SHORT_WAIT from .2 to 2. The reason I did this was it seemed that I was observing that the boot trigger was a little shorter than the actual trigger. This test confirmed my observation. After this change on boot the trigger is still brief like it was when SHORT_WAIT was .2, but the actual trigger was in fact now triggering for 2 seconds. So this means the call causing the trigger is not the __press method.

I suspect the trigger is called during the init call setting up the GPIO but I don't know how to prove that or how to fix it if it is the cause.

The next test I performed was to start with only one door configured. Then I configured a second door and restarted the service. This again caused the trigger. So it seems that after a reboot the first time the GPIO is initialized it triggers briefly. In this test case the GPIO 24 triggered on boot. A stop/start didn't trigger it again. Adding left door on GPIO 23 then caused a trigger again with a simple stop/start. After first trigger subsequent start/stops don't trigger again. I confirmed this test by disabling autostart. Then I enabled the service and started after booting and it does in fact trigger.

So clearly a call in the code is causing the trigger but I don't see any way to fix this.

Sorry for such a long message but I wanted to explain all my testing and findings.

I wonder if there is some way to prevent the relay from actually triggering unless the GPIO is fired for a longer time. Some additional hardware inline either between the GPIO and the relay to prevent the signal from getting through unless it is longer or the same on the relay side which prevents a brief closed relay from triggering the remote an requiring the relay be closed for a longer period.

I suspect this is why my old garage door opener didn't open on boot. I suspect it ignored such a brief close of the circuit. The SHORT_WAIT of .2 seconds was long enough but the slightly quicker closed circuit on boot (guessing .1 or less) was ignored.

vulcanjedi commented 4 years ago

https://www.raspberrypi.org/forums/viewtopic.php?t=237261