My home security solution
Ignore the cats in the icon

April 2021

Some pesky caveats

I made a security¹ solution² that notifies me whenever my condo door is opened while my partner and I are away. It’s great. I really like it. But, for full transparency, it’s really not a security solution because:

  1. There isn’t a whole lot of security going on. This will tell me that my door has been opened without me at home, but it won’t call my concierge downstairs or the police. Hypothetical balaclava-donned intruders will still have free reign over my belongings, and
  2. More importantly, there’s no problem to solve. I live in a condo where the only way to get to any floor is to have a key fob authorized for that floor. Sure, it’s no Fort Knox, but realistically the only people who are ever going to open my door are myself, my partner, and building management when the air filters are due for a change.

So what I actually have is:

  • The peace of mind from knowing my landlord isn’t randomly coming to my condo when nobody is home
  • An opportunity to have something to do outside of work

Oh - and the ability to have a home security camera without feeling like Jeff Bezos is watching over me or sharing my WiFi with strangers.

What it does

Every time my condo door opens, here’s what my “security solution” does:

  • Records a 7-second video (from inside the condo) and uploads it to Google Cloud Storage
  • Checks whether my partner and I are home (by pinging our cell phones via Bluetooth)
    • If neither of us are home, sends us a notification

Originally, the notifications were sent via email. But a few months in, I realized I wasn’t getting any emails. That’s to be expected - presumably when my partner and I aren’t home, people actually aren’t popping in and out of our condo. But when you’re trying to track edge cases that occur infrequently, it can get really hard to tell the difference between “this didn’t happen” and “it happened once but my system wasn’t working so I didn’t know”.

To combat this, I later decided to make a quick iOS app which shows all the times my door was opened in the last 30 days, with in-app access to the corresponding videos.

How it works

A two-part magnetic switch mounted to my door and doorframe is wired into my Raspberry Pi’s input pins. When the door opens, the input value changes, and the Pi begins a sequence of events:

  1. Records a 7-second .h264 video with the onboard camera
  2. Uploads the video to Google Cloud Platform and deletes the video from the onboard SD card
    • If there is an intruder who plucks my Pi on the way out, this will make it the tiniest bit harder to find older videos of my partner () and I () entering/exiting our condo
  3. Checks whether my partner and I are home by pinging our cell phones via bluetooth and looking for a response
  4. Sends the metadata (time, video link, presence of myself / my partner) to my Heroku server

From there, my Heroku server executes the following steps. Note that these steps could all be carried out on my Pi, but in the event of an actual intruder also capable of minimal programming, I’d rather not let them have the software keys required to view my entrance/exit habits and videos.

  1. Adds a "door opening event" to Firebase's Cloud Firestore
    • Also "prunes" my data store to remove entries older than 30 days. I actually store all 30 days' worth of events in a single document, because limiting the number of documents written/read/deleted and total stored data helps keep me in the free tier)
  2. If my partner and I are both not home, sends a notification to my iOS app via Firebase

And that’s all there is to it!


You know, I’m really proud of myself for finishing this project. That’s something I didn’t think I would say, because I traditionally think of myself as being proud of solving complex problems, and this isn’t a complex problem. Anyone with reasonable experience in Python and Swift could put this together in a day. That’s because this project pieces together a bunch of solved problems. I didn’t have to figure out encryption - TLS deals with that. I didn’t have to worry about infrastructure security - everything’s hosted on Google and Heroku. Hell, I barely had to figure out UI design - SwiftUI by default makes iOS-native-looking apps. I just needed to link these solutions together to make something fit for purpose.

But fitting together off-the-shelf solutions is, by itself, something that takes time and practice. And frankly, I haven’t had a lot of that recently.

Here’s the timeline:

  • Sept 2019: Starting my full time job
    • By this point, I’d set up the Raspberry Pi to detect a door opening, record/upload to videos to Google Cloud Storage, and send email notifications if it detected I wasn’t home
    • Essentially, everything but the iOS app had been built
  • July 2020: [10 months from start] Building the iOS App
    • Work had been busy and when I did have free time on the weekends, I wasn’t interested in coding. In July, I took a week off work and after running out of chores to do, I:
      • Added some endpoints to my server to support an iOS app
      • Built an iOS app with SwiftUI (and a few hacks)
  • Dec 2020: [15 months from start] Refining the iOS App
    • With my company closing for two weeks over the winter holidays, I found the time to fix my iOS app:
      • Removed hacks by figuring out SwiftUI state management
      • Used SwiftUI 2 features (video player)
  • April 2021: [19 months from start] Actually finishing this project
    • Finally, I got around to finishing this project with this quick writeup. After nearly 20 months (though fewer than 2 weeks of coding) I wasn’t sure I’d ever get around to finishing it - it felt like I’d missed the relevant window. I also had other things on my mind, like advancing financial policies at PTP, where I am the Treasurer of the Board of Directors, or thinking critically about where I saw my career in the next few years (business school, new job?). There wasn’t enough time to do this well enough to be worth publishing.
    • But that’s what this site is for - learning to ship, even when things are far from perfect. I think a quick architecture sketch is a good idea, for example - and yet this article doesn’t have one. Screw it, it’s shipping anyways; I can endlessly iterate when I’m more free.