Years ago I was renting a condo in a building with a bit of an older system; on the outside there were a series of buttons, each hard-wired to each of the condo units, where the units had a phone handset on the wall, with a button on the base to open the front door. Just three wires, IIRC.
I only had one key to the main door, which was annoying when I had guests who were staying a few days. It finally got annoying enough once I had a steady girlfriend who was more or less unofficially living with me. So I opened up the handset base, figured out the voltage on the wire for opening the door, and got a Raspberry Pi and a relay rated for the voltage I needed. I connected the relay's control pin to a GPIO on the Pi, and wrote a little python HTTP server that would enable the GPIO pin, and fire off a thread to turn it back off after a few seconds.
I was working at Twilio at the time, so I figured the easiest trigger would be SMS. I set up a phone number, and the backend logic for it had a list of sender phone numbers and 6-digit codes. That way I could only allow certain people's phones to trigger, and on top of that, it required a code, unique to each visitor I was allowing. It would also send a text to me every time someone used it, so I could monitor things to ensure nothing odd was happening.
I already had a small home automation system running using openHAB, with remote access set up on a VPS I rented, so it wasn't hard to hook all that together, in a way that the callback handler from Twilio could reach back into the home.
I didn't have a great way to mount it, and didn't want to mess up the wall. The Pi and relay were light enough that I ended up just hanging it from the wires connecting to from the relay to the handset base. Fortunately there was an electrical socket almost directly below the handset so I could plug in the Pi. (I forgot about it when my landlady had to come over due to a water leak; surprisingly she didn't even comment on it.)
My one worry was that the little python HTTP server would crash between closing the relay and then opening it up again after a few seconds, leaving the door persistently unlocked. But I used a default-open port on the relay, so if power went out, the relay would stay open, keeping the door locked. I also made sure that the little HTTP server would reset the GPIO to keep the relay open on startup, so if it crashed and restarted, it would ensure the door was locked. IIRC there was also something you could put in the Pi's /boot/config.txt to set GPIOs to a certain value on boot(?). And on top of that, I wrote another little python script that just sat there checking the GPIO every second, and if it remained on for more than a few seconds, it would close it. This was probably overkill, but I wanted to be as sure as possible I wouldn't be putting my neighbors into any kind of danger by perma-unlocking the front door.
Something like an ESP32 would certainly have been smaller and lower-power (maybe could have even run it off battery), but at the time I hadn't even heard of ESP32 yet (that would come a few years later, when I was bored during the pandemic and needed a project).
I only had one key to the main door, which was annoying when I had guests who were staying a few days. It finally got annoying enough once I had a steady girlfriend who was more or less unofficially living with me. So I opened up the handset base, figured out the voltage on the wire for opening the door, and got a Raspberry Pi and a relay rated for the voltage I needed. I connected the relay's control pin to a GPIO on the Pi, and wrote a little python HTTP server that would enable the GPIO pin, and fire off a thread to turn it back off after a few seconds.
I was working at Twilio at the time, so I figured the easiest trigger would be SMS. I set up a phone number, and the backend logic for it had a list of sender phone numbers and 6-digit codes. That way I could only allow certain people's phones to trigger, and on top of that, it required a code, unique to each visitor I was allowing. It would also send a text to me every time someone used it, so I could monitor things to ensure nothing odd was happening.
I already had a small home automation system running using openHAB, with remote access set up on a VPS I rented, so it wasn't hard to hook all that together, in a way that the callback handler from Twilio could reach back into the home.
I didn't have a great way to mount it, and didn't want to mess up the wall. The Pi and relay were light enough that I ended up just hanging it from the wires connecting to from the relay to the handset base. Fortunately there was an electrical socket almost directly below the handset so I could plug in the Pi. (I forgot about it when my landlady had to come over due to a water leak; surprisingly she didn't even comment on it.)
My one worry was that the little python HTTP server would crash between closing the relay and then opening it up again after a few seconds, leaving the door persistently unlocked. But I used a default-open port on the relay, so if power went out, the relay would stay open, keeping the door locked. I also made sure that the little HTTP server would reset the GPIO to keep the relay open on startup, so if it crashed and restarted, it would ensure the door was locked. IIRC there was also something you could put in the Pi's /boot/config.txt to set GPIOs to a certain value on boot(?). And on top of that, I wrote another little python script that just sat there checking the GPIO every second, and if it remained on for more than a few seconds, it would close it. This was probably overkill, but I wanted to be as sure as possible I wouldn't be putting my neighbors into any kind of danger by perma-unlocking the front door.
Something like an ESP32 would certainly have been smaller and lower-power (maybe could have even run it off battery), but at the time I hadn't even heard of ESP32 yet (that would come a few years later, when I was bored during the pandemic and needed a project).