My implementation 4 (or more?) years ago was:
- wemos d1 mini module
- hc-sr04 ultrasonic distance sensor
- photo resistor (measure light level from the automatic light or ambient if open)
- wemos 1ch relay. could have used a transistor, but i am iffy on what kind of voltage the garage button is using. electrical isolation is nice. my button does have couple modes like turning a light on as well if you let some amount of voltage through, but i didn't go there
- hacked up arduino code using mqtt and some very fiddly json parsing that's frafile if you glance at it weird. the software didn't exist when i hacked mine how i wanted it.
- homeassistant doing all the home automation things. It hooked into Homeassistant via MQTT sending messages back and forth. The distance sensor could only really tell if you the door is nearly all the way open due to how it was mounted. Knowing closed would be nicer but i would have had to mount it farther away and it's been fine so far.
I 3d printed a case/mount for it to dangle above the door from the ceiling, with distance sensor pointing down. relay wired to the same terminals (common and normally open) as the button on the wall would use.
all of the smarts of knowing if door was open or closed or what to do with the lights is in homeassistant. there are crazy amounts of examples of what you can do there (like, garage door opened event, flip on lights, have bartender bot standing by with your cocktail of choice. assuming it's after noon. or not. we don't judge here.) what I would do now:
Same hardware.
Software, either:
- Tasmota (https://github.com/arendst/Sonoff-Tasmota)
- mqtt only, but it has plugins for every sensor I've ever wanted to look at and doesn't require a reflash to switch things around. Configuring pins from a graphical ui is interesting.
- Espurna (https://github.com/xoseperez/espurna)
- does mqtt as well as straight http. If you didn't want to run an mqtt server and just wanted to curl button clicks to your relay, it's as good as any. I think it's very opinionated on how you plug things in, but i have it running some lights and other relays.
either work well, tasmota is just slightly more fun and mqtt is a fine protocol. can back up configs (or preset them with compiled firmware) and flash over the the air.
the espurna compatibility list has some ready made gear with relays you could use without ordering components separately. everything with espurna would work with tasmota i'm sure.
esphome looks cool too. i haven't used it, but i intend to check it out as it seems to do things that tasmota and espurna don't (like support deep sleep)