I also built a garage door controller. I thought I would just buy one of those on the market. Well, I tried 4 different controllers and none of them worked the way I wanted.
I decided to use a Raspberry Pi Zero-W. I also used a relay to pulse the opener contacts. I decided on two magnetic switches to sense if the door was closed in case one failed. I included a buzzer to warn when the door will move.
Unrelated but included is a light sensor. I need this because sometimes I forget to shut off the light in the garage.
Except for the RPi0, I had all the other parts left over from previous projects.
It connects to OpenHAB using mqtt. I have three items.
String GarageOverheadState "Garage Overhead [MAP(my.map):%s]" {mqtt="<[mosquitto:GarageState:state:default]",expire="80m,state=N0_RPT"} //expire="80m,state=N0_RPT"
Switch ChangeOverheadDoor "Change Overhead Door" <switch> {mqtt=">[mosquitto:GarageCommand:command:*:default]"}
String GarageLightState "Garage Light State [MAP(my.map):%s]" {mqtt="<[mosquitto:GarageLightState:state:default]",expire="80m,state=N0_RPT"}
The switch item lets me open and close the door. The String GarageOverheadState shows the state. Either Open, Closed or Unknown if the door sensors disagree. The String GarageLightState shows me if I left the garage lights on. I wrote a small python program for the RPi0 to interact with OpenHAB (via mqtt).
I have three rules:
(1) “If the door is open at 10:00 PM, close it”. It also sounds three buzzes before closing and sends me text message.
(2) “If the Garage Light is on at 10:00 PM, send a text”.
(3) “Return relay to Open”. This happens after closing the relay. Closing activates the motor of the opener but if the relay remained closed the door won’t move again.
Here is the schematic:
Here is the input/output side. From top to bottom, Buzzer, Garage Light Sensor, an LED that indicates if the relay is closed, A connector from the relay (inside) to the opener motor. A connector for the cable from the two magnetic switches. Those switches are mounted just above the door on the frame and the magnet part of the switches are mounted on the door. I was able to position them so that if the door is more then two inches off the ground, they report “Open”.
Here is a shot of where the power, usb (not used) , and hdmi (not used) connectors come into the box.
Here is an inside shot of the components and wiring.