I have built a system for my front door using ESPHome. It started as a simple device to get notifications on my phone every time someone was ringing the doorbell and I was not home, but it became much more.
My front door has an electric strike controlled with a push button in the house. Both the electric strike and the doorbell are getting powered from a 12V AC transformer.
I used a D1 mini flashed with ESPHome. It controls a dual relay module. One of the relays is connected in parallel with the electric strike’s push button. That way I can use Home Assistant to open the door. The other relay is connected with my front door lamp, which gives me the ability to turn it on from my phone or automatically using automations (for example after the door opens during night hours).
The doorbell is connected with an AC detection module. It uses a full bridge rectifier and an optocoupler to convert the AC signal to DC and feed that to a microcontroller. This way I can get a high pulse on a D1 mini input every time the doorbell rings. I used a same module on the electric strike so I can have a signal when it’s energized and use that to identify if someone is pushing the push button, if something is not working properly, or use it as a trigger in automations. If your door strike and/or you doorbell is not using AC power, you don’t need to use this AC detection module. All it needs is a high pulse on the D1 mini. For example if you have a DC signal you can use a voltage divider to feed that on the microcontroller.
I also connected a reed switch to monitor the door status. This information is used to open the relay that controls the electric strike when the door has opened. It’s also used for notifications, automations or history statistics. I can see when and how the door was opened.
Apart from the ESPHome device which is mounted in a box inside the house, I built another device using an Arduino pro mini, which allows me to open the door from outside using a keypad or a RFID card.
I didn’t want to connect this device directly with the relay that controls the electric strike to avoid easy access in the house by shortening out two cables. I connected the Arduino with the D1 mini using UART communication, so there is only a cable with 4 wires between these two devices. This way, when someone gives the correct code using the keypad or an approved card, the Arduino sends a command on the D1 mini, and the D1 mini closes the relay that controls the electric strike. After three false attempts the device is locked and it requires the master code.