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

fix boot trigger of relay #36

Open gouldner opened 4 years ago

gouldner commented 4 years ago

I fixed the issue I was reporting ( https://github.com/Jerrkawz/GarageQTPi/issues/35 ) and wanted to share my solution.

I found that the call to GPIO.setup(self.relay_pin, GPIO.OUT) starts with the GPIO sending the signal to the relay and turns off a few lines down when GPIO.output(self.relay_pin, self.invert_relay) is called.

So I moved GPIO.output(self.relay_pin, self.invert_relay) right after the setup and the trigger no longer happens.

alastaid commented 4 years ago

Hi, I had the same issue and this fixed it, thanks for posting.

craigInTx commented 3 years ago

There is still a moment (although more brief now) that the output would be toggled. better solution: change: GPIO.setup(self.relay_pin, GPIO.OUT) to: GPIO.setup(self.relay_pin, GPIO.OUT, initial=self.invert_relay) to properly set the initial state on output setup.

I created a new pull request with this change.