iTranslated by AI
Building a DIY 'Face Unlock' Smart Lock in 30 Minutes Without the Expensive SwitchBot AI Hub
Is the SwitchBot AI Hub, at ¥39,980, too expensive?
The "AI Hub" recently released by SwitchBot analyzes camera footage using a VLM (Vision Language Model) to determine "who is here" or "what is happening" to control the smart home—the concept is fantastic.
However, it costs ¥39,980. On top of that, a separate subscription is required for AI features, and you also need to purchase compatible cameras.
If you get everything, it’s a ¥50,000–¥60,000 commitment.
Then I thought to myself:
"Couldn't I just build this myself?"
Conclusion: With ¥0 in additional costs and 30 minutes of development time, I built something even better.
What I built
A system where a front door camera recognizes family members' faces and automatically unlocks the smart lock.
- Family (registered) → Auto-unlock + "Welcome home" notification
- Unknown person → Alert notification with a facial photo
- Camera failure → Auto-detection and recovery notification
I realized the "monitoring + recognition + control" capabilities of the SwitchBot AI Hub using only gear I already owned.
What I used (Everything was already at home)
| Equipment | Purpose | Additional Purchase |
|---|---|---|
| TP-Link Tapo C120 | Front door camera (RTSP supported) | ¥0 (existing) |
| Mac mini | 24/7 server | ¥0 (existing) |
| SwitchBot Lock Ultra | Smart lock | ¥0 (existing) |
All software is open source. Python + face_recognition (dlib) + ffmpeg.
Total: ¥0
System Architecture
Tapo C120 (RTSP)
↓ Get frames every 1 second
Mac mini
├─ Motion detection using frame difference
├─ Face matching with face_recognition
├─ Match → Unlock via SwitchBot API
└─ No match → Discord alert with photo
Everything is processed locally. No need to send face data to the cloud.
The SwitchBot AI Hub sends footage to a cloud-based VLM for processing. In other words, the footage of your home is being sent to the cloud. Privacy-wise, is that really okay?
Technical Details (For Engineers)
Motion Detection
Calculates the difference between the previous frame using RMSE. If it exceeds a threshold, it's determined that "something moved." Simple, but sufficient.
img1 = np.array(Image.open(path1).resize((320, 240)).convert('L'), dtype=float)
img2 = np.array(Image.open(path2).resize((320, 240)).convert('L'), dtype=float)
rmse = np.sqrt(np.mean((img1 - img2) ** 2))
Face Recognition
Uses face_recognition (dlib) to convert to a 128-dimensional vector and compares the distance with registered faces. A tolerance of 0.5 prevents misrecognition.
face_locations = face_recognition.face_locations(img, model="hog")
encodings = face_recognition.face_encodings(img, face_locations)
distances = face_recognition.face_distance(known_encodings, enc)
if min(distances) < 0.5: # Match
Sufficient accuracy is achieved with just 2–3 photos per person.
SwitchBot API Unlocking
Authenticate with HMAC-SHA256 and fire a POST request to the Lock Ultra.
requests.post(f"https://api.switch-bot.com/v1.1/devices/{LOCK_ID}/commands",
json={"command": "unlock"}, headers=auth_headers)
Comparison with SwitchBot AI Hub
| DIY System | SwitchBot AI Hub | |
|---|---|---|
| Initial Cost | ¥0 (existing equipment) | ¥39,980 + compatible camera |
| Monthly Fee | ¥0 | Subscription required |
| Face Recognition | ✅ Local processing | ✅ Cloud VLM |
| Auto-unlock | ✅ Direct API control | ✅ |
| Stranger Alert | ✅ With photo | ✅ Text notification |
| Privacy | ✅ Fully local | ❌ Cloud transmission |
| Customization | ✅ Highly flexible | ❌ Within app limits |
| Setup | 30 min (Python knowledge required) | Box opening to setup |
| Supported Cameras | Any RTSP-capable camera | SwitchBot-branded + RTSP |
Honestly, the "VLM image understanding" feature of the AI Hub is interesting. Judging things like "someone is climbing over" or "the pet has eaten" is difficult with simple face recognition.
However, regarding the use case of "unlocking the door when family returns," is it worth paying 40,000 yen for? No.
Points Where I Got Stuck
face_recognition doesn't work on Python 3.14
Since pkg_resources was removed, a patch is required.
# Directly modify face_recognition_models/__init__.py
# Before: from pkg_resources import resource_filename
# After: os.path.join(os.path.dirname(__file__), 'models')
macOS LaunchAgent and Python venv
Calling .venv/bin/python directly from a LaunchAgent resolves the symbolic link and starts the system Python. Avoided this by exec python after source activate via a bash wrapper.
I lost 15 minutes in total on these two issues. The remaining 15 minutes were for implementation.
Real-world Performance
I arrive home and stand in front of the door.
- Camera detects motion (~1 sec)
- Face recognition (~0.5 sec)
- SwitchBot API unlocks (~1 sec)
Unlocked in about 2–3 seconds. I don't even need to take out my keys or phone.
If a stranger arrives, I get an immediate notification on Discord with a facial photo. I can check it right away even when I'm away.
Regarding Security
This is a feature for convenience, not the final line of defense for security. There is a separate fingerprint pad. It is not resistant to photo attacks, so it remains in the "nice to have if available" category.
But that's the same for the SwitchBot AI Hub. There is no product yet that guarantees security solely through face recognition accuracy.
Conclusion
- SwitchBot AI Hub: ¥39,980 + subscription + purchase of compatible camera + sending footage to the cloud.
- DIY: ¥0 + 30 minutes + fully local + customizable as you like.
If you're an engineer, the DIY route is the only choice. If you have an RTSP-capable camera and a machine that runs Python, you can build it today.
Of course, the AI Hub has the advantage of "advanced situational awareness through VLM," which is difficult to achieve on your own. It has value for use cases that simple face recognition can't handle, such as pet monitoring or elder care.
But if you just want to "unlock the door with facial recognition," you don't need a 40,000 yen product.
The entire code is just over 200 lines of Python. It uses only face_recognition + SwitchBot API + ffmpeg.
Discussion